function showLayer(whichLayer) {

	if (document.getElementById) {
	// this is the way the standards work
	//document.getElementById(whichLayer).style.visibility = "visible";
	document.getElementById(whichLayer).style.display = "";
	}
	else if (document.all) {
	// this is the way old msie versions work
	//document.all[whichlayer].style.visibility = "visible";
	document.all[whichlayer].style.display = "";
	}
	else if (document.layers) {
	// this is the way nn4 works
	//document.layers[whichLayer].visibility = "visible";
	document.layers[whichLayer].style.display = "";
	}
}

function hideLayer(whichLayer) {

	if (document.getElementById) {
	// this is the way the standards work
	//document.getElementById(whichLayer).style.visibility = "hidden";
	document.getElementById(whichLayer).style.display = "none";
	}
	else if (document.all) {
	// this is the way old msie versions work
	//document.all[whichlayer].style.visibility = "hidden";
	document.all[whichlayer].style.display = "none";
	}
	else if (document.layers) {
	// this is the way nn4 works
	//document.layers[whichLayer].visibility = "hidden";
	document.layers[whichLayer].style.display = "none";
	}
}


function handleClick(whichClick) {

	if (whichClick == "story") {
		showLayer("story_block");
		hideLayer("photo_block");
		document.getElementById("photo_tab").className = "";
		document.getElementById("story_tab").className = "current";

	}
	else if (whichClick == "photo") {
		showLayer("photo_block");
		hideLayer("story_block");
		document.getElementById("photo_tab").className = "current";
		document.getElementById("story_tab").className = "";
	}
}

//Custom JavaScript Functions by Shawn Olson
//Copyright 2004 for changecss() function below
//http://www.shawnolson.net
//If you copy any functions from this page into your scripts, you must provide credit to Shawn Olson & http://www.shawnolson.net
//*******************************************
function changecss(theClass, element, value) {
	//documentation for this script at http://www.shawnolson.net/a/503/
	var cssRules;
	if (document.all) {
		cssRules = 'rules';
	}
	else if (document.getElementById) {
		cssRules = 'cssRules';
	}
	for (var S = 0; S < document.styleSheets.length; S++){
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
			if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
				document.styleSheets[S][cssRules][R].style[element] = value;
			}
		}
	}	
}
	
function validate() {
	form		= document.forms['testimonial_form'];
	errors		= new Array();
	required	= new Object();
	
	required.submission_first_name	= { 'label' : 'first name',			'regex' : /./ };
	required.submission_last_name	= { 'label' : 'last name',			'regex' : /./ };
	required.submission_state		= { 'label' : 'state / province',	'regex' : /^\d+$/ };
	required.submission_country		= { 'label' : 'country',			'regex' : /^\d+$/ };
	required.submission_email		= { 'label' : 'email',				'regex' : /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+\.[a-zA-Z]{2,6}$/ };  // /^(([^&lt;&gt;()[\]\\.,;:\s@\"]+(\.[^&lt;&gt;()[\]\\.,;:\s@\"]+)*)|(\".+\"))@(((2([0-4]\d|5[0-5])|1?\d{1,2})(\.(2([0-4]\d|5[0-5])|1?\d{1,2})){3})|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ };
	required.submission_telephone	= { 'label' : 'phone',				'regex' : /^\D*\d{3}\D*\d{3}\D*\d{4}.*$/ };

	for( field in required ) {
//		alert( required[ field ]['regex'] + '.test( "' + form.elements[ field ].value + '" ) = ' + required[ field ]['regex'].test(form.elements[ field ].value) );
		if( !required[ field ]['regex'].test(form.elements[ field ].value) )
			errors.push( "The '" + required[ field ]['label'] + "' field is required or invalid." );
		
		// State/province and country match up
		if( field == 'submission_country' ) {
			state_index	= form.elements[ 'submission_state' ].value;
			country		= form.elements[ field ].options[ form.elements[ field ].selectedIndex ].text;
			
			if( country == 'United States' ) {
				if( parseInt(state_index) === 0 || parseInt(state_index) >= 100 )
					errors.push( "The 'state / province' field in not a valid US state." );
			}
			if( country == 'Canada' ) {
				if( parseInt(state_index) >= 0 && parseInt(state_index) < 100 )
					errors.push( "The 'state / province' field is not a valid Canadian province." );
			}
		}
	}
	
	// If submitted at all, check if file and location are both submitted
	num_of_files = 3;
	for( i = 0; i <= num_of_files; i++ ) {
		file		= form.elements['filename' + i].value;
		file_loc	= form.elements['description_' + i].value;
		
		if( !file && file_loc )
			errors.push( "The 'View " + i + "' field is required." );
		
		if( file && !file_loc )
			errors.push( 'Viewo ' + i + "'s 'Location' field is required." );
	}
	
	if( !form.elements['disclaimer_status[]'].checked )
		errors.push( 'You must accept the disclaimer.' );
	
	if( errors.length > 0 ) {
		alert( 'Please fix the following errors and resubmit the form: \n\n- ' + errors.join('\n- ') );
		return false;
	}
	
	return true;
}
