// JavaScript Document
// $Id: script.basic.js,v 1.10 2009/04/08 08:31:29 tschmidt Exp $
/*function preloadAllImages() {
	MM_preloadImages('../images/nav_kasten2.gif');
	MM_preloadImages('../images/pfeil2.gif');
}*/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function loadPDF(ACTION,ID,LNG) {
	window.open("pdfView.php?action="+ACTION+"&conid="+ID+"&lngid=1");
}

function printView(bereich,eintrag,sprache) {
	var breite=510; 
	var hoehe=700; 
	var positionX=((screen.availWidth / 2) - breite / 2); 
	var positionY=((screen.availHeight / 2) - hoehe / 2); 
	var url='ausdrucken.php?type='+bereich+'&id='+eintrag+'&lng='+sprache;

	pop=window.open('','Druckansicht','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=10,left=10');  
	pop.location=url;

}
function openPrintView(url) {
	var breite=660; 
	var hoehe=700; 
	var positionX=((screen.availWidth / 2) - breite / 2); 
	var positionY=((screen.availHeight / 2) - hoehe / 2); 

	pop=window.open('','Druckansicht','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=10,left=10');  
	pop.location=url;

}
function AddToBasket(SID) {
	var AMOUNT = document.ProdDetail.order_amount.value;
	var ID = document.ProdDetail.oderProId.value;
	location.href=''+'?abskt='+ID+'&amnt='+AMOUNT+'&sid='+SID;
}

function addBasket(PROD) {
	var tmp=document.getElementById("abskt")
	tmp.value=PROD;
	document.productView.submit();
}

function AddToBasketStart(ID) {
	var tmp=document.getElementById("abskt")
	tmp.value=ID;
	document.spo.submit();
}
function AddNeuToBasket(ID) {
	var tmp=document.getElementById("abskt")
	tmp.value=ID;
	document.spn.submit();
}


function DelBasketItm(ID) {
	//location.href=''+'?dbskt='+ID;
	var amountField = document.getElementById("amnt"+ID);
	amountField.value='0';
	document.basket.submit();
}

function newsletterAbo(s)
{
	var a = false;
	var res = false;
	var s = document.getElementById('nlAboEmail').value;
	if(typeof(RegExp) == 'function') {
		var b = new RegExp('abc');
		if(b.test('abc') == true){a = true;}
	}
	
	if(a == true) {
		reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
					   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
					   '(\\.)([a-zA-Z]{2,4})$');
		res = (reg.test(s));
	} else {
		res = (s.search('@') >= 1 &&
			 s.lastIndexOf('.') > s.search('@') &&
			 s.lastIndexOf('.') >= s.length-5)
	}
	
	if(res == true) {
		document.newsletterabo.submit();	
	} else {
		alert("Die Emailadresse scheint nicht korrekt zu sein.");	
	}
}

function grossansicht(bild,x,y,url) { 
	var breite=x*1.25; 
	var hoehe=y*1.25; 
	var positionX=((screen.availWidth / 2) - breite / 2); 
	var positionY=((screen.availHeight / 2) - hoehe / 2); 
	var url=url+'bildansicht.php?pic='+bild+'&x='+x+'&y='+y;

	pop=window.open('','Bildvergrößerung','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=10,left=10');  
	pop.location=url;
}

function passwortsicherheit() { 
	var breite=600; 
	var hoehe=500; 
	var positionX=((screen.availWidth / 2) - breite / 2); 
	var positionY=((screen.availHeight / 2) - hoehe / 2); 
	var url='passwortsicherheit.php';

	pop=window.open('passwortsicherheit.php','Passwortsicheheit','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=20,left=20');  
	pop.location=url;
	
}

function verfuegbarkeit() { 
	var breite=450; 
	var hoehe=300; 
	var positionX=((screen.availWidth / 2) - breite / 2); 
	var positionY=((screen.availHeight / 2) - hoehe / 2); 
	var url='verfuegbarkeit.php';

	pop=window.open('verfuegbarkeit.php','Legende','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=20,left=20');  
	pop.location=url;
	
}

function directOrderPZN(NR,STR) {
	document.getElementById('pzn'+NR).value = STR;
}

