//---------------------- Zuletzt gesehene Artikel ---------------------------- //
    var Zeit = new Date();
    var Jetzt = Zeit.getTime();

function GetCookie(name){
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var tCookie=document.cookie;
  var i = 0;
  while (i < clen) 
  {
    var j = i + alen;
    if(tCookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = tCookie.indexOf(" ", i) + 1;
    if (i == 0) 
      break; 
  }
  return "";

}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)            
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

var LastViewIDs ="";
function LastView(ID, Pic, Claim2, StyleName, PriceNew, NewSale, ColorNumber){
		
	arrPieces = new Array(ID, Pic, Claim2, StyleName, PriceNew, NewSale, ColorNumber);
	arrLastViewIds = new Array();
  
  if(document.referrer.indexOf('search.esprit.de') <0) {
    if(parent.location.search.indexOf("noLV") < 0) {                       							// Wenn Detailansicht nicht aus "Zuletzt gesehen" aufgerufen wurde
try{
			strLastViewValue = parent.parent.parent.parent.Frame.GetCookie('LastView');
}catch(e){}
			if(strLastViewValue) {
				if(strLastViewValue.length < 4000) {

					arrLastViewIds = strLastViewValue.split('|');

					if(!in_array(arrLastViewIds, ID, 0, ColorNumber, 6, '$')) {						
						if(arrLastViewIds.length >= 18) {
							arrLastViewIds.shift();
						}
						arrLastViewIds[arrLastViewIds.length] = arrPieces.join('$');
					
						strLastViewValue = arrLastViewIds.join('|');
					}
				}
			} else {
				
				arrLastViewIds[arrLastViewIds.length] = arrPieces.join('$');
				
				strLastViewValue = arrLastViewIds.join('|');
			}
			Zeit.setTime(Jetzt + (3600000*8));																								// Expire-Zeitpunkt festlegen

      parent.parent.parent.parent.Frame.SetCookie('LastView', strLastViewValue, Zeit);   // Cookie schreiben	

      try{
      	parent.parent.FrameMainNavi.ShowMerkliste();
      }catch(e){      	
      }
    }
  }
} 

  function isInLastView(intId) {
  
    if(parent.parent.parent.parent.Frame.GetCookie('LastView')){		                          // Wenn Cookie existiert

      arrLastIDs = parent.parent.parent.Frame.GetCookie('LastView').split('|');        // aufsplitten nach Artikel

      if(arrLastIDs.length > 0) {
        for(r=0;r<arrLastIDs.length;++r) {
          arrElements = arrLastIDs[r].split('$');
          if(arrElements[0] == intId) {
            return 1;  
          }
        }
      }
    }
    return 0;
  }
  
  function in_array(arrHaystack, strNeedleOne, intFieldOne, strNeedleTwo, intFieldTwo, strSplit) {
  	
  	if(intFieldOne == undefined) {
  		intFieldOne = 0;
  	}
  	
  	if(intFieldTwo == undefined) {
  		intFieldTwo = 0;
  	}
  	
  	if(strSplit == undefined) {
  		strSplit = '';
  	}
  	
  	for(var h=0;h<arrHaystack.length;++h) {
  		if(strSplit != '') {
  			arrElements = arrHaystack[h].split(strSplit);

  			if(arrElements[intFieldOne] == strNeedleOne && arrElements[intFieldTwo] == strNeedleTwo) {
					return true;
				}
  		} else {
				if(arrHaystack[h][intFieldOne] == strNeedleOne && arrHaystack[h][intFieldTwo] == strNeedleTwo) {
					return true;
				}
			}
		}
  	return false;
 	}