function FIND(item) {
  if (document.all) return(document.all[item]);
  if (document.getElementById) return(document.getElementById(item));
  return(false);
}

var st1;
var st2;
var thetop=-1;
var flagdivvisible=0;
var oMyDiv;
var boxMyDiv;

function formatPrice(value){
  var num = new NumberFormat(value);
  num.setSeparators(true,'.',',');
  return num.toFormatted()+' '+('&euro;');
}

function writeContentDoc(Doc, TargetId) {
   if(!oMyDiv) oMyDiv=document.createElement("div");
   oMyDiv.innerHTML=Doc;
   var oInsertTarget=document.getElementById(TargetId);
   oInsertTarget.innerHTML=oMyDiv.innerHTML;
}

function writeContentBox(Doc, TargetId) {
   if(!boxMyDiv) boxMyDiv=document.createElement("div");
   boxMyDiv.innerHTML=Doc;
   var oInsertTarget=document.getElementById(TargetId);
   oInsertTarget.innerHTML=boxMyDiv.innerHTML;
}

function writeContent(url, DocTargetId, writeFunc) {
    makeHttpRequest("GET",WebServerScriptUrlSSL+url+'&rand='+Math.floor(Math.random()*1000000),'', false, writeFunc, DocTargetId);
}

function getop(){
  if (navigator.appName == "Netscape") {
    return window.pageYOffset;
  }
  else {
    return (document.body.scrollTop)?document.body.scrollTop:document.documentElement.scrollTop;
  }
}

function refreshlocation(){
    if(flagdivvisible && thetop!=getop()){
      centerDiv();
    }
    if(!flagdivvisible) {
      if(st2) clearTimeout(st2);
      return;
    }
    st2=setTimeout("refreshlocation()",10);
}

function centerDiv(){
  var suffix="";
  if(FIND('divbasketpopup').style.left.indexOf('px')>=0){
    suffix="px";
  }
  FIND('divbasketpopup').style.left=Math.floor((screen.availWidth-280)/2)+suffix;
  FIND('divbasketpopup').style.top=Math.floor(screen.availHeight/2-148)+getop()+suffix;
  thetop=getop();
}

function appendProductURL(formular){
  var urlstr = "";
  var productParams = new Array('ChangeObjectID','ProductID','Quantity');
  for(var i=0;i<productParams.length;i++){
    urlstr += "&"+productParams[i]+"="+eval("formular."+productParams[i]+".value");  
  }
  return urlstr;
}

function divpopup(url,formular){
  url+=appendProductURL(formular);
  writeContent(url,'divbasketpopup','writeContentDoc');  
  if(st1){clearTimeout(st1)};
  centerDiv();
  FIND('divbasketpopup').style.visibility='visible';
  flagdivvisible=1;
  st1=setTimeout("flagdivvisible=0;FIND('divbasketpopup').style.visibility='hidden'",7000);
  refreshlocation();
}

function closedivpopup(){
  FIND('divbasketpopup').style.visibility='hidden';
  flagdivvisible=0;    
}

function getOffset(what, offsettype) {
    var totaloffset = (offsettype == 'left') ? what.offsetLeft : what.offsetTop;
    var parentEl = what.offsetParent;
    while(parentEl != null) {
        totaloffset = (offsettype == 'left') ? totaloffset + parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl = parentEl.offsetParent;
    }
    return totaloffset;    
}

//slide teaser functions
function toLeft(SlideNo) {
  tpos-=1;
  cpos-=545;
  
  myFx.scrollTo(cpos, 0); 
  if(cpos > 545) $('to-left').style.display='block'; 
  if(cpos == 0) $('to-left').style.display='none';
  if(cpos < 545 * (SlideNo -1)) $('to-right').style.display='block';
  
  hideInfo(tpos);
}
function toRight(SlideNo) {
  tpos+=1;
  cpos+=545;
  
  myFx.scrollTo(cpos, 0);
  $('to-left').style.display='block';
  if(cpos == 545 * (SlideNo -1)) $('to-right').style.display='none';
  
  hideInfo(tpos);
}
function hideInfo(tpos) {
  //var div = $('i'+tpos).setStyles({
	//	display:'block',
	//	opacity: 0
	//});
	//new Fx.Style(div, 'opacity', {duration: 1000} ).start(1);

  $('i'+tpos).style.display='block';
  if($('i'+(tpos-1))) $('i'+(tpos-1)).style.display='none';
  if($('i'+(tpos+1)))$('i'+(tpos+1)).style.display='none';
}

