function handleparent(parentID){
    myparent = document.getElementById(parentID)
    if (myparent.style.display=="none") {
        myparent.style.display = "block"
       
    } else {
        myparent.style.display = "none"
       
    }
}

/* start ajax functions */

function createRequestObject(){
	var request_o; 
	var browser = navigator.appName; 
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o = new XMLHttpRequest();
	}
	return request_o;
}

var http = createRequestObject(); 

/* Function creates thumbnail list */

function loadCat(n){
	if(n == 1) {
		http.open('get', 'selectcategory.asp');
	} else {
		http.open('get', 'filtercategory.asp');
	}
	http.onreadystatechange = handlesearch; 
	http.send(null);
}

function loadProgram(n){
	
	var ss = document.form1.selcat.value;
	if(n == 1) {
		http.open('get', 'educationalProgFilter.asp?vv=' + ss);
	} else {
	http.open('get', 'educationalProgFilter.asp');
	}
	http.onreadystatechange = handlesearch; 
	http.send(null);
}

function findCat(n){
	
	var ss = document.form1.selcat.value;
	if(n == 1) {
		http.open('get', 'selectcategory.asp?vv=' + ss);
	} else {
		http.open('get', 'filtercategory.asp?vv=' + ss);
	}
	document.form1.selcat.selectedIndex = 0;
	http.onreadystatechange = handlesearch; 
	
	http.send(null);
}


function loadcoy(n,x) {
	
		http.open('get', 'forms/coyform2.asp?bld=' + n + '&cid=' + x);

	http.onreadystatechange = handleform; 
	http.send(null);
}

function loadprefill(n){
	
	
	var selectValue = document.form1.prefill.selectedIndex;
	var ss = document.form1.prefill.options[selectValue].value; 
	
	if((n >= "152") && (n <= "157")) {
		http.open('get', 'forms/marketingstrategy2.asp?bld=' + ss + '&catid=' + n);
	} else if((n > "300") && (n < "312")) {
		http.open('get', 'forms/coyform2.asp?bld=' + ss + '&catid=' + n);
	} else if((n > "600") && (n < "610")) {
		http.open('get', 'forms/assocform2.asp?bld=' + ss + '&catid=' + n);
	} else if((n == "701")) {
		http.open('get', 'forms/milliondollar2.asp?bld=' + ss + '&catid=' + n);
	} else if((n >= "702") && (n <= "707")) {
		http.open('get', 'forms/IAA2.asp?bld=' + ss + '&catid=' + n);	
	} else if((n >= "801") && (n <= "807")) {
		http.open('get', 'forms/IAAassoc2.asp?bld=' + ss + '&catid=' + n);	
	} else {
		http.open('get', 'forms/residentialform2.asp?bld=' + ss + '&catid=' + n);
	}
	
	http.onreadystatechange = handleform; 
	http.send(null);
}

function entrycart(){
	http.open('get', 'entrycart.asp');
	http.onreadystatechange = handlecart ; 
	http.send(null);
}


function loadmillion() {
	var subusr = document.form1.subusr.value;
	var officer = document.form1.officer.value;
	var title = document.form1.title.value;
	var builder = document.form1.builder.value;
	var builderaddress = document.form1.builderaddress.value;
	var buildercity = document.form1.buildercity.value;
	var builderstate = document.form1.builderstate.value;
	var builderzip = document.form1.builderzip.value;
	var fName = document.form1.frName.value;
	var lName = document.form1.ltName.value;
	var dollarV = document.form1.dollarV.value;
	var noUnits = document.form1.noUnits.value;
	
	var category = document.form1.category.value;
	var catname = document.form1.catname.value;
	var catid = document.form1.catid.value;
	var price = document.form1.price.value;
	var prefill = document.form1.prefill.value;
	var formtype = document.form1.formtype.value;
	
	var radioLength = document.form1.option.length;

for(var i = 0; i < radioLength; i++) {

	if(document.form1.option[i].checked) {
	var option = document.form1.option[i].value;
}
}

	http.open('get', 'million_insert.asp?subusr=' + subusr + '&officer=' + officer + '&title=' + title + '&builder=' + builder + '&builderaddress=' + builderaddress + '&buildercity=' + buildercity + '&builderstate=' + builderstate + '&builderzip=' + builderzip + '&firstName=' + fName + '&lastName=' + lName + '&dollarV=' + dollarV + '&noUnits=' + noUnits + '&option=' + option + '&category=' + catname + '&catid=' + catid + '&price=' + price + '&prefill=' + prefill + '&formtype=' + formtype);
	http.onreadystatechange = handlemillion; 
	http.send(null);
	

}

