var version = "1.0";

var OnBesucherSurvey=true;//Abfragen
//OnBesucherSurvey=false;

var _Dedug_=false;
//_Dedug_=true;

var OnAction=true;// Bärenaktion
OnAction=false;


var OnLine=true;
// Basket
var BasketProfil="";
var BasketTime=new Date();
var ArrBasket = new Array();
ArrBasket.length=0;
// END Basket 
var UserMode="Sofort";

var SetTitelImg=true;

var RootDir="/";
if(window.location.protocol=="http:")
  RootDir=window.location.protocol+"//"+window.location.host+"/Shop/";

if(window.location.protocol=="file:"){
  var ShopPos=window.location.href.indexOf("-shop.com");
  if(ShopPos>0) 
  RootDir=window.location.href.substr(0,ShopPos+9)+"/Shop/";
}

var ImgMainPath  =RootDir+"Img/Main/"+Lng+"/";
var ImgFooterPath=RootDir+"Img/Footer/"+Lng+"/";
var PicSrcDivImg =RootDir+"PicSrcDivImg/"+Lng+"/";
var PicSrcDivText=RootDir+"PicSrcDivText/"+Lng+"/";


var User_ID="";
var ServerUser_ID="";
var User_Herkunft="";
var Tracker="";
var User_Aufenthalt="";

var DetailGesichtet=false;
var DetailGesichtetMal=0;
var NavigationGeklickt=false;


var StartParam="";



var Minimum=0; // Min Bestand 

var ZX_PartnerID="";

/////////////////////////////////////////////////////


function ToCurr(value) {
  var pPrice=eval(String(value).replace(",","."));
  if(pPrice<=0.0099 && pPrice>=-0.0099) {var newPounds='0';var newPence='00'} 
  else{
    newPounds=parseInt(pPrice);
    var dec=eval('100');
    newPence=Math.round((pPrice-newPounds+0.000008 )*dec);
    compstring='9';
    for (var i=1; i <2;i++) {
      if (eval(newPence) <= eval(compstring)) 
        newPence='0'+newPence;
      compstring=compstring+'9';
    }
  }

  if(isNaN(newPounds)) newPounds='0';
  if(isNaN( newPence)) newPence='00';
  
  var newStr=' ' + newPounds + '.' + newPence + ' '; 
  return (newStr);
}


//-----------------------------------

function WartenSec(Pause){// Bei -1 ->Stop
  if(isNaN(Pause)) 
    Pause=1;
  
  var ExitFlag=0;
  if(Pause<0)
    ExitFlag=1;
  window.setTimeout("WartenSec(-1)", 1000*Pause);
  for(;;)
    if(ExitFlag==1)
      break;
}

function Window_Open(Link, ZielFrame){

  var ZF_obj=null;
  for(var w=0;w<30;w++){
    ZF_obj=eval(""+ZielFrame);
    if(!ZF_obj)
      WartenSec(1);
//    else if(!ZF_obj.document)
//      WartenSec(1);
    else 
      break;

  }
  if(ZF_obj)
    window.open(Link,ZielFrame);
}

//-----------------------------------



// Frameset, List ..
var CurrentDetail="-";
var CurrentList="-";
var CurrentIndex="0";

function SetCurrentDetailList(vIndex, vCurrentDetail, vCurrentList){
  CurrentIndex=vIndex;
  CurrentDetail=vCurrentDetail;
  CurrentList=vCurrentList;
}

function LoadCurrentDetail(){
  var AntiCache=Date.parse(Date())/1000;
  var Link="../HtmlProduct"+"/"+Lng+"/"+CurrentDetail+"?"+AntiCache;
  Window_Open(Link,"FrameMainMainMain");
}

function LoadCurrentList(){
  var Link="../HtmlList/"+Lng+"/"+CurrentList+"#A"+CurrentIndex;
  Window_Open(Link,"FrameMainMainList");
}

function LoadProductFrameSet(){
  var Link="HtmlProductFrameSet/HtmlProductFrameSet.html";
  Window_Open(Link,"FrameMainMain");
}


//////////////




// ------------------------------------------------------------
function PushBasket(addQty, addStyleNumber, addBest, addDivision, addCategory, addStyleName, addColorName, addColorNumber, addSize, addSizeNo, addPrice, addTax, addLng, addEAN, addNewSale, addAltStyleNr, addSizeThumb, addStyleThumb, addID, addEuroFlag, add2){
// Dupp Check
  addEuroFlag=ZX_PartnerID;
  addAltStyleNr=Tracker;
  
  if(UserMode=="Surf")
    UserMode="AddBasket";

  var TempArr=new Array();
  var Vor="Vor:"+ArrBasket;
  for(var b=0;b<ArrBasket.length;b++){
    TempArr.length=0;
    TempArr=ArrBasket[b].split("|");
    if(TempArr[1]==addStyleNumber)
      if(TempArr[7]==addColorNumber)
        if(TempArr[8]==addSize){// Del Dupp
          addQty=Number(addQty)+Number(TempArr[0]);
          for(var d=b;d<ArrBasket.length-1;d++)
            ArrBasket[d]=ArrBasket[d+1];
          ArrBasket.length--;
        }
  }
  PushProfil('.');
  var jetzt=new Date();
  var BasketItem=(jetzt.getTime()-BasketTime.getTime() )/1000;
  var Item=addQty+"|"+addStyleNumber+"|"+addBest+"|"+addDivision+"|"+addCategory+"|"+addStyleName+"|"+addColorName+"|"+addColorNumber+"|"+addSize+"|"+addSizeNo+"|"+addPrice+"|"+addTax+"|"+addLng+"|"+addEAN+"|"+addNewSale+"|"+BasketProfil+"|"+BasketItem+"|"+addAltStyleNr+"|"+addSizeThumb+"|"+addStyleThumb+"|"+addID+"|"+addEuroFlag+"|"+add2+" ";
  ArrBasket[ArrBasket.length] = Item;
  BasketProfil="";
  BasketTime=new Date();
  SortBasket(1);//
}


