//	SessionID aus der Referer-URL lesen und als Variable den Funktionen hinzufügen
//alert (location.search);

var sessionurl="";
var sessionid="";

sessionurl=location.search;
sessionurl=sessionurl.replace (/\?/,"");
sessionurlelemente=sessionurl.split("&");

//alert(sessionurlelemente);


//alert(sessionurlelemente.length);

for (var i = 0; i <= (sessionurlelemente.length-1); i++) {
//alert("1: "+i);
//alert("2: " +sessionurlelemente[i]);
	if (sessionurlelemente[i].match(/^PHPSESSID/)) {
		sessionid=sessionurlelemente[i];
	}
}



function hilfe(seite) {
	if (sessionid) sessionidthis=sessionid+'&'; else sessionidthis="";
	gr=writeinlinepopup(640,'max');
	parent.popiframe.location.href='/modul.cms.popup.php?'+sessionidthis+'doc='+seite+'&gr='+encodeURI(gr);
}

//	Hilfe innerhalb von Formularen
function hilfe_anzeigen(status) {
	if (status==1) status='block';
	for (i=1; i<=20; i++) {
		if (document.getElementById('formularhinweis'+i)) document.getElementById('formularhinweis'+i).style.display=status;
	}
}
							
function login(server) {
	if (sessionid) sessionidthis='?'+sessionid; else sessionidthis="?";
	writeinlinepopup(450,380);
	parent.popiframe.location.replace(server+'modul.cms.login.php'+sessionidthis);
}

function addBasket(server,shop,nr,ref) {
	if (sessionid) sessionidthis=sessionid+'&'; else sessionidthis="";
	gr=writeinlinepopup(800,400);
	if (ref=="basket") parent.popiframe.location.replace(server+'modul.shop.addBasket.php?'+sessionidthis+'gr='+encodeURI(gr)+'&domain='+shop+'&bestellnr='+nr+'&ref='+ref);
	else parent.popiframe.location.replace(server+'modul.shop.addBasket.php?'+sessionidthis+'gr='+encodeURI(gr)+'&domain='+shop+'&bestellnr='+nr+'&ref='+ref);
}

function lagerbestand(hersteller, bestellnr) {
	if (sessionid) sessionidthis=sessionid+'&'; else sessionidthis="";
	parent.popiframe.location.href='/modul.shop.lagerbestand.php?'+sessionidthis+'hersteller='+hersteller+'&bestellnr='+bestellnr;
	writeinlinepopup(800,500);
}

function fragestellen(betreff) {
	if (sessionid) sessionidthis=sessionid+'&'; else sessionidthis="";
	gr=writeinlinepopup(800,550);
	parent.popiframe.location.href='/modul.cms.fragestellen.php?'+sessionidthis+'gr='+encodeURI(gr)+'&betreff='+betreff;
}

function wunschpreis(betreff) {
	if (sessionid) sessionidthis=sessionid+'&'; else sessionidthis="";
	gr=writeinlinepopup(800,500);
	parent.popiframe.location.href='/modul.shop.wunschpreis.php?'+sessionidthis+'gr='+encodeURI(gr)+'&betreff='+betreff;
}

function fax() {
	if (sessionid) sessionidthis='?'+sessionid; else sessionidthis="";
	x=800;
	y=500;
	l=Math.round((screen.width-x)/2);
	t=Math.round((screen.height-y)/2);
	window.open ('../fax.php'+sessionidthis,'faxfenster','menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,width='+x+',height='+y+',left='+l+',top='+(t-50));
}

var pbild = new Image();
var sbild = new Image();
var purl ="";
var groesse = "250";
var verzeichnis="../";

pbild.onload = function() {
	document.getElementById('produktbild').src=""+purl+"";
}

sbild.onload = function() {
	document.getElementById("produktbild").src=verzeichnis+"images/"+groesse+".php?shop=000000000&bild=bild_laden";
	// richtiges Bild laden
	pbild.src = ""+purl+"";
}


