 var xmlHttpObject = false;
 var elid = "";
 var sendtotooltip = "";
 var tooltipactiv = false;
 var showheosug = false;
 var Mousex=0;
 var Mousey=0; 
 var blockbasket=0;
 var basketpos;
 var globrestext="";

function cimage(bildname,neuesbild)
{
 document.images[bildname].src=neuesbild;
}


function cimageadv(neuerlink, bildname, neuesbild)
{
 //cimage(bildname,neuesbild);
  document.images[bildname].src=neuesbild;
  document.getElementById("pbildlink").href = neuerlink;
}

//da firefox das bild aus dem cache nehmen würde muss eine zufallszahl dran gehängt werden:
function cimagewz(bildname,neuesbild)
{
 zufall=1 + 222 * ( Math . random () );
 document.images[bildname].src=neuesbild+"?d="+zufall;
}



// Überprüfen ob XMLHttpRequest-Klasse vorhanden und erzeugen von Objekte für IE7, Firefox, etc.
if (typeof XMLHttpRequest != 'undefined') 
{
    xmlHttpObject = new XMLHttpRequest();
}

// Wenn im oberen Block noch kein Objekt erzeugt, dann versuche XMLHTTP-Objekt zu erzeugen
// Notwendig für IE6 oder IE5
if (!xmlHttpObject) 
{
    try 
    {
        xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) 
    {
        try 
        {
            xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e) 
        {
            xmlHttpObject = null;
        }
    }
}





// Objekt erzeugen
// hier ohne Fallunterscheidung, da für das Beispiel einfacher
	

// Funktion, die bei Statusänderungen reagiert
function handleStateChange()
{
		// Derzeitigen Status zurückgeben
 alert("xmlHttpObject.readyState = " + xmlHttpObject.readyState + (xmlHttpObject.readyState >= 3 ? " HTTP-Status = " + xmlHttpObject.status : ''));
}

	
// Wenn Dokument geladen ausführen

function loadContent(curl, xelid)
{

  var currentTime = new Date()
  elid=xelid;
  if (xelid=='paymentinfo' || xelid=='box_warenkorb') curl=curl+"&tuk="+currentTime.getTime();
  xmlHttpObject.open('GET', curl); //hier war ein "False" das der firefox nicht mag...
  xmlHttpObject.onreadystatechange = handleContent;
  //xmlHttpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
  //xmlHttpObject.setRequestHeader("Content-length", "0");
  xmlHttpObject.send(null);

  return false;
}


function loadContentX(curl, xelid)
{
 loadContent(curl, xelid);
}




function handleContent()
{
 restext="";
 if (xmlHttpObject.readyState == 4) { 
   restext=xmlHttpObject.responseText;
   
   if (elid == "tooltip") {
    sendtotooltip=restext;
    elid="";
    if (tooltipactiv) Tip(sendtotooltip);
   } //(elid == "tooltip")
   
   if (elid=="heosug") {
     if (restext=="") { 
      document.getElementById('heosug').style.visibility = 'hidden';
     } else {
      if (showheosug) { 
        document.getElementById('heosug').style.visibility = 'visible'; 
        newleft=((browserWindowSize()-990)/2)+14;
        newleft=Math.round(newleft);
        document.getElementById("heosug").style.left = newleft;        
      } //(showheosug) 
     } //(restext=="")
   } //(elid=="heosug")
  
   if (elid=="checklogin") {
   // if (restext=="Q") {
   if (Left(restext, 4)=="<ok>") {
     //alert('jawohl');
     location.href="llmodusedit.php?llm=off&cb=y";
    } //(restext=="Q")
   } //(elid=="checklogin")
   
   globrestext="";                          
   if (!(elid=='')) {
     //alert(elid);
     globrestext=restext;
     
     if (globrestext.indexOf('sessionended',0)>0) {
      window.location.href="login.php";
     } //(globrestext.indexOf('sessionended',0))
     
     if (document.getElementById(elid)) document.getElementById(elid).innerHTML = restext;
   }
   HideSanduhr();
   blockbasket=0;
   
   if (Left(elid, 8)=="wkzeile_") {
     if (basketpos==0) location.href="basket.php";
     loadContent('baskreldet.php', 'gesamtsumme');
    //alert('halloli');
   } // (Left(elid, 8)=="wkzeile_")

   
 }
}