function million_edit(n) {
	var subusr = document.form1.subusr.value;
	var officer = document.form1.officer.value;
	var title = document.form1.title.value;
	var builder = document.form1.builder.value;
	var builderaddress = document.form1.builderaddress.value;
	var buildercity = document.form1.buildercity.value;
	var builderstate = document.form1.builderstate.value;
	var builderzip = document.form1.builderzip.value;
	var fName = document.form1.frName.value;
	var lName = document.form1.ltName.value;
	var dollarV = document.form1.dollarV.value;
	var noUnits = document.form1.noUnits.value;
	
	var category = document.form1.category.value;
	var catname = document.form1.catname.value;
	var catid = document.form1.catid.value;
	var price = document.form1.price.value;
	var prefill = document.form1.prefill.value;
	var formtype = document.form1.formtype.value;
	
	var radioLength = document.form1.option.length;

for(var i = 0; i < radioLength; i++) {

	if(document.form1.option[i].checked) {
	var option = document.form1.option[i].value;
}
}

	http.open('get', 'million_edit.asp?subusr=' + subusr + '&officer=' + officer + '&title=' + title + '&builder=' + builder + '&builderaddress=' + builderaddress + '&buildercity=' + buildercity + '&builderstate=' + builderstate + '&builderzip=' + builderzip + '&firstName=' + fName + '&lastName=' + lName + '&dollarV=' + dollarV + '&noUnits=' + noUnits + '&option=' + option + '&category=' + catname + '&catid=' + catid + '&price=' + price + '&prefill=' + prefill + '&formtype=' + formtype);
	http.onreadystatechange = handlemillion; 
	http.send(null);
	

}

function million_update(n) {
	
	var officer = document.form1.officer.value;
	var title = document.form1.title.value;
	
	var builder = document.form1.builder.value;
	var fName = document.form1.frName.value;
	var lName = document.form1.ltName.value;
	var dollarV = document.form1.dollarV.value;
	var noUnits = document.form1.noUnits.value;
	var option = document.form1.option.value;
	var update = document.form1.updated.value;

	http.open('get', 'million_update.asp?mid=' + n + '&officer=' + officer + '&title=' + title + '&builder=' + builder + '&firstName=' + fName + '&lastName=' + lName + '&dollarV=' + dollarV + '&noUnits=' + noUnits + '&option=' + option + '&updated=' + update);
	http.onreadystatechange = handlemillion; 
	http.send(null);
	

}

function million_delete(n) {
	
	
	var builder = eval("document.form1.builder" + n + ".value");


	http.open('get', 'million_delete.asp?mid=' + n + '&builder=' + builder);
	http.onreadystatechange = handlemillion; 
	http.send(null);
	

}

function loadSAMmarketing() {
	
	
	var sponsor = document.form1.sponsorship.value;


	http.open('get', 'SAMMarketing_spotlight.html');
	http.onreadystatechange = handleSAMmarketing; 
	http.send(null);
	

}



function handlesearch(){
	stuff = document.getElementById("searchresults"); 
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('programs').innerHTML = response;
		
	}
}

function handleform(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('essenceofform').innerHTML = response;	
	}
}

function handlecart(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('fright').innerHTML = response;	
	}
}

function handlemillion(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('million').innerHTML = response;	
	}
}

function handleSAMmarketing(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('SAM').innerHTML = response;	
	}
}

function checkpassword() {
	var ss = document.form2.pwd.value;
	http.open('get', 'checkpassword.asp?pwd=' + ss);
	http.onreadystatechange = submitpassword;
	http.send(null);
}

function submitpassword(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('recheck').innerHTML = response;
		
	}
}

/* scripts for postcards */
function loadpcimage(n){
	http.open('get', 'common/get-postcard-image.php?im=' + n);
	http.onreadystatechange = handlepostcard; 
	http.send(null);
}

function handlepostcard(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('postcardimage').innerHTML = response;	
	}
}

/* submit CFE help form */
function submithelp() {
	var name = document.helpform.name.value;
	var email = document.helpform.email.value;
	var question = document.helpform.question.value;
	var samcat = document.helpform.samcat.value;
	http.open('get', 'sendhelp.php?name=' + name + '&email=' + email + '&question=' + question + '&samcat=' + samcat);
	http.onreadystatechange = handlesubmit;
	http.send(null);
}

function handlesubmit() {
	if(http.readyState == 4) {
		var response = http.responseText;
		document.getElementById('helpform').innerHTML = response;
	}
}