function ReloadBasket(){
  if(frames['FrameHeader'])
    FrameHeader.reloadBasket();
}


function CheckPromotionBasket(){
  var TotalBasket=0;
  var TempArr=new Array();
  var HatRabatt=false;
  for(var b=0;b<ArrBasket.length;b++){
    TempArr.length=0;
    TempArr=ArrBasket[b].split("|");
    if(TempArr[1]=="X99999"){
      HatRabatt=true;
      TempArr[0]="1";
    }
    if(TempArr[0])
     if(TempArr[10])
      TotalBasket=TotalBasket+TempArr[0]*TempArr[10];
  }

  if(TotalBasket>99.50)
   if(!HatRabatt)
    if(OnAction)
     PushBasket("1","X99999", "9999","toys","teddy aktion","osterteddy aktion","one color","0","1","0","0","15.29","de", "4999999999999", "aktion", "", "one_size.gif", "74807.gif", "02026", "", "");
  return TotalBasket;
}

// 2 ------------------------------------------------------------
function buyItem(newQty,newStyleNumber, newBest,newDivision,newCategory,newStyleName,newColorName,newColorNumber,newSize,newSizeNo, newPrice,newTax,newLng, newEAN,newNewSale, newAltStyleNr, newSizeThumb, newStyleThumb, newID, newEuroFlag, new2){
  if(newQty<=0){
    alert('Die Stückzahl ('+newQty+') ist nicht korrekt!');
    return;
  }

  if(ArrBasket.length>=11){// Max 11 Positionen
    if(Lng=="nl")
      alert("Uw winkelmandje is vol. Verstuur a.u.b. uw bestelling\n\nzodat u met een leeg winkelmandje verder kunt gaan.");
    else 
      alert("Ihr Warenkorb ist voll, bitte lösen Sie zunächst eine Bestellung aus.\n\nAnschließend können Sie Ihren Einkauf mit neuem Warenkorb fortsetzen.");
    return;
  }

  var AddBasketText1="Dem Warenkorb ";
  var AddBasketText2=" hinzufügen?";
  if(Lng=="nl"){
    AddBasketText1=" in het winkelmandje leggen?";
    AddBasketText2=" ?";
  }
  
  if(Lng=="uk") 
  {
    var AddBasketText1="Add ";
  	var AddBasketText2="  to your shopping basket?";
  }
  
  if(Lng=="de" || Lng=="at")
  {
    var ConfirmText=AddBasketText1+newQty+" x '"+newStyleName+", "+newStyleNumber+", "+newColorName;
  	if(newSize > '' && newSize != 0) ConfirmText=ConfirmText+", "+newSize;
  	ConfirmText=ConfirmText+"'  EUR "+  newPrice+AddBasketText2;
  }
  
  if(Lng=="nl")
  {
    var ConfirmText=newQty+" x '"+newStyleName+", "+newStyleNumber+", "+newColorName;
    if(newSize > '' && newSize != 0) ConfirmText=ConfirmText+", "+newSize;
    ConfirmText=ConfirmText+"'  EUR "+  newPrice+AddBasketText1;
	
  }
  
  if(Lng=="uk")
  { 
    var ConfirmText = AddBasketText1 + newQty+" x '"+newStyleName+", "+newStyleNumber+", "+newColorName;
  	if(newSize > '' && newSize != 0) ConfirmText=ConfirmText+", "+newSize;
  	ConfirmText=ConfirmText+"'  GBP "+  newPrice + AddBasketText2;
	
  }

  if (confirm(ConfirmText)){
    LoadBasket();
    PushBasket(newQty,newStyleNumber, newBest,newDivision,newCategory,newStyleName,newColorName,newColorNumber,newSize,newSizeNo, newPrice,newTax,newLng,newEAN, newNewSale, newAltStyleNr, newSizeThumb, newStyleThumb, newID, newEuroFlag, new2);
    SaveBasket();
    ReloadBasket();
  }
}

// 3 ------------------------------------------------------------
function SaveBasket(){
  CheckPromotionBasket();//Bär-Aktion
  var TheBasket="";  
  for(var t=0;t<ArrBasket.length;t++)
    if(ArrBasket[t])
      TheBasket=TheBasket+ArrBasket[t]+'~';
  TheBasket=TheBasket.substring(0,TheBasket.length-1);//Lösche letzte '~', sonst ArrBasket hat ein leeren Eintrag
  var Zeit = new Date();
  var Jetzt = Zeit.getTime();
  Zeit.setTime(Jetzt + 1*24*60*60*500);// 0.5 Tage
  SetCookie('Basket_'+Lng,TheBasket,Zeit);
  
  if(GetCookie('Basket_'+Lng)!=TheBasket)
    alert("Speichern von Cookie ist nicht aktiviert!\n\nBitte setzen Sie sich mit 'info@marc-o-polo-shop.com'  in Verbindung.");
    
}

// 4 ------------------------------------------------------------
function LoadBasket(){
  var TheBasket=GetCookie('Basket_'+Lng);
  ArrBasket.length=0;
  if(TheBasket!="")
    ArrBasket=TheBasket.split("~");
  var W_Updated=false;
  var TempArr=new Array();
  var Total_Basket=CheckPromotionBasket();//Bär-Aktion
  for(var b=0;b<ArrBasket.length;b++){
    TempArr.length=0;
    TempArr=ArrBasket[b].split("|");
    if(TempArr[1]=="X99999"){
      TempArr[0]="1";
      if(Total_Basket<99.50){
        TempArr[1]="X99999";
        TempArr[5]="mop kuschelteddy 23 cm";
        TempArr[10]="8";
        TempArr[11]="15.29";
        TempArr[13]="4999999999999";
        TempArr[14]="sale";
      }
      else{
        TempArr[1]="X99999";
        TempArr[5]="osterteddy aktion";
        TempArr[10]="0";
        TempArr[11]="15.29";
        TempArr[13]="4999999999999";
      }
      var Item="";
      for(var q=0;q<TempArr.length;q++)
        Item=Item+TempArr[q]+"|";
      Item=Item.substring(0,Item.length-1);
      ArrBasket[b]=Item;
      W_Updated=true;
    }
  }
  if(W_Updated)
    SaveBasket();
//  CheckPromotionBasket();//Promotion
}

