var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

function DHTML_init() {

 if (window.opera) {
     OP = 1;
 }
 if(document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if(document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
if (window.netscape && window.screen && !DOM && !OP) {
   DHTML = 1;
   NS = 1;
 }
}

function getElem(p1,p2,p3) {
 var Elem;
 if(DOM) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.getElementById(p2) == "object")
     Elem = document.getElementById(p2);
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document.getElementsByName(p2) == "object")
     Elem = document.getElementsByName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.getElementsByTagName(p2) == "object" || (OP && typeof document.getElementsByTagName(p2) == "function"))
     Elem = document.getElementsByTagName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(MS) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.all[p2] == "object")
     Elem = document.all[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.all.tags(p2) == "object")
     Elem = document.all.tags(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(NS) {
   if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") {
   if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="index") {
    if (typeof document.layers[p2] == "object")
     Elem = document.layers[p2];
    else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
}

function getCont(p1,p2,p3) {
   var Cont;
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild) {
     if(getElem(p1,p2,p3).firstChild.nodeType == 3)
       Cont = getElem(p1,p2,p3).firstChild.nodeValue;
     else
       Cont = "";
     return(Cont);
   }
   else if(MS && getElem(p1,p2,p3)) {
     Cont = getElem(p1,p2,p3).innerText;
     return(Cont);
   }
   else return void(0);
}

function getAttr(p1,p2,p3,p4) {
   var Attr;
   if((DOM || MS) && getElem(p1,p2,p3)) {
     Attr = getElem(p1,p2,p3).getAttribute(p4);
     return(Attr);
   }
   else if (NS && getElem(p1,p2)) {
       if (typeof getElem(p1,p2)[p3] == "object")
        Attr=getElem(p1,p2)[p3][p4]
       else
        Attr=getElem(p1,p2)[p4]
         return Attr;
       }
   else return void(0);
}

function setCont(p1,p2,p3,p4) {
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild)
     getElem(p1,p2,p3).firstChild.nodeValue = p4;
   else if(MS && getElem(p1,p2,p3))
     getElem(p1,p2,p3).innerText = p4;
   else if(NS && getElem(p1,p2,p3)) {
     getElem(p1,p2,p3).document.open();
     getElem(p1,p2,p3).document.write(p4);
     getElem(p1,p2,p3).document.close();
   }
}

DHTML_init();


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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+switchVars(nm)+' muss eine gültige E-Mail Adresse sein.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+switchVars(nm)+' muss ausgefüllt werden.\n'; }



  }




  if(!document.checkoutform.agb_check.checked) {
   //alert('Sie müssen bestätigen, dass Sie die AGB gelesen haben.');
   errors+='- Sie müssen bestätigen, dass Sie die AGB gelesen haben.'
   }


  if (errors) alert('Folgende Eingaben fehlen:\n'+errors);



  document.MM_returnValue = (errors == '');
}

function switchVars(myVar) {

	if(myVar == 'cname') {
		mySwitchedVar = 'Name / Vorname';
	}

	if(myVar == 'caddress') {
		mySwitchedVar = 'Adresse';
	}

	if(myVar == 'czip') {
		mySwitchedVar = 'PLZ';
	}

	if(myVar == 'ccity') {
		mySwitchedVar = 'Ort';
	}

	if(myVar == 'cemail') {
		mySwitchedVar = 'E-Mail';
	}

	if(myVar == 'ctelephone') {
		mySwitchedVar = 'Telefon';
	}

	if(myVar == 'mypass') {
		mySwitchedVar = 'Kennwort';
	}


	return mySwitchedVar;

}



function toggleDiv(divid)
{
	mydiv = document.getElementById(divid);

	if (mydiv.style.display=="block")
	{
		mydiv.style.display="none";
		//mydiv.style.height="0px";
	} else
	{
		mydiv.style.display="block";
		//mydiv.style.height="75px";
	}
}

function showDocPopup(path, title, myWidth, myHeight) {
	myWindow = window.open(path, title, 'scrollbars=1, width=' + myWidth + ', height=' + myHeight);
}

function showPopup(path, title, myWidth, myHeight) {
	myWindow = window.open(path, title, 'scrollbars=0, width=' + myWidth + ', height=' + myHeight);

}



   function DisableButtonByCheckbox(buttonid, checkboxid) {
   chk=document.getElementById(checkboxid)
   if (chk.checked == true) {
		document.getElementById(buttonid).disabled = false;
   } else {
		document.getElementById(buttonid).disabled = true;
   }
  }