function Left(wert, anzahl) {
 wertneu=wert.substr(0,anzahl)
 return wertneu;
}


function browserWindowSize() {
var browserWinWidth = 0, browserWinHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
browserWinWidth = window.innerWidth;
browserWinHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
browserWinWidth = document.documentElement.clientWidth;
browserWinHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
browserWinWidth = document.body.clientWidth;
browserWinHeight = document.body.clientHeight;
}
//alert( 'Browser Window Width = ' + browserWinWidth +' Browser Window Height = '+browserWinHeight);
return browserWinWidth;
}






function loadContentWithParam(curl, xelid, parameters)
{
  elid=xelid;
  xmlHttpObject.open('POST', curl, false);
  xmlHttpObject.onreadystatechange = handleContent;
  xmlHttpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttpObject.setRequestHeader("Content-length", parameters.length);
  xmlHttpObject.send(parameters);
  return false;
}


function loadContentWithParamX(curl, xelid, parameters)
{
  loadContentWithParam(curl, xelid, parameters);
}


function ddrivetip(lng, infonumber){
 tooltipactiv=true;
 loadContent('infotext.php?lng='+lng+'&in='+infonumber, 'tooltip');
}

function hideddrivetip(){
 sendtotooltip="";
 tooltipactiv=false;
 UnTip();
}


function hddtp(){
 sendtotooltip="";
 tooltipactiv=false;
 UnTip();
}

//ist vorerst deaktiviert!
function heosug(eingabe, lng) {
// if (eingabe.length>1) {
//  showheosug=true;
//  loadContent('heosug.php?lng='+lng+'&sug='+eingabe, 'heosug');
//  } else {
//  showheosug=false;
//  document.getElementById('heosug').style.visibility='hidden';
//  document.getElementById('heosug').innerHTML='';  
// }
}

function HideHeosug() {
  window.setTimeout("HideHeosugNow()", 500);
}

function HideHeosugNow() {
  document.getElementById('heosug').style.visibility='hidden';
  document.getElementById('heosug').innerHTML='';  
}

function getWindowWidth(win) {    
    if (win == undefined) win = window;    
    if (win.innerWidth) {    
        return (win.innerWidth)-18;    
    }    
    else {    
        if (win.document.documentElement &&    
            win.document.documentElement.clientWidth) {    
            return win.document.documentElement.clientWidth;    
        }    
        return win.document.body.offsetWidth;    
    } 
}


function TestFunction () {
 alert('Hallo');
}


function SetSanduhr(x, y)
{
 document.getElementById('sanduhrlayerbox').style.top=y;
 document.getElementById('sanduhrlayerbox').style.left=x; 
  // alert(x);
}

function HideSanduhr()
{
 document.getElementById('sanduhrlayerbox').style.top="-500px";
  //SetSanduhr(0, -50);
}


function SetSanduhrZurMouse()
{
  SetSanduhr(Mousex+document.body.scrollLeft , Mousey+document.body.scrollTop );
  
}


function MouseXY(Ereignis)
{
  if (!Ereignis)
  Ereignis = window.event;
  Mousex = Ereignis.clientX;
  Mousey = Ereignis.clientY;
  //alert(Mousex);
}


function ScrollPos()
{

if (typeof window.pageYOffset != 'undefined') {
   scrollPos = window.pageYOffset;
}
else if (typeof document.compatMode != 'undefined' &&
     document.compatMode != 'BackCompat') {
   scrollPos = document.documentElement.scrollTop;
}
else if (typeof document.body != 'undefined') {
   scrollPos = document.body.scrollTop;
}
return scrollPos;
}

function AddToBasketVAR(artnr, lng, sid, uid, hst, aid, voa) {
if (blockbasket==0) {
 blockbasket=1;
 myindex=document.forms["formsent"+artnr].elements["artnr"].selectedIndex;
 xartnr=document.forms["formsent"+artnr].elements["artnr"].options[myindex].value; 
 menge=document.forms["formsent"+artnr].elements["menge"].value;
 ShowWaitingDingsbums(); 
 loadContent('baskrel.php?lng='+lng+'&sid='+sid+'&uid='+uid+'&hst='+hst+'&an='+xartnr+'&m='+menge+'&aid='+aid+'&voa='+voa, 'box_warenkorb');
}
 return false;
}


