//Sarah functions
function toggleDisplay(divID)
{
	// allow document.all, for older browsers
	var div = (document.getElementById) ? document.getElementById(divID) : 
		  ((document.all) ? document.all(divID) : null);
		div.className = (div.className == "open") ? "closed" : "open";
}

function swapBackground(inElem, targetImage, width, height, units)
{
	var targItem = document.getElementById(inElem);
	targItem.style.backgroundImage = "url(" + targetImage + ")";
	targItem.style.width = width + units;
	targItem.style.height = height + units;
}

function hideDiv(element)
{
	var item = document.getElementById(element);
	
	item.style.display = "none";
}

function showDiv(element)
{
	var item = document.getElementById(element);
	
	item.style.display = "block";
}

function swapHTML(inElemA, inElemB)
{
	var first = document.getElementById(inElemA);
	var second = document.getElementById(inElemB);
	
	first.innerHTML = second.innerHTML;
}

function activePage(inElem)
{
	var item = document.getElementById(inElem);
	item.style.color = "#999999";
}




function windowOpen(url, title, width, height) {
	
	var w = 480, h = 340;

	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}
	
	var leftPos = (w-width)/2;
	var topPos = (h-height)/2;
	
	var win = window.open(url,'','width=' + width + ',scrollbars=yes, resizable=yes,height='+height+',top='+topPos+',left='+leftPos);
	win.moveTo(leftPos, topPos);
  	win.focus();
}

//jquery helpers

/**
*get params from url
*/
/*
jQuery.extend({
	 getURLParam: function(strParamName,url){
		  var strReturn = "";
		  if(!url){
		  	var strHref = window.location.href;
		  }else{
		  	var strHref = url;
		  }
		  var bFound=false;
		  
		  var cmpstring = strParamName + "=";
		  var cmplen = cmpstring.length;
	
		  if ( strHref.indexOf("?") > -1 ){
		    var strQueryString = strHref.substr(strHref.indexOf("?")+1);
		    var aQueryString = strQueryString.split("&");
		    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
		      if (aQueryString[iParam].substr(0,cmplen)==cmpstring){
		        var aParam = aQueryString[iParam].split("=");
		        strReturn = aParam[1];
		        bFound=true;
		        break;
		      }
		      
		    }
		  }
		  if (bFound==false) return null;
		  return strReturn;
		}
});
*/
/**
* base url
*/
base_url = function(){
	path = 'nestcams/';
	var temp = location.pathname.split("/");
	if (temp.length > 0) {
		return 'http://'+location.hostname + '/' + temp[1] + '/';
	}
	return 'http://'+location.hostname + '/';
}