
//nur waehrend Test-Phase mit nicht ie-browser. immer fuer test explizit ent-kommentieren und
//sonst im allg. immer kommentiert lassen, sonst vergisst man es vor uebergang auf production-server.
/*
function JsError()
{
  return false;
}

window.onerror = JsError;
*/




//calc Directory

var devDir   = "/wb/svrs/kw/dev/ws/kw01/wbx01/";
var actDir   = "/wb/svrs/kw/act/ws/kw01/wbx01/";
var wbxDir   = "/wb/svrs/kw/wbx/wbx01/";
var svrDir   = "/wbx01/";

var vglDevDir   = "/wb/svrs/kw/dev";
var vglActDir   = "/wb/svrs/kw/act";


var directory = null; //die wurzel-direktory

var svr = location.hostname.toLowerCase();

function CalcDir()
{
  
  if(svr != "localhost" && svr !="main")
  {
      directory = svrDir;
  }
  else
  {
      var p = location.pathname.toLowerCase();
      var regEx01 = new RegExp(vglDevDir);
      var regEx02 = new RegExp(vglActDir);
      var result01 = p.search(regEx01);
      var result02 = p.search(regEx02);
      if(result01 == 0)
      {
        directory = devDir;
      }
      else if(result02 == 0)
      {
        directory = actDir;
      }
      else
        directory = wbxDir;
  }
}

CalcDir();


//simple browserDiff
//wir stellen nur fest, ob es IE ist
function isIE()
{
    return (navigator.userAgent.indexOf("MSIE")!=-1);
}

function isIE6plus()
{
  

  if(!isIE())
    return false;

  var appVer = navigator.appVersion;
  
  var ind = appVer.indexOf("MSIE");
  
  return (parseInt(appVer.substr(ind + 5, 1)) >= 6);
}

function isNet1_1()
{
	if(!isIE6plus())
		return false;
	var str = navigator.userAgent;
	var str02 = str.toLowerCase()
	var ind = str02.indexOf(".net clr 1.1");
	return ind != -1;
}


//click von Menu
function mclick(mindex, itemData)
{
    location.href = itemData[mindex].url;
}

//bei menupunkt onmouseout
function mlow(item, itemBackGroundColor, itemBorderColor)	
{

    var ch = item.firstChild;

    if(itemBackGroundColor != -1)
	    item.style.backgroundColor=itemBackGroundColor;
	else
    	item.style.backgroundColor="";


    if(isIE()) //IE
    {
        item.style.border = 0;
        item.style.padding = '1px';
	}
	else //NS
	{
	    ch.style.borderColor = 'transparent';
	}
}

var lastMenuItem = null;
//bei menupunkt onmouseover
function mhigh(item, itemBackGroundColor, itemBorderColor)
{
    
    //ns 6 und ggf. auch 7 laesst mitunter background stehen.
    //dies hilft ein wenig, die haeufigkeit wir geringer.
    if(lastMenuItem != null)
        mlow(lastMenuItem);
    lastMenuItem = item;    

    
    var ch = item.firstChild;
	item.style.backgroundColor= itemBackGroundColor;

    if(isIE()) //IE
    {
	    item.style.border = 'solid 1px ' + itemBorderColor;
	    item.style.padding    = '0px';
	    
    }
    else //NS
    {
	    ch.style.borderColor = itemBorderColor;
    }
}

//animiertes kontakt-Bild
function direktKontaktOnMouseOver(pic)
{
  pic.src = directory + "images/direktKontaktA.gif";
}
function direktKontaktOnMouseOut(pic)
{
  pic.src = directory + "images/direktKontakt.gif";
}



