var Lng = parent.Lng;

function CheckEmail(Email){
  if( (Email                    =="")                  ||
      (Email.indexOf("www.")    ==0)                   ||
      (Email.indexOf(" ")       >=0)                   ||
      (Email.indexOf(",")       >=0)                   ||
      (Email.indexOf(":")       >=0)                   ||
      (Email.indexOf("@.")      >=0)                   ||
      (Email.indexOf("/")       >=0)                   ||
      (Email.indexOf("!")       >=0)                   ||
      (Email.indexOf("?")       >=0)                   ||
      (Email.indexOf(";")       >=0)                   ||
      (Email.indexOf("+")       >=0)                   ||
      (Email.indexOf("*")       >=0)                   ||
      (Email.indexOf("~")       >=0)                   ||
      (Email.indexOf("(")       >=0)                   ||
      (Email.indexOf(")")       >=0)                   ||
      (Email.indexOf("§")       >=0)                   ||
      (Email.indexOf("$")       >=0)                   ||
      (Email.indexOf("^")       >=0)                   ||
      (Email.indexOf("'")       >=0)                   ||
      (Email.indexOf("#")       >=0)                   ||
      (Email.indexOf("@")       < 1)                   ||
      (Email.indexOf("_")       >  Email.indexOf("@")) ||
      (Email.lastIndexOf("@")   != Email.indexOf("@")) ||
      (Email.length - Email.lastIndexOf(".") > 5)      ||
      (Email.length - Email.lastIndexOf(".") < 3)      ||
      (Email.lastIndexOf(".")   <  Email.indexOf("@")+3) )
      return false;
  return true;
}

function sendaddi(){
 var addi = document.forms[0].sEmail.value;
 if(addi != "" && addi != "Ihre E-Mail-Adresse" && addi != "Uw e-mail adres")
 {
  	if(CheckEmail(addi))
   		this.location.href = 'HtmlMain/samoon/'+Lng+'/SC_newsletter.html?email='+addi;
	  else
	  {
	  	if(Lng == "nl")
	  		alert('Vult u a.u.b. een geldig e-mail adres in!')
	  	else
	   		alert('Bitte geben Sie eine korrekte E-Mail-Adresse ein.')
	  }
 }
 else
 {
 		if(Lng == "nl")
	  	alert('Vult u a.u.b. uw e-mail adres in.')
	  else
  		alert('Bitte geben Sie Ihre E-Mail-Adresse ein.')
 }
}


function zufallszahl(n) {
     zahl = Math.floor(Math.random() * (n + 1));
     return zahl;
}

function teaserChange(knt,utext,ttext,link, pic) {

 var ktid = String("text"+knt);
 var kpid = String("teaser"+knt);
 var Knotentext = document.getElementById(ktid);
 var Knotenpic = document.getElementById(kpid);
 
 if(navigator.appName.indexOf("Microsoft") != -1) {
 	Knotentext.childNodes[1].firstChild.nodeValue = utext;
 	Knotentext.childNodes[2].firstChild.nodeValue = ttext;
 	if(link != "#")
 	{
 		Knotentext.childNodes[0].firstChild.href = link;
 		Knotentext.childNodes[3].firstChild.href = link;
 	}
 }
 
 if(navigator.appName.indexOf("Microsoft") == -1) {
	
 	Knotentext.childNodes[3].firstChild.nodeValue = utext;
 	Knotentext.childNodes[5].firstChild.nodeValue = ttext;
 	if(link != "#")
 	{
 		Knotentext.childNodes[1].firstChild.href = link;
 		Knotentext.childNodes[7].firstChild.href = link;
 	}
 }
 if(link != "#")
	 Knotenpic.firstChild.href = link;
 Knotenpic.childNodes[0].firstChild.src = pic;

}


