
function load_function(page){
	if(page == "gallery.php"){
		document.images['big_pic1'].src='img/white.jpg';
		setTimeout('load_home_img()',500);

	} else if (page == "index.php"){
		//document.images['home_pic'].src='img/rotating.gif';
		//document.images['home_pic'].src='img/building.jpg';
		
	} else if (page == "getstarted.php"){
		if(document.theform.first_name != null){ document.theform.first_name.focus(); }
	}
	
	document.onmouseover = nostatus
	document.onmouseout = nostatus
	document.onmousedown = nostatus
}

function load_home_img(){
	change_pic(document.getElementById('pic_0'),0,1);
	document.images['big_pic1'].style.marginTop=0;
	document.images['big_pic1'].style.borderWidth=1;
	document.images['big_pic1'].style.borderStyle='solid';
	document.images['big_pic1'].style.borderColor='black';
}

function nostatus(){
	window.status = company_name;
	return true
}

function promptLogin(){
	var x = confirm("This is a password protected area.\nWould you like to continue?");
	if(x){
		document.location.href='admin';
	} else {
		return;
	}
}

function textCounter(area,maxlength){
	if(area.value.length >= maxlength){
		alert("You've reached the " + maxlength + " character limit.");
		area.value = area.value.substring(0, maxlength);
		event.returnValue = false;
	}
}


//Photo gallery functions
function change_pic(elem, num, start){
	if((document.images['big_pic1'].src != company_url+initial_img) || start == 1){
		if(document.images['big_pic1'].filters != null)
			document.images['big_pic1'].filters[0].apply();
		document.images['big_pic1'].offSrc = document.images['big_pic1'].src;
		document.images['big_pic1'].src    = document.images[elem.name].src;
		if(document.images['big_pic1'].filters != null)
			document.images['big_pic1'].filters[0].play();
		
		document.getElementById("big_pic_td").style.backgroundColor = 'ivory';
		for(var i=0; i < num_pics; i++){
			document.getElementById("pic_"+i).style.borderWidth = "1px";
			document.getElementById("pic_"+i).style.borderColor = 'black';
			document.getElementById("pictd_"+i).style.backgroundColor = '#dddddd';
		}
		document.getElementById(elem.id).style.borderWidth = "2px";
		document.getElementById(elem.id).style.borderColor = '#EFEDDE';
		document.getElementById("pictd_"+num).style.backgroundColor = '#8A867A';
		if(document.getElementById(elem.id).height > 70){
			document.images['big_pic1'].height = "390";
			document.images['big_pic1'].width = 29250 / document.getElementById(elem.id).height;
		} else {
			document.images['big_pic1'].height = document.getElementById(elem.id).height / 0.1875;
			document.images['big_pic1'].width = "400";
		}
	}
}


//Testimonials Page
function validate_testimonials_form(){
	clear_testimonials_form();
	var required = "";
	if (document.theform.name.value.length == 0) { required += "\n     - Name"; document.theform.name.className='textBoxRequired'; }
	if (document.theform.email.value.length == 0) { required += "\n     - Email"; document.theform.email.className='textBoxRequired'; }
	if (document.theform.comment.value.length == 0) { required += "\n     - Comment"; document.theform.comment.className='textBoxRequired'; }
	else if (document.theform.email.value.search(/(\w+[\w|\.|-]*\w+)(@\w+[\w|\.|-]*\w+\.\w{2,4})/) == -1) { required += "\n     - Please specify a valid email address"; document.theform.email.className='textBoxRequired'; }
	
	if (required != "") {
		alert("Please fill in the required fields:" + required);
		return false;
	}
}
		
function reset_testimonials_form(){
	var x = confirm("Are you sure you want to erase all of your data?");
	if(x){
		clear_testimonials_form();
		document.theform.name.focus();
		document.theform.reset();
	}
}

function clear_testimonials_form(){
	document.theform.name.className='textBox';
	document.theform.email.className='textBox';
	document.theform.comment.className='textBox';
}