/************* Shadow *********************/

        //erzeugen einer shadowTable aus beliebigen Element
        var timerStarted = false;        
        function ShadowItem(id, showText, width)
        {
          this.id = id;
          this.showText = showText;
          this.width = width;
          this.ready = false;
        }
  
        var shadowIndex = 0;
        var shadowItemArr = new Array();
        var shadowTimer;
        

  
        function makeShadowTable(id, showText, width)
        {
          //zunaechst nur cachen
          shadowItemArr[shadowIndex] = new ShadowItem(id, showText, width);
          shadowIndex++;
                    
          if(!timerStarted)
          {
            timerStarted = true;
            shadowTimer = window.setInterval("onTimerMakeShadow()", 10);
          }
        }

        function onTimerMakeShadow()
        {
          var i = 0;
          var isReady=true;
          for(i = 0; i < shadowItemArr.length; i++)
          {
            if(shadowItemArr[i].ready)
            continue;
            
            var t0 = document.getElementById(shadowItemArr[i].id);
            
            if(!isIE() || isIE6plus())
            {
                if(t0.complete == undefined || t0.complete)
                {
                    makeShadowTableA(shadowItemArr[i].id, shadowItemArr[i].showText, shadowItemArr[i].width);
                    shadowItemArr[i].ready = true;
                }
             }
             else
             {
                    makeShadowTableA(shadowItemArr[i].id, shadowItemArr[i].showText, shadowItemArr[i].width);
                    shadowItemArr[i].ready = true;
             
             }
            isReady = false;
          }
            
            if(isReady)
              window.clearInterval(shadowTimer);
        }




        function makeShadowTableA(id, showText, width)
        {
            //allg. vars
            var imagePath = directory + 'images/shpics/';
            
            //node der zu clonenden Table        
            var t0 = document.getElementById(id);
                        
            //parent wird benoetigt um replace durchzufuehren
            var t0parent = t0.parentNode;
            //Clone der Table, da Table als ganzes in shadowTable            
            //true heisst, alle unternodes clonen.
            var t00 = t0.cloneNode(true);
            

            //shadwowTable als umschliessende Table aufbauen
            var table = document.createElement("table");
            table.setAttribute("border", "0");
            table.setAttribute("cellSpacing", "0");
            table.setAttribute("cellPadding", "0");

            if(width.length != 0)
                table.setAttribute("width", width);


            var row01   = document.createElement("tr");
            var row02   = document.createElement("tr");
            
            //c00 ist die Celle, die dir orig-Table healt           
            var c00     = document.createElement("td");
            c00.setAttribute("vAlign", "top");
            c00.setAttribute("align", "left");
            var c01     = document.createElement("td");
            if(isIE())
                c01.setAttribute("className", "shadowRight");
            else
                c01.setAttribute("class", "shadowRight");
            
            c01.setAttribute("vAlign", "top");
            c01.setAttribute("width", "6");
            
            var img01 = document.createElement("img");
            img01.setAttribute("height", "6");
            img01.setAttribute("width", "6");
            img01.setAttribute("src",  imagePath + "shLeftTop2.gif");
            
            c01.appendChild(img01);
                                    
            var c10     = document.createElement("td");
            if(isIE())
                c10.setAttribute("className", "shadowBottom");
            else
                c10.setAttribute("class", "shadowBottom");
            
            c10.setAttribute("vAlign", "top");
            c10.setAttribute("height", "6");
            var img02 = document.createElement("img");
            img02.setAttribute("height", "6");
            img02.setAttribute("width", "6");
            img02.setAttribute("src", imagePath + "shLeftBottom2.gif");
            c10.appendChild(img02);
            
            var c11     = document.createElement("td");
            var img03 = document.createElement("img");
            img03.setAttribute("height", "6");
            img03.setAttribute("width", "6");
            img03.setAttribute("src", imagePath + "shRightBottom2.gif");
            c11.appendChild(img03);
            

            row01.appendChild(c00);
            row01.appendChild(c01);
            row02.appendChild(c10);
            row02.appendChild(c11);
            
            var tbody  = document.createElement("tbody");
            
            //orig Table in c00 legen
            c00.appendChild(t00);

            tbody.appendChild(row01);
            tbody.appendChild(row02);
            
            table.appendChild(tbody);
            
            //die origTable gegen die shadowTable ersetzen            
            t0parent.replaceChild(table, t0);

            
            if(showText)
            {
                return table.outerHTML;
            }
            else
                return 0;

         }

        //herstellen von hellen 1pixel-linien
        function makeGridLines(tableId, a)
        {
            var table = document.getElementById(tableId);
            var rows = table.rows;
            var i;
            for(i = 0; i < a.length; i++)
            {
                var cells = rows[i].cells;
                var j;
                for(j = 0; j < a[i].length; j++)
                {
                    if(a[i][j][0] == 1)
                        cells[j].style.borderBottom = 'white 1px solid';
                    if(a[i][j][1] == 1)
                    cells[j].style.borderRight = 'white 1px solid';
                    
                }
            }
        }


/******** OnTimer *************************/

function OnTimerCls(objArray)
{
    this.objArray = objArray;
    this.onTimer  = OnTimerCls_onTimer;        
}

//fuer alle eingetragenen objekte onTimer aufrufen
function OnTimerCls_onTimer()
{
    var i;
    for(i = 0; i < this.objArray.length; i++)
        this.objArray[i].onTimer();
}


///////////////////////////////////////////////
///////// LoadImagesCls - Start ///////////////
///////////////////////////////////////////////


//imageUrls ist ein Array von urls oder null
//images ist ein Array von images oder null
//entweder imageUrls oder images muss null sein, oder beides.
function LoadImagesCls(imageUrls01, images)
{
    this.loadImages01 = LoadImagesCls_loadImages01;    
    this.loadImages02 = LoadImagesCls_loadImages02;    

    //der image-Array
    this.imageArr = null;
    if(imageUrls01 != null)
        this.imageArr = this.loadImages01(imageUrls01);
    else
    if(images != null)
        this.imageArr = this.loadImages02(images);
    
    this.loadComplete = LoadImagesCls_complete;
}