function BigTeaserRotation()
{
	var Zeit = new Date();
	var Jetzt = Zeit.getTime();
	Zeit.setTime(Jetzt + 1*24*60*60*14000);// 14 Tage

	newSrc = "Img/Title/samoon/";
	
	sfx = (Lng == "at") ? "_at" : "";

	switch(parent.GetCookie('BigTeaser'))
	{
		case '1':
			document.images.BigTeaser.src= newSrc + "sc_keyvisual2"+sfx+".jpg";
			parent.SetCookie('BigTeaser','2');
			break;

//		case '2':
//			document.images.BigTeaser.src= newSrc + "sc_keyvisual3"+sfx+".jpg";
//			parent.SetCookie('BigTeaser','3');
//			break;

		default:
			document.images.BigTeaser.src= newSrc + "sc_keyvisual"+sfx+".jpg";
			parent.SetCookie('BigTeaser','1');
			break;
	}
}


function SwitchRightVisual(){
	var Zeit = new Date();
	var nun = Zeit.getTime();
	Zeit.setTime(nun + 1*1*60*60*14000);// 14 Tage

  if(parent.GetCookie('Visual') != '1') {
		document.getElementById('Keyvisual_2_2').style.visibility = 'hidden';
		parent.SetCookie('Visual','1',Zeit)
	}
	else {
		document.getElementById('Keyvisual_2_1').style.visibility = 'hidden';
		parent.SetCookie('Visual','2',Zeit)
	}
}

var zahl;

function zufallTeaser(id1,pic1,id2,pic2) { // Rotation
	
	zahl = zufallszahl(9);
	var picLink = "Img/Teaser/gerryweber/";
	var deepParam = "?product_id=";
	
	// bei 2 teasern	
	if(zahl % 2 == 0) 
	{
		document.getElementById("sale").firstChild.search = deepParam+id1;
		document.getElementById("sale").firstChild.firstChild.src = picLink+pic1;
		
	}
	else	
	{
		document.getElementById("sale").firstChild.search = deepParam+id2;
		document.getElementById("sale").firstChild.firstChild.src = picLink+pic2;
	}

}

var tag;
function thawteDate() {
	var zeit = new Date();
	var jahr = zeit.getFullYear();
	var monat = zeit.getMonth()+1;
	var atZag;
	if(monat<10)
		monat = "0"+monat;
	tag = zeit.getDate();
	if(tag<10)
		azTag = "0"+tag;
	else azTag = tag;
	document.getElementById("thawteBoxDateText").firstChild.nodeValue = jahr+"-"+monat+"-"+azTag;
}

function initFlash() {
	
	var tmpStr = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="905" height="400" id="GWM-Flash" align="middle">\
									<param name="allowScriptAccess" value="sameDomain" />\
									<param name="movie" value="http://www.house-of-gerryweber.de/Shop/Img/Teaser/samoon/layer_elton_john_sc.swf" />\
									<param name="quality" value="high" />\
									<param name="wmode" value="transparent" />\
									<param name="bgcolor" value="#ffffff" />\
									<embed src="http://www.house-of-gerryweber.de/Shop/Img/Teaser/samoon/layer_elton_john_sc.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="905" height="400" name="GWM-Flash" align="middle"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\
								</object>';
	
	if(parent.GetCookie('EltonJohn') != '1')
	{						
		document.getElementById("layer_elton_john").innerHTML = tmpStr;
		var Zeit = new Date();
  	var nun = Zeit.getTime();
  	Zeit.setTime(nun + 7*24*60*60*1000);// 7 Tage
		parent.SetCookie('EltonJohn','1',Zeit);
	}
	
}

function hidelayer(nav) {

	if ( document.all ) {
		document.all[nav].style.visibility = "hidden";
	}
	if ( document.getElementById ){
		document.getElementById( nav ).style.visibility = "hidden";
	}
	else {
		document.layers[nav].visibility = "hidden";
	}
}