function directOrderReset(SID) {
	location.href='direktbestellung.html?sid='+SID;
}

function directOrderGo(SID) {
	document.directorder.action = "warenkorb.html?sid="+SID;
	document.directorder.submit();
}

// DIVs ein- und ausblenden
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// -------- Funktionen zusammenfassen -------------------------------------------- 

// Reimport DIVs öffnen
function reimport_divs_open(){
	//alert ("So, so, Sie verwenden also " + navigator.appName);
		if (navigator.appName == "Microsoft Internet Explorer") {
			//alert ("IF Abfrage ausgewaehlt");
			MM_showHideLayers('reimportinfo','','show');
			MM_showHideLayers('reimportschatten','','show');
		} else {
			//alert ("ELSE Abfrage ausgewaehlt");
			MM_showHideLayers('reimportinfo','','show');
			MM_showHideLayers('reimportschatten','','show');
		}
}
// Reimport DIVs schliessen
function reimport_divs_close(){
		MM_showHideLayers('reimportinfo','','hide');
		MM_showHideLayers('reimportschatten','','hide');
}

// sprechzeiten DIVs öffnen
function sprechzeiten_divs_open(){
	if (navigator.appName == "Microsoft Internet Explorer"){
		document.getElementById('ccinfos').style.width = '250'; 
		document.getElementById('ccinfos').style.left = '200';
		document.getElementById('ccinfos').style.top = '165'; 
		document.getElementById('ccinfos').style.display = 'block'; 
	} else if (navigator.appName == "Opera") {
		document.getElementById('ccinfos').style.display = 'block';
	} else {
		document.getElementById('ccinfos').style.display = 'block';	
	}
}
// sprechzeiten DIVs schliessen
function sprechzeiten_divs_close(){
		document.getElementById('ccinfos').style.display = 'none';
}

// Kerastase DIVs öffnen
function kerastase_divs_open(ID){
	/* ID´s können verschiedene Stati haben
	 * 1 = Normales Beauty&Wellness DIV
	 * 2 = öffnet Kerastase Infoseite 2
	 * 3 = öffnet Kerastase Infoseite 3
	 */
	
	if(ID == 1) {
		if (navigator.appName == "Microsoft Internet Explorer") {
			document.getElementById('kerastaseinfo').style.width = '475';
			document.getElementById('kerastaseinfo').style.top = '482';
			MM_showHideLayers('kerastaseinfo','','show');
			MM_showHideLayers('kerastaseinfo1','','hide');
			MM_showHideLayers('kerastaseinfo2','','hide');
		} else if (navigator.appName == "Opera") {
			document.getElementById('kerastaseinfo').style.width = '475';
			document.getElementById('kerastaseinfo').style.top = '460';
			MM_showHideLayers('kerastaseinfo','','show');
			MM_showHideLayers('kerastaseinfo1','','hide');
			MM_showHideLayers('kerastaseinfo2','','hide');	
		} else {
			MM_showHideLayers('kerastaseinfo','','show');
			MM_showHideLayers('kerastaseinfo1','','hide');
			MM_showHideLayers('kerastaseinfo2','','hide');
		}
	} else if (ID == 2) {
		if (navigator.appName == "Microsoft Internet Explorer") {
			document.getElementById('kerastaseinfo1').style.width = '475';
			document.getElementById('kerastaseinfo1').style.top = '482';
			MM_showHideLayers('kerastaseinfo','','hide');
			MM_showHideLayers('kerastaseinfo1','','show');
			MM_showHideLayers('kerastaseinfo2','','hide');
		} else if (navigator.appName == "Opera") {
			document.getElementById('kerastaseinfo1').style.width = '475';
			document.getElementById('kerastaseinfo1').style.top = '490';
			MM_showHideLayers('kerastaseinfo','','hide');
			MM_showHideLayers('kerastaseinfo1','','show');
			MM_showHideLayers('kerastaseinfo2','','hide');	
		} else {
			MM_showHideLayers('kerastaseinfo','','hide');
			MM_showHideLayers('kerastaseinfo1','','show');
			MM_showHideLayers('kerastaseinfo2','','hide');
		}
	} else if (ID == 3) {
		if (navigator.appName == "Microsoft Internet Explorer") {
			document.getElementById('kerastaseinfo2').style.width = '475';
			document.getElementById('kerastaseinfo2').style.top = '482';
			MM_showHideLayers('kerastaseinfo','','hide');
			MM_showHideLayers('kerastaseinfo1','','hide');
			MM_showHideLayers('kerastaseinfo2','','show');
		} else if (navigator.appName == "Opera") {
			document.getElementById('kerastaseinfo1').style.width = '475';
			document.getElementById('kerastaseinfo1').style.top = '490';
			MM_showHideLayers('kerastaseinfo','','hide');
			MM_showHideLayers('kerastaseinfo1','','hide');
			MM_showHideLayers('kerastaseinfo2','','show');	
		} else {
			MM_showHideLayers('kerastaseinfo','','hide');
			MM_showHideLayers('kerastaseinfo1','','hide');
			MM_showHideLayers('kerastaseinfo2','','show');
		}
	}	
}
// Kerastase DIVs schliessen
function kerastase_divs_close(){
	MM_showHideLayers('kerastaseinfo','','hide');
	MM_showHideLayers('kerastaseinfo1','','hide');
	MM_showHideLayers('kerastaseinfo2','','hide');
}

