
var button_gear_flag=0;
var button_team_flag=0;
var button_news_flag=0;
var button_product_flag=0;
var button_company_flag=0;
var button_legal_flag=0;
var button_login_flag=0;


var isIE = false;
if (navigator.appName != "Netscape")
  isIE=true;


function popup (comp,popupdiv,scontent,x,y)
{ pdiv=document.getElementById(popupdiv);
  if (pdiv!=null) 
  { pdiv.innerHTML='<table class="popuptable" border="0" bgcolor="#888888" cellpadding="3" cellspacing="1" width="100%"><tr><td height="1" bgcolor="#FFFEE4" valign="top">'+scontent+
    '</table>';
    var curleft = curtop = 0;
    lastcomp=comp;
    if (comp.offsetParent)
   { do
       { curleft += comp.offsetLeft;
	    curtop += comp.offsetTop;
      } while (comp = comp.offsetParent);
    }
    if (x!=null&&y!=null )
    { curleft+=x;
    	curtop+=y;
    } else
    { curleft-=200;
    	curtop+=0;
    }
    pdiv.style.top=curtop+"px";
    pdiv.style.top=curtop+"px";
  	 pdiv.style.left=curleft+"px";
    pdiv.style.display="block";
  }
}
 

function changebg(comp,imgsrc)
{ if (comp.style.backgroundImage!='url(/'+imgsrc+')')
  { comp.style.backgroundImage ='url(/'+imgsrc+')';
 }
  return 0;
}

function isDefined(object, variable)
{ if (typeof(object) == 'undefined') 
    return false;
  return true;
}

function posDiv (companc,comp,x,y)
{ anchestor=document.getElementById(companc);
  comp=document.getElementById(comp);
  if (comp!=null &&anchestor!=null ) 
  { var curleft = curtop = 0;
    lastcomp=anchestor;
    if (anchestor.offsetParent)
   { do
       { curleft += anchestor.offsetLeft;
	    curtop += anchestor.offsetTop;
      } while (anchestor = anchestor.offsetParent);
    }
    if (x!=null&&y!=null )
    { curleft+=x;
    	curtop+=y;
    } else
    { curleft-=200;
    	curtop+=0;
    }
    comp.style.top=curtop+"px";
    comp.style.top=curtop+"px";
    comp.style.left=curleft+"px";
    
  }
}


function sdiv(divname)
{ if ( document.getElementById(divname)!=null)
   document.getElementById(divname).style.display='block';
 else 
   alert('error sdiv '+divname);	
}
 
function setDivPos(divname,x,y)
{ if ( document.getElementById(divname)!=null)
  { document.getElementById(divname).style.left=x+'px';
    document.getElementById(divname).style.top=y+'px';
  } else 
   alert('error sdiv '+divname);	
}

function hdiv(divname)
{ if ( document.getElementById(divname)!=null)
   document.getElementById(divname).style.display='none';
  else 
   alert('error hdiv '+divname);	
}

function movedivz(divname,newz)
{ if ( document.getElementById(divname)!=null)
   document.getElementById(divname).style.zIndex=newz;
  else 
   alert('error movedivz '+divname);	
}

function getdivz(divname)
{ if ( document.getElementById(divname)!=null)
    return document.getElementById(divname).style.zIndex;
  else 
   alert('error getdivz '+divname);	
}

function isdivVis(divname)
{ if ( document.getElementById(divname)!=null)
    return document.getElementById(divname).style.display!='none';
  else 
   alert('error isdivVis '+divname);	
}

function existsDiv(divname)
{ return document.getElementById(divname)!=null
}

function getDiv(divname)
{ return document.getElementById(divname)
}


function setDivC(divname,content)
{ if ( document.getElementById(divname)!=null)
   document.getElementById(divname).innerHTML=content;
  else 
   alert('error setting div content '+divname);	
}

function n2c(number)
{ ret="";
  ret=ret+String.fromCharCode(number);
  return ret;
}

function checkmail(s)
{ 
  var a = false;
 var res = false;
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

 if(a == true)
 {
  reg = new RegExp(n2c(94)+'([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);
   
 }

 return(res);
}


function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}


function checkup_date(csrc)
{ allowedc="0123456789.";
  
  var src=csrc;	 
  var fields=src.split('.');
  
  if (fields.length!=3)
  { 
  } if(fields.length==3 && (fields[0].length==2||fields[0].length==1)&& (fields[1].length==2 ||fields[1].length==1) && fields[2].length==4)
  { source_date = new Date(fields[2],fields[1]-1,fields[0]);
    if(fields[2] != source_date.getFullYear())
    { return 1;
    }

    if(fields[1]-1 != source_date.getMonth())
    {  return 1;
    }
	
    if(fields[0] != source_date.getDate())
    {  return 1;
    }
  	
  	 
    return 0;
  } else
  { 
  	
  }
  return 1;
}


function dAlign(target,scomp,x,y)
{ pdiv=document.getElementById(target);
  comp=document.getElementById(scomp);
  if (pdiv!=null) 
  { 
    var curleft = curtop = 0;
    lastcomp=comp;
    if (comp.offsetParent)
   { do
       { curleft += comp.offsetLeft;
	    curtop += comp.offsetTop;
      } while (comp = comp.offsetParent);
    }
    if (x!=null&&y!=null )
    { curleft+=x;
    	curtop+=y;
    } else
    { curleft-=200;
    	curtop+=0;
    }
    pdiv.style.top=curtop+"px";
    pdiv.style.top=curtop+"px";
  	 pdiv.style.left=curleft+"px";
    pdiv.style.display="block";
  }
}


function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();
// Global object to hold drag information.

var dragObj = new Object();


// Global object to hold drag information.

var dragObj = new Object();
var img_path='/tsg_images/';



function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.
  var container=document.getElementById(id);
  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX ;//+ window.scrollX;
    y = event.clientY ;//+ window.scrollY;
  }
 

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.offsetLeft, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.offsetTop,  10);
  //dragObj.elStartLeft  = dragObj.elNode.style.left;
  //dragObj.elStartTop   = dragObj.elNode.style.top;

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;
  
  // Update element's z-index.

  //dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
     + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
     + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX ;//+ window.scrollX;
    y = event.clientY ;//+ window.scrollY;
  }
 

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Clear the drag element global.

  dragObj.elNode = null;

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

function change(imgname,imgsrc)

{ if ( document.getElementById(imgname)!=null)
    return document.getElementById(imgname).src=imgsrc;
  else 
   alert('error change '+imgname);
  return 0;
}