function tCcall(newSale) {
	
	var error = 0;
	var tmpArr = new Array();
	var errWert=0;
	var auswahl = 4;
	
	if(scStartRotier)
	{
		if(Lng == "at")	
		{
			if(auswahl > eval("sc_"+newSale+"AT.length"))
			{
				auswahl = eval("sc_"+newSale+"AT.length");
			}
			tmpArr = parent.xAusY(auswahl,eval("sc_"+newSale+"AT.length")); //xAusY in Shop.js
		}
		else
		{
			if(auswahl > eval("sc_"+newSale+".length"))
			{
				auswahl = eval("sc_"+newSale+".length");
			}
			tmpArr = parent.xAusY(auswahl,eval("sc_"+newSale+".length")); //xAusY in Shop.js
		}
	}
	else 
	{
		tmpArr = new Array(0,1,2,3);
	}
	
	
	for(var i=0; i<tmpArr.length;i++)
	{ 
		var z = i+1+errWert; //errWert damit keine Lücke entsteht falls ein Artikel nicht da ist.
		if(newSale == "startNew")
			z += 4;
		
		//alert(eval("sc_"+newSale))
		//alert(eval("sc_"+newSale+"["+tmpArr[i]+"]"));
		try 
		{ 
			//alert("sc_start_id_"+z+"\n"+eval("sc_"+newSale+"["+tmpArr[i]+"]"))
			if(Lng == "at")	
				saleBoxTeaserChange("sc_start_id_"+z, eval("sc_"+newSale+"AT["+tmpArr[i]+"]"),newSale); 
			else
				saleBoxTeaserChange("sc_start_id_"+z, eval("sc_"+newSale+"["+tmpArr[i]+"]"),newSale); 
		}
		catch (e) 
		{
			//alert(e)
			/*  
			error++;			
			if(error==4)
				document.images.saleBg.src = "../../Img/Title/taifun/sc_sale_ersatz.jpg";
			*/
			errWert--;
			//alert(errWert)
		}
		var idWert = 0;
		if(errWert<0)
		{ 
			try 
			{
				findIdInArray(eval("sc_"+newSale+"["+tmpArr[i]+"]"),newSale);
				tCcall(newSale);
			}
			catch(E) {}
			
			if(newSale == "startNew")
				idWert += 4;
			
			switch(auswahl) 
			{
				case 3:
					idWert = idWert+4;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					break;
				case 2:
					idWertAktuell = idWert+4;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					idWert = idWert+3;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					break;
				case 1:
					idWert = idWert+4;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					idWert = idWert+3;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					idWert = idWert+2;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					break;
				case 0:
					idWert = idWert+4;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					idWert = idWert+3;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					idWert = idWert+2;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					idWert = idWert+1;
					document.getElementById("sc_start_id_"+idWert).style.display = "none";
					break;
			}
			
		
		}
	}
}


function saleBoxTeaserChange(kid, id, newSale) {
 var Knotenpic = document.getElementById(kid);

 var pic = "PicDestStyleOver_List_Cross/"+eval('Artikel_'+id)[2];
 var pbasic = eval('Artikel_'+id)[0];
 var pnew = eval('Artikel_'+id)[1];
 

 // IE
 if(navigator.appName.indexOf("Microsoft") != -1) {
 	
 	if(id != "99999") 
 	{
 		//Knotenpic.firstChild.href = "GW_HtmlProductFrameSet/de/"+id+".html";
 		
 		if(newSale == "startNew")
 			Knotenpic.firstChild.href = "http://"+window.location.host+"/Shop/HtmlWeltDir/samoon/"+Lng+"/SC_index_collection.html?pid="+id+"&refer=startmain";
 		if(newSale == "startSale")
 			Knotenpic.firstChild.href = "http://"+window.location.host+"/Shop/HtmlWeltDir/samoon/"+Lng+"/SC_index_sale.html?pid="+id+"&refer=startmain";
 	}
 		
 	else 
 		Knotenpic.firstChild.href = "#";
 		Knotenpic.firstChild.firstChild.src = pic;
 		Knotenpic.childNodes[2].firstChild.nodeValue = pbasic+" EUR";
 		Knotenpic.childNodes[3].firstChild.nextSibling.nodeValue = " "+pnew+" EUR";
 }
 
 // Nicht-IE
 if(navigator.appName.indexOf("Microsoft") == -1) {
 	if(id != "99999") 
 	{
 		//Knotenpic.firstChild.href = "GW_HtmlProductFrameSet/de/"+id+".html";
 		
 		if(newSale == "startNew")
 			Knotenpic.firstChild.nextSibling.href = "HtmlWeltDir/samoon/"+Lng+"/SC_index_collection.html?pid="+id+"&refer=startmain";
 		if(newSale == "startSale")
 			Knotenpic.firstChild.nextSibling.href = "HtmlWeltDir/samoon/"+Lng+"/SC_index_sale.html?pid="+id+"&refer=startmain";
 	}
 		
 	else
 		Knotenpic.firstChild.nextSibling.href = "#";
 		Knotenpic.childNodes[1].firstChild.src = pic;
 		Knotenpic.childNodes[3].firstChild.nodeValue = pbasic+" EUR";
 		Knotenpic.childNodes[5].firstChild.nextSibling.nodeValue = " "+pnew+" EUR";
 }
}