/* confirm email */
function checkemail() {
	var email = document.form1.email.value;
	var email3 = document.form1.email3.value;
	
	var email2 = document.form1.email2.value;
	var email4 = document.form1.email4.value;
	
	var company3 = document.form1.company3.value;
	var confirmCompany = document.form1.confirmCompany.value;
	
	var qty = document.form1.qty.value;
	
	//var selectValue = document.form1.boothtype.selectedIndex;
	//var bthtype = document.form1.boothtype.options[selectValue].value;
	
	var selectHow = document.form1.hearabout.selectedIndex;
	var hearabt = document.form1.hearabout.options[selectHow].value;
	
	
	if(email!= email3) {
		alert("You have not entered the same email values. Please try again.");
		document.form1.email3.focus();
		document.form1.email3.style.background = "#ff0000";
		return false;
	}
	
	if(email2 != email4) {
		alert("You have not entered the same email values. Please try again.");
		document.form1.email4.focus();
		document.form1.email4.style.background = "#ff0000";
		return false;
	}
	
	if(company3 != confirmCompany) {
		alert("You have not entered the same Company Names. Please try again.");
		document.form1.confirmCompany.focus();
		document.form1.confirmCompany.style.background = "#ff0000";
		return false;	
	}
	
	if(qty == "") {
		alert("You have not entered a booth quantity. Please try again.");
		document.form1.qty.focus();
		document.form1.qty.style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("booth").value == "") {
		alert("You have not entered a booth number. Please try again.");
		document.getElementById("booth").focus();
		document.getElementById("booth").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("firstName").value == "") {
		alert("You have not entered a First Name. Please try again.");
		document.getElementById("firstName").focus();
		document.getElementById("firstName").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("lastName").value == "") {
		alert("You have not entered a Last Name. Please try again.");
		document.getElementById("lastName").focus();
		document.getElementById("lastName").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("company").value == "") {
		alert("You have not entered a Company. Please try again.");
		document.getElementById("company").focus();
		document.getElementById("company").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("address1").value == "") {
		alert("You have not entered an Address. Please try again.");
		document.getElementById("address1").focus();
		document.getElementById("address1").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("city").value == "") {
		alert("You have not entered a City. Please try again.");
		document.getElementById("city").focus();
		document.getElementById("city").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("ste").value == "") {
		alert("You have not entered a State. Please try again.");
		document.getElementById("ste").focus();
		document.getElementById("ste").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("zip").value == "") {
		alert("You have not entered a Zip Code. Please try again.");
		document.getElementById("zip").focus();
		document.getElementById("zip").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("phone").value == "") {
		alert("You have not entered a Phone Number. Please try again.");
		document.getElementById("phone").focus();
		document.getElementById("phone").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("email").value == "") {
		alert("You have not entered an Email. Please try again.");
		document.getElementById("email").focus();
		document.getElementById("email").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("firstName2").value == "") {
		alert("You have not entered a First Name. Please try again.");
		document.getElementById("firstName2").focus();
		document.getElementById("firstName2").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("lastName2").value == "") {
		alert("You have not entered a Last Name. Please try again.");
		document.getElementById("lastName2").focus();
		document.getElementById("lastName2").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("bp_address1").value == "") {
		alert("You have not entered an Address. Please try again.");
		document.getElementById("bp_address1").focus();
		document.getElementById("bp_address1").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("city2").value == "") {
		alert("You have not entered a City. Please try again.");
		document.getElementById("city2").focus();
		document.getElementById("city2").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("ste2").value == "") {
		alert("You have not entered a State. Please try again.");
		document.getElementById("ste2").focus();
		document.getElementById("ste2").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("zip2").value == "") {
		alert("You have not entered a Zip Code. Please try again.");
		document.getElementById("zip2").focus();
		document.getElementById("zip2").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("phone2").value == "") {
		alert("You have not entered a Phone Number. Please try again.");
		document.getElementById("phone2").focus();
		document.getElementById("phone2").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("email2").value == "") {
		alert("You have not entered an Email. Please try again.");
		document.getElementById("email2").focus();
		document.getElementById("email2").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("company3").value == "") {
		alert("You have not entered a Company. Please try again.");
		document.getElementById("company3").focus();
		document.getElementById("company3").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("cm_address1").value == "") {
		alert("You have not entered an Address. Please try again.");
		document.getElementById("cm_address1").focus();
		document.getElementById("cm_address1").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("city3").value == "") {
		alert("You have not entered a City. Please try again.");
		document.getElementById("city3").focus();
		document.getElementById("city3").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("ste3").value == "") {
		alert("You have not entered a State. Please try again.");
		document.getElementById("ste3").focus();
		document.getElementById("ste3").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("zip3").value == "") {
		alert("You have not entered a Zip Code. Please try again.");
		document.getElementById("zip3").focus();
		document.getElementById("zip3").style.background = "#ff0000";
		return false;
	}
	
	if(document.getElementById("phone3").value == "") {
		alert("You have not entered a Phone Number. Please try again.");
		document.getElementById("phone3").focus();
		document.getElementById("phone3").style.background = "#ff0000";
		return false;
	}
	
	if(hearabt == "---") {
		alert("You have not selected How You Hear About Us. Please try again.");
		document.getElementById("hearabout").focus();
		document.getElementById("hearabout").style.background = "#ff0000";
		return false;
	}
	
	//return true;
}  


