function AddBookmark(){
	if (document.all){
		window.external.AddFavorite("http://www.applied-energy.com/", "Applied Energy Products Ltd");
	} else {
		if(window.sidebar) window.sidebar.addPanel("Applied Energy Products Ltd", "http://www.applied-energy.com/", "");
	}
}

function OpenStaffTools(){
	var twidth=760;
	var theight=500;
	var left=(screen.width-twidth)/2;
	var top=(screen.height-theight)/2;
	window.open('about:blank', 'aestaff', 'status=yes,toolbar=no,location=no,resizable=no,menu=no,scrollbars=no,width='+twidth+',height='+theight+',left='+left+',top='+top);
}

function ShowOpt(id){
	var el_name=document.getElementById('opt_name_'+id);
	var el_value=document.getElementById('opt_value_'+id);

	for(i=1;i<=numprodfields;i++){
		if(document.getElementById('opt_name_'+i)){
			document.getElementById('opt_name_'+i).style.fontWeight='normal';
		}
		if(document.getElementById('opt_value_'+i)){
			document.getElementById('opt_value_'+i).style.display='none';
		}
	}

	if(el_name){
		el_name.style.fontWeight='bold';
	}
	if(el_value){
		el_value.style.display='block';
	}
}

function ToggleRatings(){
	var starDiv=document.getElementById('ratingdiv');
	var outerDiv=document.getElementById('ratepage');
	
	if(document.getElementById('ratingthank').style.display=='block') return;
	
	if(starDiv.style.display=='block'){
		outerDiv.className='unselected';
		starDiv.style.display='none';
	}else{
		outerDiv.className='selected';
		starDiv.style.display='block';
	}
}

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function RatingSaved(){
	if (xmlHttp.readyState==4){
		if(xmlHttp.responseText == 'Done'){
			document.getElementById('ratingdiv').style.display='none';
			document.getElementById('ratingthank').style.display='block';
			setTimeout("document.getElementById('ratepage').style.display='none'", '2000');
		} else {
//			alert(xmlHttp.responseText);
			setTimeout("document.getElementById('ratepage').style.display='none'", '500');
		}
	}
}

function StarOver(starId){
	for(i=0; i<=starId; i++){
		document.getElementById('star' + i).src='/images/star_on.gif';
	}
}

function StarOut(){
	for(i=0; i<5; i++){
		document.getElementById('star' + i).src='/images/star_off.gif';
	}
	
}

function StarClick(starId){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		setTimeout("document.getElementById('ratepage').style.display='none'", '500');
		return;
	} 
	var url="/savepagerating.php";
	url=url+"?url="+escape(location.href);
	url=url+"&rating="+starId;
	xmlHttp.onreadystatechange=RatingSaved;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