//Methode, die die Images laed
function LoadImagesCls_loadImages01(imageUrls01)
{
    var imgArr = new Array(imageUrls01.length);
    var i;
    for(i = 0; i < imageUrls01.length; i++)
    {
            imgArr[i] = new Image();
	        imgArr[i].src = imageUrls01[i];
    }

    return imgArr;
}

//Methode, die die images kopiert
function LoadImagesCls_loadImages02(images)
{
    var imgArr = new Array(images.length);
    var i;
    for(i = 0; i < images.length; i++)
    {
            imgArr[i] = images[i];
    }

    return imgArr;
}

//Diese Methode prueft, ob ALLE images geladen sind. Ist das der Fall,
//wird true zurueckgegeben, sonst false.
function LoadImagesCls_complete()
{
    var i;
    for(i = 0; i < this.imageArr.length; i++)
    {

        if(!this.imageArr[i].complete)
            return false;
    }
    return true;
}

///////// LoadImagesCls - End ///////////////

//Parameter-uebergabe fuer home
var refSource = "";
function getRefSource()
{
   var v = location.search;
   
   if(v == "")
      return;
   
   var w = /=/;
   var pos01 = v.search(w);
   
   if(pos01 == -1 || pos01 == v.length - 1)
     return;  
   
   refSource = unescape(v.substring(pos01 + 1));
}


//wir benutzen auch searchString = location.search fuer parameter uebergabe. ganzer string ?xxx=... .
//dieser string muss global verfuegbar sein, und ist im allgemeienn leer.
//wenn aber parameter existieren wird er gesetzt. Muss global sein, da auch in menus abgefragt.
var searchString = "";


    //verallgemeinert fuer beliebig viele parameter
	//lierfert einen assozierten array zurueck, mit dem man wie folgt die
	//uebergebenen parameter erhaelt var v01 = a["key"]; wenn pruefung dann z.B. if(a["key"] == null) pruefeon ob existiert.
	//an die aufgerufene Seite, die getParams aufruft, kann uebergeben werden: nichts, z.B. www.uuu.com/abc.htm.
	//ein oder mehrere parameter, z.B. www.uuu.com/abc.htm?aaa=dkdkkd ddkd dkdkd&bbb=ddfdf ddfd dfd
	//und auch mit parametern wo value fehlt z.B. www.uuu.com/abc.com?aaa= .
	//alles ist zu escapen und wird hier unescaped.
	function getParams()
	{
		var b = new Array();
	
		var str01 = location.search;
		if(str01.length == 0)
			return b;
			
		str01 = str01.substring(1);
		
		var a = new Array();
		var pos;
		var lastPos = 0;
		var w = /&/;
		var i = 0;
		var str02 = str01;
		while(true)
		{
			pos = str02.search(w);
			if(pos == -1)
			{
				if(str02.length != 0)
				a[i] = str02;
				break;
			}
			a[i] = str02.substring(lastPos, pos);
			str02 = str02.substring(pos + 1);
			i++
		}
		
		w = /=/;
		
		for(i = 0; i < a.length; i++)
		{
		
			var pos = a[i].search(w);
			var key = a[i].substring(0, pos);
			var val = unescape(a[i].substring(pos + 1));
			b[key] = val;					
			
		}
				
		return b;
	}
	
	//dito nur searchstr nutzung
	function getParamsHomeAAA()
	{
		var b = new Array();
	
		var str01 = searchString;
		if(str01.length == 0)
			return b;
			
		str01 = str01.substring(1);
		
		var a = new Array();
		var pos;
		var lastPos = 0;
		var w = /&/;
		var i = 0;
		var str02 = str01;
		while(true)
		{
			pos = str02.search(w);
			if(pos == -1)
			{
				if(str02.length != 0)
				a[i] = str02;
				break;
			}
			a[i] = str02.substring(lastPos, pos);
			str02 = str02.substring(pos + 1);
			i++
		}
		
		w = /=/;
		
		for(i = 0; i < a.length; i++)
		{
		
			var pos = a[i].search(w);
			var key = a[i].substring(0, pos);
			var val = unescape(a[i].substring(pos + 1));
			b[key] = val;					
			
		}
				
		return b;
	}

	

	//fuer spezielle Suchm-Homes
	function getParamsXX()
	{
		var b = new Array();
	
		var str01 = searchString;
		if(str01.length == 0)
			return b;
			
		str01 = str01.substring(1);
		
		var a = new Array();
		var pos;
		var lastPos = 0;
		var w = /&/;
		var i = 0;
		var str02 = str01;
		while(true)
		{
			pos = str02.search(w);
			if(pos == -1)
			{
				if(str02.length != 0)
				a[i] = str02;
				break;
			}
			a[i] = str02.substring(lastPos, pos);
			str02 = str02.substring(pos + 1);
			i++
		}
		
		w = /=/;
		
		for(i = 0; i < a.length; i++)
		{
		
			var pos = a[i].search(w);
			var key = a[i].substring(0, pos);
			var val = unescape(a[i].substring(pos + 1));
			b[key] = val;					
			
		}
				
		return b;
	}

	function getParamsKeys(searchStr)
	{
		var b = new Array();
	
		var str01 = searchStr;
		if(str01.length == 0)
			return b;
			
		str01 = str01.substring(1);
		
		var a = new Array();
		var pos;
		var lastPos = 0;
		var w = /&/;
		var i = 0;
		var str02 = str01;
		while(true)
		{
			pos = str02.search(w);
			if(pos == -1)
			{
				if(str02.length != 0)
				a[i] = str02;
				break;
			}
			a[i] = str02.substring(lastPos, pos);
			str02 = str02.substring(pos + 1);
			i++
		}
		
		w = /=/;
		
		for(i = 0; i < a.length; i++)
		{
		
			var pos = a[i].search(w);
			var key = a[i].substring(0, pos);
			b[i] = key;
			
		}
				
		return b;
	}