var xmlDoc;
var xmlDoc1;
var xmlDoc2;
var htmlDoc;
var htmlDoc1;
var htmlDoc2;
function requestXMLFrom(adress,funcname,retid)
{ var req = null;
  if (retid==null || retid=="")
    retid=0;
  try
  { req = new XMLHttpRequest();
  }
  catch (ms)
  { try
    { req = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (nonms)
    { try
      { req = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch (failed)
      { req = null;
      }
    }  
  }

  if (req == null)
  alert("Error creating request object!");
                  
  //anfrage erstellen (GET, url ist localhost,
  //request ist asynchron      
  req.open("GET",adress, true);
  req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8;");
  //req.setRequestHeader("charset", "latin1");
  req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
  req.onreadystatechange = function()
  { switch(req.readyState) 
    { case 4: if(req.status!=200) 
              { //alert("Fehler: "+req.status+" "+adress+" "+" "+req.responseText); 
              } else
              { switch (retid)
                { case 0 : xmlDoc=req.responseXML;	
                           htmlDoc=req.responseText;	
                           break;
                  case 1 : xmlDoc1=req.responseXML;	
                           htmlDoc1=req.responseText;	
                           break;
                  case 2 : xmlDoc2=req.responseXML;	
                           htmlDoc2=req.responseText;	
                           break;
                }if (funcname.length==0)
                {	
                } else if (funcname.indexOf("(")>=0)
                { eval (funcname);
                } else
                { eval (funcname+"();");
                }
              }
              break;
      default: return false;
               break;     
    }
  };
  req.send(null);
  
	
}

function postXMLFrom(adress,parameters, funcname,retid)
{ var preq = null;
   if (retid==null || retid=="")
    retid=0;
  try
  { preq = new XMLHttpRequest();
  }
  catch (ms)
  { try
    { preq = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (nonms)
    { try
      { preq = new ActiveXObject("Microsoft.XMLHTTP");
      } 
      catch (failed)
      { preq = null;
      }
    }  
  }

  if (preq == null)
  alert("Error creating request object!");
                  
  //anfrage erstellen (GET, url ist localhost,
  //request ist asynchron      
   preq.open("POST",adress, true);
   preq.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=utf-8;");
   preq.setRequestHeader("Content-length", parameters.length);
   //preq.setRequestHeader("charset", "latin1");
   preq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
   preq.setRequestHeader("Connection", "close");
   
   

  //Beim abschliessen des request wird diese Funktion ausgef&uuml;hrt
  preq.onreadystatechange = function()
  { switch(preq.readyState) 
    { case 4: if(preq.status!=200) 
              { alert("Fehler: "+preq.status+" "+adress+" "+" "+preq.responseText); 
              } else
              {  switch (retid)
                { case 0 : xmlDoc=preq.responseXML;	
                           htmlDoc=preq.responseText;	
                           break;
                  case 1 : xmlDoc1=preq.responseXML;	
                           htmlDoc1=preq.responseText;	
                           break;
                  case 2 : xmlDoc2=preq.responseXML;	
                           htmlDoc2=preq.responseText;	
                           break;
                }if (funcname.length==0)
                {	
                } else if (funcname.indexOf("(")>=0)
                { eval (funcname);
                } else
                { eval (funcname+"();");
                }
              }
              break;
      default: return false;
               break;     
    }
  };
  
  preq.send(parameters);
	
}


function buttonVslid(id,offset)
{ backpos=$(id).css('background-position');
  $(id).css('top',offset+'px');
  //alert(x+' '+offset+'px');	
}

function createVslidButton(slidid,w1,h1,xofs,image,text,css1,linked,js)
{ overadd="";
  outadd="";
  downadd="";
  upadd="";
  if (linked!="")
  { outadd="buttonVslid('#"+linked+"',-"+0+");";
    overadd="buttonVslid('#"+linked+"',-"+h1+");";
    downadd="buttonVslid('#"+linked+"',-"+(h1*2)+");";
    upadd="buttonVslid('#"+linked+"',-"+(h1)+");";
  }

  document.write('<div onmousedown="buttonVslid(\'#'+slidid+'\',-'+(h1*2)+'); '+downadd+'" onmouseup="buttonVslid(\'#'+slidid+'\',-'+(h1)+'); '+upadd+'" '+
                 'onmouseover="$(\'#'+slidid+'_text\').css(\'color\',\'#ffffff\'); $(\'#'+slidid+'_link\').css(\'color\',\'#ffffff\'); buttonVslid(\'#'+slidid+'\',-'+h1+'); '+overadd+'" '+
                 'onmouseout="$(\'#'+slidid+'_text\').css(\'color\',\'#888888\'); $(\'#'+slidid+'_link\').css(\'color\',\'#888888\');  buttonVslid(\'#'+slidid+'\',-'+00+');'+outadd+'" '+
                 'style="float:left; width:'+w1+'px; overflow:hidden; height:'+h1+'px; cursor:pointer; '+css1+'" onclick="'+js+'">'+
                 '<div id="'+slidid+'" style="position:relative; top:0px;left:-'+xofs+'px; background:url(/'+image+'); background-repeat:no-repeat; width:500px; height:500px;" '+
                 'onmouseover="$(\'#'+slidid+'_text\').css(\'color\',\'#ffffff\');" '+
                 '></div>'+
                 '<div id="'+slidid+'_text" style="position:relative; left:0px; top:-'+500+'px; width:100%; height:'+h1+'px; text-align:center;" '+
                 'onmouseover="$(\'#'+slidid+'_text\').css(\'color\',\'#ffffff\');" '+
                 '>'+text+'</div>'+
                 '</div>'+
                 ''+
                 '');
	
}



function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}




var menucall=0;

function passfilter()
{ var ret='&c='+document.filter.c.value+''+
           '&gridpage='+document.filter.gridpage.value+''+
           '&matchpage='+document.filter.matchpage.value+''+
           '&detailtab='+document.filter.detailtab.value+''+
           '&filterpanel='+document.filter.filterpanel.value+''+
           '&search='+document.filter.search.value+''+
           '&model='+document.filter.model.value+''+
           '&p='+document.filter.p.value+''+
           '&s='+document.filter.s.value+''+
           '&np='+document.filter.np.value+''+
           '&gender1='+document.filter.gender1.value+''+
           '&gender2='+document.filter.gender2.value+''+
           '&gender3='+document.filter.gender3.value+''+
           '&fp0='+document.filter.fp0.value+''+
           '&fp1='+document.filter.fp1.value+''+
           '&fp2='+document.filter.fp2.value+''+
           '&fp3='+document.filter.fp3.value+''+
           '&fp4='+document.filter.fp4.value+''+
           '&fp5='+document.filter.fp5.value+''+
           '&sw1='+document.filter.sw1.value+''+
           '&sw2='+document.filter.sw2.value+''+
           '&sw3='+document.filter.sw3.value+''+
           '&sw4='+document.filter.sw4.value+''+
           '&cat1='+document.filter.cat1.value+''+
           '&cat2='+document.filter.cat2.value+''+
           '&cat3='+document.filter.cat3.value+''+
           '&cat4='+document.filter.cat4.value+''+
           '&c1='+document.filter.c1.value+''+
           '&c2='+document.filter.c2.value+''+
           '&c3='+document.filter.c3.value+''+
           '&c4='+document.filter.c4.value+''+
           '&c5='+document.filter.c5.value+''+
           '&c6='+document.filter.c6.value+''+
           '&c7='+document.filter.c7.value+''+
           '&c8='+document.filter.c8.value+''+
           '&c9='+document.filter.c9.value+''+
           '&c10='+document.filter.c10.value+''+
           '&c11='+document.filter.c11.value+''+
           '&c12='+document.filter.c12.value+''+
           '&c13='+document.filter.c13.value+''+
           '&c14='+document.filter.c14.value+''+
           '&c15='+document.filter.c15.value+''+
           '&c16='+document.filter.c16.value+''+
           '&c17='+document.filter.c17.value+''+
           '&c18='+document.filter.c18.value+''+
           '&c19='+document.filter.c19.value+''+
           '&c20='+document.filter.c20.value+''+
           '&c21='+document.filter.c21.value+''+
           '&s0='+document.filter.s0.value+''+
           '&s1='+document.filter.s1.value+''+
           '&s2='+document.filter.s2.value+''+
           '&s3='+document.filter.s3.value+''+
           '&s4='+document.filter.s4.value+''+
           '&s5='+document.filter.s5.value+''+
           '&p1='+document.filter.p1.value+''+
           '&p2='+document.filter.p2.value+''+
           '&p3='+document.filter.p3.value+''+
           ''+
           '';
  return ret;	
}

function flipf(name,override)
{ if ($('#ff_'+name).val()==1 && override!=1 || override==0)
  { $('#ff_'+name).val(0);
    $('#'+name).css('background','');
    $('#'+name).css('color','#666666');
  } else
  { $('#ff_'+name).val(1);
    $('#'+name).css('background','url(/tsg_images/filterlist_bar.png)');
    $('#'+name).css('color','#ffffff');
  }
  if (override!="0")
    UpdateGrid();
  
}

function flipfn(name,override)
{ if ($('#ff_'+name).val()==1 && override!=1 || override==0)
  { $('#ff_'+name).val(0);
    $('#'+name).css('background','');
    $('#'+name).css('color','#666666');
  } else
  { $('#ff_'+name).val(1);
    $('#'+name).css('background','url(/tsg_images/filterlist_bar.png)');
    $('#'+name).css('color','#ffffff');
  }
 
}

function setf(name,override)
{ if ($('#ff_'+name).val()==1 && override!=1 || override==0)
  { $('#ff_'+name).val(0);
    $('#'+name).css('background','');
    $('#'+name).css('color','#cccccc');
   }else
  { $('#ff_'+name).val(1);
    $('#'+name).css('background','url(/tsg_images/filterlist_bar.png)');
    $('#'+name).css('color','#ffffff');
  }
  if (override!="0")
    UpdateGrid();
 
 
}

function flipc(name)
{ if ($('#ff_'+name).val()==1)
  { $('#ff_'+name).val(0);
    $('#'+name).css('background','');
  } else
  { $('#ff_'+name).val(1);
    $('#'+name).css('background','url(/tsg_images/color_active.png)');
  }
  
  UpdateGrid();

}

function flips(name,i)
{ if ($('#ff_'+name).val()==1)
  { $('#ff_'+name).val(0);
    buttonVslid('#'+name,-00);
   }else
  { $('#ff_'+name).val(1);
    buttonVslid('#'+name,-44);

  }
  
 UpdateGrid();

}



function flipp(name,i)
{ if ($('#ff_'+name).val()==1)
  { $('#ff_'+name).val(0);
    buttonVslid('#'+name,-00);
  } else
  { $('#ff_'+name).val(1);
    buttonVslid('#'+name,-44);
   
  }
  UpdateGrid();

}

function UpdateGrid()
{ 
  
  if (document.getElementById('gridline')!=null)
    updateGridLine();
  else if (menucall== 1) 
  { document.location.href="/index.php?sfpc=TSG_Gear"+passfilter();
  } else if(typeof updateOverview != 'function' ) 
  { document.location.href="/index.php?sfpc=TSG_OVERVIEW"+passfilter();
  } else 
    updateOverview();
  menucall=0;
	
}

function resetfilter()
{ 
  resetColorFilter();

}

function resetColorFilter()
{ for (i=0;i<21;i++)
  { $('#c'+i).css('background','');
    $('#ff_c'+i).val(0);	
  }  
  UpdateGrid();	
}



function resetCatFilter(override)
{ flipf("cat1",0)
  flipf("cat2",0)
  flipf("cat3",0)
  flipf("cat4",0)
  if (override!="1")
    UpdateGrid();	
}


function resetWeltFilter(override)
{ flipf("sw1",0)
  flipf("sw2",0)
  flipf("sw3",0)
  flipf("sw4",0)
  if (override!="1")
    UpdateGrid();
}

function resetGenderFilter(override)
{ flipf("gender1",0)
  flipf("gender2",0)
  flipf("gender3",0)
  if (override!="1")
    UpdateGrid();
}

function resetPriceFilter()
{ buttonVslid('#p1',-00);
  buttonVslid('#p2',-00);
  buttonVslid('#p3',-00);
  
  $('#ff_p1').val(0);
  $('#ff_p2').val(0);
  $('#ff_p3').val(0);
  UpdateGrid();
	
}

function resetSizeFilter()
{ $('#s1').css('background','url(/tsg_images/s_'+1+'.png)');
  $('#s2').css('background','url(/tsg_images/s_'+2+'.png)');
  $('#s3').css('background','url(/tsg_images/s_'+3+'.png)');
  $('#s4').css('background','url(/tsg_images/s_'+4+'.png)');
  $('#s5').css('background','url(/tsg_images/s_'+5+'.png)');
  $('#ff_s1').val(0);
  $('#ff_s2').val(0);
  $('#ff_s3').val(0);
  $('#ff_s4').val(0);
  $('#ff_s5').val(0);
  UpdateGrid();
}



var atHome=0;

$(document).ready(function(){
    $("#newsletter").defaultValue("Enter your email address");  
    resetSearch ();;
       
}); 

function resetSearch () {
  document.getElementById('search').value='';
  
}


function searchCheck () {
  if (products_showed==0)
  { $('#cid').val('');
    $('#sfpc').val('TSG_OVERVIEW');
    document.getElementById('filter').submit();
  }
   if (products_showed==0)
    { $('#cid').val('');
      $('#sfpc').val('TSG_OVERVIEW');
      document.getElementById('filter').submit();
    }
    else if (document.getElementById('gridline')!=null)
    {   updateGridLine();  }
    else if (document.getElementById('filterpanel')!=null)
    {   updateOverview();  }
    else
    {  alert(3);
       document.location.href='index.php?sfpc=TSG_OVERVIEW'+passfilter();
    }

  enableGear(0);
  //document.location.href='/index.php?sfpc=TSG_OVERVIEW'+passfilter();
  
  return false;
}


function changeIdImg(compname,imgsrc)
{ var comp=document.getElementById(compname);
  if (comp!=null )
  { comp.style.background='url(/'+imgsrc+')';
  } else
  alert('');
  return 0;
}

function enableGear(mode)
{ if (mode==1)
  { document.getElementById('button_gear').style.backgroundImage='url(/'+img_path+'n_main_but1.png)';
    document.getElementById('button_gear_link').style.color='#ffffff';
    if ($('#tsg_mainsubMenu').css('display')=='none') $('#tsg_mainsubMenu').fadeIn(250);
    document.getElementById('tsg_mainsubMenu').title='';
  } else if (mode==0)
  { document.getElementById('tsg_mainsubMenu').title='close';
    window.setTimeout('enableGear(2);',1000);
  } else
  { if ($("#tsg_mainsubMenu").attr("title")=="close")
    { document.getElementById('button_gear').style.backgroundImage='url(/'+img_path+'n_main_but0.png)';
      document.getElementById('button_gear_link').style.color='#666666';
    }
    divClose("#tsg_mainsubMenu");
  }
 if (button_gear_flag==1)
  { $("#button_gear").css('background','url(/tsg_images/n_main_but1.png)');
    $("#button_gear_link").css('color','#ffffff');
 }

}

function enableTeam(mode)
{ if (mode==1)
  { document.getElementById('button_team').style.backgroundImage='url(/'+img_path+'n_main_but1.png)';
    document.getElementById('button_team_link').style.color='#ffffff';
    if ($('#tsg_teamSubMenu').css('display')=='none') $('#tsg_teamSubMenu').fadeIn(250);
    document.getElementById('tsg_teamSubMenu').title='';
  } else if (mode==0)
  { doclose=1;
    document.getElementById('tsg_teamSubMenu').title='close';
    window.setTimeout('enableTeam(2);',1000);
  } else
  { if ($("#tsg_teamSubMenu").attr("title")=="close")
    { document.getElementById('button_team').style.backgroundImage='url(/'+img_path+'n_main_but0.png)';
      document.getElementById('button_team_link').style.color='#666666';
    }
    divClose("#tsg_teamSubMenu");
  }
  if (button_team_flag==1)
  { $("#button_team").css('background','url(/tsg_images/n_main_but1.png)');
    $("#button_team_link").css('color','#ffffff');
 }
}

function divClose(windowDef)
{ if ($(windowDef).attr("title")=="close")
  { if ($(windowDef).css('display')!='none') $(windowDef).fadeOut(250);
    
  }
 
}

var doclose=0;
var doclose2=0;
var doclose3=0;

function flipfilter()
{ if ($('#filterpanel').css('display')=='none') 
  { $('#filterpanel').slideDown('slow'); 
    if (document.filter.filterpanel!=null)	
      document.filter.filterpanel.value="block";
  }else 
  { $('#filterpanel').slideUp('slow');
    if (document.filter.filterpanel!=null)	
      document.filter.filterpanel.value="none";		 
  }
}
 


function prepare_reg() 
{ $('#reg_name').defaultValue('your first name');
  $('#reg_surname').defaultValue('your surname');
  $('#reg_email').defaultValue('your email');
  $('#reg_land').defaultValue('your country eg. US');
  $('#reg_country').defaultValue('your state eg. bavaria');
  $('#reg_city').defaultValue('your city');
  $('#reg_postal').defaultValue('your postal code');
  $('#reg_street').defaultValue('your street and number');
  Recaptcha.create("6Le4-ggAAAAAAA1gDmD4SEua0ZC3QsLWivX08UPp",
   "recaptcha_div", {
   theme: "blackglass",
   callback: Recaptcha.focus_response_field
  });
  
}





function afterListDelete()
{ sitealert("Info",htmlDoc);
   if (document.getElementById('content_title').innerHTML=="WISHLIST")
    openWishlist();
  else  if (document.getElementById('content_title').innerHTML=="CART")
    openCart();
  refreshnavi();
}

function setFilter(tags,model,pbp)
{ list=tags.split(";");
  resetWeltFilter(1);
  resetCatFilter(1);
  if (isDefined(model))
  { document.filter.search.value=model;
    if (model!="")
       menucall=1;
  } else
  {  document.filter.search.value="";
	
  }
  if (isDefined(pbp))
  { document.filter.pbp.value=pbp;
    document.filter.dsid.value='';	
  }
  for (i=0;i<list.length;i++)
  { if (list[i].indexOf('gender')==0)
      flipfn(list[i],1);
    else if (list[i].indexOf('cat')==0)
      flipfn(list[i],1);
    else if (list[i].indexOf('sw')==0)
      flipfn(list[i],1);
    
  }

 
  UpdateGrid();
  
  enableGear(0);
 
}

function setFilterGotoGear(tags,model,pbp)
{ list=tags.split(";");
  resetWeltFilter(1);
  resetCatFilter(1);
  if (isDefined(model))
  {   document.filter.search.value=model;
  } else
  {  document.filter.search.value="";
	
  }
  if (isDefined(pbp))
    document.filter.pbp.value=pbp;
  for (i=0;i<list.length;i++)
  { if (list[i].indexOf('gender')==0)
      flipf(list[i],(1));
    else if (list[i].indexOf('cat')==0)
      flipf(list[i],(1));
    else if (list[i].indexOf('sw')==0)
      flipf(list[i],(1));
   
  }
  
  enableGear(0);
  document.filter.sfpc.value='TSG_Gear';
  document.filter.submit();
}


function afterListClick(id,openId)
{ //$("#blend0").fadeOut(250);;
  if (typeof(reloadGrid)=="function") 
    requestXMLFrom('/index.php?sfpc=DATA_gridline&formfunc=getGridLine&dsid=id'+passfilter(),'reloadGrid('+id+')');
  else
   document.location.href="index.php?sfpc=TSG_GEAR&dsid="+id+"&id="+openId;
}

function moveToCart(order)
{ sitealert("MoveToCart",htmlDoc);
  openWishlist(order);
  refreshnavi();
  window.setTimeout("$('#blend').fadeOut(250)",1000);	 
}

function refreshLogin()
{ requestXMLFrom('/index.php?sfpc=NAVI_DYNAMIC', 'setDivC("dynamic_navi",htmlDoc1);',1);
}

function doLogin()
{ username= $('#mainloginname').val();
  password= $('#mainloginpassword').val();
  cook= $('#maincook').val();
  
  requestXMLFrom('/index.php?sfpc=contentPort&formfunc=getUsername&username='+username+'&password='+password+'&login=yes&cook='+cook, 'sitealert("LOGIN",htmlDoc); if (htmlDoc.indexOf("Login failed")==0) window.setTimeout("openLogin()",1500); else refreshDynaNavi();');
  //requestXMLFrom('/index.php?sfpc=NAVI_DYNAMIC', 'setDivC("dynamic_navi",htmlDoc1);',1);
  if ($('#movecart_on_login').val()==1) 
  { window.setTimeout(" if ($('#loginflag').val()==1) requestXMLFrom('/index.php?sfpc=contentPort&formfunc=moveCartContents', ' refreshDynaNavi(); /*sitealert(\\'CARTMOVE\\',htmlDoc);*/')",1500);

  }
  closeWindow();	
  
}


function doLogout()
{ requestXMLFrom('index.php?logout=true', '',1);
  window.setTimeout('refreshLogin()',250);
  closeWindow();
  sitealert("LOGOUT",'you logged out, thanks for the visit');
}

function moveToWishlist(order)
{ sitealert("MoveToWishlist",htmlDoc);
  openCart(order);
  refreshnavi();
  window.setTimeout("$('#blend').fadeOut(250)",1000);	 
}


function openWishlist(order)
{ requestXMLFrom('/index.php?sfpc=ContentPort&formfunc=showWishlist&order='+order+'&random='+new Date().getTime(),' siteContent("WISHLIST",htmlDoc);');
  
	 
}

function afterRegister()
{ 
  if (htmlDoc.indexOf("recapcha is wrong")==0)
  { Recaptcha.reload();
  } else if (htmlDoc.indexOf("creation succeed")>=0)
  { closeWindow();
    sitealert('Register',"Your registration was successful. Please check your emails to activate your account.");
  } else
  { sitealert('Register',htmlDoc);
  }	 
}


function addToCart(id)
{ 
  sitealert('AddToCart','Article has heen added to your cart');
  openCart();
  refreshnavi();	
  window.setTimeout("refreshLogin();",500);	 
  window.setTimeout("$('#blend').fadeOut(250)",1000);	 
  
}




function openProfile(mode)
{ if (mode!= 0 &&mode!= 1 &&mode!= 2)
     mode=1;
  requestXMLFrom('/index.php?sfpc=switch_profile&formfunc=showProfile&addrpage='+$('#addrpage').val()+'&random='+new Date().getTime(),'actual_slide=1; openProfile2(); buttonVslid("#profile_t1",-22); '+"doProfileWarp("+mode+"); profile_changing=0; "+'  ');
  
}
function openProfile2(rules)
{ siteContent("PROFILE",htmlDoc);
  if (document.getElementById('recaptcha_div')!=null)
    prepare_reg(); 
  if (document.getElementById('show_addrpage')!=null)
   setDivC('show_addrpage',(parseInt($('#addrpage').val())+parseInt(1))+"")
  
}

function openCart(order)
{ requestXMLFrom('/index.php?sfpc=ContentPort&formfunc=openCart&order='+order+'&random='+new Date().getTime(),'siteContent("CART",htmlDoc);');
  
}


function openCheckout()
{ if ($('#articlecount').val()==0) 
  { sitealert('CHECKOUT','Checkout not possible, sorry but you have no items in your cart');	
  } else 
  {	
    requestXMLFrom('/index.php?sfpc=CHECKOUT&random='+new Date().getTime(),' siteContent("CHECKOUT",htmlDoc);  setDefaultsForCheckout(); buttonVslid("#check_t1",-22); if ($("#loginflag").val()=="1") {  window.setTimeout("doCheckoutSlid(2);",250);  }');
    actual_slide=1;	 
  }
   
}



function setDefaultsForCheckout()
{ $('#cartloginname').defaultValue('username');
  $('#cartloginpassword').defaultValue('password');
  $('#ba_name').defaultValue('name');
  $('#ba_surname').defaultValue('surname');
  $('#ba_email').defaultValue('email');
  $('#ba_phone').defaultValue('phone');
  $('#ba_land').defaultValue('country, use \'US\' for \'USA\'');
  $('#ba_country').defaultValue('state');
  $('#ba_postal').defaultValue('postal');
  $('#ba_city').defaultValue('city');
  $('#ba_street').defaultValue('street');
  $('#sa_name').defaultValue('name');
  $('#sa_surname').defaultValue('surname');
  $('#sa_land').defaultValue('country, use \'US\' for \'USA\'');
  $('#sa_country').defaultValue('state');
  $('#sa_postal').defaultValue('postal');
  $('#sa_city').defaultValue('city');
  $('#sa_street').defaultValue('street');
  $('#coupon').defaultValue('enter a coupon number if available');
  
}

function openLogin()
{ closeWindow();
  closeWindow();
  requestXMLFrom('/index.php?sfpc=form_login&random='+new Date().getTime(),'openLogin2()');
	 
}

function refreshnavi()
{ requestXMLFrom('/index.php?sfpc=navi_dynamic&random='+new Date().getTime(),'setDivC("dynamic_navi",htmlDoc);');
	
}

function openLogin2()
{ loginContent("LOGIN",htmlDoc);
  $("#mainloginname").defaultValue('username');
  $("#mainloginpassword").defaultValue('password');
	 
}

var redo="";
var accountpage=0;
$(document).ready(function()
  {
    if (redo.length>0)
    { switch  (parseInt(redo))	
      { case -1: openLogin(); break;
        case -2: openProfile(); break;
        case -3: openCheckout(); break;
        case -4: openWishlist(); break;
        case -5: openCart(); break;
      }
    }
        
  }); 

var profile_changing=0;
function askfor(name,olddata,divtarget)
{ setDivC(divtarget,'<input type="text" class="tsg_input_textline_white" id="new_data" value="'+olddata+'" onblur="postXMLFrom(\'index.php\',\'sfpc=ContentPort&formfunc=updatePersonal&addrpage=\'+$(\'#addrpage\').val()+\'&field='+name+'&newdata=\'+encodeURI($(\'#new_data\').val())+\'\',\' openProfile('+actual_slide+');\');">');
 
  profile_changing=1;
  
  $(".countrycontrol").fadeOut(250);
  $("#new_data").focus();
  
}



var actual_slide=1;



function doAddfunction( id)
{  switch(id)
  { case 0: break;
	case 1: doCheckoutSlid(2); setDivC('checkout_continue_button_title','CONTINUE'); if ($('#loginflag').val()==1)  $('#CHECK_OK').fadeIn('250'); setDivC('checkout_add_button_title','BACK'); break;break;
	case 2: doCheckoutSlid(0); if ($('#loginflag').val()==1)  $('#CHECK_OK').fadeOut('250'); break;
	case 3: doCheckoutSlid(2); break
	case 4: if ($('#skipShip').val()  != 1)
                  { doCheckoutSlid(2);
                    id=2;
                  } else
                   doCheckoutSlid(3); break;
	case 5: doCheckoutSlid(4); break;case 6: setDivC('checkout_continue_button_title','BACK'); $('#CHECK_ADD').fadeIn('250'); setDivC('checkout_add_button_title','CHECKOUT'); 
 	case 6: doCheckoutSlid(5); break;case 6: setDivC('checkout_continue_button_title','BACK'); $('#CHECK_ADD').fadeIn('250'); setDivC('checkout_add_button_title','CHECKOUT'); 
 		
	default : break;
  }
  

}

function refreshDynaNavi ()
{ requestXMLFrom('/index.php?sfpc=NAVI_DYNAMIC', 'setDivC("dynamic_navi",htmlDoc1); ',1);
	
}

function doCheckoutSlid( id)
{ 
  doslid=1;
  
  newslide=id;
  username= $('#cartloginname').val();
  password= $('#cartloginpassword').val();
  cook= $('#cook').val();
  buttonVslid('#but_co_add1',0);
  buttonVslid('#but_co_add',0);
  switch(id)
  { case 0: id=1; $('#CHECK_ADD').fadeIn('250'); setDivC('checkout_continue_button_title','SIGN IN');  setDivC('checkout_add_button_title','CONTINUE'); break;
	case 1: requestXMLFrom('/index.php?sfpc=contentPort&formfunc=getUsername&username='+username+'&password='+password+'&login=yes&cook='+cook, 'sitealert("LOGIN",htmlDoc); ');
                  requestXMLFrom('/index.php?sfpc=NAVI_DYNAMIC', 'setDivC("dynamic_navi",htmlDoc1); openCheckout();',1);
                  window.setTimeout(" if ($('#loginflag').val()==1) requestXMLFrom('/index.php?sfpc=contentPort&formfunc=moveCartContents', 'sitealert(\\'CARTMOVE\\',htmlDoc); refreshDynaNavi();')",500);
                  
	case 2: $('#CHECK_ADD').fadeIn('250'); 
                  setDivC('checkout_continue_button_title','CONTINUE');  
                  setDivC('checkout_add_button_title','BACK'); break;
	case 3: if (checkGuestFields ()>0)
                  { sitealert("BILLING ADRESS","Please enter all needed information");
                    doslid=0; 
                  } else  if ($('#userland_short').val()=="00" || $('#userland_short').val()=="0" )
                  { sitealert("BILLING ADRESS","Please enter a valid country");
                    doslid=0; 
                   	
                  } else 
                  { setDivC('checkout_continue_button_title','CONTINUE'); setDivC('checkout_add_button_title','BACK');
                  	
                  }
                  if ($('#skipShip').val() != 1)
                  { id=4;
                    newslide=id;
                  } 
                  break;
	case 4: if (checkGuestFields2 ()>0  && $('#skipShip').val() == 1)
                  { 
                    sitealert("DELIVERY ADRESS","Please enter all needed information");
                    doslid=0; 
                   	
                  } else  if (($('#deliveryland_short').val()=="00" || $('#deliveryland_short').val()=="0" )& $('#skipShip').val() == 1 )
                  { 
                    sitealert("BILLING ADRESS","Please enter a valid country");
                    doslid=0; 
                   	
                  }  else
                    setDivC('checkout_continue_button_title','CONTINUE'); setDivC('checkout_add_button_title','BACK'); break;
	case 5: setDivC('checkout_continue_button_title','CONTINUE'); setDivC('checkout_add_button_title','BACK'); break;
                 
                 
                  break;
	case 6: if ($("#loginflag").val()==0)
                  { printBAdress();
                    if ($('#skipShip').val() == 1) 
                      printSAdress();
                    else
                      setDivC("adress_ship","");
                    
                  } else
                  { requestXMLFrom('/index.php?sfpc=contentPort&formfunc=getBillingAdress', 'setDivC("adress_bill",htmlDoc); ');
                    if ($('#skipShip').val() == 1) 
                      printSAdress();
                    else
                      setDivC("adress_ship","");
                    
                  }
                  requestXMLFrom("index.php?sfpc=contentPort&formfunc=getCartSummary"+
                                    "&address="+($('#skipShip').val() == 1?$("#addrpage").val():-1)+
                                    "&sa_land="+$('#sa_land').val()+
                                    "&ba_land="+$('#ba_land').val()+
                                    "&short="+sshort , 
                                    'setDivC("cart_summary",htmlDoc2); ',2);
                  printPayment();
                  printShipping();
                  setDivC('checkout_continue_button_title','DO CHECKOUT NOW');      
                  break;
	case 7: if ($('#TCAccept:checked').val()!=1)
                  { sitealert('Terms&Conditions','You must accept Terms and Conditions before checking out.');
                  } else if ($("#loginflag").val()==0)
                  { requestXMLFrom('/index.php?sfpc=contentPort&formfunc=doShopGuest'+
                        '&payment='+$("#checkoutPaymentType").val()+
                        '&ship_avail='+$("#ship_avail").val()+
                        '&shipment='+$("#checkoutShippingType").val()+
                        '&address='+($('#skipShip').val() == 1?1:-1)+
                        '&ship_avail='+$("#ship_avail").val()+
                        '&ba_name='+$("#ba_name").val()+
                        '&ba_surname='+$("#ba_surname").val()+
                        '&ba_phone='+$("#ba_phone").val()+
                        '&ba_email='+$("#ba_email").val()+
                        '&ba_land='+$("#ba_land").val()+
                        '&ba_postal='+$("#ba_postal").val()+
                        '&ba_city='+$("#ba_city").val()+
                        '&ba_street='+$("#ba_street").val()+
                        '&sa_name='+$("#sa_name").val()+
                        '&sa_surname='+$("#sa_surname").val()+
                        '&sa_land='+$("#sa_land").val()+
                        '&sa_postal='+$("#sa_postal").val()+
                        '&sa_city='+$("#sa_city").val()+
                        '&sa_street='+$("#sa_street").val()
                        , 'closeWindow(); sitealert("CHECKOUT",htmlDoc); ');
                  } else
                    requestXMLFrom('/index.php?sfpc=contentPort&formfunc=doShopUser'+
                        '&payment='+$("#checkoutPaymentType").val()+
                        '&ship_avail='+$("#ship_avail").val()+
                        '&saveadress='+$('#saveadress:checked').val()+
                        '&shipment='+$("#checkoutShippingType").val()+
                        '&sa_name='+$("#sa_name").val()+
                        '&sa_surname='+$("#sa_surname").val()+
                        '&sa_land='+$("#sa_land").val()+
                        '&sa_postal='+$("#sa_postal").val()+
                        '&sa_city='+$("#sa_city").val()+
                        '&sa_street='+$("#sa_street").val()+
                        '&address='+($('#skipShip').val() == 1?1:-1), 'closeWindow(); sitealert("CHECKOUT",htmlDoc); ');   
                                   
                  break;
          default : break;
  }
  if (id==4)
  { if ($('#skipShip').val() != 1)
      sshort=$('#userland_short').val();
    else
      sshort=$('#deliveryland_short').val();
    requestXMLFrom("index.php?sfpc=dataport&formfunc=transport_details&useShip="+$('#skipShip').val()+"&short="+sshort+"&addrpage="+$('#addrpage').val(),"setDivC('transport_details',htmlDoc);");
    	
  }
  
  if (id>6)
    id=6;
  if (actual_slide!=id)
  if (doslid==1)
  { $('#checkout_content_'+actual_slide).animate({
        height: '0px',
        //buttonVslid("");
       }, 'slow');
    window.setTimeout("hdiv('checkout_content_"+actual_slide+"');",1000);
    $('#checkout_content_'+id).animate({
        height: '270px',
        //buttonVslid("");
      }, 'slow');

    $('#check_t'+id+'_title').css('color','#ffffff');
    $('#check_t'+actual_slide+'_title').css('color','#666666');

    buttonVslid("#check_t"+actual_slide,0);
    buttonVslid("#check_t"+id,-22);
    actual_slide=id;	
    x = document.getElementById('checkout_content_'+id);
    y = document.getElementById('cartoptions');
    x.appendChild(y);
  }
}



function printBAdress () 
{ setDivC("adress_bill",'<table border="0" width="100%">'+
          '<tr><td class="tgtext_14" style="color:#cccccc" colspan="2" onclick="doCheckoutSlid(2);">BILLING ADRESS' +
          '<tr><td>name:<td>' +$("#ba_name").val()+
          '<tr><td>Surname:<td>' +$("#ba_surname").val()+
          '<tr><td>Country:<td>' +$("#ba_land").val()+
          '<tr><td>Adress:<td>' +$("#ba_postal").val()+" "+$("#ba_city").val()+" "+$("#ba_street").val()+
          '<tr><td>&nbsp;' +
          '</table>');
	
}

function printSAdress () 
{ setDivC("adress_ship",'<table border="0" width="100%">'+
          '<tr><td class="tgtext_14" style="color:#cccccc" colspan="2" onclick="doCheckoutSlid(3);">SHIPPING ADRESS' +
          '<tr><td>name:<td>' +$("#sa_name").val()+
          '<tr><td>Surname:<td>' +$("#sa_surname").val()+
          '<tr><td>Country:<td>' +$("#sa_land").val()+
          '<tr><td>Adress:<td>' +$("#sa_postal").val()+" "+$("#sa_city").val()+" "+$("#sa_street").val()+
          '<tr><td>&nbsp;' +
          '</table>');
	
}

function printPayment () 
{ setDivC("payment_type",'<table border="0" width="100%">'+
          '<tr><td class="tgtext_14" style="color:#cccccc" colspan="2" onclick="doCheckoutSlid(5);">PAYMENT TYPE' +
          '<tr><td>Payment:<td>' +PaymentTypes[$("#checkoutPaymentType").val()]+
          '<tr><td>&nbsp;' +
          '</table>');
	
}

function printShipping () 
{ setDivC("shipping_type",'<table border="0" width="100%">'+
          '<tr><td class="tgtext_14" style="color:#cccccc" colspan="2" onclick="doCheckoutSlid(4);">SHIPPING METHOD' +
          '<tr><td>Shipping:<td>' +ShippingTypes[$("#checkoutShippingType").val()]+
          '<tr><td>&nbsp;' +
          '</table>');
;
	
}
var PaymentTypes=new Array();
var ShippingTypes=new Array();
PaymentTypes[0]="PayPal";
PaymentTypes[1]="Bank Transfer";
PaymentTypes[2]="Credit Card";
ShippingTypes[0]="FedEX";
ShippingTypes[1]="DPD";
function doProfileSlid( id)
{ 
  $('#profile_t'+id+'_title').css('color','#ffffff');
  $('#profile_t'+actual_slide+'_title').css('color','#666666');
  $('#profile_content_'+actual_slide).animate({
        height: '0px',
        //buttonVslid("");
      }, 'slow');
  $('#profile_content_'+id).animate({
        height: '270px',
        //buttonVslid("");
      }, 'slow');

  buttonVslid("#profile_t"+actual_slide,0);
  buttonVslid("#profile_t"+id,-22);
  
  actual_slide=id;	
  switch(id)
  { case 0: break;
	case 1:  break;
	case 2:  break;
	case 3:  break;
	case 4:  break;
	case 5:  break;
	case 6:  break;
	default : break;
  }
  
 
}


function setAdress(name,surname,land,postal,city,street,landshort)
{ $('#sa_name').val(name);
  $('#sa_surname').val(surname);
  //$('#sa_country').val(land);
  $('#sa_land').val(landshort);
  $('#deliveryland_short').val(land);
  $('#sa_postal').val(postal);
  $('#sa_city').val(city);
  $('#sa_street').val(street);
  
}

function getDivPos (companc)
{ anchestor=document.getElementById(companc);
  if (anchestor!=null ) 
  { var curleft = curtop = 0;
    lastcomp=anchestor;
    if (anchestor.offsetParent)
    { do
       { curleft += anchestor.offsetLeft;
	    curtop += anchestor.offsetTop;
      } while (anchestor = anchestor.offsetParent);
    }

    
   
    prev_end= curtop+$('#'+companc).height();
    prev_endx= curleft+$('#'+companc).width();
    var nt = curtop;
    var nl = curleft;

    if (prev_end>f_scrollTop()+f_clientHeight())
      nt= (f_scrollTop()+f_clientHeight()-$('#'+companc).height());
    else if (curtop<f_scrollTop())
      nt=f_scrollTop()
    if (curleft<f_scrollLeft())
      nl=f_scrollLeft();
    else if (prev_endx>f_scrollLeft()+f_clientWidth())
      nl=(f_scrollLeft()+f_clientWidth()-$('#'+companc).width());
 
    $('#'+companc).animate({
        left: nl+'px',
        top: nt+'px',
       
       }, 50);
  
  }
}



function doProfileWarp( id)
{ if (id==2)
  { $('#profile_t2_title').css('color','#ffffff');
    $('#profile_t1_title').css('color','#666666');
    $('#profile_content_1').css('height','0px');
    $('#profile_content_2').css('height','270px');
    buttonVslid("#profile_t1",0);
    buttonVslid("#profile_t2",-22);
	
  } else 
  { $('#profile_t1_title').css('color','#ffffff');
    $('#profile_t2_title').css('color','#666666');
    $('#profile_content_2').css('height','0px');
    $('#profile_content_1').css('height','270px');
    buttonVslid("#profile_t2",0);
    buttonVslid("#profile_t1",-22);
  }
  
  
  actual_slide=id
 
}

function setmodes(name, mode)
{ if (mode==0)
  { $(name).css('background','url(/tsg_images/n_search_typefield.png) ');  
    $(name).css('color','#ffffff');
    
  } else if (mode==1)
  { $(name).css('background','url(/tsg_images/n_search_typefield_a.png) ');  
    $(name).css('color','#000000');
  } else
  { $(name).css('background','url(/tsg_images/n_search_typefield_f.png) ');  
    $(name).css('color','#000000');
  }
}


function addWishlist(id)
{ 
   sitealert('Wishlist',xmlDoc.getElementsByTagName("action")[0].childNodes[0].nodeValue);
   window.setTimeout("$('#blend').fadeOut(250)",1000);	
   refreshLogin();
	
}

function checkuserland(id)
{ var fields=new Array();
  fields = htmlDoc.split(";");
  if (fields[0]=='00')
  { sitealert("ERROR","your land could not be found. Please use 'DE' for Germany or 'US' for USA");
    if(id==0)
    { $('#ba_land').val(fields[0]+" "+fields[1]);
      $('#userland_short').val("00");
    } else
    { $('#sa_land').val(fields[0]+" "+fields[1]);
      $('#deliveryland_short').val("00");
    }
  }
  else if(id==0)
  { $('#userland_short').val(fields[0]);	
    $('#ba_land').val(fields[0]+" "+fields[1]);	
  } else
  { $('#deliveryland_short').val(fields[0]);
    $('#sa_land').val(fields[0]+" "+fields[1]);
  } 
  
}


function addrbook_Del()
{ if (confirm('are you want to delete adress nr '+(parseInt($('#addrpage').val())+1)+'')) 
    requestXMLFrom('/index.php?sfpc=ContentPort&formfunc=removeaddr&addrpage='+$('#addrpage').val()+'&random='+new Date().getTime(),'$(\'#addrpage\').val(parseInt($(\'#addrpage\').val())-1); openProfile('+actual_slide+')' );
	
}

function addrbook_New()
{ $('#addrpage').val('999'); 
  requestXMLFrom('/index.php?sfpc=ContentPort&formfunc=newaddr&addrpage='+$('#addrpage').val()+'&random='+new Date().getTime(),'openProfile('+actual_slide+')' ); 
	
}

function configureProduct(id,update,mode)
{ // sitealert("notice","our online shop will be available soon");
  requestXMLFrom('/index.php?sfpc=contentport&formfunc=configProd&id='+id+'&mode='+mode+'&update='+update+'&id='+id+'&random='+new Date().getTime(),'sitealert("CHOOSE SIZE",htmlDoc,"BACK TO SHOP");');

	
}



function checkRegisterFields()
{ if (document.register.reg_pass1.value=="")
    setmodes('#reg_pass1',2);
  else
    setmodes('#reg_pass1',0);
  if (document.register.reg_pass2.value=="")
    setmodes('#reg_pass2',2);
  else
    setmodes('#reg_pass2',0);
  if (document.register.reg_name.value=="your first name")
    setmodes('#reg_name',2);
  else
    setmodes('#reg_name',0);
   if (document.register.reg_surname.value=="your surname")
    setmodes('#reg_surname',2);
  else
    setmodes('#reg_surname',0);
   if (document.register.reg_land.value=="your land eg. US")
    setmodes('#reg_land',2);
  else
    setmodes('#reg_land',0);
   if (document.register.reg_city.value=="your city")
    setmodes('#reg_city',2);
  else
    setmodes('#reg_city',0);
   if (document.register.reg_country.value=="your country eg. bavaria")
    setmodes('#reg_country',2);
  else
    setmodes('#reg_country',0);
   if (document.register.reg_street.value=="your street and number")
    setmodes('#reg_street',2);
  else
    setmodes('#reg_street',0);
   if (document.register.reg_email.value=="your email")
    setmodes('#reg_email',2);
  else
    setmodes('#reg_email',0);
   if (document.register.reg_postal.value=="your postal code")
    setmodes('#reg_postal',2);
  else
    setmodes('#reg_postal',0);
}

function checkGuestFields()
{ var cnt=0;
  if ($('#ba_name').val()=="" || $('#ba_name').val()=="name" )
  { setmodes('#ba_name',2); cnt++; }
  else
    setmodes('#ba_name',0);
  if ($('#ba_surname').val()=="" || $('#ba_surname').val()=="surname" )
  { setmodes('#ba_surname',2); cnt++; }
  else
    setmodes('#ba_surname',0);
  if ($('#ba_email').val()=="" || $('#ba_email').val()=="email")
  { setmodes('#ba_email',2); cnt++; }
  else
    setmodes('#ba_email',0);
  if ($('#ba_land').val()=="" || $('#ba_land').val()=="country, use 'US' for 'USA'")
  { setmodes('#ba_land',2); cnt++; }
  else
    setmodes('#ba_land',0);

 if ($('#ba_postal').val()=="" || $('#ba_postal').val()=="postal")
  { setmodes('#ba_postal',2); cnt++; }
  else
    setmodes('#ba_postal',0);
 if ($('#ba_city').val()=="" || $('#ba_city').val()=="city")
  { setmodes('#ba_city',2); cnt++; }
  else
    setmodes('#ba_city',0);
 if ($('#ba_street').val()=="" || $('#ba_street').val()=="street")
  { setmodes('#ba_street',2); cnt++; }
  else
    setmodes('#ba_street',0  );
  return cnt;
}


function checkGuestFields2()
{ var cnt=0;
  
  if ($('#sa_name').val()=="" || $('#sa_name').val()=="name" )
  { setmodes('#sa_name',2); cnt++ ; }
  else
  { setmodes('#sa_name',0); }
  if ($('#sa_surname').val()=="" || $('#sa_surname').val()=="surname" )
  { setmodes('#sa_surname',2); cnt++ ; }
  else
  { setmodes('#sa_surname',0); }
  if ($('#sa_land').val()=="" || $('#sa_land').val()=="country, use 'US' for 'USA'" || $('#sa_land').val()=="00 not found" )
  { setmodes('#sa_land',2); cnt++ ; }
  else
  { setmodes('#sa_land',0); }

  
  if ($('#sa_postal').val()=="" || $('#sa_postal').val()=="postal" )
  { setmodes('#sa_postal',2); cnt++ ; }
  else
  { setmodes('#sa_postal',0);  }
  if ($('#sa_city').val()=="" || $('#sa_city').val()=="city" )
  { setmodes('#sa_city',2); cnt++ ; }
  else
  { setmodes('#sa_city',0);  }
  if ($('#sa_street').val()=="" || $('#sa_street').val()=="street" )
  { setmodes('#sa_street',2); cnt++ ; }
  else
  { setmodes('#sa_street',0);  }
  return cnt;
}

var products_showed=0;
var state=1;
var statefilter=0;
var matchpanel=0;
$(document).ready(function(){
 refreshLogin();
  
 $("#cellouter").height($("#content_outer").height() ) ;
 //alert($("#content_outer").height( )+"->"+ $("#cellouter").height( ));

$("#panelshifter").click(function () 
{ matchpanel=(matchpanel+1)%2;
      
      if (matchpanel==1)
      {   $("#matchpanel").slideDown("slow");
         scrollDown(0);
      }
      else
        $("#matchpanel").slideUp("slow");

});


});
  


function scrollDown(cnt)
{ window.scroll(0,9000);
  cnt++;
  //setDivC('debug',cnt+(new Date()).getTime());
  if (cnt<10) 
    setTimeout('scrollDown("'+cnt+'");',50);  	
  	
}


function sitealert(title,message,buttext)
{ setDivC('info_title',title);
  setDivC('info_message',message);
  if (buttext!="" && buttext!=null)
     setDivC('info_ok_text',buttext);
  else 
     setDivC('info_ok_text',"OK");
  if (tempY+300 > $('#blend').height())
    setDivPos('messagepop',tempX-250/2,$('#blend').height()-250);
  else
    setDivPos('messagepop',tempX-250/2,tempY);
  $('#blend').fadeIn(250);
 	
  window.setTimeout("getDivPos('messagepop');",50);	
}

function siteContent(title,message)
{ setDivC('content_title',title);
  setDivC('content_message',message);
  if ($('#blend0').is(':visible')!=1)
     $('#blend0').fadeIn(250);
 
  setDivPos('contentpop',f_clientWidth()/2-$('#contentpop').width()/2,f_clientHeight()/2-$('#contentpop').height()/2);
}

function siteWContent(title,message)
{ setDivC('contentw_title',title);
  setDivC('contentw_message',message);
  if ($('#blend4').is(':visible')!=1)
     $('#blend4').fadeIn(250);
 
  setDivPos('contentwpop',f_clientWidth()/2-$('#contentwpop').width()/2,f_clientHeight()/2-$('#contentwpop').height()/2);
}


function loginContent(title,message)
{ setDivC('login_title',title);
  setDivC('login_message',message);

  if ($('#blend3').is(':visible')!=1)
     $('#blend3').fadeIn(250);
  setDivPos('loginpop',f_clientWidth()/2-$('#loginpop').width()/2,f_clientHeight()/2-$('#loginpop').height()/2);
  window.setTimeout("getDivPos('loginpop');",50);	
}

function closeWindow()
{ if ($("#blend").css('display')=="block")
    $("#blend").fadeOut(250);
  else if ($("#blend2").css('display')=="block")
    $("#blend2").fadeOut(250);
  else if ($("#blend3").css('display')=="block")
    $("#blend3").fadeOut(250);
  else if ($("#blend4").css('display')=="block")
    $("#blend4").fadeOut(250);
  else if ($("#blend0").css('display')=="block")
    $("#blend0").fadeOut(250);
 	
}



function get_SW()
{ sw=1;
  if ($('#ff_sw1').val()=="1") sw=1;
  else if ($('#ff_sw2').val()=="1")  sw=2;
  else if ($('#ff_sw3').val()=="1")  sw=3;
  else if ($('#ff_sw4').val()=="1") sw=4;

  return sw;
}
