
//****************************************************
// IsMac
//****************************************************
function IsMac()
{
  if(navigator.appVersion.indexOf("Win") != -1)
  {
    return false;
  }
  else if(navigator.appVersion.indexOf("Mac") != -1)
  {
    return true;
  }
  else return false;
}


var popUpCaseStudyWin=0;
//****************************************************
// popUpCaseStudyWindow
//****************************************************
function popUpCaseStudyWindow(url)
{
  	if(popUpCaseStudyWin)
  	{
    	if(!popUpCaseStudyWin.closed) popUpCaseStudyWin.close();
  	}
	
	// this to tell our popup that it's being called from within the site
	url = url + "?popup=1";
	
	if (IsMac())
	{
  		popUpCaseStudyWin = open(url, 'casestudy', 'left=50,top=50,height=600,width=429,toolbar=yes,menubar=yes,scrollbars=yes,resizable=no,location=yes,directories=yes,status=yes');
	}
	else
	{
		popUpCaseStudyWin = open(url, 'casestudy', 'left=50,top=50,height=600,width=459,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,directories=yes,status=yes');
	}
	
	popUpCaseStudyWin.focus();
}

var popUpLinkWin=0;
//****************************************************
// popUpLinkWindow
//****************************************************
function popUpLinkWindow(sURL)
{
  	if(popUpLinkWin)
  	{
    	if(!popUpLinkWin.closed)
		{
			popUpLinkWin.close();
			popUpLinkWin=0;
		}
  	}
	
	var url = sURL;
	popUpLinkWin = open(url, 'website', 'left=50,top=50,height=600,width=500,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,directories=yes,status=yes');
	if(popUpLinkWin) popUpLinkWin.focus();
}


//****************************************************
// ConvertHTML
// Converts the opening and closing HTML tags to parens
//****************************************************
function ConvertHTML(sInput)
{
	var sOutput = sInput;
    sOutput=sOutput.replace(/</g,"(");
    sOutput=sOutput.replace(/>/g,")");
	return sOutput;
}
//****************************************************
// JSTrim
// Removes leading and trailing characters from a string
//****************************************************
function JSTrim (inputString, removeChar) 
{
	var returnString = inputString;
	if (removeChar.length)
	{
	  while(''+returnString.charAt(0)==removeChar)
		{
		  returnString=returnString.substring(1,returnString.length);
		}
		while(''+returnString.charAt(returnString.length-1)==removeChar)
	  {
	    returnString=returnString.substring(0,returnString.length-1);
	  }
	}
	return ConvertHTML(returnString);
}
//****************************************************
// JSTrimSpace
// Removes leading and trailing spaces from a string
//****************************************************
function JSTrimSpace(inputString)
{
	return JSTrim(inputString,' ');
}

//****************************************************
// InvokeSearch
//****************************************************
function InvokeSearch()
{
	var sString="";
	sString = JSTrim(document.searchbox.query.value,' ');
	document.searchbox.query.value=sString;
	
	if (sString.length==0)
	{
		alert("Please enter a search term or phrase");
		return false;
	}
	
	setTimeout('document.searchbox.submit()',50);
	return true;
}