// lastschrift DIVs öffnen
function lastschrift_divs_open(){
	if (navigator.appName == "Microsoft Internet Explorer") {
		MM_showHideLayers('lastschriftinfo','','show');
		MM_showHideLayers('lastschriftschatten','','show');
	} else {
		MM_showHideLayers('lastschriftinfo','','show');
		MM_showHideLayers('lastschriftschatten','','show');
	}
}
// lastschrift DIVs schliessen
function lastschrift_divs_close(){
		MM_showHideLayers('lastschriftinfo','','hide');
		MM_showHideLayers('lastschriftschatten','','hide');
}

// -------- Funktionen zusammenfassen -------------------------------------------- 


// Popup fuer Wie bestelle ich
function helpgross(bild,x,y) { 
	var breite=x*1.25; 
	var hoehe=y*1.25; 
	var positionX=((screen.availWidth / 2) - breite / 2); 
	var positionY=((screen.availHeight / 2) - hoehe / 2); 
	var url='bildansicht_help.php?pic='+bild+'&x='+x+'&y='+y;

	pop=window.open('','Bildvergrößerung','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=10,left=10');  
	pop.location=url;
}

// -------- Warenkorb Funktionen -------------------------------------------- 
function wkDrucken(wk,printas) { 
	var breite=600; 
	var hoehe=800; 
	var positionX=((screen.availWidth / 2) - breite / 2); 
	var positionY=((screen.availHeight / 2) - hoehe / 2); 
	var url='print_basket.php?wk='+wk+'&printas='+printas;

	pop=window.open('','Bestellschein','toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=10,left=10');  
	pop.location=url;
}

function wkSenden() {
	if(document.getElementById('sendBasket').style.display == 'none') {
		document.getElementById('sendBasket').style.display = 'block';
	} else {
		document.getElementById('sendBasket').style.display = 'none';
	}
}

function wkMailSend() {
	document.wkMailForm.submit();
}

wmtt = null;

document.onmousemove = updateWMTT;

function updateWMTT(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (wmtt != null) {
		wmtt.style.left = (x - 200) + "px";
		wmtt.style.top 	= (y + 40) + "px";
	}
}

function showWMTT(id) {
	wmtt = document.getElementById(id);
	wmtt.style.display = "block"
}

function hideWMTT() {
	wmtt.style.display = "none";
}

