/*************************************************
** Javascript file for SFerrino WebDev Projects
** Steven Ferrino, steven@sferrinodesigns.com
** version: 1.24
**
**
*************************************************/


/* 
My own little concotion for testing forms and required fields
*/
function _testForm(oSel) {

	var myForm = document.getElementById(oSel);

	var oCount = myForm.length;

	/* 	I start Out true just in case an older version of a browser doesn't like anything
	 		it will still work itself out, we will just have the posibility that they didn't 
			fill out the whole form */
			
	var canSub = true;
	for (var i = 0; i < oCount; i++) {
		var customer_Ele = myForm[i];
		if ((customer_Ele.getAttribute('needed') == "true") && (customer_Ele.value == "") ) {
			try {
				alert(customer_Ele.getAttribute('msg'));
				customer_Ele.style.borderColor="red";
				customer_Ele.focus();

				// Of Cource IE couldn't plan nice with the other little reigndeer
				if (customer_Ele.addEventListener){
					customer_Ele.addEventListener('keypress', function() { customer_Ele.style.borderColor = "grey"; }, false); 
				} else if (customer_Ele.attachEvent){
					customer_Ele.attachEvent('onkeypress', function() { customer_Ele.style.borderColor="#ffffff"; } );
				}
				canSub = false;
				break;
			} catch(er) { }
		} 
		else if (customer_Ele.getAttribute('passPhrase') != null) {

			// they have a capcha phrase and it should be checked
			if (customer_Ele.getAttribute('passPhrase') != customer_Ele.value) {
//				alert(customer_Ele.getAttribute('passPhrase') + ":" + customer_Ele.value);
	
				alert("Pass Phrase does not match");
				customer_Ele.style.borderColor="red";
				customer_Ele.value = "";
				customer_Ele.focus();
				
				if (customer_Ele.addEventListener){
					customer_Ele.addEventListener('keypress', function() { customer_Ele.style.borderColor = "grey"; }, false); 
				} else if (customer_Ele.attachEvent){
					customer_Ele.attachEvent('onkeypress', function() { customer_Ele.style.borderColor="#ffffff"; } );
				}
				canSub = false;
				break;
			}
		}
		else {

		}	
	}
	if (canSub) {		
		return true;
	} else {
		return false;
	}			
}

function newsLetter() {
	if ((window.open) && (myConstantContact)) {
		 window.open (myConstantContact, "mywindow","location=0,status=1,scrollbars=1,width=500,height=400");
	} else {
		alert("Constant Contact Variable not set to myConstantContact");
	}
}



function keepAlive(oSel, oPlace) {
	window.clearTimeout(timerMan);
	oSel.style.display = "block";
	document.getElementById(oPlace).src = "/images/" + oPlace + "_on.gif" ;
}

function allowDie(oSel, oImg) {
	timerMan = window.setTimeout("allowDieNow('" + oSel + "','" + oImg + "');", 500);
}

function allowDieNow(oSel, oImg) {
	window.clearTimeout(timerMan);	
	document.getElementById(oSel).style.display = "none";
	flyOut = "";	
	oPlace = oImg.replace("_off.gif", "");
	document.getElementById(oPlace).src = "/images/" + oImg;		
}

function fixFlash() {
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
		theObjects[i].outerHTML = theObjects[i].outerHTML;
	
	}
}
