/** setStepBox()
 * Sets style information for step box based on page name.
 * no parameters
 * returns nothing
 **/
function setStepBox() {
	if (document.getElementById('stepimg3')) { s1 = document.getElementById('stepimg1'); } 
	if (document.getElementById('stepimg3')) { s2 = document.getElementById('stepimg2'); }
	if (document.getElementById('stepimg3')) { s3 = document.getElementById('stepimg3'); }
	winurl = window.location.href.toLowerCase();
	
	if (s1 && winurl.indexOf('entry_1.php')!==-1) { 
		s1.src = '/img/contestform/step1_hi.jpg';
	}
	if (s2 && winurl.indexOf('entry_2.php')!==-1 || winurl.indexOf('entry_2_photo.php')!==-1) {
		s2.src = '/img/contestform/step2_hi.jpg';
	}
	if (s3 && winurl.indexOf('entry_fin.php')!==-1) {
		s3.src = '/img/contestform/step3_hi.jpg';
	}
}

/** doExpertise()
 * elObj = obj
 * returns nothing
 **/
function doExpertise() {
	expertiseObj = document.entryform.expertise;
	val = '';
	for (i=0; i<expertiseObj.length; i++) {
		//alert(expertiseObj[i].value+'='+expertiseObj[i].checked);
		if (expertiseObj[i].checked == true) { val = expertiseObj[i].value; break; }
	}
	ageObj = document.getElementById('contestform_age');
	ageFld = document.entryform.elements['age'];
	if (val.toUpperCase()=='YOUTH') {
		ageObj.style.visibility = 'visible';
	} else {
		ageObj.style.visibility = 'hidden' ;
		ageFld.value = '';
	}
}

/** doPaymentMethod()
 * Turns form elements on/off depending on choice of payment method
 * elObj = obj
 * returns nothing
 **/
function doPaymentMethod(elObj) {
	f = elObj.form;
	if (elObj.value.toUpperCase()!=='CC') {
		//*NOT* CC Payment
		//clear 'em
		f.ccnum.value = '';
		f.ccexpmo.selectedIndex = 0;
		f.ccexpyr.selectedIndex = 0;
		f.ccname.value = '';
		
		//disable 'em
		f.ccnum.disabled = true;
		f.ccexpmo.disabled = true;
		f.ccexpyr.disabled = true;
		f.ccname.disabled = true;
		
		//set color on labels
		document.getElementById('ccnumtxt').className = 'label';
		document.getElementById('ccexptxt').className = 'label';
		document.getElementById('ccnametxt').className = 'label';
		
		//HIDE the cc payment div, containing cc form fields
		document.getElementById("ccpayment").style.visibility = 'hidden';
		document.getElementById("ccpayment").style.display = 'none';
		
		//SHOW the check payment div, containing information about paying w/check
		document.getElementById("checkpayment").style.visibility = 'visible';
		document.getElementById("checkpayment").style.display = 'block';
	} else {
		//CC Payment
		//enable 'em
		f.ccnum.disabled = false;
		f.ccexpmo.disabled = false;
		f.ccexpyr.disabled = false;
		f.ccname.disabled = false;
		
		//set color on labels
		document.getElementById('ccnumtxt').className = 'label_req';
		document.getElementById('ccexptxt').className = 'label_req';
		document.getElementById('ccnametxt').className = 'label_req';
		
		//SHOW the cc payment div, containing cc form fields
		document.getElementById("ccpayment").style.visibility = 'visible';
		document.getElementById("ccpayment").style.display = 'block';
		
		//HIDE the check payment div, containing information about paying w/check
		document.getElementById("checkpayment").style.visibility = 'hidden';
		document.getElementById("checkpayment").style.display = 'none';
	}
}

/*
getDocHeight()
This function will return any document’s height. It’s been tested in IE6/7, FF2/3, Safari (Windows), 
Google Chrome and Opera 9.5. If the actual document’s body height is less than the viewport height 
then it will return the viewport height instead.
*/
function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

/*
postproc__toggleDisplay(state)
Show/Hide the post processing alert message
*/
function postproc__setMsg() {
	if (postprocMsg!=='') {
		postproc__msgObj.innerHTML = postprocMsg ; //msg var set in inc.postproc.php
		
		//account for height of header info (need to be updated if page layout changes)
		hdrObjH = document.getElementById('pg_hdr').offsetHeight;
		navObjH = document.getElementById('Navigation').offsetHeight;
		
		//set the position of the veil beneath the header, then size it.
		postproc__veilObj.style.top = hdrObjH+navObjH;
		postproc__veilObj.style.height = getDocHeight() + (hdrObjH + navObjH) + 'px';
		
		//turn it on
		postproc__toggleDisplay(1);
	} else {
		postproc__msgObj.innerHTML = '' ;
		postproc__toggleDisplay(0);
	}
}

/*
postproc__toggleDisplay(state)
Show/Hide the post processing alert message
*/
function postproc__toggleDisplay(state) {
	postproc__shellObj.style.visibility = (state==1) ? 'visible' : 'hidden' ;
}