// -------- Suchplugins -------------------------------------------- 
function pluginpruefung() {
	var agent = navigator.userAgent;
	var teste = agent.match(/Firefox\/1/);
	var hideall = true;

	if(teste!=null) {
	if(teste.length==1) {
		hideall = false;
		document.getElementById('ff2').style.display = "none";
		document.getElementById('ie7').style.display = "none";
		document.getElementById('op9').style.display = "none";
	}
	}
	
	var teste2 = agent.match(/Firefox\/2/) || agent.match(/Firefox\/3/);
	if(teste2!=null) {
	if(teste2.length==1) {
		hideall = false;
		document.getElementById('ff1').style.display = "none";
		document.getElementById('ie7').style.display = "none";
		document.getElementById('op9').style.display = "none";
		document.getElementById('op9').style.display = "none";
	}
	}
	
	var teste3 = agent.match(/MSIE 7/);
	if(teste3!=null) {
	if(teste3.length==1) {
		hideall = false;
		document.getElementById('ff1').style.display = "none";
		document.getElementById('ff2').style.display = "none";
		document.getElementById('op9').style.display = "none";
	}
	}
	
	var teste4 = agent.match(/Opera/);
	if(teste4!=null) {
	if(teste4.length==1) {
		hideall = false;
		document.getElementById('ff1').style.display = "none";
		document.getElementById('ff2').style.display = "none";
		document.getElementById('ie7').style.display = "none";
	}
	}
	
	if(hideall==true) {
		document.getElementById('PluginMsg').style.display = "block";
		document.getElementById('ff1').style.display = "none";
		document.getElementById('ff2').style.display = "none";
		document.getElementById('ie7').style.display = "none";
		document.getElementById('op9').style.display = "none";
	}
}

var showAll=false;
var firststart=true;
function showAllPlugins() {
	if(showAll==false && firststart==false) {
		showAll=true;
		pluginpruefung();
	} else {
		showAll=false;
		firststart=false;
		document.getElementById('ff1').style.display = "block";
		document.getElementById('ff2').style.display = "block";
		document.getElementById('ie7').style.display = "block";
		document.getElementById('op9').style.display = "block";
	}	
}

var showHelp=false;
function showOperaHelp() {
	if(showHelp==false) {
		document.getElementById('operaHelp').style.display = "block";
		showHelp=true;
	} else {
		document.getElementById('operaHelp').style.display = "none";
		showHelp=false;
	}
}

function addOpera() { // Opera 9
	location.href="http://www.aponeo.de/extras/search_plugins/aponeo-de.se7";
}

function addProvider() { // Firefox 2, IE7	
	try {
		window.external.AddSearchProvider('http://www.aponeo.de/extras/search_plugins/aponeo_suche.xml');
	} catch (e) {	
		alert("Um dieses Suchplugin installieren zu können, benötigen Sie den Browser\r\nInternet Explorer 7 oder Firefox2.");
		return;
	}
}

function errorMsg() {
	alert("Mozilla oder Netscape ab v6 ist notwendig,\num das Plugin zu installieren.");
}

function addEngine() {
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
		window.sidebar.addSearchEngine(
			"http://www.aponeo.de/extras/search_plugins/aponeo-de.src",
			"http://www.aponeo.de/extras/search_plugins/aponeo-de.png",
			"aponeo-de",
			"Medizin" );
	} else {
		errorMsg();
	}
}

function openExtSearch() {
	var idv = document.getElementById('SearchFormHeadExtend');

	if(idv.style.display=='block') {
		idv.style.display='none';
	} else {
		idv.style.display='block';
	}
}

function toggleNavBar(div, action) {
	var obj=eval(document.getElementById(div));
	var expdate = new Date (); 
        expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000)); //Verfallsdatum setzen
		
	if(obj!=null) {
		if(action==null) {
			if(obj.style.display=='block') {
				obj.style.display='none';
				var sC = SetCookie(div, 'none', expdate);
			} else if(obj.style.display=='none') {
				obj.style.display='block';
				var sC = SetCookie(div, 'block', expdate);
			} else {
				obj.style.display='none';
				var sC = SetCookie(div, 'none', expdate);			
			}
		} else {
			obj.style.display=action;
		}
	}
}

// --- Cookie Handling --------------------------

//var xyz = SetCookie('Name', 'Wert', 'Ablaufdatum')
function SetCookie (name, value, expires) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}

//DeleteCookie('Name')
function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
	
//var xyz = GetCookie("Name")
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function jumpMenuGo(objId,targ,restore){ //v9.0
  var selObj = null;  with (document) { 
  if (getElementById) selObj = getElementById(objId);
  if (selObj) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0; }
}

function openPwRequest(url,sid) {
	var tmp = document.loginform.email.value;
	if(tmp.length>5) {
		location.href=url + "?pwreq=" + tmp + "&sid=" + sid;
	} else {
		location.href=url + "?sid=" + sid;
	}
}
