function showTipBox(title){
  //alert(document.getElementById("tipBox").childNodes[0].childNodes.length);
	document.getElementById('tipBox').childNodes[0].nodeValue = title;
	document.getElementById('tipBox').style.visibility = 'visible';
}
function hideTipBox(){
  document.getElementById('tipBox').style.visibility = 'hidden';
}
function loadSite(content){
	// content may be	/content/00_product/
    // 					/content/00_product/someSite.php
    //					/content/00_product/someSite.php?someParameter=this is some parameter
    // alert(content);
    // top.location.href="/?content=" + encodeURIComponent(content);
    window.top.location.href="/index.phtml?content="+ escap(content);
      
}


function newSite(mytitle,myname){
    var w=720;
    var h=480;
    var mytop='';
    var mytop='center';
    var myleft='front'; 
    settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";
    win=window.open(mytitle,myname,settings);
  
}



function scartItemChange(content,obj,prod_id){
    //content += "&quantity=" + obj.value;
    //window.top.location.href="/?content="+ escap(content);
	//content += "&quantity=" + obj.value;
	document.form.content.value = content;
	document.form.prod_id.value=prod_id;
	document.form.submit();
}
function showInfo(content){
		window.open(content, '', 'menubar=no, height=200, width=300');
}
function showPopupList(content){
		window.open(content, '', 'menubar=no, location=no, height=650, width=640, scrollbars=yes, resizable=yes ');
}
function sdw(content){
		window.open(content, '', 'menubar=no, location=no, height=650, width=960, scrollbars=yes, resizable=yes ');
}

function showPopupListFromForm(content){
		// get the form input values
    for($i=0; $i<document.getElementsByTagName("input").length; $i++){
    	alert(document.getElementsByTagName('input')[$i].name);
    }
}

function searchValidate(){
    // leas one entry is needed
    leasOne=false;
    // check for input fields != empty
	for($i=0; $i<document.getElementsByTagName("input").length; $i++){
      inpName = document.getElementsByTagName('input')[$i].id;
	  // only chek the one that is needed for the search, identified by id='search'
	  erg = inpName.match(/search/);
      if(erg){
        if(document.getElementsByTagName('input')[$i].value != ''){
        	leasOne=true;
        }
      }
    }
	if(!leasOne){
	  // if nothing was typed in in the input fields, check the selected boxes, least one of them should be != any
	  for($i=0; $i<document.getElementsByTagName('select').length; $i++){
        inpName = document.getElementsByTagName('select')[$i].id;
	    // only chek the one that is needed for the search, identified by id='search'
	    erg = inpName.match(/search/);
        if(erg){
		  if(document.getElementsByTagName('select')[$i].selectedIndex != 0){
        	leasOne=true;
          }
        }
	  }
	}

    if(leasOne){
    	document.form.submit();
    }
    else{
      alert('Please enter a search value');
    }
}

function cursorPos (Ereignis)
  {
    if (navigator.appName == "Netscape")
      {
        // document.getElementById('banner').onmousemove = cursorPos;
        //document.captureEvents();
		x = Event.pageX;
        y = Event.pageY;
      }
    else
      {
        x = window.event.offsetX;
        y = window.event.offsetY;
      }
    return new Array(x,y);
}




// document.onMousemove=mosePos;
function mousePos(e){
	if(movingObject != null){
		if(mouseMoveTimer && !movingObjectLocked){
			window.clearTimeout(mouseMoveTimer);
		}
		if(document.all){
		    if((window.event.clientX + 200) > document.body.clientWidth){
				x=window.event.clientX - 205;
				tipBoxRanges['xmax']=+5;
				tipBoxRanges['xmin']=-205;
			}
			else{
				x=window.event.clientX + document.body.scrollLeft + 5;
				tipBoxRanges['xmax']=205
				tipBoxRanges['xmin']=-5;
			}
		    if((window.event.clientY + 200) > document.body.clientHeight){
				y=window.event.clientY + document.body.scrollTop - 205;
				tipBoxRanges['ymax']=+5;
				tipBoxRanges['ymin']=-205;
			}
			else{
				y=window.event.clientY + document.body.scrollTop + 5;
				tipBoxRanges['ymax']=205;
				tipBoxRanges['ymin']=-5;
			}
		}
		else{
		    if((e.pageX + 200) > window.innerWidth){
				x=e.pageX + pageXOffset - 250;
				tipBoxRanges['xmax']=+5;
				tipBoxRanges['xmin']=-205;
			}
			else{
				x=e.pageX + pageXOffset + 5;
				tipBoxRanges['xmax']=205
				tipBoxRanges['xmin']=-5;
			}
		    if((e.pageY + 200) > window.innerHeight){
				y=e.pageY + pageYOffset - 205;
				tipBoxRanges['ymax']=+5;
				tipBoxRanges['ymin']=-205;
			}
			else{
				y=e.pageY + pageYOffset + 5;
				tipBoxRanges['ymax']=205;
				tipBoxRanges['ymin']=-5;
			}
		}
		//window.status = "moving x=" + x + ",y=" + y + " - but xpos=" + xpos + ",ypos=" + ypos;
		if(!movingObjectLocked){
			xpos=x;
			ypos=y;
			// window.status = "set x=" + x + ",y=" + y;
			mouseMoveTimer = window.setTimeout("visibilityControl('visible')",500);
		}
	}
}

