var mailwin = null;
var remwin = null;
var WKwin = null;
var newswin = null;



function gotopage(page, aid, cat)
{
	if(cat != "-1")
		window.location.href = page + "Auswahl="+aid+"&cat="+cat;
}

//produkt weiterempfehlen - öffnet ein neus Fenster um die email adressen einzugeben
function openmailwin(aid,delay)
{
	var url = "Shop/Mail.aspx?delay="+delay+"&Auswahl="+aid;
	var parameter = "menubar=no,toolbar=no,statusbar=no,location=no,width=400px,height=540px";
	
	var mailwin = window.open('', 'Weiterempfehlen',parameter);
	try{
		
		if(mailwin.location.href.indexOf("Mail") != -1){
		//	alert("Fall 1 - Pop-Up ist geöffnet");
	      mailwin.location.href = url+'&is_open=1';
		}else{
		//	alert("Fall 2 - Pop-Up ist nicht geöffnet");
			mailwin = window.open(url+'&is_open=0','Weiterempfehlen',parameter);
		}
	}catch(e){
		mailwin.location.href = url+'&is_open=1';
	}
	if (mailwin != null) {
		mailwin.window.focus();
	}
}

//produkt vormerken - öffnet ein fenster um das vormerken eines produkts zu bestätigen
function openrememberwin(aid,delay)
{
	var url = "Shop/Remember.aspx?delay="+delay+"&Auswahl="+aid;
	var parameter = "menubar=no,toolbar=no,statusbar=no,location=no,width=400px,height=370px";
	
	var remwin = window.open('', 'Merkzettel',parameter);
	try{
		
		if(remwin.location.href.indexOf("Remember") != -1){
		//	alert("Fall 1 - Pop-Up ist geöffnet");
	      remwin.location.href = url+'&is_open=1';
		}else{
		//	alert("Fall 2 - Pop-Up ist nicht geöffnet");
			remwin = window.open(url+'&is_open=0','Merkzettel',parameter);
		}
	}catch(e){
		popuphandlerrem.location.href = url+'&is_open=1';
	}
	if (remwin != null) {
		remwin.window.focus();
	}
}

//produkt in den Warenkorb geben - öffnet ein fenster um den Vorgang zu laden
function openWKwin(aid,delay)
{
	var url = "Shop/Warenkorbpop.aspx?delay="+delay+"&Auswahl="+aid;
	var parameter = "menubar=no,toolbar=no,statusbar=no,location=no,width=400px,height=370px";
	
	var WKwin = window.open('', 'Warenkorb',parameter);
	try{
		
		if(WKwin.location.href.indexOf("Warenkorb") != -1){
		//	alert("Fall 1 - Pop-Up ist geöffnet");
	      WKwin.location.href = url+'&is_open=1';
		}else{
		//	alert("Fall 2 - Pop-Up ist nicht geöffnet");
			WKwin = window.open(url+'&is_open=0','Warenkorb',parameter);
		}
	}catch(e){
		WKwin.location.href = url+'&is_open=1';
	}
	if (WKwin != null) {
		WKwin.window.focus();
	}
}


//produkt in den Warenkorb geben - öffnet ein fenster um den Vorgang zu bestätigen
function openNewsletterwin(aid,id,name)
{
	var url = "Shop/Newsletterpop.aspx?Auswahl="+aid+"&id="+id+"&name="+name;
	var parameter = "menubar=no,toolbar=no,statusbar=no,location=no,width=400px,height=320px";
	
	var newswin = window.open('', 'Newsletter',parameter);
	try{
		
		if(newswin.location.href.indexOf("Newsletterpop") != -1){
		//	alert("Fall 1 - Pop-Up ist geöffnet");
	      newswin.location.href = url+'&is_open=1';
		}else{
		//	alert("Fall 2 - Pop-Up ist nicht geöffnet");
			newswin = window.open(url+'&is_open=0','Newsletter',parameter);
		}
	}catch(e){
		newswin.location.href = url+'&is_open=1';
	}
	if (newswin != null) {
		newswin.window.focus();
	}
}