// ==============================
// Zeitschaltuhr
// ==============================
function TimeSwitch(JahrVon,MonatVon,TagVon,StundeVon,MinuteVon, JahrBis,MonatBis,TagBis,StundeBis,MinuteBis)
{
	//-ff liefert 'true' zu einem bestimmten Zeitpunkt
	var jetztneu = new Date();
	var Jetzt = Date.UTC(jetztneu.getUTCFullYear(),jetztneu.getUTCMonth(),jetztneu.getUTCDate(),jetztneu.getUTCHours()+1,jetztneu.getUTCMinutes(),jetztneu.getUTCSeconds());

	MonatVon--; //Date-Monatszählung beginnt bei 0 = Januar
	MonatBis--;

	if( Jetzt >= Date.UTC(JahrVon,MonatVon,TagVon,StundeVon,MinuteVon,00) && Jetzt <= Date.UTC(JahrBis,MonatBis,TagBis,StundeBis,MinuteBis,00) )
	{
		//Zeit eintagen Jahr->Monat->Tag->Stunde->Minute->Sekunde
		return true;
	}
}


// ==============================
// PopUps
// ==============================


function WinOutNewsletterPopup() {
  if(parent.GetCookie('Kunde') != '1' && parent.GetCookie('NLPopup') != '1')
  {
		window.open('http://gerryweber.twt.de/gwtcnl/index.php','NewsletterPopup', 'width=519,height=343,scrollbars=no,toolbar=no,status=no,resizable=no,top=100,screenX=100,screenY=100');    
		var Zeit = new Date();
  	var nun = Zeit.getTime();
  	Zeit.setTime(nun + 1*24*60*60*14000);// 14 Tage
		parent.SetCookie('NLPopup','1',Zeit)
	}
}

function WinOutFeedback(){
	if(Lng == "at")
		window.open('HtmlMain/samoon/at/SC_feedback.html','Ihre_Meinung', 'width=700,height=496,scrollbars=no,toolbar=no,status=no,resizable=no,top=100,screenX=100,screenY=100');    
	else if (Lng == "nl")
		window.open('HtmlMain/samoon/nl/SC_feedback.html','Ihre_Meinung', 'width=700,height=496,scrollbars=no,toolbar=no,status=no,resizable=no,top=100,screenX=100,screenY=100');    
	else
		window.open('HtmlMain/samoon/de/SC_feedback.html','Ihre_Meinung', 'width=700,height=496,scrollbars=no,toolbar=no,status=no,resizable=no,top=100,screenX=100,screenY=100');    
}

function WinOutBestellablauf(){
	if(Lng == "at")
		window.open('HtmlMain/samoon/at/SC_bestellablauf_s1.html','Bestellablauf', 'width=924,height=590,scrollbars=no,toolbar=no,status=no,resizable=no,top=100,screenX=100,screenY=100');    
	else if (Lng == "nl")
		window.open('HtmlMain/samoon/nl/SC_bestellablauf_s1.html','Bestellablauf', 'width=924,height=590,scrollbars=no,toolbar=no,status=no,resizable=no,top=100,screenX=100,screenY=100'); 
	else
		window.open('HtmlMain/samoon/de/SC_bestellablauf_s1.html','Bestellablauf', 'width=924,height=590,scrollbars=no,toolbar=no,status=no,resizable=no,top=100,screenX=100,screenY=100');       
}

function WinSchloesser(){
	window.open('https://gerry-weber.adartists-online.net/gerryweber_schloss/','688477','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=688,height=477');
	void(0);
}