function prbild(url, text) {
	purl=url;
	sbild.src = verzeichnis+"images/"+groesse+".php?shop=go2a&bild=bild_laden";
	if (top.document.getElementById('inlinepopuptitel')) {
		top.document.getElementById('inlinepopuptitel').innerHTML=text;
	}
}

function prbild2(hersteller,bild) {
	document.getElementById("produktbild").src=verzeichnis+"images/250.php?shop="+hersteller+"&bild="+bild;
}

function przoom(hersteller,produkt,bild) {
	if (sessionid) sessionidthis=sessionid+'&'; else sessionidthis="";
	gr=writeinlinepopup('max','max');
	parent.popiframe.location.replace('/modul.shop.produktgallerie.php?'+sessionidthis+'gr='+gr+'&hersteller='+hersteller+'&produkt='+produkt+'&bild='+bild);
//top.popiframe.document.location.href = '/modul.shop.produktgallerie.php?'+sessionidthis+'gr='+gr+'&hersteller='+hersteller+'&produkt='+produkt+'&bild='+bild;
//	writeinlinepopup(800,570);
}

function awzoom(bild,ordner) {
	if (sessionid) sessionidthis=sessionid+'&'; else sessionidthis="";
	gr=writeinlinepopup(900,600);
	parent.popiframe.location.replace('/modul.cms.gallerie.php?'+sessionidthis+'gr='+encodeURI(gr)+'&bild='+bild+'&ordner='+ordner);
}

function flvvideo(name) {
	if (sessionid) sessionidthis=sessionid+'&'; else sessionidthis="";
	gr=writeinlinepopup(800,600);
	parent.popiframe.location.replace('../template/media/flv/video.php?'+sessionidthis+'gr='+encodeURI(gr)+'&video='+name);
}

function getWindowSize() {
	var yPos;
	var myHeight;
	var myWidth;
	var ie;
	if (self.innerHeight) {
		yPos = self.pageYOffset;
		myHeight = self.innerHeight;
		myWidth = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		yPos = document.documentElement.scrollTop;
		myHeight = document.documentElement.clientHeight;
		myWidth = document.documentElement.clientWidth;
		ie=1;
	} else if (document.body) {
		yPos = document.body.scrollTop;
		myHeight = document.body.clientHeight;
		myWidth = document.body.clientWidth;
		ie=1;
	}
	return new Array(yPos, myHeight, myWidth, ie);
}


function writeinlinepopup(breite,hoehe) {
	fensterwerte = getWindowSize();
	yPos = fensterwerte[0];
	myHeight = fensterwerte[1];
	myWidth = fensterwerte[2];
	ie = fensterwerte[3];
	//	- Prüfen, ob gewünschte Höhe ins Fenster passt, wenn nein, Höhe korregieren
	//	- wenn maximale Höhe angezeigt werden soll, diese automatisch ermitteln
	if ((hoehe > myHeight) || (hoehe=="max")) hoehe = myHeight - 40;
	//	- Prüfen, ob gewünschte Breite ins Fenster passt, wenn nein, Breite korregieren
	//	- wenn maximale Breite angezeigt werden soll, diese automatisch ermitteln
	if ((breite > myWidth) || (breite=="max")) breite = myWidth - 60;
	//	- Größe des Popups ändern
	parent.document.getElementById('pop').style.width= breite+ 'px';
	parent.document.getElementById('pop').style.margin='0px';
	parent.document.getElementById('inlinepopupiframe').style.width= breite + 'px';
	parent.document.getElementById('pop').style.height= hoehe + 'px';
	parent.document.getElementById('inlinepopupiframe').style.height= hoehe - 38 + 'px';
	//	Verschieben in y-Richtung
	yGo = (myHeight - hoehe) / 2;
	document.getElementById("pop").style.top = yPos+ yGo +"px";
	//	Verschieben in x - Richtung
	x = (myWidth - breite) / 2;
	document.getElementById("pop").style.left = x +"px";

	if (document.body.scrollHeight > myHeight) offHeight = document.body.scrollHeight + 150;
	else offHeight = myHeight;
	document.getElementById("off").style.height = offHeight + "px";
//	document.getElementById("off").style.height = document.body.scrollHeight + 150 + "px";
	document.getElementById('off').style.display='block';
	document.getElementById('pop').style.display='block';
	//	gibt die tatsächliche Größe des Popups zurück
	return breite+"|"+hoehe;
}



