
function updateWK(val,ID,typ)
{
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {

	var URI = "updateWK.php?ID="+ID+"&value="+val+"&typ="+typ;
	//alert (URI);
	xmlHttp.open("GET", URI , true); 
	xmlHttp.onreadystatechange = updateTotals;
	xmlHttp.send("ID="+ID+"&value="+val+"&typ="+typ);
	
  }
  else
    // if the connection is busy, try again after one second  
    setTimeout('updateWK('+val+','+ID+','+typ+')', 1000);
}

function updateWK2(el,ID,typ)
{
	if (el.value) 
	{
		//alert ("value Allright");
		var minamount=0;
		val=el.value;
		if (val!=0 && el.getAttribute("minamount") && el.getAttribute("minamount")>val)
		{
		val=el.getAttribute("minamount");
		el.value=val;
		}
	}
	else val=el;
	if (updateWK2.arguments.length==4)
	{
	var specs=updateWK2.arguments[3];
	}
	else
	{
	var specs= new Array();
	if (document.getElementById("color_"+typ+"_"+ID)) 	specs.push(document.getElementById("color_"+typ+"_"+ID).value);
	if (document.getElementById("size_"+typ+"_"+ID)) 	specs.push(document.getElementById("size_"+typ+"_"+ID).value);
	specs=escape(specs.join(", "));
	}
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	  {
	
		var URI = "updateWK2.php?ID="+ID+"&value="+val+"&typ="+typ+"&specs="+specs;
		//alert (URI);
		xmlHttp.open("GET", URI , true); 
		xmlHttp.onreadystatechange = updateTotals2;
		xmlHttp.send("ID="+ID+"&value="+val+"&typ="+typ+"&specs="+specs);
		
	  }
	  else
	    // if the connection is busy, try again after one second  
	    setTimeout('updateWK2('+val+','+ID+','+typ+')', 1000);
}