function show_form(){
	document.getElementById("comment_output").style.height = "125px";
	document.getElementById("comment_form").style.display = "";
	document.getElementById("comment_header").style.display = "none";
	document.theform.name.focus();
}


//Get started page
function validate_getstarted_form(){
	clear_getstarted_form();
	var required = "";
	if (document.theform.first_name.value.length == 0) { required += "\n     - First Name"; document.theform.first_name.className='textBoxRequired'; }
	if (document.theform.last_name.value.length == 0) { required += "\n     - Last Name"; document.theform.last_name.className='textBoxRequired'; }
	if (document.theform.street.value.length == 0) { required += "\n     - Address"; document.theform.street.className='textBoxRequired'; }
	if (document.theform.zip.value.length == 0) { required += "\n     - Zip"; document.theform.zip.className='textBoxRequired'; }
	if (document.theform.phone1.value.length == 0 || document.theform.phone2.value.length == 0 || document.theform.phone3.value.length == 0) { required += "\n     - Phone Number"; document.theform.phone1.className='textBoxRequired'; document.theform.phone2.className='textBoxRequired'; document.theform.phone3.className='textBoxRequired'; }
	if (document.theform.email.value.length == 0) { required += "\n     - Email"; document.theform.email.className='textBoxRequired'; }
	else if (document.theform.email.value.search(/(\w+[\w|\.|-]*\w+)(@\w+[\w|\.|-]*\w+\.\w{2,4})/) == -1) { required += "\n     - Please specify a valid email address"; document.theform.email.className='textBoxRequired'; }
	
	if (required != "") {
		alert("Please fill in the required fields:" + required);
		document.theform.second_half.value = 0;
		return false;
	}
	
	if(document.theform.second_half.value == 0){
		document.getElementById("table1").style.display = "none";
		document.getElementById("table2").style.display = "";
		document.theform.second_half.value = 1;
		return false;
	}
	
	if(document.theform.second_half.value == 1){
		var counter = 0;
		for(var i=0; i<document.theform.budget.length; i++){
			if(document.theform.budget[i].checked == true){
				counter++;
			}
		}
		if(counter <= 0){
			alert("Please choose your budget for this project.");
			return false;
		}
		
		if (document.theform.hear_about.value.length == 0){
			alert("How did you hear about us?");
			document.theform.hear_about.className='textBoxRequired';
			return false;
		}
	}
	
	if ((document.theform.hear_about.value == "Referral") && (document.theform.hear_about_referral.value.length == 0)) {
		alert("Who referred you?");
		document.theform.hear_about_referral.className='textBoxRequired';
		document.theform.hear_about_referral.focus();
		return false;
	}
}

function reset_getstarted_form(){
	var x = confirm("Are you sure you want to erase all of your data?");
	if(x){
		document.getElementById("table1").style.display = "";
		document.getElementById("table2").style.display = "none";
		document.theform.second_half.value = 0;
		
		clear_getstarted_form();
		document.theform.first_name.focus();
		document.getElementById("referral_text").style.display = "none";
		document.theform.reset();
	}
}

function clear_getstarted_form(){
	document.theform.first_name.className='textBox';
	document.theform.last_name.className='textBox';
	document.theform.street.className='textBox';
	document.theform.zip.className='textBox';
	document.theform.phone1.className='textBox';
	document.theform.phone2.className='textBox';
	document.theform.phone3.className='textBox';
	document.theform.email.className='textBox';
	document.theform.hear_about_referral.className='textBox';
}

function check_referral(elem){
	if(elem.value == "Referral"){
		document.getElementById("referral_text").style.display = "";
		document.theform.hear_about_referral.focus();
	} else {
		document.getElementById("referral_text").style.display = "none";
	}
}

function go_back(){
	document.getElementById("table1").style.display = "";
	document.getElementById("table2").style.display = "none";
	document.theform.second_half.value = 0;
}