function sendYellowpayForm(){
	var myForm = document.Form1;
	document.Form1.submit();
}


function printdiv()
 {
  var URL = window.location ;
  var printwindow = window.open(URL,"");
  printwindow.print();
 }

function GetUrlValue(Entry)
{
  urlText=location.search;
  fc=urlText.slice(0,1);
  if(fc=="?")
  {
    l=urlText.length;
    urlText=urlText.slice(1,l);
    ArgSet=urlText.split("&");
    for(i=0;i<ArgSet.length;i++)
    {
      as=ArgSet[i].split("=");
      if(as[0]==Entry)
      {
        var result=as[1].split("%26");
        alert(result[0]);
        return (result[0]);
      }
    }
    ArgSet=urlText.split("%26");
    return ("");
  }
}

function SetCookieYellowpay() {


	//generate expire
	var oTime = new Date();
	expireTime = oTime.getTime() + 10000;

	oTime.setTime(expireTime);

	//write cookie
	document.cookie = "NAME=redirect; expire=" + oTime.toGMTString();
	document.cookie = "NAME=redirect2; expire=" + oTime.toGMTString();

	alert(document.cookie);
}



function getCookie(NameOfCookie){
    if (document.cookie.length > 0) {
    begin = document.cookie.indexOf(NameOfCookie+"=");
    if (begin != -1) {
      begin += NameOfCookie.length+1;
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
    }
  }
  return null;
}

function setCookie(NameOfCookie, value) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (10000));

  document.cookie = NameOfCookie + "=" + escape(value) + "; expires=" + ExpireDate.toGMTString();
}

function delCookie(NameOfCookie) {
  if (getCookie(NameOfCookie)) {
    document.cookie = NameOfCookie + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function DoTheCookieStuff()
{
 visited=getCookie('visitedyellowpay');
 if (visited==null)
 {
setCookie('visitedyellowpay','yes');

//send form
document.forms.Form1.submit();
 }
}

//ZEIT

function ZeitAnzeigen() {
var Wochentagname =  new Array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");

 var Jetzt = new Date();
 var Tag = Jetzt.getDate();
 var Monat = Jetzt.getMonth() + 1;
 var Jahr = Jetzt.getYear();
 if(Jahr < 999) Jahr += 1900;
 var Stunden = Jetzt.getHours();
 var Minuten = Jetzt.getMinutes();
 var Sekunden = Jetzt.getSeconds();
 var WoTag = Jetzt.getDay();
 var Vortag  = ((Tag < 10) ? "0" : "");
 var Vormon  = ((Monat < 10) ? ".0" : ".");
 var Vorstd  = ((Stunden < 10) ? "0" : "");
 var Vormin  = ((Minuten < 10) ? ":0" : ":");
 var Vorsek  = ((Sekunden < 10) ? ":0" : ":");
 var Datum = Vortag + Tag + Vormon + Monat  + "." + Jahr;
 var Uhrzeit = Vorstd + Stunden + Vormin + Minuten + Vorsek + Sekunden;
 var Gesamt = Wochentagname[WoTag] + ", " + Datum + ", " + Uhrzeit;

 if(DHTML) {
   if(NS) setCont("id","Uhr",null,"<span class=\"Uhr\">" + Gesamt + "<\/span>");
   else   setCont("id","Uhr",null,Gesamt);
 }
 else return;

 window.setTimeout("ZeitAnzeigen()",1000);
}

/*
function startCountdown(startNum){

		setTimeout();
			clearInterval(aktivInterval);
		}

}
*/


function artInfoSwapMenuColorOver(menuID){

	document.getElementById(menuID).id = "itemcardNavigationLink0ver";

}

function artInfoSwapMenuColorOut(menuID){

	document.getElementById("itemcardNavigationLink0ver").id = menuID;

}

function ShowWaitMsg()

	{

		//document.all.pleasewaitScreen.style.pixelTop = (document.body.scrollTop + 50);

		//document.all.pleasewaitScreen.style.visibility="visible";



		document.getElementById("pleasewaitScreen").style.pixelTop = (document.body.scrollTop + 50);

		document.getElementById("pleasewaitScreen").style.display="block";


	}

function HideWaitMsg()

	{

		document.getElementById("pleasewaitScreen").style.display="none";

	}


function preloadImages() {
   if (document.images) {
      for (var i = 0; i < preloadImages.arguments.length; i++) {
         (new Image()).src = preloadImages.arguments[i];
      }
   }
}

function setFocus(id){
	try{
	focusfield = document.getElementById(id);
	focusfield.focus();
	} catch (e){
		myException = e;
	}
}


