

var headImages = new Array();

function generateIndex(size){

var randomIndex = Math.floor(Math.random()*size);
return randomIndex;

}

function alertForm(formName) {

var elem = document.getElementById(formName).elements;
for(var i = 0; i < elem.length; i++)
{
alert(elem[i].name);
} 
}

function makeVisible(prefix, visible, visArray) {
	//alert(visible);
	
	// if visible isn't empty, append prefix and proceed
	if(visible) {
	visible = prefix + visible;
	var visStyle;

	for(var i=0;i<visArray.length;i++) 
	{
		var vis = visArray[i];

		if(vis == visible) {
			visStyle = "";
		} else {
			visStyle = "none";
		}

		var visElement;			
		if (document.getElementById) {	
			// this is the way the standards work
			visElement = document.getElementById(vis);
		} else if (document.all) {
			// this is the way old msie versions work
			visElement = document.all[vis];
		} else if (document.layers) {
			// this is the way nn4 works
			visElement = document.layers[vis];
		}
		if(visElement) {
			visElement.style.display=visStyle;	
		}
	}		
	}

}

function selectCountry(country, stateElName, provinceElName, stateArray, provinceArray) {
	//alert(country);

	var countryElement;
	var countryCode;
	var stateEl;
	var provinceEl;

	if (document.getElementById) {	
		// this is the way the standards work
		countryElement = document.getElementById(country);
		stateEl = document.getElementById(stateElName);
		provinceEl = document.getElementById(provinceElName);
	} else if (document.all) {
		// this is the way old msie versions work
		countryElement = document.all[country];
		stateEl = document.all[stateElName];
		provinceEl = document.all[provinceElName];
	} else if (document.layers) {
		// this is the way nn4 works
		countryElement = document.layers[country];
		stateEl = document.layers[stateElName];
		provinceEl = document.layers[provinceElName];
	}
	if(countryElement) {
		countryCode = countryElement.value;
	}
	
	//alert(countryCode);
    
	var stateStyle = "";
	var provinceStyle = "none";
    
	if (countryCode != 'US' && countryCode != '') {
		//alert("other country");
		stateStyle = "none";
		provinceStyle = "";
		if(stateEl) {
			//alert(stateEl.selectedIndex);
			stateEl.selectedIndex = 0;
		}
	} else {
		//alert("united states");
		stateStyle = "";
		provinceStyle = "none";
		if(provinceEl) {
			//alert(provinceEl.value);
			provinceEl.value = "";
		}
	}
		
	for(var i=0;i<stateArray.length;i++) 
	{
		var state = stateArray[i];
		var stateElement;			
		if (document.getElementById) {	
			// this is the way the standards work
			stateElement = document.getElementById(state);
		} else if (document.all) {
			// this is the way old msie versions work
			stateElement = document.all[state];
		} else if (document.layers) {
			// this is the way nn4 works
			stateElement = document.layers[state];
		}
		if(stateElement) {
			stateElement.style.display=stateStyle;
		}
	}	
	
	for(var i=0;i<provinceArray.length;i++) 
	{
		var province = provinceArray[i];
		var provinceElement;			
		if (document.getElementById) {	
			// this is the way the standards work
			provinceElement = document.getElementById(province);
		} else if (document.all) {
			// this is the way old msie versions work
			provinceElement = document.all[province];
		} else if (document.layers) {
			// this is the way nn4 works
			provinceElement = document.layers[province];
		}
		if(provinceElement) {
			provinceElement.style.display=provinceStyle;	
		}
	}	
}

function toggleLayer(cb, whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		if(cb.checked) {
			style2.display = "block";
		} else {
			style2.display = "none"
		}
	} else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		if(cb.checked) {
			style2.display = "block";
		} else {
			style2.display = "none"
		}
	} else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		if(cb.checked) {
			style2.display = "block";
		} else {
			style2.display = "none"
		}
	}
}

function copyZipCode(val, copyTo) {
	if (document.getElementById) {
		// this is the way the standards work
		var z2 = document.getElementById(copyTo);
		z2.value = val;
	} else if (document.all) {
		// this is the way old msie versions work
		var z2 = document.all[copyTo];
		z2.value = val;
	} else if (document.layers) {
		// this is the way nn4 works
		var z2 = document.layers[copyTo];
		z2.value = val;
	}
}

function popupUrl(url) {
  window.open(url, "SCPS Privacy Policy", "height=600,width=550,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,menubar=no,status=no");
}

function emailPopup() {
    url = "/emailPageForm.htm";
    url = url+"?purl="+escape(window.location);
    window.open(url,'emailwindow','width=450,height=390');
}