// 5 ------------------------------------------------------------
function SortBasket(Idx){
  var t=0;
  for(;;){
    if(t>=ArrBasket.length) break;
    if(t<0) break;
    if(ArrBasket[t] && !ArrBasket[t+1]) break;
    if(!ArrBasket[t] || !ArrBasket[t+1]) {alert("Error in SortBasket:" + t); break;};
    var TempItem0=new Array();
    var TempItem1=new Array();
    TempItem0=ArrBasket[t].split("|");
    TempItem1=ArrBasket[t+1].split("|");
    if(TempItem0[Idx]>TempItem1[Idx]) {
      var tBa=ArrBasket[t];
      ArrBasket[t]=ArrBasket[t+1];
      ArrBasket[t+1]=tBa;
      t=t-1;
      continue;
    }
    t++;
  }
}




// 6 ------------------------------------------------------------
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)            
  endstr = document.cookie.length;	               
  return unescape(document.cookie.substring(offset, endstr));
}
	                
// 7 ------------------------------------------------------------
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 "";
}


// 8 ------------------------------------------------------------
function SetCookie(name,value,expires){
  var AddStr="; path=/;";
  if(location.protocol != "file:")
   	AddStr+= " domain=marc-o-polo-shop.com";// Schränkt ein
  //AddStr="";

  if(expires!=null)
    AddStr=AddStr+"; expires=" + expires.toGMTString();
  document.cookie = name + "=" + escape (value) +AddStr;
}







// 12 ------------------------------------------------------------

function PushProfil(Val){
  BasketProfil=BasketProfil+""+Val;
  // Temporär...
  BasketProfil="";
  return BasketProfil;
}


//-----------------------------------
function changeSpaces(theString) {
  var chString='';
  for (var i=0; i <= theString.length; i++)
    if (theString.charAt(i)==' ') 
      chString=chString+'^';
    else
      chString=chString+theString.charAt(i);
  return chString;
}


//-----------------------------------
function replaceSpaces(theString) {
  var chString='';
  for(var i=0;i<=theString.length;i++)
    if (theString.charAt(i)=='^')
       chString=chString+' ';
    else if(theString.substring(i,i+3)=='%5E'){
       chString=chString+' ';
       i=i+2;
    }

    else if(theString.substring(i,i+3)=='%3E'){
       chString=chString+'>';
       i=i+2;
    }

    else
      chString=chString+theString.charAt(i);
  return chString;
}
//-----------------------------------





function DMToEuro(val){
  val=eval(String(val).replace(",","."));
  if(isNaN(val))return -1;
  return ToCurr(val*eval(0.51129));
}

function EuroToDM(val){
  val=eval(String(val).replace(",","."));
  if(isNaN(val))return -1;
  return ToCurr(val/eval(0.51129));
}

//-----------------------------------

function DrawNewSale(PreisNew, PreisSale, NewSale){

  PreisNew=Number(PreisNew);
  PreisSale=Number(PreisSale);

  if(PreisNew==0)
    return "";

  var EuroSymbol="EUR";
//EuroSymbol="&#x20AC;";
//EuroSymbol="&#8364;";

  var SieSparen=Number(PreisNew-PreisSale);
  var SieSparenProz=-100*(SieSparen/PreisNew);
  SieSparenProz=Math.round(SieSparenProz+0.000008);
  
  if(NewSale=="sale"){
    return  "<font color='#FF0000'><B>sale</B></font><BR>"+SieSparenProz+"% | "+ToCurr(PreisSale)+" "+EuroSymbol+"<BR><BR>";
  }
  else if(NewSale=="new"){
    return  "<font color='#FF0000'><B>new</B></font><BR>"+ToCurr(PreisNew)+" "+EuroSymbol+"<BR><BR>";
  }
  else{
    return "<BR>"+ToCurr(PreisNew)+" "+EuroSymbol+"<BR><BR>";
  }
}



//-----------------------------------
function WinOutHelp(){
  var WinOutHelp = window.open('../../../help/index_de.htm','WinOutHelp','width=720,height=550,screenX=20,screenY=20, scrollbars=yes');
  if (navigator.appName == 'Microsoft Internet Explorer')
    WinOutHelp.moveTo(20,20);
}


//-----------------------------------

function CaptionToFileName(CaptionVal){
  var RetVal="";
  var TempVal="";
  for(var c=0;c<CaptionVal.length;c++){
    TempVal=CaptionVal.charAt(c);
    if(TempVal<"0") 
      TempVal="_";
    RetVal=RetVal+TempVal;
  }
  return RetVal;
}

//-----------------------------------


function OnLoadNavi(Welt, Division, Category){

  if(Division=="" && Category==""){// Reset
    var Link=RootDir+"HtmlNavi/de/dummy3.html";
    Window_Open(Link,"FrameTopNavi3");
    if(SetTitelImg){
     if(Welt=="CAMPUS"){
      Link=RootDir+"WeltTitle/"+Lng+"/CAMPUS.htm";}
     else{
      Link=RootDir+"WeltTitle/"+Lng+"/"+Welt+".htm";
      Window_Open(Link,"FrameMainMain");
     }
    }
    SetTitelImg=true;
  }
}