function updateTotals()
{
 if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
      xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlRoot = xmlResponse.documentElement;
      var typArray = xmlRoot.getElementsByTagName("typ");
	  var totArray = xmlRoot.getElementsByTagName("tot");
	  var sumArray = xmlRoot.getElementsByTagName("sum");
	  var totsumArray = xmlRoot.getElementsByTagName("totsum");
	  var typ = typArray[0].firstChild.data;
	  var tot = totArray[0].firstChild.data;
	  var sum  = sumArray[0].firstChild.data;
	  //sum=Number.sum.toFixed(2);
	  totsum = totsumArray[0].firstChild.data;
	  //alert(totsum);
	  //totsum=Number.totsum;
	  if (typ=="CD")
	  {
	   if (document.getElementById("stkCD"))  {document.getElementById("stkCD").innerHTML=tot; document.getElementById("totCD").innerHTML=sum;}
	  }
	  else
	  {
	  if (document.getElementById("stkN"))  document.getElementById("stkN").innerHTML=tot;
	  }
	  if (document.getElementById("tot"))  {document.getElementById("tot").innerHTML=totsum;}
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("updateTotals(): There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

function updateTotals2()
{
 if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
      xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlRoot = xmlResponse.documentElement;
	  var reloadArray = xmlRoot.getElementsByTagName("reload");
	  var reload=reloadArray[0].firstChild.data;
	  
      var typArray = xmlRoot.getElementsByTagName("typ");
	  var typ = typArray[0].firstChild.data;
	  
	  if (reload=="yes")
	  {
		modifyQueryString(typ,"add");
		QueryString.go();
	  	return;
	  }
	  var totArray = xmlRoot.getElementsByTagName("tot");
	  var sumArray = xmlRoot.getElementsByTagName("sum");
	  var totsumArray = xmlRoot.getElementsByTagName("totsum");
	
	  
	  var tot = totArray[0].firstChild.data;
	  var sum  = sumArray[0].firstChild.data;
	  //sum=Number.sum.toFixed(2);
	  totsum = totsumArray[0].firstChild.data;
	 //alert ("stk"+typ);
	  //totsum=Number.totsum;
	  if (document.getElementById("stk"+typ)){
	  document.getElementById("stk"+typ).innerHTML=tot; 
	  document.getElementById("tot"+typ).innerHTML=sum;
	  }
	  if (document.getElementById("tot"))  {document.getElementById("tot").innerHTML=totsum;}
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("updateTotals2(): There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}
function modifyQueryString(typ,method)
{
 	var opened = QueryString.get("open");
 	if (opened)
	{
		var openElements=opened.split(",");
		if (method=="add")	{if (openElements.indexOf(typ)<0)openElements.push(typ);}
		else if (method=="remove")
		{
		if (openElements.indexOf(typ)>=0) {openElements.splice(openElements.indexOf(typ),1);}
		}
		if (openElements.length) QueryString.set("open",openElements.join(","));
		else QueryString.remove("open");
		//QueryString.make();
		//alert (openElements.join(","));
		//alert (QueryString.make());
	}
	else if (method=="add")
	{
	QueryString.set("open",typ);
	}
}

function checkout()
{
	QueryString.set("mode","order");
	QueryString.remove("open");
	QueryString.go();
}

function getPressemeldung(ID)
{
if (IDshown==ID) return;
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {

	var URI = "showPresse.php?ID="+ID;
	//alert(URI);
	xmlHttp.open("GET", URI , true); 
	xmlHttp.onreadystatechange = showPressemeldung;
	xmlHttp.send("ID="+ID);
	IDshown=ID;
  }
  else
    // if the connection is busy, try again after one second  
    setTimeout('getPressemeldung('+ID+')', 1000);
}


function getGig(ID)
{
if (IDshown==ID) return;
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {

	var URI = "showGigs.php?ID="+ID;
	//alert(URI);
	xmlHttp.open("GET", URI , true); 
	xmlHttp.onreadystatechange = showGig;
	xmlHttp.send("ID="+ID);
	IDshown=ID;
  }
  else
    // if the connection is busy, try again after one second  
    setTimeout('getGig('+ID+')', 1000);
}
function showPressemeldung()
{
 if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
       var PM = "";
	   var autor = "";
	  // extract the XML retrieved from the server
      xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlRoot = xmlResponse.documentElement;
      var meldungArray = xmlRoot.getElementsByTagName("meldung");
	  var autorArray = xmlRoot.getElementsByTagName("autor");
	  
	  if (meldungArray.length) var PM = meldungArray[0].firstChild.data;
	  if (autorArray.length) var autor = autorArray[0].firstChild.data;
	  autor= unescape(autor);
	  PM = unescape(PM);
	 
	  //alert (document.getElementById("gig"));
	  if (document.getElementById("meldung"))document.getElementById("meldung").style.display='meldung';
	  if (document.getElementById("m_text"))  document.getElementById("m_text").innerHTML=PM;
	  if (document.getElementById("m_autor"))  document.getElementById("m_autor").innerHTML=autor;
	
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("showPressemeldung(): There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}
function showGig()
{
 if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
       var tag = "";
	   var ort = "";
	   var descr  = "";
	   var weblink = "";
	   var mail  = "";
	  
	  // extract the XML retrieved from the server
      xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlRoot = xmlResponse.documentElement;
      var tagArray = xmlRoot.getElementsByTagName("tagchen");
	  var ortArray = xmlRoot.getElementsByTagName("ort");
	  var descrArray = xmlRoot.getElementsByTagName("descr");
	  var linkArray = xmlRoot.getElementsByTagName("link");
	  var mailArray = xmlRoot.getElementsByTagName("mail");
	  if (tagArray.length) var tag = tagArray[0].firstChild.data;
	  if (ortArray.length) var ort = ortArray[0].firstChild.data;
	  if (descrArray.length) var descr  = descrArray[0].firstChild.data;
	  if (linkArray.length) var weblink = linkArray[0].firstChild.data;
	  if (mailArray.length) var mail  = mailArray[0].firstChild.data;
	  descr= unescape(descr);
	  tag = unescape(tag);
	  ort = unescape(ort);
	  mail = unescape(mail);
	  weblink  = unescape(weblink);
	  //
	  
	  //alert (document.getElementById("gig"));
	  if (document.getElementById("gig")){
	  document.getElementById("gig").style.display='block';
	  /*if (document.body.scrollTop) var addScr=document.body.scrollTop;
		else if (window.pageYOffset) var addScr=window.pageYOffset;
		else var addScr=0;
		 document.getElementById("gig").style.top=(300+addScr)+'px';
		 document.getElementById("gig").style.display='block';*/
	  }
	  if (document.getElementById("gigdate"))  document.getElementById("gigdate").innerHTML=tag;
	  if (document.getElementById("gighead"))  document.getElementById("gighead").innerHTML=ort;
	  if (document.getElementById("gigdescr"))  document.getElementById("gigdescr").innerHTML=descr;
   if (document.getElementById("gigmail") && mail!="") {
    document.getElementById("gigmail").innerHTML=mail;
	document.getElementById("gigmail").style.display='block';
	document.getElementById("gigmail").href='mailto:'+mail;
	}
	else if (document.getElementById("gigmail"))document.getElementById("gigmail").style.display="none";
  if (document.getElementById("giglink") && weblink!= "")  {
  document.getElementById("giglink").innerHTML=weblink;
  document.getElementById("giglink").style.display='block';
  if(weblink.indexOf("http://")==-1)weblink="http://"+weblink; //weblink;
  document.getElementById("giglink").href=weblink;
  }
  else if (document.getElementById("giglink"))document.getElementById("giglink").style.display="none";
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("showGig(): There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

function hideGig(){
if (document.getElementById("gig"))document.getElementById("gig").style.display='none';

}

function numbersonly(myfield, e, dec)
{
var key;
var keychar;
if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) ||
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
{
   return true;
}
// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

function noTags(myfield, e)
{
var key;
var keychar;
if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
if (("><").indexOf(keychar) > -1)return false;
return true;
}

function checkWK(){
if(totsum)
{
if (totsum==0 || totsum=="0.00" || totsum=="0,00") {
alert ("Sie müssen mindestens einen Artikel im Warenkorb haben TOT"+totsum); return false;
}
else {location.href="shop.php?mode=order";return;}
}
alert ("Sie müssen mindestens einen Artikel im Warenkorb haben");return false;
}



function radioWin(CD){
radio = window.open("", "RadioBlechhaufn", "height=295,width=653,left=100,top=50,dependent=yes");
radio.focus();
}

function hideDiv(){
document.getElementById('impressum').style.left='-1000px';
document.getElementById('agb').style.left='-1000px';
}

function showDiv(nr){
hideDiv();
if (nr==1)document.getElementById('impressum').style.left='355px';
else document.getElementById('agb').style.left='355px';
}

function hideTeaser(ID)
{
if (whichBrs()=='Internet Explorer')
	{
	//alert ("");
	var doShow=0;
	for (var i=0;i<PIDs.length;i++)
	{
	if (doShow) document.getElementById('teaser_'+PIDs[i]).style.visibility='hidden';
	if (ID==PIDs[i]) {doShow=1;document.getElementById('text_'+PIDs[i]).style.display='block';document.getElementById('text_'+PIDs[i]).style.border='2px solid #A50A2D'; }
	else{document.getElementById('text_'+PIDs[i]).style.display='none';}
	}
	}
}

function showTeaser(ID){
	if (whichBrs()=='Internet Explorer')
	{
	for (var i=0;i<PIDs.length;i++)
	{
	document.getElementById('teaser_'+PIDs[i]).style.visibility='visible';
	//document.getElementById('text_'+PIDs[i]).style.display='none';
	}
	document.getElementById('text_'+ID).style.display='none';
	}
}
function showBandmem(mem)
{
if (IE6 && document.getElementById('span_'+mem))
{
//alert ('span_'+mem);
if (mem=="chk")document.getElementById('span_'+mem).style.left='-170px';
else document.getElementById('span_'+mem).style.left='0';
document.getElementById('span_'+mem).style.top='-120px';
}
}

function hideBandmem(mem)
{
if (IE6 && document.getElementById('span_'+mem))
{

document.getElementById('span_'+mem).style.left='-2000px';
document.getElementById('span_'+mem).style.top='0';
}
}

function whichBrs() {
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}

function showM(ID){
if (IDshown)document.getElementById("text_"+IDshown).style.display='none';
IDshown=ID;
document.getElementById("text_"+ID).style.display='block';
}
function hideM(ID)
{
document.getElementById("text_"+ID).style.display='none';
IDshown=0;
}
function xmaswin(){
xmaswin=window.open('','xmasspecial','width=605,height=690');
xmaswin.focus();
}

function clearGBE()
//if (cleared) return;
{
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
	var URI = "clearGBE.php";
	//alert (URI);
	xmlHttp.open("GET", URI , true); 
	xmlHttp.onreadystatechange = writeCLR;
	xmlHttp.send(null);
	
  }
  else
    // if the connection is busy, try again after one second  
    setTimeout('clearGBE()', 1000);
}

function writeCLR()
{
if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
	
    if (xmlHttp.status == 200) 
    {
      //alert ("200");
	  // extract the XML retrieved from the server
       xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlDocumentElement = xmlResponse.documentElement;
      // get the text message, which is in the first child of
      //  the document element
     res = xmlDocumentElement.firstChild.data;
	 //cleared=1;
	document.getElementById("clr").value=res;
	//alert (res);
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("refreshSortCriteria(): There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

function openWKDET(kind)
{
	 
	if (document.getElementById(kind+'_detail').style.display=='none')
	{
		document.getElementById(kind+'_detail').style.display='block';
		document.getElementById('open'+kind).src='../img/wk_close.gif';
		modifyQueryString(kind,"add");
	}
	else 
	{
		document.getElementById(kind+'_detail').style.display='none';
		document.getElementById('open'+kind).src='../img/wk_open.gif';
		modifyQueryString(kind,"remove");
	}
}

function changePic(kuerzel,ID,callerval)
{
//depends on global array "allGarmentPics"
	if (document.getElementById('PIC_'+kuerzel+"_"+ID))
	{
		for (var i=0;i<=allGarmentPics[ID].length;i++)
		{
			if (allGarmentPics[ID][i][0]==callerval)
			{
				document.getElementById('PIC_'+kuerzel+"_"+ID).src=allGarmentPics[ID][i][1];
				document.getElementById('LYTE_'+kuerzel+"_"+ID).href=allGarmentPics[ID][i][2];
				break;
			}
		}
	
	}
}