function AddToBasket(artnr, lng, sid, uid, hst, aid, voa) {

if (blockbasket==0) {
 blockbasket=1;
 menge=document.forms["formsent"+artnr].elements["menge"].value;
 ShowWaitingDingsbums();
 loadContent('baskrel.php?lng='+lng+'&sid='+sid+'&uid='+uid+'&hst='+hst+'&an='+artnr+'&m='+menge+'&aid='+aid, 'box_warenkorb');
}
 return false;
}



function AddToBasketVARNL(artnr, lng, sid, uid, hst, aid, voa) {
if (blockbasket==0) {
 blockbasket=1;
 myindex=document.forms["formsent"+artnr].elements["artnr"].selectedIndex;
 xartnr=document.forms["formsent"+artnr].elements["artnr"].options[myindex].value; 
 menge=document.forms["formsent"+artnr].elements["menge"].value;
 ShowWaitingDingsbums(); 
 loadContent('baskrelnl.php?lng='+lng+'&sid='+sid+'&uid='+uid+'&hst='+hst+'&an='+xartnr+'&m='+menge+'&aid='+aid+'&voa='+voa, 'info_wk');
}
 return false;
}


function AddToBasketNL(artnr, lng, sid, uid, hst, aid, voa) {

if (blockbasket==0) {
 blockbasket=1;
 menge=document.forms["formsent"+artnr].elements["menge"].value;
 ShowWaitingDingsbums();
 loadContent('baskrelnl.php?lng='+lng+'&sid='+sid+'&uid='+uid+'&hst='+hst+'&an='+artnr+'&m='+menge+'&aid='+aid, 'info_wk');
}
 return false;
}




function DelFromBasket(dieid, elid) {
 ShowWaitingDingsbums();
 loadContent('baskdel.php?var=del&id='+dieid, elid);
 basketpos--;

 //do
 //{
 // a=3; //dummy
 //}
 //while (blockbasket==1);

 //alert('juchu');
 //loadContent('baskreldet.php', 'gesamtsumme');

 //document.getElementById("gesamtsumme").innerHTML=""; 
 //document.getElementById("versandinweise_wksave").innerHTML=""; 
 //document.getElementById("gesamtsumme_preise").innerHTML=""; 
 //document.getElementById("gesamtsumme_endpreis").innerHTML=""; 
 //document.getElementById("gesamtsumme_text").innerHTML=""; 
 //document.getElementById("gesamtsumme_endpreis").innerHTML=""; 
}




function SetActiveCCard(id, uid) {
if (blockbasket==0) {
 blockbasket=1;
 //menge=document.forms["formsent"+artnr].elements["menge"].value;
 ShowWaitingDingsbums();
 loadContent('setactivecard.php?uid='+uid+'&id='+id, '');
}
// return false;
}


function ShowWaitingDingsbums() {
 //<div id="sanduhrlayerbox"><img src="images/all/design/sanduhr.gif" border="0" width="32" height="32" /></div>
 //alert(ScrollPos());
 //document.getElementById('sanduhrlayerbox').style.top="50%";
 document.getElementById('sanduhrlayerbox').style.top=(ScrollPos()+350)+"px";
 //document.getElementById('sanduhrlayerbox').style.left=x; 
 //SetSanduhr(270, 350+document.body.scrollTop);
}

function ShowAddCard(action, id) {
  document.getElementById('add_card').style.top=(ScrollPos()+350)+"px";
  document.forms["ccardedit"].elements["action"].value=action;  
  
  if (action=="up") {
    document.forms["ccardedit"].elements["cardowner"].value=document.forms["ccardlist"].elements["cardowner"+id].value;
    document.forms["ccardedit"].elements["cardnumber"].value=document.forms["ccardlist"].elements["cardnumber"+id].value;
    document.forms["ccardedit"].elements["cardcheck"].value="***";
    document.forms["ccardedit"].elements["cardmonth"].selectedIndex=document.forms["ccardlist"].elements["cardmonth"+id].value;
    document.forms["ccardedit"].elements["cardyear"].selectedIndex=document.forms["ccardlist"].elements["cardyear"+id].value;
    document.forms["ccardedit"].elements["updateid"].value=id;
  } //(action=="up")
}