function ResetNavi(CurMode){
  UserMode=CurMode;
  Link=RootDir+"HtmlNavi/de/Welt.html";
  Window_Open(Link,"FrameTopNavi1");
  Link=RootDir+"HtmlNavi/de/dummy2.html";
  Window_Open(Link,"FrameTopNavi2");
  Link=RootDir+"HtmlNavi/de/dummy3.html";
  Window_Open(Link,"FrameTopNavi3");

}

function ersetzeSonderzeichen(Wert) {
	Wert = Wert.replace(/\+/gi, "_/_");
		Wert = Wert.replace(/\s/gi, "_");
		Wert = Wert.replace(/ä/gi, "ae");
		Wert = Wert.replace(/%E4/gi, "ae");
		Wert = Wert.replace(/ü/gi, "ue");
		Wert = Wert.replace(/%FC/gi, "ue");
		Wert = Wert.replace(/ö/gi, "oe");
		Wert = Wert.replace(/%F6/gi, "ue");
	return Wert;
}


function LoadNavi(Welt, Division, Category){
	if(_Dedug_)
		alert(Welt+" | "+Division+" | "+Category);

	var NaviLink="";
	var MainLink="";

	var tLng = Lng;
	if(tLng == "at") tLng = "de";		
		
		
	if(Welt.indexOf("welt=") != -1) {
  		Welt = Welt.substr(Welt.indexOf("welt=")+5,Welt.length);
  }
    
  if(Division.indexOf("division=") != -1) {
  		Division = Division.substr(Division.indexOf("division=")+9,Division.length);
  }
  
  if(Category.indexOf("category=") != -1) {
  		Category = Category.substr(Category.indexOf("category=")+9,Category.length);
  		
  		if(Category.indexOf("&") != -1 && welt!= "junior") 
  		{
  			Category = Category.substring(0,Category.indexOf("&"));
  		}
  }
  
  var metaValue;
  
  if(Welt.indexOf("meta=") != -1) {
  		metaValue = Welt.substr(Welt.indexOf("meta=")+5,Welt.length);
  		MainLink = loadServiceSeiten(metaValue,tLng);
  }
  
	// Großebuchstaben an 1. Stelle
	if(Category != "") {
		var strTempCategory = "";
		Category = ersetzeSonderzeichen(Category);
		Category = Category.substring(0,1).toUpperCase() + Category.substring(1);

		// Großebuchstaben an 1. Stelle bei Category mit 2 Wörtern	
		if((Category.indexOf("Long_sleeve_shirts") == -1) &&
		   (Category.indexOf("Boots") == -1) &&
		   (Category.indexOf("T-shirts") == -1 ) )
		{

			if(Category.indexOf("_") > 0)
			{
				Category = Category.split("_");
			
				for(var G = 0; G < Category.length; G++)
				{
					if(Category[G].substring(0,1) != "_")
					{
						if(Lng != "uk")
							Category[G] = Category[G].substring(0,1).toUpperCase() + Category[G].substring(1);
						else
						{
							if(G == 0)
								Category[G] = Category[G].substring(0,1).toUpperCase() + Category[G].substring(1);
						}
					}
				}
				Category = Category.join("_");
			}
			// genau wie oben nur mit "-" anstelle vo "_"

			if(Category.indexOf("-") > 0)
			{
				Category = Category.split("-");
			
				for(var G= 0; G < Category.length; G++)
				{
					if(Category[G].substring(0,1) != "-")
					{
						Category[G] = Category[G].substring(0,1).toUpperCase() + Category[G].substring(1);
					}
				}
				Category = Category.join("-");
			}
		}
		//alert(Category);
	} // Ende Großbuchstaben
	
	// Deeplinkvereinfachung
	switch(Category) 
	{
		case "Jacken":
				Category="Jacken_/_Maentel";
				break;
		case "Pullover":
				Category="Pullover_/_Troyer";
				break;
		case "Shirts":
				Category="T-Shirts_/_Tops";
				break;
		case "Jackets":
				Category="Jackets_/_Coats";
				break;
		case "Caps":
				Category="Caps_/_Hats";
				break;
		case "Caps":
				Category="Caps_/_Hats";
				break;
		case "T-shirts":
				Category = Welt=="men" ? "T-Shirts" : "T-Shirts_/_Tops";
				break;
		case "Boots":		
				Category="Boots_/_Half_boots";
				break;
		case "Longsleeve":
				Category="Long_sleeve_shirts";
				break;
		case "Stiefel":
				Category="Schuhe";
				break;
		case "Halbschuhe":
				Category="Schuhe";
				break;
	}
		

	//alert(Category)
	//Deutsch - Höllandisch Übersetzung weil die Herrschaften deutsche Deeplinks für Holland an Google weitergegeben haben...
	
	//if(location.href.indexOf("_nl") != -1) {
	if(Lng == "nl") {
		switch(Category) {
			case "Jacken_/_Maentel":
				Category="Jassen_/_Mantels";
				break;
			case "Pullover_/_Troyer":
				Category="Truien";
				break;
			case "Hosen": 
				Category="Broeken";
				break;
			case "Langarmshirts": 
				Category="Lange_Mouven";
				break;
			case "Unterwaesche": //men
				Category="Herenlingerie";
				break;
			case "Nachtwaesche": 
				Category="Nachtkleding";
				break;
			case "Strickjacken": 
				Category="Cardigans";
				break;
			case "Sakkos": 
				Category="Colberts";
				break;
				//women
			case "Blazer": 
				Category="Blazers";
				break;
			case "Blusen": 
				Category="Blouses";
				break;
			case "Unterwaesche": //women
				Category="Lingerie";
				break;
			case "Halbschuhe": 
				Category="Halfschoenen";
				break;
			case "Socken": 
				Category="Sokken";
				break;
			case "Taschen": 
				Category="Tassen";
				break;
			case "Geldboersen": 
				Category="Portefeuilles";
				break;
			case "Guertel": 
				Category="Riemen";
				break;
			case "Schals": 
				Category="Sjaals";
				break;
			case "Schals": 
				Category="Sjaals";
				break;
			case "Schmuck": 
				Category="Sieraden";
				break;
			case "Uhren": 
				Category="Horloges";
				break;
			case "T-Shirts_/_Tops":
				Category="T-Shirts_/_Topjes";
				break;
		case "Roecke_/_Kleider":
				Category="Rokken_/_Jurken";
				break;
		}
	}
	
	//////////////
	
	if(Welt.indexOf("meta") == -1) { 
		MainLink=RootDir+"start_main_main_"+tLng+".htm";
	}


  if(Welt != "" && Welt.indexOf("meta") == -1) 
  {
    if(Lng != 'de' && Lng != 'at')
    	NaviLink=RootDir+"HtmlMainFrameSet/"+tLng+"/"+Welt+".htm";
    else
    	{
    		NaviLink=RootDir+"HtmlWelt/"+tLng+"/"+Welt+".html";
    	}
  }
    
  if(Welt.indexOf("meta") != -1)
  	NaviLink = MainLink;
      
  if(Welt == "test") 
  	NaviLink = RootDir+"HtmlMainFrameSet/"+tLng+"/"+Welt+".htm";

	if(Division != "")
	{
		if(tLng != 'de' && tLng != 'at')
		{
		/*	if(Division=="new"){
				window.setTimeout("FrameMain.FrameLeftNavi.click('"+Division+ ((Category != "") ? "' ,'"+Category+"'" : "'")+")",1000);
			}else if(Division=="core"){
				window.setTimeout("FrameMain.FrameLeftNavi.click('"+Division+ ((Category != "") ? "' ,'"+Category+"'" : "'")+")",1000);
			}else if(Division=="products"){
				window.setTimeout("FrameMain.FrameLeftNavi.click('"+Division+ ((Category != "") ? "' ,'"+Category+"'" : "'")+")",1000);	
			}else if(Division=="campus"){
				window.setTimeout("FrameMain.FrameLeftNavi.click('"+Division+ ((Category != "") ? "' ,'"+Category+"'" : "'")+")",1000);
			}else if(Division=="sale"){
				window.setTimeout("FrameMain.FrameLeftNavi.click('"+Division+ ((Category != "") ? "' ,'"+Category+"'" : "'")+")",1000);
			}else if(Division=="outfits"){
				window.setTimeout("FrameMain.FrameLeftNavi.click('"+Division+ ((Category != "") ? "' ,'"+Category+"'" : "'")+")",1000);
			}*/
			FrameMain.location.href = NaviLink;
			Category = unescape(Category).replace(/\s/gi, '_').replace(/ä/gi, 'ae').replace(/ü/gi, 'ue').replace(/ö/gi, 'oe');

			if(Division=="new" || Division=="core" || Division=="campus" || Division=="sale" || Division=="outfits" || Division=="specials"&& Division != "products")
			{
				//alert("ok1")
				if(Category != '')
					window.setTimeout("FrameMain.FrameLeftNavi.location.href = '"+RootDir+"HtmlWeltDir/"+tLng+"/"+Welt+"/"+Welt+"_"+Division+".html?"+Category+"'",1000);
				else
					window.setTimeout("FrameMain.FrameLeftNavi.location.href = '"+RootDir+"HtmlWeltDir/"+tLng+"/"+Welt+"/"+Welt+"_"+Division+".html'",1000);
			}
			else if(Division == "products")
			{ 
			//	alert("ok2")
				if(Category != '')
					window.setTimeout("FrameMain.FrameLeftNavi.location.href = '"+RootDir+"HtmlWeltDir/"+tLng+"/"+Welt+"/"+Welt+".html?"+Category+"'",1000);
				else
					window.setTimeout("FrameMain.FrameLeftNavi.location.href = '"+RootDir+"HtmlWeltDir/"+tLng+"/"+Welt+"/"+Welt+".html'",1000);
			}			
		}
		else
		{
			Category = unescape(Category).replace(/\s/gi, '_').replace(/ä/gi, 'ae').replace(/ü/gi, 'ue').replace(/ö/gi, 'oe');

			if(Division=="new" || Division=="core" || Division=="campus" || Division=="sale" || Division=="outfits" || Division=="specials" && Division != "products")
			{
				//alert("ok1")
				if(Category != '')
					window.setTimeout("FrameMain.location.href = '"+RootDir+"/HtmlWeltDir/de/"+Welt+"/"+Welt+"_"+Division+".html?"+Category+"'",1000);
				else
					window.setTimeout("FrameMain.location.href = '"+RootDir+"/HtmlWeltDir/de/"+Welt+"/"+Welt+"_"+Division+".html'",1000);
			}
			else if(Division == "products")
			{ 
			//	alert("ok2")
				if(Category != '')
					window.setTimeout("FrameMain.location.href = '"+RootDir+"/HtmlWeltDir/de/"+Welt+"/"+Welt+".html?"+Category+"'",1000);
				else
					window.setTimeout("FrameMain.location.href = '"+RootDir+"/HtmlWeltDir/de/"+Welt+"/"+Welt+".html'",1000);
			}
		}
	}
	
	if(Welt.indexOf("meta") == -1 &&Division != "products" && Division != "new" && Division != "core" && Division != "outfits" && Division != "campus" && Division != "sale" && Division != "core")
	{
		var strTempDivision = "";
		Division = ersetzeSonderzeichen(Division);
		Division = Division.substring(0,1).toUpperCase() + Division.substring(1);

		if(Division.indexOf("_") > 0)
		{
			Division = Division.split("_");
			
			for(var G= 0; G < Division.length; G++){
				if(Division[G].substring(0,1) != "_"){
					Division[G] = Division[G].substring(0,1).toUpperCase() + Division[G].substring(1);
				}
			}
			Division = Division.join("_");
		}
		if(Division.indexOf("-") > 0){
			Division = Division.split("-");
			
			for(var G= 0; G < Division.length; G++){
				if(Division[G].substring(0,1) != "-"){
					Division[G] = Division[G].substring(0,1).toUpperCase() + Division[G].substring(1);
				}
			}
			Division = Division.join("-");
		}
		if(Category != "Girls" && Category != "Boys"){
	//		window.setTimeout("FrameMain.FrameLeftNavi.click('products' ,'"+Division+"')",1000);
		} else{
			window.setTimeout("FrameMain.FrameLeftNavi.click('products' ,'"+Division+"&"+Category+"')",1000);
		}
	}
	//if(Welt != '' && Division == 'Katalog')
		//NaviLink = NaviLink=RootDir+"HtmlMainFrameSet/"+tLng+"/"+Welt+"_katalog.htm";
	
	//alert(NaviLink);
	
	FrameMain.location.href = NaviLink;
	if((tLng == 'de' || tLng == 'at') && !Welt.match('meta'))
		FrameNavi.location.href=RootDir + '/HtmlNavi/'+tLng+'/navi_'+Welt+'.html';

}