//links href setzen
function setLinkWithParams(id, href)
{
  var v = document.getElementById(id);
  
  
  var str = "";
  if(searchString != "")
    str = searchString;
  
  v.href = href + str;
}





//links href setzen
function setLink(id, href)
{
  var v = document.getElementById(id);
  
  var str = "";
  if(refSource != "")
    str = "?refSource=" + refSource;
  
  v.href = href + str;
}
//links href setzen
function setLinkA(id, href)
{
  var v = document.getElementById(id);
  
  var str = "";
  if(searchString != "")
    str = searchString;
  
  v.href = href + str;
}

//links href setzen
function setLinkShop(id, href)
{
  var v = document.getElementById(id);
  
  var str = "";
  if(searchString != "")
    str = searchString;
  
  v.href = href + str;
}

function setLinkShopXX(id, href)
{

  var v = document.getElementById(id);
    
  v.href = href + searchString;
}

//showQuasiPic zur Aktivierung des servers
function showQuasiPic()
{
  document.write("<img src=" + directory +  "activator/qpic.aspx" +  ">");
}

function twCount01(id, pageId)
{
  document.write("<img src=" + directory +  "activator/twcnt01.aspx?id=" + escape(id) + "&pageId=" + escape(pageId)       +  ">");
}



//fuer counter
function TestIgnore() 
{ 
   if(document.cookie) 
   { 
   
      var Name = ""; 
      var Wert = ""; 
      var Cookiestring = document.cookie; 
      
      for(;;) 
      { 
      
         var Wertstart = Cookiestring.indexOf("=") + 1; 
         var Wertende = Cookiestring.indexOf("; "); 
         if(!Wertstart) 
         { 
            return 0; 
         } 
         
         if(Wertende == -1) Wertende = Cookiestring.length; 
         Name = Cookiestring.substring(0,Wertstart-1); 
         Wert = Cookiestring.substring(Wertstart,Wertende); 
         if(Name == "Ignorieren" && Wert == "TRUE") 
         { 
            return 1; 
         } 
         Cookiestring = Cookiestring.substring(Wertende+2,Cookiestring.length); 
         
       } 
       
    } 
    else 
    { 
       return 0; 
    } 
}

	//hoverBtnX-Function
	function picButtonOnMouseOver(pic, src)
	{
		pic.src = src;
	}
	//hoverBtnX-Function
	function picButtonNowOnMouseOut(pic, src)
	{
		pic.src = src;
	}

//sichtbar machen bzw. unsichtbar machen von elementen

    var lastTableIdXXY = null;
    var lastImgIdXXY   = null;

	function intTableHiddingSys(lastTableId, lastImgId)
	{
		lastTableIdXXY = lastTableId;
		lastImgIdXXY   = lastImgId;
	}


	function showElement01(idTable, idImg, cntPageName)
	{
		if(lastTableIdXXY != null)
		{
			var el = document.getElementById(lastTableIdXXY);
			el.className = "cssHidden01";
		}
		if(idImg != null && lastImgIdXXY != null)
		{
			var el = document.getElementById(lastImgIdXXY);
			el.src = "../../images/pfeilRechts02.gif";
			
		}
		
		var el = document.getElementById(idTable);
		el.className = "cssVisible01";
		lastTableIdXXY = idTable;
		if(idImg != null)
		{
			var el = document.getElementById(idImg);
			el.src = "../../images/pfeilRechts.gif";
			lastImgIdXXY = idImg; 
		}
		if(cntPageName != null)
			doCntSelection(cntPageName, shopId);
	}
 