//produkt in den Warenkorb geben - öffnet ein fenster um den Vorgang zu bestätigen
function openMediawin(aid,id,bild)
{
	var url = "Shop/Fotopop.aspx?Auswahl="+aid+"&product="+id+"&bild="+bild;
	var parameter = "menubar=no,toolbar=no,statusbar=no,location=no,width=460px,height=398px";
	
	var newswin = window.open('', 'Bildanzeige',parameter);
	try{
		
		if(newswin.location.href.indexOf("Fotopop") != -1){
		//	alert("Fall 1 - Pop-Up ist geöffnet");
	      newswin.location.href = url+'&is_open=1';
		}else{
		//	alert("Fall 2 - Pop-Up ist nicht geöffnet");
			newswin = window.open(url+'&is_open=0','Bildanzeige',parameter);
		}
	}catch(e){
		newswin.location.href = url+'&is_open=1';
	}
	if (newswin != null) {
		newswin.window.focus();
	}
}


//produkte vergleichen
function openCompareWin(aid,delay)
{
	var url = "Shop/Vergleichenpop.aspx?delay="+delay+"&Auswahl="+aid;
	var parameter = "menubar=no,toolbar=no,statusbar=no,location=no,top=0px,left=0px,width="+screen.width+"px,height="+screen.height+"px";
	
	var remwin = window.open('', 'Vergleichen',parameter);
	try{
		
		if(remwin.location.href.indexOf("Vergleichen") != -1){
		//	alert("Fall 1 - Pop-Up ist geöffnet");
	      remwin.location.href = url+'&is_open=1';
		}else{
		//	alert("Fall 2 - Pop-Up ist nicht geöffnet");
			remwin = window.open(url+'&is_open=0','Vergleichen',parameter);
		}
	}catch(e){
		popuphandlerrem.location.href = url+'&is_open=1';
	}
	if (remwin != null) {
		remwin.window.focus();
	}
}

//produkt in den Warenkorb geben - öffnet ein fenster um den Vorgang zu bestätigen
function openHelpwin()
{
	var url = "Shop/Hilfe.aspx";
	var parameter = "menubar=no,toolbar=no,statusbar=no,location=no,width=770px,height=470px";
	
	var newswin = window.open('', 'Hilfe',parameter);
	try{
		
		if(newswin.location.href.indexOf("Hilfe") != -1){
		//	alert("Fall 1 - Pop-Up ist geöffnet");
	      newswin.location.href = url+'?is_open=1';
		}else{
		//	alert("Fall 2 - Pop-Up ist nicht geöffnet");
			newswin = window.open(url+'?is_open=0','Hilfe',parameter);
		}
	}catch(e){
		newswin.location.href = url+'?is_open=1';
	}
	if (newswin != null) {
		newswin.window.focus();
	}
}

var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printscreen(name,url)
{
	if (document.layers){
	//Netscape 4 specific code
		pre = 'document.';
		post1 = '';
	}
	if (document.getElementById){
		//Netscape 6 specific code
		pre = 'document.getElementById("';
		post1 = '")';
	}
	if (document.all){
		//IE4+ specific code
		pre = 'document.all.';
		post1 = '';		
	}

	var myLayer = eval(pre + 'content' + post1);
		
	var parameter = "menubar=no,toolbar=no,statusbar=no,location=no,width=750px,height=540px";
	var printWin = window.open("","printSpecial",parameter);
	myLayer
	var text = myLayer.innerHTML.replace(/<< back/,"").replace(/&lt;&lt; back/,"");
	text = text.replace(/<a/,"<a style='disable:true'").replace(/<A/,"<a style='disable:true'");

	printWin.document.open();	
	printWin.document.write("<html><head><script language='javascript' src='Shop/Javascripts/shop.js' type='text/javascript'></script><link href='Shop/css/webshop.css' rel='stylesheet' type='text/css'></link></head><body onload='killlinks()'><form onsubmit='return false;'>" + text + "</form><div style='font-family:verdana;font-size:10;'>Um diesen Artikel bei "+name+" zu bestellen, gehen sie auf "+url+" und geben Sie bitte den Artikelnamen im Bestellformular manuell ins Suchfeld ein. </div></body></html>");
	printWin.document.close();
	if (gAutoPrint)
		printWin.print();
}

function showAdresse(id)
{
	var div = document.getElementById("adresse");
	if(div != null)
	{
		if(id == 1)
			div.style.display = "block";
		else div.style.display = "none";
	}
}


/*ändern des bildes eines elements*/
function changepic(obj,filename)
{
	obj.src = "Grafik/application/buttons/"+filename;
}

//zerstört alle links innerhalb eines dokuments
function killlinks()
{
	for(i=0; i< document.links.length; i++)
	{
		document.links[i].href  = "#";
	}
}
