/*
  This file contains some common JavaScript functions that are used throughout the site

*/

function changeClass(Obj, newClassName) {
  Obj.className = newClassName;
}

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {
	return window.innerWidth != null? 
		window.innerWidth :
		document.documentElement && document.documentElement.clientWidth ?
			document.documentElement.clientWidth : 
			document.body != null ? 
				document.body.clientWidth : 
				null;
}
function pageHeight() {
	return  window.innerHeight != null? 
		window.innerHeight : 
		document.documentElement && document.documentElement.clientHeight ?
			document.documentElement.clientHeight : 
			document.body != null? 
				document.body.clientHeight : 
				null;
}
function posLeft() {
	return typeof window.pageXOffset != 'undefined' ? 
		window.pageXOffset :
		document.documentElement && document.documentElement.scrollLeft ? 
			document.documentElement.scrollLeft : 
			document.body.scrollLeft ? 
				document.body.scrollLeft : 
				0;
}
function posTop() {
	return typeof window.pageYOffset != 'undefined' ?  
		window.pageYOffset : 
		document.documentElement && document.documentElement.scrollTop ? 
			document.documentElement.scrollTop : 
			document.body.scrollTop ? 
				document.body.scrollTop : 
				0;
}
function posRight() {return posLeft()+pageWidth();}
function posBottom() {return posTop()+pageHeight();}

function popup(url) {
	featuresWindow = window.open(url,"popUpWin","toolbar=no,scrollbars=yes,location=no,status=no,resizable=yes,width=417,height=575");
}
function setblink(elem,time) { $(blink).delay(time/1000, elem, time); }
function blink(elem, time) {
	if( elem.style.visibility == 'hidden' )
		elem.style.visibility = 'visible';
	else
		elem.style.visibility = 'hidden';
	$(blink).delay(time/1000, elem, time);
}

/* These three really don't belong here. Hide/Show btns is mostly just the CustInfo page, but a few other things too.  saveLeadAndCancel is signup. */
function hideButtons() {
	var submitB = document.getElementById("submitB");
	if( submitB ) submitB.style.visibility = "hidden";
	var revertB = document.getElementById("revertB");
	if( revertB ) revertB.style.visibility = "hidden";
}
function showButtons() {
	var submitB = document.getElementById("submitB");
	if( submitB ) submitB.style.visibility = "visible";
	var revertB = document.getElementById("revertB");
	if( revertB ) revertB.style.visibility = "visible";
}
function saveLeadAndCancel() {
	document.getElementById("cancelH").value = "1";
	document.data_form.action="/signup/forms/cancel.html";
	document.forms['data_form'].submit();
}
function setSelectValue(select, value) { 
	select = $(select);
	for(i = 0; i < select.options.length; i++) { 
		if (select.options[i].value != null && select.options[i].value == value) {
			select.options[i].selected = true; 
			return; 
		} else if (select.options[i].text == value) {
			select.options[i].selected = true; 
			return;		
		}
	} 
}