function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function changePhoto(id,file){
   document.getElementById('photo').style.backgroundImage = 'url(photos/'+id+'/'+file+'_l.jpg)';
}
function changePhoto2(id,file){
   document.getElementById('photo').style.backgroundImage = 'url(../photos/'+id+'/'+file+'_l.jpg)';
}
function changePhoto3(id,file){
   document.getElementById('photo').style.backgroundImage = 'url(http://www.puppetshowbooks.com/photos/'+id+'/'+file+'_l.jpg)';
}
function ri(r) { // rateit
   document.getElementById("star-rating").style.width = 20*r + 'px';
   document.getElementById("star-rating").style.backgroundPosition='left bottom';
// submit form or use AJAX to save the rating in DB
}



star_x = "";  // variable that holds the star rating

// on form submit we check form and build the variables to send to our php script
function rate_rest(){
   alert (star_x);
  /*var email = document.getElementById('email').value;
  var review =  document.getElementById('review').value;
  if(review != ""){
	// send
	if(email == "") email = "email";
	var url = "../ratereview.php?email="+email+"&review="+ escape(review)+"&rate="+star_x;
	var url = "../ratereview.php?rate="+star_x;
	http.open("GET", url, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null)
  /*}else{
	alert("Please Fill in the Review Field");
  }<input type="button" value="Submit Review" onclick="rate_rest()"/>*/
}


// function that updates the page after submit
function handleHttpResponse() {
  if (http.readyState == 4) {
	results = http.responseText.split("|");
	if(results[0] ==1){
	  document.getElementById('rest_actions').innerHTML="<p style='height:55px;color:green'>Thank you for your feedback</p>";
	  //alert(results[1]);
	}else{
	  document.getElementById('rest_actions').innerHTML="<p style='height:55px;color:red'>An Error Has Occured, Please Try Again</p>";
	  //alert(results[1]);
	}

  }
}

// our generic AJAX script
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
	try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	  try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
		xmlhttp = false;
	  }
	}
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	try {
	  xmlhttp = new XMLHttpRequest();
	} catch (e) {
	  xmlhttp = false;
	}
  }
  return xmlhttp;
}
var http = getHTTPObject(); // Create the HTTP Object


// when user clicks a star we set the star variable
function star(x){
  document.getElementById(x).src='images/star_on.gif';
  if(star_x != "") document.getElementById(star_x).src='images/star_off.gif';
	if(star_x == x) star_x="";
	else star_x = x;
   document.rating.ratedValue.value=x;	
   /*alert (document.rating.ratedValue.value);*/
}
// onmouseover event .. kill all stars if rated and update the source on the rest of the stars
function stars(x){
  killem();
  switch(x){
	case 5:
	  document.getElementById('e').src='images/star_on.gif';
	case 4:
	  document.getElementById('d').src='images/star_on.gif';
	case 3:
	  document.getElementById('c').src='images/star_on.gif';
	case 2:
	  document.getElementById('b').src='images/star_on.gif';
	case 1:
	  document.getElementById('a').src='images/star_on.gif';
	  break;
  }
}
// kills all the stars sources
function killem(){
  document.getElementById('a').src='images/star_off.gif';
  document.getElementById('b').src='images/star_off.gif';
  document.getElementById('c').src='images/star_off.gif';
  document.getElementById('d').src='images/star_off.gif';
  document.getElementById('e').src='images/star_off.gif';
}

// onmouseout event that similarily kills the source
function starsx(x){
  switch(x){
	case 5:
	  if(star_x != 'e') document.getElementById('e').src='images/star_off.gif';
	case 4:
	  if(star_x != 'd') document.getElementById('d').src='images/star_off.gif';
	case 3:
	  if(star_x != 'c') document.getElementById('c').src='images/star_off.gif';
	case 2:
	  if(star_x != 'b') document.getElementById('b').src='images/star_off.gif';
	case 1:
	  if(star_x != 'a') document.getElementById('a').src='images/star_off.gif';
	  break;
  }
  switch(star_x){
	case 'e':
	  stars(5);
	  break;
	case 'd':
	  stars(4);
	  break;
	case 'c':
	  stars(3);
	  break;
	case 'b':
	  stars(2);
	  break;
	case 'a':
	  stars(1);
	  break;
  }

}



function display_full_benefits(){           
   if (document.getElementById('full_benefits').style.display ==  'inline'){
      document.getElementById('full_benefits').style.display =  'none';
   }else{
      document.getElementById('full_benefits').style.display =  'inline';
   }
}

function popitup(url) {
	newwindow=window.open(url,'name','height=550,width=550');
	if (window.focus) {newwindow.focus()}
	return false;
}