function HideAddCard() {
  document.getElementById('add_card').style.top="-1000px";
  document.forms["ccardedit"].elements["cardowner"].value="";
  document.forms["ccardedit"].elements["cardnumber"].value="";
  document.forms["ccardedit"].elements["cardcheck"].value="";
  document.forms["ccardedit"].elements["cardmonth"].selectedIndex=0;
  document.forms["ccardedit"].elements["cardyear"].selectedIndex=0;
}

function ShowWKSave() {
  document.getElementById('wk_save').style.top=(ScrollPos()+350)+"px";
}

function HideWKSave() {
  document.getElementById('wk_save').style.top="-400px";
}

function ShowLLMExit() {
  document.forms["login"].elements["username"].value="";
  document.forms["login"].elements["password"].value="";  
  document.getElementById('llmexit').style.top=(40)+"px";
}

function HideLLMExit() {
  document.getElementById('llmexit').style.top="-400px";
}

function CheckLogin() {
 user=document.forms["login"].elements["username"].value;
 pass=document.forms["login"].elements["password"].value;
 loadContent('checklogin.php?un='+user+'&pw='+pass, 'checklogin'); 
 document.forms["login"].elements["username"].value="";
 document.forms["login"].elements["password"].value="";
return false;
}


function ShowPDLogin() {
  document.forms["login"].elements["username"].value="";
  document.forms["login"].elements["password"].value="";  
  document.getElementById('pdlogin').style.top=(ScrollPos()+350)+"px";
}

function HidePDLogin() {
  document.getElementById('pdlogin').style.top="-600px";
}



function Lesezeichen(){

  if (window.sidebar)
    {
    // firefox
    window.sidebar.addPanel(SeitenTitel,SeitenURL,Kommentar);
    }
  else if(window.opera && window.print)
    {
    // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',SeitenURL);
    elem.setAttribute('title',SeitenTitel);
    elem.setAttribute('rel','sidebar');
    elem.click();
    }
  else if(document.all)
    {
    // ie
    window.external.AddFavorite(SeitenURL,SeitenTitel);
    }
}


function ShowAbsatz(absatzid) {

  document.getElementById(absatzid).style.position='';
  document.getElementById(absatzid).style.visibility='visible';
  
  document.getElementById(absatzid+'_link').style.position='absolute';
  document.getElementById(absatzid+'_link').style.visibility='hidden';
 
 }
 
function HideAbsatz(absatzid) {

  document.getElementById(absatzid).style.position='absolute';
  document.getElementById(absatzid).style.visibility='hidden';
 
  document.getElementById(absatzid+'_link').style.position='';
  document.getElementById(absatzid+'_link').style.visibility='visible';
 }

function ChangeAppUsername(elementenid) {

 usernameinhalt=document.getElementById(elementenid).value;
 usernameinhalt2=usernameinhalt.replace(/é/, '&eacute;')
 if (usernameinhalt==GLng330 || usernameinhalt2==GLng330) {
  document.getElementById(elementenid).value = "";
  document.getElementById(elementenid).className = "headertop_login_aktiv";
 }
}

function ChangeAppPassword() {
 //document.getElementById("loginpassword").value = "";
 //document.getElementById("loginpassword").className = "headertop_login_aktiv";
 document.getElementById("headertop_login_passwort").innerHTML='<input name="password" id="loginpassword" size="26" type="password" class="headertop_login_aktiv" onblur="CheckBlur();CheckEmptyPassword()" />';
window.setTimeout("focusit()" , 500); 
}

function focusit() {
 document.getElementById("loginpassword").focus();
}

function CheckEmptyUsername(elid) {
 if(document.getElementById(elid).value == "") {
 
 usernameinhalt=GLng330;
 usernameinhalt=usernameinhalt.replace(/&eacute;/, 'é');
 document.getElementById(elid).value = usernameinhalt;
 document.getElementById(elid).className = "headertop_login_inaktiv"; 
 }
}

function CheckEmptyPassword() {
 if(document.getElementById("loginpassword").value == "") {
  document.getElementById("headertop_login_passwort").innerHTML='<input value="'+GLng331+'" name="password" size="26" id="loginpassword" type="text" class="headertop_login_inaktiv" onClick="ChangeAppPassword();" onfocus="CheckFocus();ChangeAppPassword();" />';
 }
}

function HideMessage(id) {
 loadContent('hidemessage.php?id='+id, 'blogmeldung');
}
//document.onmousedown = MouseXY; 
