var newwindow;
function poplite(url)
{
	newwindow=window.open(url,'lite','width=420,height=500,scrollbars=yes,resizable=yes');
	if (window.focus) {newwindow.focus()}
}
function popipix(url)
{
	newwindow=window.open(url,'ipix','width=320,height=360,resizable=yes');
	if (window.focus) {newwindow.focus()}
}
function pop575(url)
{
	newwindow=window.open(url,"_blank",'width=575,height=450,resizable=yes,target=_blank');
	if (window.focus) {newwindow.focus()}
}

function printPage() { print(document); }

/**
	 * Method preventDoubleClickSubmitForm is invoked when user clicks on the Save button or any button that submits a form.
	 * The method prevents user from clicking the Save button too many times.
	 * 
	 *
	 * @author Nathan Steiner
	 * @since 2/11/2004
	 */
	 
	 var submitDone = false;
 
function preventDoubleClickSubmitForm(myForm, button) {	   	  
	      if (!submitDone) {
	         submitDone = true;
	         //button.value = 'Please Wait';
	         if (button != null) {
		         button.disabled = true;
		     }
	         myForm.submit();
	      } 
	      else {
	        alert ("Already submitted, please wait!");
	      }
	   return true;
	 }
	 
/** 
 	* Method replaceAll replaces all the isntances of a substring A 
 	* with substring B in a String. We use the JavaScript: replace
 	* function in a loop to achieve this.
 	*
 	* @author Nilesh Pusuluri/ Shanti Mangala
 	* @since 3/30/2006
 	*/
 	
 function replaceAll(inputString,A,B)
 {
	s = new String(inputString);
    while(s.indexOf(A) > -1)
   {
    	s = s.replace(A,B);
   }
   return s;
  }

/** 
 	* Method clearDefault clears the default value "Search the Site" 
 	* in the Search box when Search Box is in focus. 
 	* Method is invoked by the onFocus event.
 	*
 	* @author Gene Summers
 	* @since 4/18/2006
 	*/
  
  function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

function help(url)
{
	newwindow=window.open(url,'help','width=320,height=200,resizable=yes');
	if (window.focus) {newwindow.focus()}
}

/**
* Called by the search engine forms in the header as well as the forms on 
* the results pages.  Used to verify search criteria.
*/
function submitSearchEngineForm(sForm, isNewSearch) {

	var query = sForm.query.value;
	//alert(query);
	var totalLength = query.length;
	//alert(totalLength);
	
	var searchedQuery;
	//alert(searchedQuery);
	
	// False if called from a search results form
	if (isNewSearch == 'false') {
		//alert('isNewSearch  is false');
		searchedQuery = sForm.searchedQuery.value;
		totalLength = query.length + searchedQuery.length;
		//alert(totalLength);
	}
  
	if(query =='') {
		alert("Please enter the search criteria");
	} else if (query =='Search the Site') {
		alert("Please enter the search criteria");
	} else if (query =='Search Within Results') {
		alert("Please enter the search criteria");
	} else if (totalLength > 128) {	
		alert("Search Query maximum length is 128");
	} else { 	 
		//alert('submitting form');	
 		sForm.submit();	
	}
}

function populateTrafficSourceHiddenFields(formName) { 
	// Get the __utmz cookie value. This is the cookies that 
	// stores all traffic source  information. 
	var campaign = _uGC(document.cookie, '__utmz=', ';'); 
	
	// It separates the traffic source tracking cookie 
	// and populates a variable. 
	var source  = _uGC(campaign, 'utmcsr=', '|'); 
	var medium  = _uGC(campaign, 'utmcmd=', '|'); 
	var term    = _uGC(campaign, 'utmctr=', '|'); 
	var content = _uGC(campaign, 'utmcct=', '|'); 
	var campaignName = _uGC(campaign, 'utmccn=', '|'); 
	var objForm = eval("document." + formName);
	if(objForm){
		objForm.elements["trafficSource.source"].value = source;
		objForm.elements["trafficSource.medium"].value = medium;
		objForm.elements["trafficSource.term"].value = term;
		objForm.elements["trafficSource.content"].value = content;
		objForm.elements["trafficSource.campaign"].value = campaignName;
	}
} 
function _uGC(l,n,s) {
    // used to obtain a value form a string of key=value pairs
    if (!l || l=="" || !n || n=="" || !s || s=="") return "-";
    var i,i2,i3,c="-";
    i=l.indexOf(n);
    i3=n.indexOf("=")+1;
    if (i > -1) {
       i2=l.indexOf(s,i); if (i2 < 0) { i2=l.length; }
       c=l.substring((i+i3),i2);
    }
    return c;
}