function toggle(whichLayer,onoff) {
	var myLeaf = document.getElementById(whichLayer);
	if ((myLeaf.style.display == "none") || onoff===true) {
		myLeaf.style.display = "block";
	} else {
		myLeaf.style.display = "none";
	}
}

function get_other(list) {
	//list = document.getElementById(listName);
	if (list.options[list.selectedIndex].value == "Other" || list.options[list.selectedIndex].value == "-----") {
		if (newValue = prompt("Enter other value")) {
			newOption = new Option(newValue,newValue,false,true);
			list.options[list.length] = newOption;
		}
		else {
			list.selectedIndex = 0;
		}
	}
}

/*
 
*/
var popy
function PopWin(theURL,winName,features) { window.open(theURL,winName,features); }
function PopW(theURL,winName,features) { 
    if(!window.focus) return true;	if(popy!=null){ if(!popy.closed) popy.window.close();
    }   popy=window.open(theURL,winName,features);  popy.focus();
    return false;
}

function openWindow(windowURL,windowName,windowWidth,windowHeight) {
  window.name = 'parentWnd';
  newWindow = window.open(windowURL,windowName,'width='+windowWidth+',height='+windowHeight+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0');
  newWindow.focus();
}

function openVideoPopup(windowURL,windowWidth,windowHeight) {
  windowName = 'videoPopup';
  newWindow = window.open(windowURL,windowName,'width='+windowWidth+',height='+windowHeight+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
  newWindow.focus();
}

function MenuMouseover(newcolor)
{
	if (document.all)
	{
		eSrc = window.event.srcElement;
		theTD = eSrc;
		theTD = theTD.parentElement;
		while (theTD.tagName != "TD") {
			theTD = theTD.parentElement;
		}
		theTD.style.backgroundColor = newcolor;
	}
}

function EmailFriendPopup() {
	window.open('/email_friend/?url_from='+escape(document.location),'','scrollbars=no,width=291,height=200');
}

function delstory(sid) {
	if (confirm('Are you sure you want to delete this story?')) {
		location.href='/admin-story.php?action=delete_story&sid='+sid;
	}
}

/*
	IE Versions between April 2006 and April 2008 had an issue where the user was required
	to click on an object in order to activate it.
	This problem is apparently now fixed (who uses IE anyway???) but this code remains here
	for users with legacy versions.
	ieupdate is called in the template just before </body> tag.
*/
function ieupdate(){
 var strBrowser = navigator.userAgent.toLowerCase();
 if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0){
  var theObjects = document.getElementsByTagName('embed');
  var theObjectsLen = theObjects.length;
  for (var i = 0; i < theObjectsLen; i++) {
   if(theObjects[i].outerHTML){
    if(theObjects[i].data){
     theObjects[i].removeAttribute('data');
    }
    var theOuterHTML = theObjects[i].outerHTML;
    theObjects[i].outerHTML = theOuterHTML;
   }
  }
  var theObjects = document.getElementsByTagName('object');
  var theObjectsLen = theObjects.length;
  for (var i = 0; i < theObjectsLen; i++) {
   if(theObjects[i].outerHTML){
    if(theObjects[i].data){
     theObjects[i].removeAttribute('data');
    }
    var theParams = theObjects[i].getElementsByTagName("param");
    var theParamsLength = theParams.length;
    for (var j = 0; j < theParamsLength; j++) {
      if(theParams[j].name.toLowerCase() == 'flashvars'){
        var theFlashVars = theParams[j].value;
      }
    }
    var theOuterHTML = theObjects[i].outerHTML;
    var re = /<param name="FlashVars" value="">/ig;
    theOuterHTML = theOuterHTML.replace(re,"<param name='FlashVars' value='" + theFlashVars + "'>");
    theObjects[i].outerHTML = theOuterHTML;
   }
  }
 }
}

function putContent(content) {
	document.write(content);
}