function loadServiceSeiten(wert,tLng) {
	// 19.04.07 Andreas: Deeplinks auf Metanavigation

	if(tLng != 'de' && tLng != 'at'){
		if(wert=="datenschutz") {
			MainLink=RootDir+"HtmlHelp/"+Lng+"/datenschutz/datenschutz.html";
		}
		if(wert=="agb") {
			MainLink=RootDir+"HtmlHelp/"+Lng+"/agb/agb.html";
		}
		if(wert=="kontakt") {
			MainLink=RootDir+"HtmlHelp/"+Lng+"/kontakt/kontakt.html";
		}
		if(wert=="service") {
			MainLink=RootDir+"HtmlHelp/"+Lng+"/service/service.html";
		}
		if(wert=="lob") {
			MainLink=RootDir+"HtmlHelp/"+Lng+"/lob_und_kritik/lob_und_kritik.html";
		}
		if(wert=="newsletter") {
			MainLink="http://newsletter.marc-o-polo.de/public/remotebox.jsp";
		}
	}	
	else
	{
		if(wert=="datenschutz") {
			MainLink=RootDir+"HtmlFooter/"+Lng+"/datenschutz/datenschutz.html";
		}
		if(wert=="agb") {
			MainLink=RootDir+"HtmlFooter/"+Lng+"/agb/agb.html";
		}
		if(wert=="kontakt") {
			MainLink=RootDir+"HtmlFooter/"+Lng+"/kontakt/kontakt.html";
		}
		if(wert=="service") {
			MainLink=RootDir+"HtmlFooter/"+Lng+"/service/service.html";
		}
		if(wert=="lob") {
			MainLink=RootDir+"HtmlFooter/"+Lng+"/lob_und_kritik/lob_und_kritik.html";
		}
		if(wert=="newsletter") {
			MainLink="http://newsletter.marc-o-polo.de/public/remotebox.jsp";
		}
	}	
	return MainLink;
}