/*		Inlinepopup ausblenden		*/
function deleteinlinepopup() {
	// Debug für iPad usw.
	if (!parent.popiframe) {
		top.location.reload();
	}

	else {
		document.getElementById('off').style.display='none';
		document.getElementById('pop').style.display='none';
		parent.popiframe.location.replace('/modul.cms.popupnothing.php');
	}
}



var shopcurver=false;
var shoprubbermaid=false;
var shoptc=false;

var shoplogos=false;

var meinshophover=false;
var helphover=false;
var ueberunshover=false;
var warenkorbhover=false;


var menueon=0;
var waittime=false;


function hovershopin(id, hoehe) {
	fensterwerte = getWindowSize();
	yPos = fensterwerte[0];
	myHeight = fensterwerte[1];
	if ((hoehe > myHeight) || (hoehe=="max")) hoehe = myHeight - 40;
	document.getElementById(id).style.height= hoehe + "px";
	yGo = (myHeight - hoehe) / 2;
	document.getElementById(id+'out').style.top = yPos + yGo +"px"
	document.getElementById(id+'inner').style.height= hoehe - 38 + "px";
	document.getElementById('off').style.display='block';
	if (document.body.scrollHeight > myHeight) offHeight = document.body.scrollHeight + 150;
	else offHeight = myHeight;
	document.getElementById("off").style.height = offHeight + "px";
	hoverinwait(id, 0);
}

function hovershopout(id) {
	document.getElementById('off').style.display='none';
	hoverout(id);
}



function hoverin(id, mausklick, atag) {
	menueon=id;
	switch (id) {
		case 'shopcurver': clearTimeout(shopcurver); break;
		case 'shoprubbermaid': clearTimeout(shoprubbermaid); break;
		case 'shoptc': clearTimeout(shoptc); break;
		case 'shoplogos': clearTimeout(shoplogos); break;
		case 'meinshophover': clearTimeout(meinshophover); break;
		case 'helphover': clearTimeout(helphover); break;
		case 'ueberunshover': clearTimeout(ueberunshover); break;
		case 'warenkorbhover': clearTimeout(warenkorbhover); break;
	}
	document.getElementById(id).style.display ='block';
}

function hoverinwait(id, warten, quelle) {
	var tablet = 0;
	if (
		(navigator.userAgent.indexOf("iPad") != -1) ||
		(navigator.userAgent.indexOf("iPhone") != -1) ||
		(navigator.userAgent.indexOf("Tablet PC") != -1) ||
		(navigator.userAgent.indexOf("Android") != -1)
	) tablet = 1;
	
	if (quelle!=1 && tablet==1) return;
	if (quelle==1 && tablet!=1) return;
	
	if (quelle==1 && menueon!=0 && menueon==id) { hoverout2(id);  return }
	
	if (menueon!=0 || warten == 0) hoverin(id);
	else waittime=setTimeout('hoverin("'+id+'");',250);
}

function hoverout2(id) {
	document.getElementById(id).style.display ='none';
	if (menueon==id) menueon=0;
}

function hoverout(id) {
	clearTimeout(waittime);
	switch (id) {
//shops ohne timeout schließen	
		case 'shopcurver': 
		case 'shoprubbermaid': 
		case 'shoptc':
		case 'shoplogos': hoverout2(id); break;
		case 'meinshophover': meinshophover=setTimeout('hoverout2("'+id+'");',200); break;
		case 'helphover': helphover=setTimeout('hoverout2("'+id+'");',200); break;
		case 'ueberunshover': ueberunshover=setTimeout('hoverout2("'+id+'");',200); break;
		case 'warenkorbhover': warenkorbhover=setTimeout('hoverout2("'+id+'");',200); break;
	}
}