mouseMoveTimer=null;
alphaControlTimer=null;
movingObject = null;
movingObjectLocked=false;
mouseIsInTippBox=false;
xpos=null;
ypos=null;
tipBoxRanges=new Array();
tipBoxRanges['xmin']=0;
tipBoxRanges['xmax']=0;
tipBoxRanges['ymin']=0;
tipBoxRanges['ymax']=0;
callerObject = null;
mouseOutOfTippBoxTimer=null;

function mouseInTippBoxControl(locState){
	mouseIsInTippBox=locState;
	//window.status = "mouseInTippBoxControl:" + locState;
	if(locState == false){
		mouseOutOfTippBoxTimer = window.setTimeout("resetTippBox('MouseMovedOutFromTipBox')",200);
	}
}

function alphaControl(){
  if(movingObject.filters.alpha.opacity < 100){
	movingObject.filters.alpha.opacity += 15;
	alphaControlTimer = window.setTimeout("alphaControl()",10);
  }
}

function visibilityControl(elementVisibilityStyle){
  if(movingObject){
	if(document.all){
	  movingObject.filters.alpha.opacity = 0;
	}
	movingObject.style.top=ypos;
	movingObject.style.left=xpos;
	movingObject.style.visibility=elementVisibilityStyle;
    if(document.all){
	  alphaControl();
	}
	movingObjectLocked=true;
  }
}

function fillResultSetTextBox(elementObject){
  if(mouseOutOfTippBoxTimer){
     window.clearTimeout(mouseOutOfTippBoxTimer);
  }
  if(elementObject != callerObject){
	  movingObject = document.getElementById('resultSetTextBox');
      movingObject.value = decodeURIComponent(elementObject.id);
	  movingObjectLocked=false;
	  xpos=null;
	  ypos=null;
	  mouseIsInTippBox=false;
	  elementObject.onmousemove=mousePos;
	  callerObject = elementObject;
  }
}

function resetTippBox(reason){
  //window.status=reason;
  if(mouseIsInTippBox == false && movingObject ){
  	  // window.status='resetTracking';
	  if(mouseMoveTimer){
		  window.clearTimeout(mouseMoveTimer);
	  }
	  if(alphaControlTimer){
		  window.clearTimeout(alphaControlTimer);
	  }
	  movingObject.style.visibility='hidden';
	  movingObject=null;
	  movingObjectLocked=false;
	  mouseIsInTippBox=false;
	  callerObject=null;
  }	  
}

function removeResultSetTextBox(elementObject){
    if(movingObjectLocked){
		// tippbox is shown dont close the tipbox if the mouse moves to the tip box
		if(x < xpos+tipBoxRanges['xmin'] || x > xpos+tipBoxRanges['xmax'] || y < ypos+tipBoxRanges['ymin'] || y > ypos+tipBoxRanges['ymax']){
		  resetTippBox('elementMouseOut and not in tipBoxRange');
		}
	}
	else{
	  // tippbox isn't shown, therefore the mouse also can not be in the tipp box
	  resetTippBox('elementMouseOut');
	}
}


/*
	ar=new Array ("%20","%21","%22","%23","%24","%25","%26","%27","%28","%29","%2a","%2b","%2c","%2d","%2e","%2f","%30","%31","%32","%33","%34","%35","%36","%37","%38","%39","%3a","%3b","%3c","%3d","%3e","%3f","%40","%41","%42","%43","%44","%45","%46","%47","%48","%49","%4a","%4b","%4c","%4d","%4e","%4f","%50","%51","%52","%53","%54","%55","%56","%57","%58","%59","%5a","%5b","%5c","%5d","%5e","%5f","%60","%61","%62","%63","%64","%65","%66","%67","%68","%69","%6a","%6b","%6c","%6d","%6e","%6f","%70","%71","%72","%73","%74","%75","%76","%77","%78","%79","%7a","%7b","%7c","%7d");
	s=" !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}";
*/
ar=new Array ("%20","%21","%22","%23","%24","%25","%26","%27","%28","%29","%2a","%2b","%2c","%2d","%2e","%2f","%30","%31","%32","%33","%34","%35","%36","%37","%38","%39","%3a","%3b","%3c","%3d","%3e","%3f","%40","%41","%42","%43","%44","%45","%46","%47","%48","%49","%4a","%4b","%4c","%4d","%4e","%4f","%50","%51","%52","%53","%54","%55","%56","%57","%58","%59","%5a","%5b","%5c","%5d","%5e","%5f","%60","%61","%62","%63","%64","%65","%66","%67","%68","%69","%6a","%6b","%6c","%6d","%6e","%6f","%70","%71","%72","%73","%74","%75","%76","%77","%78","%79","%7a","%7b","%7c","%7d");
s=" !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}";

function escap(dat) {
	rv="";
	for (m=0;m<dat.length;m++){
		rv+=ar[s.indexOf(dat.charAt(m))];
	}
	// rv="javascript\;document.location(\""+rv+"\")";
	return rv;
}

function bazzasheild(){
	document.forms.dform.weburl.value=escap(document.forms.dform.url.value);
}

function bazzacheck(){
	if (document.forms.dform.url.value<=""){
		alert("You must enter URL to protect!"); return false
	}
	if (1==1){
		bazzasheild();
	} 
}

function termsOfDelivery(obj){
	if (obj.checked){
	  state=false;
	}
	else{
	  state=true;
	}
	document.form.submitBtnOrderSummary.disabled=state;
}