function OnlyLoadNavi(Welt, Division, Category){
  if(_Dedug_)
   alert(Welt+","+Division+","+Category);
   Welt = Welt.toLowerCase();
 
  var NaviLink="";
  var MainLink="";

  if(Welt != "sale")
   NaviLink=RootDir+"HtmlWeltDir/"+Lng+"/"+Welt+"/"+Welt+"_products.html";
 
  if(Division!="")
  Division = Division.replace(/Ä/, "AE");
  Division = Division.replace(/Ö/, "OE");
  Division = Division.replace(/Ü/, "UE");
    NaviLink=NaviLink+"?"+Division;

  if(Category!=""){
  Category = Category.replace(/Ä/, "AE");
  Category = Category.replace(/Ö/, "OE");
  Category = Category.replace(/Ü/, "UE");

    NaviLink=NaviLink+"&"+Category;
  }
  //alert(NaviLink);
  FrameMain.FrameLeftNavi.location.href = NaviLink;
  
}


function UpdateImg(Bild){
  var IMG=CaptionToFileName(Bild);
  var JPG=RootDir+"PicSrcDivImg/"+Lng+"/"+IMG+".jpg";
  var GIF=RootDir+"PicSrcDivText/"+Lng+"/"+IMG+".gif";
  if(FrameLeftTop){
     FrameLeftTop.document.images.devision_img.src=JPG;
     FrameLeftTop.document.images.devision_txt.src=GIF;
  }
}

var NaviIsLoaded=true;

var ShopIsLoaded=false;
var CheckCount=0;

function NaviLoaded(){
  NaviIsLoaded=true;
}

function OnLoadShop(){


  CheckCount++;
  
  //alert(NaviIsLoaded +"\n"+ShopIsLoaded)
  if(NaviIsLoaded && !ShopIsLoaded) 
  {
  	//alert("ok")
    InitShop();
  }
  else
  	{
  	//alert("ok2")
    window.setTimeout("OnLoadShop()",250);
  }
    
  if(CheckCount>=100 && CheckCount<=103){
    ShopIsLoaded=true;    
    NaviIsLoaded=true;
    //alert("ok")
    InitShop();
//    alert(CheckCount);
  }
}

