 
 // array of possible countries in the same order as they appear in the country selection list 
 var categoryLists = new Array(2) 
 categoryLists["empty"] = ["Select a category"]; 
 categoryLists["people"] = ["Full Name", "Age", "Gender", "Hometown", "Favorite Bar", "Favorite Drink"];
 categoryLists["peoplevals"] = ["name", "age", "sex", "home_town", "fav_bar", "fav_drink"]; 
 categoryLists["bar"] = ["Bar Name", "Region", "Address", "City", "State", "Country"]; 
 categoryLists["barvals"] = ["name", "region", "address", "city", "state", "country"]; 
 categoryLists["sex"] = ["Male", "Female"];
 categoryLists["sexvals"] = ["male", "female"];
 categoryLists["region"] = ["Bernal Heights","Castro","China Town","Civic Center","Cole Valley","Cow Hollow","Diamond Heights","Downtown","Financial District","Fisherman's Wharf","Glen Park","Haight","Marina","Mission","Noe Valley","North Beach","Pacific Heights","Portero Hill","Presido","Richmond","Russian Hill","Seacliff","SOMA","St Francis Wood","Sunset","Telegraph Hill","Twin Peaks","Western Addition"];
 categoryLists["regionvals"] = ["Bernal Heights","Castro","China Town","Civic Center","Cole Valley","Cow Hollow","Diamond Heights","Downtown","Financial District","Fisherman's Wharf","Glen Park","Haight","Marina","Mission","Noe Valley","North Beach","Pacific Heights","Portero Hill","Presido","Richmond","Russian Hill","Seacliff","SOMA","St Francis Wood","Sunset","Telegraph Hill","Twin Peaks","Western Addition"];


 /******************************************************************
 *  searchTypeChange() is called from the onchange event of a select element. 
 *  param selectObj - the select object which fired the on change event. 
 ********************************************************************/ 
 
function searchTypeChange(selectObj) { 
 // get the index of the selected option 
 var idx = selectObj.selectedIndex; 
 // get the value of the selected option 
 var which = selectObj.options[idx].value;
 var whichvals = which + "vals"
 // use the selected option value to retrieve the list of items from the categoryLists array 
 cList = categoryLists[which]; 
 vList = categoryLists[whichvals]; 
 // get the category select element via its known id
 if (selectObj.id == "search_type") {
   var cSelect = document.getElementById("search_cat");
 }
 else if (selectObj.id == "search_cat" && (which == "sex" || which == "region" )){
   var cSelect = document.getElementById("cat_options");
   var textb = document.getElementById("query");
   textb.style.display = "none";
   cSelect.style.display = "inline";
 }
else {
   var cSelect = document.getElementById("cat_options");
   var textb = document.getElementById("query");
   textb.style.display = "inline";
   cSelect.style.display = "none";
   return;
}
   
 // remove the current options from the category select 
 var len=cSelect.options.length; 
 while (cSelect.options.length > 0) { 
 cSelect.remove(0); 
 } 
 var newOption; 
 // create new options 
 for (var i=0; i<cList.length; i++) { 
 newOption = document.createElement("option"); 
 newOption.value = vList[i];  
 newOption.text=cList[i]; 
 // add the new option 
 try { 
 cSelect.add(newOption);  // this will fail in DOM browsers but is needed for IE 
 } 
 catch (e) { 
 cSelect.appendChild(newOption); 
 } 
 } 
 } 


/************************************************************************
  Star Ratings Widget JS
************************************************************************/
selected = "false"

function showWriteCommentsForm() {
  document.getElementById('write_comment').style.display = 'block';
  document.getElementById('write_comment_link').style.display = 'none';
  document.getElementById('errmsg').style.display = "block";
}

function clearReviewForm() {
  document.getElementById('write_comment').style.display = 'none';
  document.getElementById('write_comment_link').style.display = 'block';
  selected = "false"
  for (var i=1; i <= 5; i++ ) {
       var img_id = "star" + i;
       document.getElementById(img_id).src = "/static/img/small_star_off.gif";
  }
  document.getElementById('errmsg').style.display = "none";
}

function setStars(num_stars) {
  document.getElementById('star_value').value = num_stars;
  selected ="true";
  for (var i=1; i <= num_stars; i++ ) {
      var img_id = "star" + i;
      document.getElementById(img_id).src = "/static/img/small_star_on.gif";
  }
  
  for (var j = 5; j > num_stars; j--) {
     var img_id = "star" + j;
     document.getElementById(img_id).src = "/static/img/small_star_off.gif";
  }
}

function showStars(num_stars) {
  if (num_stars == '0' && selected == "false") {
     for (var i=1; i <= 5; i++ ) {
       var img_id = "star" + i;
       document.getElementById(img_id).src = "/static/img/small_star_off.gif";
     }
  }
  else if (selected == "false") {
    for (var i=1; i <= num_stars; i++ ) {
      var img_id = "star" + i;
      document.getElementById(img_id).src = "/static/img/small_star_on.gif";
    }
  }
}

function updateCommentAuthor(){
  document.getElementById('nickname').value = "Anonymous";
}

/* commenting out until we launch. Don't want internal users using this.
function share () {
  var a=document, b=a.createElement('script'),w=window,g={};g.altWindow=w.open('','_blank','height=370px,width=720px,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');setTimeout(function(){g.altWindow.focus()},1000);function f(o){try{var d=new google.share.EmailWidget(g);d.display()}catch(e){if(o>20)return;setTimeout(function(){f(o+1)},o<10?1<<o:1000)}};b.src='http://www.google.com/s2/sharing/js?script=socialsharing&key=AAAAJ--gdtJYHC_fJptEAHT5Bf3CyVkKtkTsgXiSRui1pjdmzEX0QZeihel6NJ-1FJBvOg';a.body.appendChild(b);f(0)}
*/