var aufruf = 1;
function InitShop(){
	//alert("init Aufruf = "+aufruf);
	aufruf++;
  ShopIsLoaded=true;
  var StartDatum = new Date();
  var StartZeit = StartDatum.getTime();
  var TitelNummer=1;
  User_ID="";
  TitelNummer=GetCookie('Titel');
  
  //StartParam=newString;
  StartParam=self.location.search.substr(1);

  User_Aufenthalt=oldString;

  User_Herkunft=GetCookie('User_Herkunft');
  User_ID=GetCookie('User_ID');
  ServerUser_ID=GetCookie('UserId');

  if(User_ID.length<5) 
    Promi=true;

  if(User_ID.length<5) User_ID=Date.parse(Date())/1000;

  Trenne=User_Aufenthalt.indexOf("://");
  if(Trenne>0) 
    User_Aufenthalt=User_Aufenthalt.substr(Trenne+3, 32);
  Trenne=User_Aufenthalt.indexOf("/");
  if(Trenne>0) 
    User_Aufenthalt=User_Aufenthalt.substr(0, Trenne);

  var Trenne=User_Herkunft.indexOf("://");
  if(Trenne>0) 
    User_Herkunft=User_Herkunft.substr(Trenne+3, 32);

  Trenne=User_Herkunft.indexOf("/");
  if(Trenne>0) 
    User_Herkunft=User_Herkunft.substr(0, Trenne);
    
  if(User_Aufenthalt=="www.marc-o-polo-shop.com")
    User_Aufenthalt="A_"+Lng;

  if(User_Herkunft=="www.marc-o-polo-shop.com")
    User_Herkunft="H_"+Lng;

  if(User_Herkunft.length<1) 
    User_Herkunft=User_Aufenthalt;
    
  Tracker=User_ID+' '+User_Herkunft+'->'+User_Aufenthalt;
  var MaxWidth=screen.availWidth;
  if(MaxWidth<950)
    MaxWidth=800;
  else if(MaxWidth<1024)
    MaxWidth=1024;

  var Jetzt = new Date(); 
  if(TitelNummer<"1") TitelNummer=1;  
	//TitelNummer=100;			// auskommentieren um rotieren der titelbilder ABSCHALTEN


  var MaxImage=5;//0-1-2-3

  TitelNummer++;
  if(TitelNummer>MaxImage)
    TitelNummer=1;  

  var Zeit = new Date();
  Jetzt = Zeit.getTime();
  Zeit.setTime(Jetzt + 60*24*60*60*1000);// 60 Tage
  SetCookie ('Titel',TitelNummer,Zeit);
  SetCookie ('User_ID',User_ID,Zeit);
  SetCookie ('User_Herkunft',User_Herkunft,Zeit);
  
  if(GetCookie('User_Herkunft')!=User_Herkunft){
    alert("Speichern von Cookies ist nicht aktiviert!\n\nBitte setzen Sie sich mit 'info@marc-o-polo-shop.com'  in Verbindung.");
    
  }

  if(StartParam.length>1)
  {
		// + Kein Eistieg 
		// + Division Eistieg 
		// + Produkt Eistieg
		// - ArtikelSuche Eistieg (für Werbe-Sachen)

		if(StartParam.indexOf("product_id") == -1) //ohne product_id
		{
    	//if(!isNaN(StartParam.substr(0,5)) && !isNaN(StartParam.substr(0,8))) StartParam = "000" + StartParam;
    	if(isNaN(StartParam.substr(0,5)))
    	{
	  		var loc2 = top.window.location.href;
	  		var ParamArr=new Array();
	  		var StartParam_2="";
	  		var StartParam_3="";
    	
    	 if(loc2.indexOf('&') > 0)
    	 {
    	 		ParamArr=new Array();
    	  	ParamArr=StartParam.split("&");
    	  	StartParam_2="";
    	  	StartParam_3="";
    	  	if(ParamArr.length>1)
    	  	{
    	    	if(ParamArr[0]) StartParam=ParamArr[0];
    	    	if(ParamArr[1]) StartParam_2=ParamArr[1];
    	    	if(ParamArr[2]) StartParam_3=ParamArr[2];
    	  	}
    	 }
    	 if(loc2.indexOf('|') > 0)
    	 {
    	 		ParamArr=new Array();
    	  	ParamArr=StartParam.split("|");
    	  	StartParam_2="";
    	  	StartParam_3="";
    	  	if(ParamArr.length>1)
    	  	{
    	    	if(ParamArr[0]) StartParam=ParamArr[0];
    	    	if(ParamArr[1]) StartParam_2=ParamArr[1];
    	    	if(ParamArr[2]) StartParam_3=ParamArr[2];
    	  	}
    	 }
    	 
    	 //alert(StartParam +"\n"+ StartParam_2 +"\n"+ StartParam_3)
    	 
    	 if(isNaN(StartParam_2) || StartParam_3=="") // Navi
    	 {
 					/* auskommentiert weil das nun inna LoadNavi Funktion passieren soll, wegen Übersicht und so..
    	    if(StartParam == "men" ||
    	       StartParam == "women" ||
    	       StartParam == "junior" ||
    	       StartParam == "underwear" ||
    	       StartParam == "legwear" ||
    	       StartParam == "shoes" ||
    	       StartParam == "accessoires" ||
    	       StartParam == "eyewear" ||
    	       StartParam == "silver+gold" ||
    	       StartParam == "fragrances" ||
    	       StartParam == "1sale" ||
			   		 StartParam == "xmas" ||
			   		 StartParam.indexOf("meta") != -1)
			   	*/
			   	
			   	
    	    LoadNavi(StartParam, StartParam_2, StartParam_3);				 			//Einstieg über Division
    	    
    	 }
    	 else
    	 	{
    	    if(StartParam_2!="")
    	      ZX_PartnerID=StartParam_2;
    	  }
    	
   		}
    	else //Deeplink auf Produkt
    		{
      		NaviAutoSet=true;
      		ExternStart=RootDir+"HtmlProductFrameSet/HtmlProductFrameSet.html";  //Produkt-Einstieg über ID
      		//SetCurrentDetailList(StartParam, StartParam+".html", "DummyList.html");
      		//SetTitelImg=false;
      		pID = "";
      		colorID = "";
      		
      		blnOnlyID = StartParam.indexOf('&') < 0 ? true : false;
      		int8or5ID = blnOnlyID ? StartParam.length : StartParam.substring(0, StartParam.indexOf('&')).length;
      		//alert(int8or5ID+'|'+blnOnlyID+'\n'+StartParam);
      		
      		pID = blnOnlyID ? StartParam : StartParam.substring(0, StartParam.indexOf('&'));
      		//if(int8or5ID == 5) pID = "000" + pID;

					colorID = int8or5ID == 5 ? StartParam.substring(6) : StartParam.substring(9);
      		
      		
      		//alert(pID+'|'+colorID);
      		window.setTimeout("SetProdukt(pID, colorID)",1000);
      		//window.setTimeout("ResetNaviAuto()",10000);
    		}
    }
    
    // Andreas 14.11.07 - Deeplink mit "product_id" wegen Webtrekkpixel
		product_id = filterParamValue("product_id");
		paramColor = filterParamValue("color");
    
    if(product_id != "")
  		window.setTimeout("SetProdukt(product_id,paramColor)",1000);
  	else 
  	{
  		if(paramColor != "")
  			window.setTimeout("SetProdukt(StartParam.substr(0,8),paramColor)",1000);
  	}
   
  }
  
  if(ZX_PartnerID.length>7)
    SetCookie ('ZX_PartnerID',ZX_PartnerID,Zeit);
  else
    ZX_PartnerID=GetCookie('ZX_PartnerID');


  var TimePoint=Date.parse(Date())/1000;
}

var StartFall=0;// Kein
var Promi=false;

var Cnt=0;


function SetProdukt(pid,color){
	
	if(pid)
	{
		//Product_id auf 8 Stellen erweitern
		if(pid.length < 8) 
		{
			var writeNull = "";
			var writeNullCount = 8-pid.length;
			for(var i=0; i<writeNullCount;i++) 
				writeNull += "0";
			pid = writeNull+pid;
		}
		
		window.setTimeout('FrameMain.location.href = "http://www.marc-o-polo-shop.com/cgi-bin/search_dbid.pl?terms='+pid+'&language='+Lng+'&Color='+color+'";', 500);   
	}
	//alte Variante
	else
	{
		window.setTimeout('FrameMain.location.href = "http://www.marc-o-polo-shop.com/cgi-bin/search_dbid.pl?terms='+StartParam.substr(0,8)+'&language='+Lng+'&Color='+StartParam.substr(6)+'";', 500);	
	}	
}

function ResetNaviAuto(){
  NaviAutoSet=false;
}



function SetUserMode(NewUserMode){
  UserMode=NewUserMode;
}


// Andreas 14.11.07: Funktion die den Wert des Parameter rausfiltert
function filterParamValue(paramName) {
	
	var tmpParamName = paramName
	if(StartParam.indexOf(paramName) != -1) 
	{
	  	paramName = StartParam.substring(StartParam.indexOf(paramName+"="));
	  	if(paramName.indexOf("&") != -1) 
	  		paramName = paramName.substring(paramName.indexOf(paramName+"="),paramName.indexOf("&"));
	  	else
	  		paramName = paramName.substring(paramName.indexOf(paramName+"="));
	  	
	  	paramName = paramName.replace(tmpParamName+"=", "");
	  	return paramName;
	}
	else return "";
}

//für den Sucheinstíeg
function filterPValue(paramName) {
	var arrStartParam = location.search.substr(1).split("&");

	var Rueckgabe = "";
	for(var i=0; i<arrStartParam.length; i++){
		keyVal = arrStartParam[i].split("=");
		if(keyVal[0].toLowerCase()==paramName){
			Rueckgabe = keyVal[1];
		}
	}
	return Rueckgabe;
}


function GetParameter(ParameterName, param){
	
	//param ist location.search oder parent.location.search je nach Übergabe
	//?pid=15075&farbe=949
	
  if(param.substring(1).indexOf(ParameterName) >=0)
  {
    var start = (param.substring(1).indexOf(ParameterName) + (ParameterName.length + 1)) + 1;
    if(param.substring(start).indexOf("&") > 0)
      var ende = start + param.substring(start).indexOf("&")
    else
      var ende = param.substring(start);
  }

 var rueckgabe = "";

 if(start != ende)
   rueckgabe = param.substring(start, ende);
 else
   rueckgabe = param.substring(ende);

 //alert(ParameterName+": "+rueckgabe)
 return rueckgabe;
}  

//H?he und Breite des/der FaderDivs(Hinweislayer + Best?tigungslayer) bestimmen
function getPageSize(obj, blnScroller){
	if(blnScroller == undefined) blnScroller = true;
	
	if(obj == undefined) obj = this;
	var xScroll, yScroll;
	if (obj.innerHeight && obj.scrollMaxY) {
		
		xScroll = obj.document.body.scrollWidth;
		yScroll = obj.innerHeight + obj.scrollMaxY;
	} else if (obj.document.body.scrollHeight > obj.document.body.offsetHeight){ // all but Explorer Mac
		
		xScroll = obj.document.body.scrollWidth;
		yScroll = obj.document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		
		xScroll = obj.document.body.offsetWidth;
		yScroll = obj.document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (obj.innerHeight) {	// all except Explorer
		windowWidth = obj.innerWidth;
		windowHeight = obj.innerHeight;
	} else if (obj.document.documentElement && obj.document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = obj.document.documentElement.clientWidth;
		windowHeight = obj.document.documentElement.clientHeight;
	} else if (obj.document.body) { // other Explorers
		windowWidth = obj.document.body.clientWidth;
		windowHeight = obj.document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	pageWidth = (obj.document.body.clientWidth < 826 && !document.all && blnScroller) ? (pageWidth - 16) : pageWidth;
	
	if(!document.all)
		pageWidth = (pageHeight > windowHeight) ? (pageWidth - 16) : pageWidth;
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	
	return arrayPageSize;
}