function toggleCell(obj,stateval){
	if(stateval == "ON"){
		// set background color of td as red
		obj.bgcolor
	}else{
		// set it back to white
	}
}

function settabs(){
	// Analyses the current URL of page and sets tab display colors/images accordingly
	var active_color = "#91D54B";
	var padding = "10px 6px 4px 6px;";
	var inactive_color = "";
	var parts = document.location.href.split('/');
	var filename = parts[parts.length-1];
	//alert("Filename - " + filename);
	if((filename.indexOf("index") >= 0)||(filename == "")){
		document.getElementById('home-btn').src = "/images/home-alt-btn.gif";
	}else if(filename.indexOf("announcements") >= 0){
		document.getElementById('announcements-btn').src = "/images/announcements-alt-btn.gif";
	}else if(filename.indexOf("events") >= 0){
		document.getElementById('events-btn').src = "/images/events-alt-btn.gif";
	}else if(filename.indexOf("news") >= 0){
		document.getElementById('news-btn').src = "/images/news-alt-btn.gif";
	}else if(filename.indexOf("history") >= 0){
		document.getElementById('history-btn').src = "/images/history-alt-btn.gif";
    }else if(filename.indexOf("about-us") >= 0){
		document.getElementById('about-us-btn').src = "/images/about-us-alt-btn.gif";
	}else if(filename.indexOf("contact-us") >= 0){
		document.getElementById('contact-us-btn').src = "/images/contact-us-alt-btn.gif";
	}else if(filename.indexOf("location") >= 0){
		document.getElementById('location-btn').src = "/images/location-alt-btn.gif";
	}else if(filename.indexOf("links") >= 0){
		document.getElementById('links-btn').src = "/images/links-alt-btn.gif";
	}
}

function nav_rollover(imgID,status){
	var imgobjID = imgID + "-btn";
	if(status == "on"){
		document.getElementById(imgobjID).src = "/images/" + imgID + "-alt-btn.gif";
	}else{
		document.getElementById(imgobjID).src = "/images/" + imgID + "-btn.gif";
	}
	settabs();
}

function check_contactform(){
	// checks the fields for Contact-form.php submission
    if(document.getElementById('fromname') != null){
	    if(document.getElementById('fromname').value == ""){
		    alert("Please tell us your name.");
            document.getElementById('fromname').focus();
            return false;
        }
    }
    if(document.getElementById('mfrom') != null){
	    if(document.getElementById('mfrom').value != ""){
            //only check this if they supplied it
            if(echeck(document.getElementById('mfrom').value) == false){
		        // doesn't look like a valid email address
		        alert("That doesn't appear to be a valid Email Address.");
		        document.getElementById('mfrom').focus();
                return false;
            }
        }
	}
    if(document.getElementById('subject') != null){
	    if(document.getElementById('subject').value == ""){
		    alert("Please provide a message Subject.");
            document.getElementById('subject').focus();
            return false;
        }
    }
    if(document.getElementById('msg') != null){
	    if(document.getElementById('msg').value == ""){
		    alert("Please include your Message.");
            document.getElementById('msg').focus();
            return false;
        }
    }
    return true;
}

// ################## OLD CODE HERE ################## //
function clear_reqfields(blockname){
	// this will clear the fields for Request Form radio button 2
	if(blockname == "idblock"){
		if(document.getElementById('useremail') != null){
			document.getElementById('useremail').value = "";
		}
		if(document.getElementById('userid') != null){
			document.getElementById('userid').value = "";
		}
	}else if(blockname == "zipblock"){
		if(document.getElementById('userlname') != null){
			document.getElementById('userlname').value = "";
		}
		if(document.getElementById('useremail2') != null){
			document.getElementById('useremail2').value = "";
		}
		if(document.getElementById('userzip') != null){
			document.getElementById('userzip').value = "";
		}
	}
	setprogress_bar();
}
function check_unsubscribe(){
	if(document.getElementById('email_address') != null){
		if(document.getElementById('email_address').value == ""){
			alert("You must supply an email address to unsubscribe.");
			return false;
		}
	}else{
		return true;
	}
}

function open_giftpref(){
	// opens gift preferences window
	toggleLayer("gift_div","block");
	location.href="#giftblock";
	//var url = "gift_prefs.aspx";
	//var newwindow = window.open(url,'giftprefs','height=400,width=600,resizable=yes,menubar=no,location=no,scrollbars=yes');
	return false;
}

function open_oid(){
	// opens 'What is an Olivia ID' window
	toggleLayer("oid_div","block");
	location.href="#oidblock";
	//var url = "olivia_id.aspx";
	//var newwindow = window.open(url,'oid','height=400,width=600,resizable=yes,menubar=no,location=no,scrollbars=yes');
	return false;
}

function open_contest_rules(){
	// opens 'Contest Rules' window
	toggleLayer("crules_div","block");
	//var url = "contest_rules.aspx";
	//var newwindow = window.open(url,'crules','height=400,width=600,resizable=yes,menubar=no,location=no,scrollbars=yes');
	return false;
}

function open_terms(){
	// opens terms and conditions window
	// if user clicks agree, it returns a value to a hidden var in page
	// if that var has a value, then it updates the contract received date to today
	toggleLayer("terms_and_conds_div","block");
	location.href="#tcblock";
	//var url = "terms_and_conditions.aspx";
	//var newwindow = window.open(url,'termsandcond','height=400,width=600,resizable=yes,menubar=no,location=no,scrollbars=yes');
	//while(newwindow.closed == false){
		//sleep 1;
	//}
	return false;
}

function simulate_click(btnName, Action, argstring){
	// simulates a button click from a link
	var cont = false;
	var url = "https://www.oliviatest.com/profile/profile-addresses.aspx?" + btnName + "=1";
	if(window.location.host == "207.34.147.93"){
		// DEV Server
		url = "https://207.34.147.93/devsite/profile-addresses.aspx?" + btnName + "=1";
	}else if(window.location.host == "192.168.3.201"){
		// Jonathan DEV
		url = "https://192.168.3.201/oliviadev/profile-addresses.aspx?" + btnName + "=1";
	}
	if(argstring != ""){
		url = url + "&" + argstring;
	}
	//alert("Requesting URL: " + url);
	// use AJAX here
	if(Action == "delete"){
		// show confirm block
		if(confirm("Are you sure you want to delete this address? Click OK to remove this address")){
			cont = true;
		}
	}else{
		cont = true;
	}
	if(cont){
		// ok, perform the requested action	
		var xmlhttp;
		var xmlresponse;
		var retval = false;
		if (window.XMLHttpRequest){
			xmlhttp = new XMLHttpRequest();
			xmlhttp.overrideMimeType('text/xml');
			xmlhttp.open("GET",url,false);
			xmlhttp.send(null);
			xmlresponse = xmlhttp.responseText;
			//alert(xmlresponse.substring(xmlresponse.indexOf("instructionlabel"),xmlresponse.indexOf("instructionlabel")+500));
		}else if (window.ActiveXObject){
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			//xmlhttp.overrideMimeType('text/xml');
			if (xmlhttp) {
				xmlhttp.open("GET",url,false);
				xmlhttp.send(null);
				xmlresponse = xmlhttp.responseText;
				//alert(xmlresponse.substring(xmlresponse.indexOf("instructionlabel"),xmlresponse.indexOf("instructionlabel")+500));
			}else {
				//alert("xmlhttp not assigned");
			}
		}
	}else{
		return;
	}
	window.location.reload();
}

function buildQueryString(theFormName) {
	theForm = document.forms[theFormName];
	var qs = ''
	for (e=0;e<theForm.elements.length;e++) {
		if (theForm.elements[e].name!='') {
			qs+=(qs=='')?'?':'&'
			qs+=theForm.elements[e].name+'='+escape(theForm.elements[e].value)
			}
		}
	return qs
}


function callToServer(theFormName) {
	//alert("Loading IFrame content!");
	var IFrameObj = document.getElementById('QASFrame'); // our IFrame object
	if (!document.createElement) {return true};
	var IFrameDoc;
	//var URL = 'server.html' + buildQueryString(theFormName);
	// let's determine the correct country object
	var countryobj = "";
	if(document.getElementById('contactcountry') != null){
		countryobj = document.getElementById('contactcountry');
	}else{
		countryobj = document.getElementById('contactcountryddl')
	}
	// ONLY Verify US Addresses
	if(countryobj.options[countryobj.options.selectedIndex].value.substr(0,13) == "UNITED STATES"){
		var argstring = "address1=" + escape(document.getElementById('address1').value) + "&";
		argstring = argstring + "address2=" + escape(document.getElementById('address2').value) + "&";
		if(document.getElementById('apt') != null){
			argstring = argstring + "address3=" + escape(document.getElementById('apt').value) + "&";
		}else{
			argstring = argstring + "address3=" + escape(document.getElementById('address3').value) + "&";
		}
		argstring = argstring + "city=" + escape(document.getElementById('city').value) + "&";
		argstring = argstring + "state=" + escape(document.getElementById('state').value) + "&";
		argstring = argstring + "zip=" + escape(document.getElementById('zip').value);
		// Olivia Server Settings
		var url = "/profile/prowebplug.aspx?" + argstring;
		if(window.location.host == "207.34.147.93"){
			// DEV Server
			url = "/devsite/prowebplug.aspx?" + argstring;
		}else if(window.location.host == "192.168.3.201"){
			// Jonathan DEV
			url = "/oliviadev/prowebplug.aspx?" + argstring;
		}
		//alert("Requesting URL: " + url);
		if (IFrameObj == null && document.createElement) {
			//alert("Creating the IFrame now");
			// create the IFrame and assign a reference to the
			// object to our global variable IFrameObj.
			// this will only happen the first time 
			// callToServer() is called
			try {
				var tempIFrame=document.createElement('iframe');
				tempIFrame.setAttribute('id','QASFrame');
				tempIFrame.style.border='1px';
				tempIFrame.style.width='600px';
				tempIFrame.style.height='300px';
				IFrameObj = document.body.appendChild(tempIFrame);
				//alert("appending tmpIFrame");
				if (document.frames) {
					// this is for IE5 Mac, because it will only
					// allow access to the document object
					// of the IFrame if we access it through
					// the document.frames array
					IFrameObj = document.frames['QASFrame'];
				}
			} catch(exception) {
				// This is for IE5 PC, which does not allow dynamic creation
				// and manipulation of an iframe object. Instead, we'll fake
				// it up by creating our own objects.
				//alert("Caught exception = creating iframeHTML...");
				iframeHTML='<iframe id="QASFrame" style="';
				iframeHTML+='border:1px;';
				iframeHTML+='width:0px;';
				iframeHTML+='height:0px;';
				iframeHTML+='"><\/iframe>';
				document.body.innerHTML+=iframeHTML;
				IFrameObj = new Object();
				IFrameObj.document = new Object();
				IFrameObj.document.location = new Object();
				IFrameObj.document.location.iframe = document.getElementById('QASFrame');
				IFrameObj.document.location.replace = function(location) {
				this.iframe.src = location;
				}
			}
			if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
				// we have to give NS6 a fraction of a second
				// to recognize the new IFrame
				setTimeout('callToServer("'+theFormName+'")',10);
				return false;
			}
			
			if (IFrameObj.contentDocument) {
				// For NS6
				IFrameDoc = IFrameObj.contentDocument; 
			} else if (IFrameObj.contentWindow) {
				// For IE5.5 and IE6
				IFrameDoc = IFrameObj.contentWindow.document;
			} else if (IFrameObj.document) {
				// For IE5
				IFrameDoc = IFrameObj.document;
			} else {
				alert('No IFrameDoc object available');
				return true;
			}
			//alert("Setting location to " + url);
			IFrameDoc.location.replace(url);
			location.href = "#qasblock";
		}else{
			// set the source
			//IFrameObj.src = AJAXFetch("https://" + window.location.host + url);
			IFrameObj.src = url;
			location.href = "#qasblock";
		}
	}
	return handleResponse();
}
	
function handleResponse() {
	//alert("inside handleResponse");
	if(document.getElementById('addressverified') != null){
		if(document.getElementById('addressverified').value == "1"){
		//alert("Found addressverified");
			// ok, we're already verified - just return true to submit form
			return true;
		}
	}
	if(document.getElementById('addr_verified') != null){
		if(document.getElementById('addr_verified').value == "1"){
		//alert("Found addr_verified");
			// ok, we're already verified - just return true to submit form
			return true;
		}
	}
	if(document.getElementById('newadd_verified') != null){
		if(document.getElementById('newadd_verified').value == "1"){
		//alert("Found newadd_verified");
			// ok, we're already verified - just return true to submit form
			return true;
		}
	}
	//alert("Showing the divs!");
	if(document.getElementById('address1').value != ""){
		//alert("We have an address - show iframe");
		// we have an address, show the iframe
		if(document.getElementById('regdiv') != null){
			toggleLayer('regdiv',"none");
		}
		if(document.getElementById('reg_div') != null){
			toggleLayer('reg_div',"none");
		}
		if(document.getElementById('login_div') != null){
			toggleLayer('login_div',"none");
		}
		if(document.getElementById('new_div') != null){
			toggleLayer('new_div',"none");
		}
		if(document.getElementById('radio1div') != null){
			toggleLayer('radio1div',"none");
			toggleLayer('radio2div',"none");
			toggleLayer('radio3div',"none");
			toggleLayer('step2_link_div',"none");
		}
		if(document.getElementById('addeditform') != null){
			toggleLayer('addeditform',"none");
		}
		toggleLayer('qasdiv',"block");
	}else{
		//alert("NO address - show form");
		if(document.getElementById('regdiv') != null){
			toggleLayer('regdiv',"block");
		}
		if(document.getElementById('reg_div') != null){
			toggleLayer('reg_div',"block");
		}
		if(document.getElementById('login_div') != null){
			toggleLayer('login_div',"block");
		}
		if(document.getElementById('new_div') != null){
			toggleLayer('new_div',"block");
		}
		if(document.getElementById('radio1div') != null){
			toggleLayer('radio1div',"block");
			toggleLayer('radio2div',"block");
			toggleLayer('radio3div',"block");
			toggleLayer('step2_link_div',"block");
		}
		if(document.getElementById('addeditform') != null){
			toggleLayer('addeditform',"block");
		}
		toggleLayer('qasdiv',"none");
	}
	return false;
}

function AJAXFetch(url){
	alert("Fetching " + url);
	var xmlhttp;
	var xmlresponse = "";
	if (window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
		xmlhttp.overrideMimeType('text/xml');
		xmlhttp.open("GET",url,false);
		xmlhttp.send(null);
		xmlresponse = xmlhttp.responseText;
	}else if (window.ActiveXObject){
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	//	xmlhttp.overrideMimeType('text/xml');
		if (xmlhttp) {
			xmlhttp.open("GET",url,false);
			xmlhttp.send(null);
			xmlresponse = xmlhttp.responseText;
		}
	}
	return xmlresponse;
}

function prowebverify(){
//alert("Inside prowebverify");
	return callToServer("Form1");
	
	// ok, we need to make sure this is not the 2nd submit from the QAS page
	if(document.getElementById('addressverified') != null){
		if(document.getElementById('addressverified').value == "1"){
			// ok, we're already verified - just return true to submit form
			return true;
		}else{
			// not verified yet, we're off to do that
			// let's warn the user here
			alert("Olivia.com will compare the address entered with the U.S. Postal Service to ensure accuracy. A pop-up window may appear briefly in this process. If an alteration is needed in the address entered, you will be taken back to the address screen. If the information is valid the process will continue.");		
		}
	}else if(document.getElementById('addr_verified') != null){
		if(document.getElementById('addr_verified').value == "1"){
			// ok, we're already verified - just return true to submit form
			return true;
		}else{
			// not verified yet, we're off to do that
			// let's warn the user here
			alert("Olivia.com will compare the address entered with the U.S. Postal Service to ensure accuracy. A pop-up window may appear briefly in this process. If an alteration is needed in the address entered, you will be taken back to the address screen. If the information is valid the process will continue.");
		}
	}else if(document.getElementById('newadd_verified') != null){
		if(document.getElementById('newadd_verified').value == "1"){
			// ok, we're already verified - just return true to submit form
			return true;
		}else{
			// not verified yet, we're off to do that
			// let's warn the user here
			alert("Olivia.com will compare the address entered with the U.S. Postal Service to ensure accuracy. A pop-up window may appear briefly in this process. If an alteration is needed in the address entered, you will be taken back to the address screen. If the information is valid the process will continue.");
		}
	}

	// let's determine the correct country object
	var countryobj = "";
	if(document.getElementById('contactcountry') != null){
		countryobj = document.getElementById('contactcountry');
	}else{
		countryobj = document.getElementById('contactcountryddl')
	}
	// ONLY Verify US Addresses
	if(countryobj.options[countryobj.options.selectedIndex].value.substr(0,13) == "UNITED STATES"){
		// Let's try a remote call with the data and see if we get a response set
		// maybe we can do the work in Javascript and send the data back to original
		// form submission for updating/inserting
		var argstring = "address1=" + document.getElementById('address1').value + "&";
		argstring = argstring + "address2=" + document.getElementById('address2').value + "&";
		if(document.getElementById('apt') != null){
			argstring = argstring + "address3=" + document.getElementById('apt').value + "&";
		}else{
			argstring = argstring + "address3=" + document.getElementById('address3').value + "&";
		}
		argstring = argstring + "city=" + document.getElementById('city').value + "&";
		argstring = argstring + "state=" + document.getElementById('state').value + "&";
		argstring = argstring + "zip=" + document.getElementById('zip').value;
		// these are hard code in the Sample QAS Code we are using now
		// no need to pass country or DataID
		//argstring = argstring + "CountryName=" + countryobj.options[countryobj.options.selectedIndex].value.substr(0,13) + "&";
		//argstring = argstring + "DataID=USA";
		// Olivia Server Settings
		var url = "https://www.oliviatest.com/profile/prowebplug.aspx?" + argstring;
		if(window.location.host == "207.34.147.93"){
			// DEV Server
			url = "https://207.34.147.93/devsite/prowebplug.aspx?" + argstring;
		}else if(window.location.host == "192.168.3.201"){
			// Jonathan DEV
			url = "https://192.168.3.201/oliviadev/prowebplug.aspx?" + argstring;
		}
		//alert("Requesting URL: " + url);
		// ok - let's hide the regdiv and show the iframe QAS div
		//toggleLayer('regdiv',"none");
		//toggleLayer('qasdiv',"block");
		var xmlhttp;
		var xmlresponse;
		var retval = false;
		if (window.XMLHttpRequest){
			xmlhttp = new XMLHttpRequest();
			xmlhttp.overrideMimeType('text/xml');
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			xmlresponse = xmlhttp.responseText;
			if(xmlresponse.indexOf('Final Captured Address') >= 0){
				// ok - we have a verified address - no need to continue
				//retval = true;
				retval = false;
			}
			//alert(xmlhttp.responseText);
			//alert(xmlresponse.indexOf('Final Captured Address'));
		}else if (window.ActiveXObject){
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		//	xmlhttp.overrideMimeType('text/xml');
			if (xmlhttp) {
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);
				xmlresponse = xmlhttp.responseText;
				if(xmlresponse.indexOf('Final Captured Address') >= 0){
					// ok - we have a verified address - no need to continue
					//retval = true;
					retval = false;
				}
				//alert(xmlhttp.responseText);
				//alert(xmlresponse.indexOf('Final Captured Address'));
			}else {
				//alert("xmlhttp not assigned");
			}
		}
		// ok, did we get a final address yet?
		// if not, we open a window and let them choose
		// otherwise just return true here and we'll carry on.
		if(retval){
			// ok, just return, we're good to go
			return true;
			//return false; // testing
		}else{
			// show them the window - we need help with address verify
			//alert("Requesting URL: " + url);
			// set our main window name so we can write back to it
			window.name = "main";
			var newwindow = window.open(url,'prowebverify','height=400,width=600,resizable=yes,menubar=no,location=no,scrollbars=yes');
			if (window.focus) {newwindow.focus();}
			
			// let's NOT wait for the other window, let's make them submit via the other window
			return false;
			
			//while(newwindow.closed == false){
				//sleep 1;
			//}
			// now let's make sure we have values
			//if((document.getElementById('address1').value != "") &&
			//	(document.getElementById('city').value != "") &&
			//	(document.getElementById('state').value != "") &&
			//	(document.getElementById('zip').value != "")){
			//	return true;
			//}else{
				// looks like we didn't get a full address
				// just return - no update
			//	return false;
			//}
		}
	}else{
		return true;
	}
}

function prowebverify_old(){
	//var url = "https://webservices.olivia.com/ProWebCS/VerifyInput.aspx";
	//newwindow = window.open(url,'prowebverify','height=400,width=200,resizable=false,menubar=false,location=false');
	//if (window.focus) {newwindow.focus()}
	// let's determine the correct country object
	var countryobj = "";
	if(document.getElementById('contactcountry') != null){
		countryobj = document.getElementById('contactcountry');
	}else{
		countryobj = document.getElementById('contactcountryddl')
	}
	// ONLY Verify US Addresses
	if(countryobj.options[countryobj.options.selectedIndex].value.substr(0,13) == "UNITED STATES"){
		// Let's try a remote call with the data and see if we get a response set
		// maybe we can do the work in Javascript and send the data back to original
		// form submission for updating/inserting
		var argstring = "address1=" + document.getElementById('address1').value + "&";
		argstring = argstring + "address2=" + document.getElementById('address2').value + "&";
		argstring = argstring + "address3=" + document.getElementById('address3').value + "&";
		argstring = argstring + "city=" + document.getElementById('city').value + "&";
		argstring = argstring + "state=" + document.getElementById('state').value + "&";
		argstring = argstring + "zip=" + document.getElementById('zip').value + "&";
		argstring = argstring + "CountryName=" + countryobj.options[countryobj.options.selectedIndex].value.substr(0,13) + "&";
		argstring = argstring + "DataID=USA";
		//var url = "https://192.168.3.201/oliviadev/prowebplug.aspx?" + argstring;
		var url = "https://207.34.147.93/devsite/prowebplug.aspx?" + argstring;
		//alert("Requesting URL: " + url);
		var xmlhttp;
		var xmlresponse;
		var retval = false;
		if (window.XMLHttpRequest){
			xmlhttp = new XMLHttpRequest();
			xmlhttp.overrideMimeType('text/xml');
			xmlhttp.open("GET",url,false);
			xmlhttp.send(null);
			xmlresponse = xmlhttp.responseText;
			if(xmlresponse.indexOf('Final Captured Address') >= 0){
				// ok - we have a verified address - no need to continue
				//retval = true;
				retval = false;
			}
			//alert(xmlhttp.responseText);
			//alert(xmlresponse.indexOf('Final Captured Address'));
		}else if (window.ActiveXObject){
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		//	xmlhttp.overrideMimeType('text/xml');
			if (xmlhttp) {
				xmlhttp.open("GET",url,false);
				xmlhttp.send(null);
				xmlresponse = xmlhttp.responseText;
				if(xmlresponse.indexOf('Final Captured Address') >= 0){
					// ok - we have a verified address - no need to continue
					//retval = true;
					retval = false;
				}
				//alert(xmlhttp.responseText);
				//alert(xmlresponse.indexOf('Final Captured Address'));
			}else {
				//alert("xmlhttp not assigned");
			}
		}
		// ok, did we get a final address yet?
		// if not, we open a window and let them choose
		// otherwise just return true here and we'll carry on.
		if(retval){
			// ok, just return, we're good to go
			return true;
			//return false; // testing
		}else{
			// show them the window - we need help with address verify
			//alert("Requesting URL: " + url);
			// set our main window name so we can write back to it
			window.name = "main";
			var newwindow = window.open(url,'prowebverify','height=400,width=600,resizable=yes,menubar=no,location=no,scrollbars=yes');
			if (window.focus) {newwindow.focus();}
			while(newwindow.closed == false){
				//sleep 1;
			}
			// now let's make sure we have values
			if((document.getElementById('address1').value != "") &&
				(document.getElementById('city').value != "") &&
				(document.getElementById('state').value != "") &&
				(document.getElementById('zip').value != "")){
				return true;
			}else{
				// looks like we didn't get a full address
				// just return - no update
				return false;
			}
		}
	}else{
		return true;
	}
}

function toggleaddon(addonID, action){
	var divid = addonID + "-addon";
	toggleLayer(divid, action);
}

function togglevacations(vacType){
	var active_color = "#91D54B";
	var padding = "10px 6px 4px 6px;";
	var inactive_color = "";
	// displays/hides vacation DIVs in "My Vacations"
	if(vacType == "pastvacs"){
		// show Past Vacations block
		toggleLayer(vacType, 'block');
		// hide Present/Future Vacations block
		toggleLayer('presvacs', 'none');
		document.getElementById('pastcell').style.border = active_color;
		document.getElementById('pastcell').style.padding = padding;
		document.getElementById('presentcell').style.border = inactive_color;
		document.getElementById('presentcell').style.padding = padding;
	}else{
		// show Present/Future Vacations block
		toggleLayer(vacType, 'block');
		// hide Past Vacations block
		toggleLayer('pastvacs', 'none');
		document.getElementById('presentcell').style.border = active_color;
		document.getElementById('presentcell').style.padding = padding;
		document.getElementById('pastcell').style.border = inactive_color;
		document.getElementById('pastcell').style.padding = padding;
	}
}

function activateDiv(divID){
	var active_color = "#91D54B";
	document.getElementById(divID).style.border = active_color;
}

function deactivateDiv(divID){
	//var inactive_color = "#E4F1F9";
	var inactive_color = "";
	document.getElementById(divID).style.backgroundColor = inactive_color;
	document.getElementById(divID).style.border = inactive_color;
}

function togglereservations(secID){
	var active_color = "#C8DDE9";
	var padding = "10px 6px 4px 6px;";
	var inactive_color = "#E4F1F9";
	// displays/hides Reservation DIVs in "My Vacations -> Edit Trip Preferences"
	// show Info block
	toggleLayer(secID, 'block');
	// set colors
	deactivateDiv('resinfodiv');
	deactivateDiv('dininginfodiv');
	// set color for active element
	activateDiv(secID + 'div');
	if(secID == "resinfo"){
		// hide all other blocks
		toggleLayer('dininginfo', 'none');
	}else if(secID == "dininginfo"){
		// hide all other blocks
		toggleLayer('resinfo', 'none');
	}else{
		// show all
		toggleLayer('resinfo', 'block');
		toggleLayer('dininginfo', 'block');
	}
}

function setmaintabs(){
	var color = "#E4F1F9";
	var padding = "10px 6px 4px 6px";
	if(document.getElementById('membenLabel') != null){
		document.getElementById('membenLabel').style.backgroundColor = color;
		document.getElementById('membenLabel').style.padding = padding;
	}
	if(document.getElementById('myprofLabel') != null){
		document.getElementById('myprofLabel').style.backgroundColor = color;
		document.getElementById('myprofLabel').style.padding = padding;
	}
	if(document.getElementById('myvacLabel') != null){
		document.getElementById('myvacLabel').style.backgroundColor = color;
		document.getElementById('myvacLabel').style.padding = padding;
	}
	if(document.getElementById('aboutmeLabel') != null){
		document.getElementById('aboutmeLabel').style.backgroundColor = color;
		document.getElementById('aboutmeLabel').style.padding = padding;
	}
	if(document.getElementById('logoutLabel') != null){
		document.getElementById('logoutLabel').style.backgroundColor = color;
		document.getElementById('logoutLabel').style.padding = padding;
	}
}


function readcookie(name){
	var nameEQ = name + "=";
	//alert("Cookies = " + document.cookie);
	if(document.cookie != null){
		var ca = document.cookie.split(';');
		for(var i=0; i<ca.length; i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
	}
	return "";
}

function check_flight_time(){
	// for vacation-prefs.aspx
	// if flight date included, must include a time value
	// for an update
	if(document.getElementById('flight_in_date') != null){
		if(document.getElementById('flight_in_time').value != ""){
			if(document.getElementById('flight_in_date').value == ""){
				alert("You MUST include a date for the time specified.");
				document.getElementById('flight_in_date').style.backgroundColor = "#FF0000";
				document.getElementById('flight_in_date').focus();
				return false;
			}
		}else{
			document.getElementById('flight_in_date').style.backgroundColor = "#FFFFFF";
		}
	}
	if(document.getElementById('flight_out_date') != null){
		if(document.getElementById('flight_out_time').value != ""){
			if(document.getElementById('flight_out_date').value == ""){
				alert("You MUST include a date for the time specified.");
				document.getElementById('flight_out_date').style.backgroundColor = "#FF0000";
				document.getElementById('flight_out_date').focus();
				return false;
			}
		}else{
			document.getElementById('flight_out_date').style.backgroundColor = "#FFFFFF";
		}
	}
	return true;
}

function check_contact_request(){
	if(document.getElementById('howhelp') != null){
		if(document.getElementById('howhelp').selectedIndex <= 0){
			alert("Please tell us what we can help with.");
			document.getElementById('howhelp').style.backgroundColor = "#FF0000";
			document.getElementById('howhelp').focus();
			return false;
		}else{
			document.getElementById('howhelp').style.backgroundColor = "#FFFFFF";
		}
	}
	if(document.getElementById('trip_choice') != null){
		if(document.getElementById('trip_choice').selectedIndex <= 0){
			alert("Please tell us what trip you are inquiring about.");
			document.getElementById('trip_choice').style.backgroundColor = "#FF0000";
			document.getElementById('trip_choice').focus();
			return false;
		}else{
			document.getElementById('trip_choice').style.backgroundColor = "#FFFFFF";
		}
	}
	if(document.getElementById('comment') != null){
		if(document.getElementById('comment').value == ""){
			alert("Please tell us your Comment(s)/Concern(s).");
			document.getElementById('comment').style.backgroundColor = "#FF0000";
			document.getElementById('comment').focus();
			return false;
		}else{
			document.getElementById('comment').style.backgroundColor = "#FFFFFF";
		}
	}
	if(document.getElementById('cemail') != null){
		if(document.getElementById('cemail').value == ""){
			alert("Please tell us your Email Address.");
			document.getElementById('cemail').style.backgroundColor = "#FF0000";
			document.getElementById('cemail').focus();
			return false;
		}else{
			document.getElementById('cemail').style.backgroundColor = "#FFFFFF";
		}
	}
	if(document.getElementById('cphone') != null){
		if(document.getElementById('cphone').value == ""){
			alert("Please tell us your Contact Phone Number.");
			document.getElementById('cphone').style.backgroundColor = "#FF0000";
			document.getElementById('cphone').focus();
			return false;
		}else{
			document.getElementById('cphone').style.backgroundColor = "#FFFFFF";
		}
	}
	
}

function togglecontest(){
	// ok - so we check the fields first
	var step1_status = getLayerStatus("step1_div");
	if(step1_status == ""){
		// first load - this is the displayed layer
		step1_status = "block";
	}
	var step2_status = getLayerStatus("step2_div");
	var step3_status = getLayerStatus("step3_div");
	var step4_status = getLayerStatus("step4_div");
	var step5_status = getLayerStatus("step5_div");
	if(step1_status == "block"){
		if(document.getElementById('howdidyouhearcat') != null){
			// check the 1st 5 questions
			//alert("Cat SelectedIndex = " + document.getElementById('howdidyouhearcat').selectedIndex);
			//alert("Val SelectedIndex = " + document.getElementById('howdidyouhearval').selectedIndex);
			if(document.getElementById('howdidyouhearcat') != null){
				if(document.getElementById('howdidyouhearcat').selectedIndex <= 0){
					alert("Please tell us how you heard about us.");
					document.getElementById('1cell').style.color = "#FF0000";
					document.getElementById('1cell').style.fontWeight = "bold";
					return false;
				}else if(document.getElementById('howdidyouhearcat').selectedIndex == 5){
					if(document.getElementById('howdidyouhearval').selectedIndex < 3){
						// must input an Olivia ID
						if(document.getElementById('sFriendID') != null){
							if(document.getElementById('sFriendID').value == ""){
						//		alert("Please supply the OliviaID of your friend.");
						//		document.getElementById('1cell').style.color = "#FF0000";\n document.getElementById('16cell').style.fontWeight = "bold";
						//		return false;
							}else{
								var isnum = parseFloat(document.getElementById('sFriendID').value);
								if(isNaN(isnum)){
									alert("You MUST provide a numeric value for an Olivia ID.");
									document.getElementById('1cell').style.color = "#FF0000";
									document.getElementById('1cell').style.fontWeight = "bold";
									return false;
								}
							}
						}
					}
				}else if(document.getElementById('howdidyouhearcat').selectedIndex == 7){
					if(document.getElementById('sHPWho') != null){	
						if(document.getElementById('sHPWho').value == ""){
						//	alert("Please supply the OliviaID of your House Party Host.");
						//	document.getElementById('1cell').style.color = "#FF0000";
						//  document.getElementById('1cell').style.fontWeight = "bold";
						//	return false;
						}else{
							var isnum = parseFloat(document.getElementById('sHPWho').value);
							if(isNaN(isnum)){
								alert("You MUST provide a numeric value for an Olivia ID.");
								document.getElementById('1cell').style.color = "#FF0000";
								document.getElementById('1cell').style.fontWeight = "bold";
								return false;
							}
						}
					}
				}else{
					document.getElementById('1cell').style.color = "#000000";
					document.getElementById('1cell').style.fontWeight = "normal";
				}
			}
			if(document.getElementById('RS_CONTACT_MARKETING.MAINID.MAINID') != null){
				if(document.getElementById('RS_CONTACT_MARKETING.MAINID.MAINID').selectedIndex <= 0){
					alert("Please tell us which of the announcements listed below influenced your decision to contact Olivia today.");
					document.getElementById('1bcell').style.color = "#FF0000";
					document.getElementById('1bcell').style.fontWeight = "bold";
					return false;
				}else{
					document.getElementById('1bcell').style.color = "#000000";
					document.getElementById('1bcell').style.fontWeight = "normal";
				}
			}
			if(document.getElementById('RS_CONTACT_INFO.Credit_Cards_used.cbCreditCardUse') != null){
				if(document.getElementById('RS_CONTACT_INFO.Credit_Cards_used.cbCreditCardUse').selectedIndex <= 0){
					alert("Please tell us which type of credit card do you prefer.");
					document.getElementById('2cell').style.color = "#FF0000";
					document.getElementById('2cell').style.fontWeight = "bold";
					return false;
				}else{
					document.getElementById('2cell').style.color = "#000000";
					document.getElementById('2cell').style.fontWeight = "normal";
				}
			}
			if(document.getElementById('RS_CONTACT_INFO.ANNUAL_HOUSEHOLD_INCOME.sIncome') != null){
				if(document.getElementById('RS_CONTACT_INFO.ANNUAL_HOUSEHOLD_INCOME.sIncome').selectedIndex <= 0){
					alert("Please tell us your total annual household income.");
					document.getElementById('3cell').style.color = "#FF0000";
					document.getElementById('3cell').style.fontWeight = "bold";
					return false;
				}else{
					document.getElementById('3cell').style.color = "#000000";
					document.getElementById('3cell').style.fontWeight = "normal";
				}
			}
			if(document.getElementById('RS_CONTACT_INFO.HOME_RENT_OR_OWN.sHome') != null){
				if(document.getElementById('RS_CONTACT_INFO.HOME_RENT_OR_OWN.sHome').selectedIndex <= 0){
					alert("Please tell us if you own or rent your home.");
					document.getElementById('4cell').style.color = "#FF0000";
					document.getElementById('4cell').style.fontWeight = "bold";
					return false;
				}else{
					document.getElementById('4cell').style.color = "#000000";
					document.getElementById('4cell').style.fontWeight = "normal";
				}
			}
			toggleLayer('step2_div',"block");
			toggleLayer('step1_div',"none");
			toggleLayer('step3_div',"none");
			toggleLayer('step4_div',"none");
			toggleLayer('step5_div',"none");
		}
	}else if(step2_status == "block"){
		// check the 2nd 5 questions
		if(document.getElementById('INQCLIENTCONTACTS.GENDER.Gender') != null){
			if(document.getElementById('INQCLIENTCONTACTS.GENDER.Gender').selectedIndex <= 0){
				alert("Please tell us your gender.");
				document.getElementById('5cell').style.color = "#FF0000";
				document.getElementById('5cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('5cell').style.color = "#000000";
				document.getElementById('5cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_INFO.IDENTIFY_AS.cbIdentityAs') != null){
			if(document.getElementById('RS_CONTACT_INFO.IDENTIFY_AS.cbIdentityAs').selectedIndex <= 0){
				alert("Please tell us what do you identify as.");
				document.getElementById('6cell').style.color = "#FF0000";
				document.getElementById('6cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('6cell').style.color = "#000000";
				document.getElementById('6cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_INFO.HOW_OUT.cbHowOut') != null){
			if(document.getElementById('RS_CONTACT_INFO.HOW_OUT.cbHowOut').selectedIndex <= 0){
				alert("Please tell us how \"out\" you are.");
				document.getElementById('7cell').style.color = "#FF0000";
				document.getElementById('7cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('7cell').style.color = "#000000";
				document.getElementById('7cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_INFO.MARITAL_STATUS.cbMaritalStatus') != null){
			if(document.getElementById('RS_CONTACT_INFO.MARITAL_STATUS.cbMaritalStatus').selectedIndex <= 0){
				alert("Please tell us your status.");
				document.getElementById('8cell').style.color = "#FF0000";
				document.getElementById('8cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('8cell').style.color = "#000000";
				document.getElementById('8cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_INFO.ETHNICITY.cbEthnicID') != null){
			if(document.getElementById('RS_CONTACT_INFO.ETHNICITY.cbEthnicID').selectedIndex <= 0){
				alert("Please tell us your ethnicity.");
				document.getElementById('9cell').style.color = "#FF0000";
				document.getElementById('9cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('9cell').style.color = "#000000";
				document.getElementById('9cell').style.fontWeight = "normal";
			}
		}
		toggleLayer('step3_div',"block");
		toggleLayer('step1_div',"none");
		toggleLayer('step2_div',"none");
		toggleLayer('step4_div',"none");
		toggleLayer('step5_div',"none");
	}else if(step3_status == "block"){
		// check the 3rd 5 questions
		if(document.getElementById('RS_CONTACT_INFO.BUDGET_RANGE.sBudget') != null){
			if(document.getElementById('RS_CONTACT_INFO.BUDGET_RANGE.sBudget').selectedIndex <= 0){
				alert("Please tell us how much you usually spend per person on a 7-day vacation.");
				document.getElementById('10cell').style.color = "#FF0000";
				document.getElementById('10cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('10cell').style.color = "#000000";
				document.getElementById('10cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_PREFS.ACCOMODATIONS.cbAccommodations') != null){
			if(document.getElementById('RS_CONTACT_PREFS.ACCOMODATIONS.cbAccommodations').selectedIndex <= 0){
				alert("Please tell us what kind of accomodations you prefer when you travel.");
				document.getElementById('11cell').style.color = "#FF0000";
				document.getElementById('11cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('11cell').style.color = "#000000";
				document.getElementById('11cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_PREFS.VACATION_FREQUENCY.cbVacaFeq') != null){
			if(document.getElementById('RS_CONTACT_PREFS.VACATION_FREQUENCY.cbVacaFeq').selectedIndex <= 0){
				alert("Please tell us how often you vacation.");
				document.getElementById('12cell').style.color = "#FF0000";
				document.getElementById('12cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('12cell').style.color = "#000000";
				document.getElementById('12cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_INFO.PREF_TRAVEL_WITH.cbTravelWith') != null){
			var objarray = getElementsById('RS_CONTACT_INFO.PREF_TRAVEL_WITH.cbTravelWith');
			var haschoice = 0;
			for(var i=0; i<objarray.length; i++){
				if(objarray[i].checked){
					haschoice = 1;
				}
			}
			if(haschoice == 0){
				// nothing selected - must choose at least one checkbox
				alert("Please tell us who you prefer to vacation with.");
				document.getElementById('13cell').style.color = "#FF0000";
				document.getElementById('13cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('13cell').style.color = "#000000";
				document.getElementById('13cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_INFO.OCCUPATION_LEVEL.cbOccupationLevel') != null){
			if(document.getElementById('RS_CONTACT_INFO.OCCUPATION_LEVEL.cbOccupationLevel').selectedIndex <= 0){
				alert("Please tell us what your occupational level is.");
				document.getElementById('14cell').style.color = "#FF0000";
				document.getElementById('14cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('14cell').style.color = "#000000";
				document.getElementById('14cell').style.fontWeight = "normal";
			}
		}
		toggleLayer('step4_div',"block");
		toggleLayer('step1_div',"none");
		toggleLayer('step2_div',"none");
		toggleLayer('step3_div',"none");
		toggleLayer('step5_div',"none");
	}else if(step4_status == "block"){
		// check the 4th 5 questions
		if(document.getElementById('RS_CONTACT_INFO.OCCUPATION_STATUS.cbOccupationStatus') != null){
			if(document.getElementById('RS_CONTACT_INFO.OCCUPATION_STATUS.cbOccupationStatus').selectedIndex <= 0){
				alert("Please tell us what your occupational status is.");
				document.getElementById('15cell').style.color = "#FF0000";
				document.getElementById('15cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('15cell').style.color = "#000000";
				document.getElementById('15cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_INFO.EDUCATION_LEVEL.cbEdLevel') != null){
			if(document.getElementById('RS_CONTACT_INFO.EDUCATION_LEVEL.cbEdLevel').selectedIndex <= 0){
				alert("Please tell us your highest level of education completed.");
				document.getElementById('16cell').style.color = "#FF0000";
				document.getElementById('16cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('16cell').style.color = "#000000";
				document.getElementById('16cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_INFO.PATRONIZE_GL_BUSINESS.cbPatronize') != null){
			if(document.getElementById('RS_CONTACT_INFO.PATRONIZE_GL_BUSINESS.cbPatronize').selectedIndex <= 0){
				alert("Please tell us if you actively patronize LGBT, LGBT-friendly and/or LGBT-owned businessess.");
				document.getElementById('17cell').style.color = "#FF0000";
				document.getElementById('17cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('17cell').style.color = "#000000";
				document.getElementById('17cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('tSURVEY_RESULT.srMbrPgm_Benefit') != null){
			// checkboxes
			var objarray = getElementsById('tSURVEY_RESULT.srMbrPgm_Benefit');
			var haschoice = 0;
			for(var i=0; i<objarray.length; i++){
				if(objarray[i].checked){
					haschoice = 1;
				}
			}
			if(haschoice == 0){
				// nothing selected - must choose at least one checkbox
				alert("Please rank the potential Olivia Membership Program benefits.");
				document.getElementById('18cell').style.color = "#FF0000";
				document.getElementById('18cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('18cell').style.color = "#000000";
				document.getElementById('18cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('TABLE/FIELD TBD.srMbrPgm_Tvl_Benefit') != null){
			// checkboxes
			var objarray = getElementsById('TABLE/FIELD TBD.srMbrPgm_Tvl_Benefit');
			var haschoice = 0;
			for(var i=0; i<objarray.length; i++){
				if(objarray[i].checked){
					haschoice = 1;
				}
			}
			if(haschoice == 0){
				alert("Please rank the potential Olivia Travel benefits.");
				document.getElementById('19cell').style.color = "#FF0000";
				document.getElementById('19cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('19cell').style.color = "#000000";
				document.getElementById('19cell').style.fontWeight = "normal";
			}
		}
		toggleLayer('step5_div',"block");
		toggleLayer('step1_div',"none");
		toggleLayer('step2_div',"none");
		toggleLayer('step3_div',"none");
		toggleLayer('step4_div',"none");
		toggleLayer('submit_div',"block");
		toggleLayer('next_div',"none");
	}else if(step5_status == "block"){
		// check the last 5 questions
		//alert("Will submit after this");
		if(document.getElementById('RS_CONTACT_MARKETING.DESTINATION_INTEREST.cbTravelin') != null){
			var objarray = getElementsById('RS_CONTACT_MARKETING.DESTINATION_INTEREST.cbTravelin');
			var haschoice = 0;
			for(var i=0; i<objarray.length; i++){
				if(objarray[i].checked){
					haschoice = 1;
				}
			}
			if(haschoice == 0){
				alert("Please tell us where you would like to travel for your next vacation.");
				document.getElementById('20cell').style.color = "#FF0000";
				document.getElementById('20cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('20cell').style.color = "#000000";
				document.getElementById('20cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_MARKETING.TRAVEL_INTEREST.cbInterests') != null){
			if(document.getElementById('RS_CONTACT_MARKETING.TRAVEL_INTEREST.cbInterests').selectedIndex <= 0){
				alert("Please tell us what kind of vacation appeals to you the most.");
				document.getElementById('21cell').style.color = "#FF0000";
				document.getElementById('21cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('21cell').style.color = "#000000";
				document.getElementById('21cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_PREFS.FP_OTHER_FACTOR.tbFP_9') != null){
			if(document.getElementById('RS_CONTACT_PREFS.FP_OTHER_FACTOR.tbFP_9').selectedIndex <= 0){
				alert("Please tell us when you are choosing your Olivia vacation, which are the most important in your purchase decision.");
				document.getElementById('22cell').style.color = "#FF0000";
				document.getElementById('22cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('22cell').style.color = "#000000";
				document.getElementById('22cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_MARKETING.ACTIVITIES_INTERESTS.clAct') != null){
			var objarray = getElementsById('RS_CONTACT_MARKETING.ACTIVITIES_INTERESTS.clAct');
			var haschoice = 0;
			for(var i=0; i<objarray.length; i++){
				if(objarray[i].checked){
					haschoice = 1;
				}
			}
			if(haschoice == 0){
				alert("Please tell us which of the following activities are you most interested to have on your next vacation.");
				document.getElementById('23cell').style.color = "#FF0000";
				document.getElementById('23cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('23cell').style.color = "#000000";
				document.getElementById('23cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('RS_CONTACT_PREFS.BEST_VACATION_LENGTH.cbHowLong') != null){
			if(document.getElementById('RS_CONTACT_PREFS.BEST_VACATION_LENGTH.cbHowLong').selectedIndex <= 0){
				alert("Please tell us how long you like your vacation.");
				document.getElementById('24cell').style.color = "#FF0000";
				document.getElementById('24cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('24cell').style.color = "#000000";
				document.getElementById('24cell').style.fontWeight = "normal";
			}
		}
	}
	var currentwidth = document.getElementById('prog_ind_img').width/301 * 100;
	currentwidth = parseInt(currentwidth) + 1;
	if(step4_status == "block"){
		// we're on the final screen - hard code this to 90%
		setprogress_bar(90);
	}else if(document.referrer == ""){
		// came in cold - bookmark or typed manually - add 20%
		currentwidth = currentwidth + 20;
		setprogress_bar(currentwidth);
	}else if(document.referrer.indexOf("register.aspx") >= 0){
		// if we came from Registration process
		currentwidth = currentwidth + 10;
		setprogress_bar(currentwidth);
	}else{
		// all other entry points
		currentwidth = currentwidth + 20;
		setprogress_bar(currentwidth);
	}
}

function getElementsById(sId){
	var outArray = new Array();	
	if(typeof(sId)!='string' || !sId){
		return outArray;
	}
	if(document.evaluate){
		var xpathString = "//*[@id='" + sId.toString() + "']"
		var xpathResult = document.evaluate(xpathString, document, null, 0, null);
		while ((outArray[outArray.length] = xpathResult.iterateNext())) { }
		outArray.pop();
	}else if(document.all){
		for(var i=0,j=document.all[sId].length;i<j;i+=1){
			outArray[i] =  document.all[sId][i];
		}
	}else if(document.getElementsByTagName){
		var aEl = document.getElementsByTagName( '*' );	
		for(var i=0,j=aEl.length;i<j;i+=1){
			if(aEl[i].id == sId ){
				outArray.push(aEl[i]);
			}
		}
	}
	return outArray;
}

function toggleContestTab(tabID){
	if(tabID == "step1"){
			document.getElementById('step1div').style.className = "mytabon";
			document.getElementById('step1spacerdiv').style.className = "spaceron";
			document.getElementById('step2div').style.className = "mytab";
			document.getElementById('step2spacerdiv').style.className = "spacer";
			document.getElementById('step3div').style.className = "mytab";
			document.getElementById('step3spacerdiv').style.className = "spacer";
			document.getElementById('step4div').style.className = "mytab";
			document.getElementById('step4spacerdiv').style.className = "spacer";
			document.getElementById('step5div').style.className = "mytab";
			document.getElementById('step5spacerdiv').style.className = "spacer";
			toggleLayer('step1_div',"block");
			toggleLayer('step2_div',"none");
			toggleLayer('step3_div',"none");
			toggleLayer('step4_div',"none");
			toggleLayer('step5_div',"none");
	}else if(tabID == "step2"){
			document.getElementById('step1div').style.className = "mytab";
			document.getElementById('step1spacerdiv').style.className = "spacer";
			document.getElementById('step2div').style.className = "mytabon";
			document.getElementById('step2spacerdiv').style.className = "spaceron";
			document.getElementById('step3div').style.className = "mytab";
			document.getElementById('step3spacerdiv').style.className = "spacer";
			document.getElementById('step4div').style.className = "mytab";
			document.getElementById('step4spacerdiv').style.className = "spacer";
			document.getElementById('step5div').style.className = "mytab";
			document.getElementById('step5spacerdiv').style.className = "spacer";
			toggleLayer('step1_div',"none");
			toggleLayer('step2_div',"block");
			toggleLayer('step3_div',"none");
			toggleLayer('step4_div',"none");
			toggleLayer('step5_div',"none");
	}else if(tabID == "step3"){
			document.getElementById('step1div').style.className = "mytab";
			document.getElementById('step1spacerdiv').style.className = "spacer";
			document.getElementById('step2div').style.className = "mytab";
			document.getElementById('step2spacerdiv').style.className = "spacer";
			document.getElementById('step3div').style.className = "mytabon";
			document.getElementById('step3spacerdiv').style.className = "spaceron";
			document.getElementById('step4div').style.className = "mytab";
			document.getElementById('step4spacerdiv').style.className = "spacer";
			document.getElementById('step5div').style.className = "mytab";
			document.getElementById('step5spacerdiv').style.className = "spacer";
			toggleLayer('step1_div',"none");
			toggleLayer('step2_div',"none");
			toggleLayer('step3_div',"block");
			toggleLayer('step4_div',"none");
			toggleLayer('step5_div',"none");
	}else if(tabID == "step4"){
			document.getElementById('step1div').style.className = "mytab";
			document.getElementById('step1spacerdiv').style.className = "spacer";
			document.getElementById('step2div').style.className = "mytab";
			document.getElementById('step2spacerdiv').style.className = "spacer";
			document.getElementById('step3div').style.className = "mytab";
			document.getElementById('step3spacerdiv').style.className = "spacer";
			document.getElementById('step4div').style.className = "mytabon";
			document.getElementById('step4spacerdiv').style.className = "spaceron";
			document.getElementById('step5div').style.className = "mytab";
			document.getElementById('step5spacerdiv').style.className = "spacer";
			toggleLayer('step1_div',"none");
			toggleLayer('step2_div',"none");
			toggleLayer('step3_div',"none");
			toggleLayer('step4_div',"block");
			toggleLayer('step5_div',"none");
	}else if(tabID == "step5"){
			document.getElementById('step1div').style.className = "mytab";
			document.getElementById('step1spacerdiv').style.className = "spacer";
			document.getElementById('step2div').style.className = "mytab";
			document.getElementById('step2spacerdiv').style.className = "spacer";
			document.getElementById('step3div').style.className = "mytab";
			document.getElementById('step3spacerdiv').style.className = "spacer";
			document.getElementById('step4div').style.className = "mytab";
			document.getElementById('step4spacerdiv').style.className = "spacer";
			document.getElementById('step5div').style.className = "mytabon";
			document.getElementById('step5spacerdiv').style.className = "spaceron";
			toggleLayer('step1_div',"none");
			toggleLayer('step2_div',"none");
			toggleLayer('step3_div',"none");
			toggleLayer('step4_div',"none");
			toggleLayer('step5_div',"block");
	}
}

function togglerequest(divID){
	//toggleLayer('req_submit_button_div',"none"); // hide the submit button by default
	if(document.getElementById('request_submit') != null){
		if(document.getElementById('request_submit').value == "Submit Registration"){
			document.getElementById('request_submit').value = "Submit Request";
		}
	}
	if(divID == "login_div"){
		toggleLayer('login_div', "block");
		toggleLayer('reg_div', "none");
		document.getElementById('alreadyreg').checked = false;
		toggleLayer('new_div', "none");
		document.getElementById('btnnew').checked = false;
		toggleLayer('step2_link_div',"block");
		document.getElementById('prog_ind_img').width = "30%";
		toggleLayer('req_submit_button_div', "none");
		toggleLayer('step1_link_div', "none");
	}else if(divID == "reg_div"){
		toggleLayer('login_div', "none");
		document.getElementById('btnlogin').checked = false;
		toggleLayer('reg_div', "block");
		toggleLayer('new_div', "none");
		toggleLayer('step2_link_div',"block");
		document.getElementById('prog_ind_img').width = "20%";
		document.getElementById('btnnew').checked = false;
		toggleLayer('req_submit_button_div', "none");
		toggleLayer('step1_link_div', "none");
	}else if(divID == "new_div"){
		toggleLayer('login_div', "none");
		document.getElementById('btnlogin').checked = false;
		toggleLayer('reg_div', "none");
		toggleLayer('step2_link_div',"block");
		document.getElementById('alreadyreg').checked = false;
		toggleLayer('new_div', "block");
		document.getElementById('prog_ind_img').width = "20%";
		if(document.getElementById('hp_msg') != null){
			// only for House Party Request!!
			if(window.location.search.indexOf("houseparty") >= 0){
				document.getElementById('hp_msg').innerHTML = "<br><center><b>Only past travelers may host a House Party.<br>We invite you to <a href=\"request.aspx?request=cat\">request a catalog</a> or <a href=\"request.aspx?request=res\">make a reservation request</a> to start your journey.<br>Please enjoy an Olivia excursion and then visit this area of Olivia.com again and let the House Party fun begin!</b></center><br><br>";
				toggleLayer('req_submit_button_div', "block");
				if(document.getElementById('request_submit') != null){
					document.getElementById('request_submit').value = "Submit Registration";
				}
				toggleLayer('step1_link_div', "none");
				toggleLayer('step2_link_div', "none");
				document.getElementById('norequest').value = 1;
			}
		}else{
			toggleLayer('req_submit_button_div', "block");
			toggleLayer('step1_link_div', "block");
		}
	}else if(divID == "infodiv"){
		// show Registration Info, hide Step#2
		toggleLayer('infodiv',"block");
		toggleLayer('maindiv',"none");
		toggleLayer('req_submit_button_div', "none");
		toggleLayer('step1_link_div', "none");
	}else if(divID == "maindiv"){
		// show Request Info, hide Step#1
		toggleLayer('maindiv',"block");
		toggleLayer('infodiv',"none");
		toggleLayer('req_submit_button_div', "block");
		toggleLayer('step1_link_div', "block");
	}else if(divID == "reservation_div"){
		// show Reservation Request selections, hide Step#1
		toggleLayer('infodiv',"none");
		toggleLayer('reservation_div',"block");
		toggleLayer('catalog_div',"none");
		toggleLayer('houseparty_div',"none");
		toggleLayer('waitlist_div',"none");
		toggleLayer('req_submit_button_div',"block"); // show the submit button
		toggleLayer('step1_link_div', "block");
	}else if(divID == "catalog_div"){
		// show Catalog Request selections, hide Step#1
		toggleLayer('infodiv',"none");
		toggleLayer('catalog_div',"block");
		toggleLayer('reservation_div',"none");
		toggleLayer('houseparty_div',"none");
		toggleLayer('waitlist_div',"none");
		toggleLayer('req_submit_button_div',"block"); // show the submit button
		toggleLayer('step1_link_div', "block");
	}else if(divID == "houseparty_div"){
		// show HouseParty Request selections, hide Step#1
		toggleLayer('infodiv',"none");
		toggleLayer('houseparty_div',"block");
		toggleLayer('waitlist_div',"none");
		toggleLayer('reservation_div',"none");
		toggleLayer('catalog_div',"none");
		toggleLayer('req_submit_button_div',"block"); // show the submit button
		toggleLayer('step1_link_div', "block");
	}else if(divID == "waitlist_div"){
		// show Waitlist Request selections, hide Step#1
		toggleLayer('infodiv',"none");
		toggleLayer('waitlist_div',"block");
		toggleLayer('houseparty_div',"none");
		toggleLayer('reservation_div',"none");
		toggleLayer('catalog_div',"none");
		toggleLayer('req_submit_button_div',"block"); // show the submit button
		toggleLayer('step1_link_div', "block");
	}else{
		alert("didn't toggle anything..");
	}
	setprogress_bar();
}

function togglerefer(divID){
	if(divID == "login_div"){
		toggleLayer('login_div', "block");
		toggleLayer('step2_link_div',"block");
		toggleLayer('reg_div', "none");
		toggleLayer('new_div', "none");
		document.getElementById('alreadyreg').checked = false;
		document.getElementById('btnnew').checked = false;
		//document.getElementById('prog_ind_img').width = "30%";
	}else if(divID == "reg_div"){
		toggleLayer('login_div', "none");		
		toggleLayer('reg_div', "block");
		toggleLayer('step2_link_div',"block");
		toggleLayer('new_div', "none");
		toggleLayer('next_btn_lnk',"block");
		document.getElementById('btnlogin').checked = false;
		document.getElementById('btnnew').checked = false;
		//document.getElementById('prog_ind_img').width = "20%";
	}else if(divID == "new_div"){
		toggleLayer('login_div', "none");
		toggleLayer('reg_div', "none");
		toggleLayer('new_div', "block");
		toggleLayer('step2_link_div',"block");
		document.getElementById('alreadyreg').checked = false;
		document.getElementById('btnlogin').checked = false;
		//document.getElementById('prog_ind_img').width = "20%";
	}else if(divID == "maindiv"){
		// show Referal Form
		toggleLayer('maindiv',"block");
		toggleLayer('infodiv',"none");
		toggleLayer('ref_submit_button_div', "block");
		toggleLayer('step2_link_div',"none");
	}else if(divID == "more_friends_div"){
		// we are adding another friend form - just toggle next one
		var i = 2;
		var divid = "friend" + i;
		while(i <= 4){
			var lstat = getLayerStatus(divid);
			if(lstat == "block"){
				// move to next one for display
				i++;
				divid = "friend" + i;
			}else{
				// show this and exit
				toggleLayer(divid,"block");
				// if we've just toggled #4, then hide the 'add' link
				if(i == 4){
					toggleLayer('more_friends_div',"none");
				}
				i = 5;
			}
		}
	}else{
		alert("didn't toggle anything..");
	}
	//setprogress_bar();
}

function setprogress_bar(progressval){
	// set the progess bar
	var progress = 0;
	var cidval = readcookie("cid");
	if(cidval.length > 0){
		progress = 50;
	}
	if(progressval != null){
		if(progressval > 0){
			progress = progressval;
		}
	}else{
		if(document.getElementById('btnlogin') != null){
			// ok - we're at the request screen
			// calculate our progress
			if(document.getElementById('btnlogin').checked){
				// we are choosing login option - only 3 steps
				progress = 10;
				if(document.getElementById('UserName').value != ""){
					progress = progress + 10;
				}
				if(document.getElementById('UserPass').value != ""){
					progress = progress + 10;
				}
				//alert("[login] Progress => " + progress);
			}
			if(document.getElementById('alreadyreg').checked){
				// we are choosing possible match cases option - up to 5 steps
				progress = 5;
				if(document.getElementById('useremail').value != ""){
					progress = progress + 7;
				}
				if(document.getElementById('userid').value != ""){
					progress = progress + 7;
				}
				if(document.getElementById('userlname').value != ""){
					progress = progress + 5;
				}
				if(document.getElementById('useremail2').value != ""){
					progress = progress + 5;
				}
				if(document.getElementById('userzip').value != ""){
					progress = progress + 5;
				}
				//alert("[alreadyreg] Progress => " + progress);
			}
			if(document.getElementById('btnnew').checked){
				// we are choosing New Registration option, possible match case - up to 5 steps
				progress = 5;
				if(document.getElementById('fname').value != ""){
					progress = progress + 2;
				}
				if(document.getElementById('lname').value != ""){
					progress = progress + 2;
				}
				if(document.getElementById('email').value != ""){
					progress = progress + 2;
				}
				if(document.getElementById('email5').value != ""){
					progress = progress + 2;
				}
				if(document.getElementById('address1').value != ""){
					progress = progress + 2;
				}
				if(document.getElementById('city').value != ""){
					progress = progress + 1;
				}
				if(document.getElementById('state').value != ""){
					progress = progress + 1;
				}
				if(document.getElementById('contactcountryddl').SelectedIndex > 0){
					progress = progress + 1;
				}
				if(document.getElementById('zip').value != ""){
					progress = progress + 1;
				}
				if(document.getElementById('dayphone').value != ""){
					progress = progress + 1;
				}
				//alert("[new] Progress => " + progress);
			}
			if(document.getElementById('HPPARTYMONTH') != null){
				// we have House Party Request
				if(document.getElementById('HPPARTYMONTH').SelectedIndex > 0){
					progress++;
				}
				if(document.getElementById('HPPARTYDAY').SelectedIndex > 0){
					progress++;
				}
				if(document.getElementById('HPPARTYYEAR').SelectedIndex > 0){
					progress++;
				}
				if(document.getElementById('HPSIZE').SelectedIndex > 0){
					progress++;
				}
				if(document.getElementById('HPVENUE').SelectedIndex > 0){
					progress++;
				}
			}
			if(document.getElementById('cbinterests') != null){
				// we have Catalog Request
				if(document.getElementById('cbinterests').SelectedIndex > 0){
					progress += 2;
				}
				if(document.getElementById('cbtravelwith').SelectedIndex > 0){
					progress += 2;
				}
			}
			if(document.getElementById('request_choice') != null){
				// we have Catalog Request
				if(document.getElementById('request_choice').SelectedIndex > 0){
					progress += 5;
				}
			}
			if(document.getElementById('memoNotes') != null){
				// we have Waitlist Request
				if(document.getElementById('memoNotes').value != ""){
					progress += 5;
				}
			}
		}
		var parts = document.location.href.split('/');
		var filename = parts[parts.length-1];
		if(filename.indexOf("contest-entry.aspx") >= 0){
			if(window.location.search.indexOf("contest=1") >= 0){
				// we are registering a New User for Contest Entry
				progress = 25;
				// let's see where we are
				if((getLayerStatus("sorry_not_system") == "block")||(getLayerStatus("sorry_not_system") == "")){
					
					progress = 35;
					toggleLayer('sorry_not_system',"none");
					if(document.getElementById('newlabel') != null){
						document.getElementById('newlabel').innerHTML = "<H3>CONTEST ENTRY REGISTRATION.</H3>";
					}
				}else if((getLayerStatus("think_know_you") == "block")||(getLayerStatus("think_know_you") == "")){
					// Security questions #1
					progress = 45;
					if(document.getElementById('secmsg') != null){
						document.getElementById('secmsg').innerHTML = "<H3>CONTEST ENTRY REGISTRATION.</H3>";
					}
				}else if((getLayerStatus("think_know_you2") == "block")||(getLayerStatus("think_know_you2") == "")){
					// Security questions #2
					progress = 45;
					if(document.getElementById('clientsecmsg') != null){
						document.getElementById('clientsecmsg').innerHTML = "<H3>CONTEST ENTRY REGISTRATION.</H3>";
					}
				}else if((getLayerStatus("think_know_you3") == "block")||(getLayerStatus("think_know_you3") == "")){
					// Security questions #1
					progress = 35;
					if(document.getElementById('multimsg') != null){
						document.getElementById('multimsg').innerHTML = "<H3>CONTEST ENTRY REGISTRATION.</H3>";
					}	
				}
			}else{
				progress = 50;
			}
		}else{
			if(window.location.search.indexOf("noreq=1") >= 0){
				// we are at final registration screen for New User
				// they requested a House Party but are not travellers
				progress = 75;
			}
			if(window.location.search.indexOf("fk=") >= 0){
				// we are at multi-match registration screen
				progress = 50;
			}
			if(document.getElementById('secuserid') != null){
				// maybe we're at the Security Questions
				// set to 75%
				progress = 75;
			}
			if(document.getElementById('suclabel') != null){
				// maybe we're at the final Success Screen
				// set to 100% if so
				if(document.getElementById('suclabel').innerHTML.indexOf("Activate") > 0){
					progress = 100;
				}
			}
		}
	}
	var percent_pixels = (progress/100) * 301;
	//alert("Setting progress to " + progress + "% => " + percent_pixels + " pixels");
	document.getElementById('prog_ind_img').width = percent_pixels;
}

function togglepwreset(){
	// turns 'off' the pwreset form
	// and displays Msg for "Please wait..."
	//alert("Toggling pwreset form..." + document.getElementById('pwresetform'));
	toggleLayer('pwresetform',"none");
	if(document.getElementById('PWResetBtn').value == "Retrieve Your Secret Question For Verification"){
		document.getElementById('Msg').innerHTML = "Retrieving secret question, please wait...";
	}else{
		document.getElementById('Msg').innerHTML = "Resetting password, please wait...";
	}
}

function togglelogin(){
	// turns 'off' the pwreset form
	// and displays Msg for "Please wait..."
	//alert("Toggling pwreset form..." + document.getElementById('pwresetform'));
	toggleLayer('loginform',"none");
	if(document.getElementById('Msg') != null){
		document.getElementById('Msg').innerHTML = "Logging in, please wait...";
	}
}

function toggleLayer(whichLayer, onoff){
	// onoff = "" - hide layer
	// onoff = "block" = show layer
	if (document.getElementById){
		// this is the way the standards work
		if(document.getElementById(whichLayer) != null){
			var style2 = document.getElementById(whichLayer).style;
			style2.display = onoff;
		}
	}else if (document.all){
		// this is the way old msie versions work
		if(document.all[whichLayer] != null){
			var style2 = document.all[whichLayer].style;
			style2.display = onoff;
		}
	}else if (document.layers){
		// this is the way nn4 works
		if(document.layers[whichLayer] != null){
			var style2 = document.layers[whichLayer].style;
			style2.display = onoff;
		}
	}
}

function getLayerStatus(whichLayer){
	// returns state of layer - "block" or "none"
	if (document.getElementById){
		// this is the way the standards work
		if(document.getElementById(whichLayer) != null){
			var style2 = document.getElementById(whichLayer).style;
			return style2.display;
		}
	}else if (document.all){
		// this is the way old msie versions work
		if(document.all[whichLayer] != null){
			var style2 = document.all[whichLayer].style;
			return style2.display;
		}
	}else if (document.layers){
		// this is the way nn4 works
		if(document.layers[whichLayer] != null){
			var style2 = document.layers[whichLayer].style;
			return style2.display;
		}
	}
	return "none";
}

function pass_check(str) {
	if(str == ""){
		// no arg passed - look for password field value
		if(document.getElementById('password') != null){
			str = document.getElementById('password').value;
		}
	}
	// check the length first
	if((str.length < 8)||(str.length > 32)){
		// password length incorrect
		alert("Passwords must be 8-32 characters long - please try another password.");
		return false;
	}
	// next look for at least one special character
	var i;
	var digit_ok = false;
	var letter_ok = false;
	for(i=0; i<str.length; i++){
		// is this a special character?
		var ch_code = str.charCodeAt(i); // get's the ASCII code value
		if((ch_code >= 48)&&(ch_code <= 57)){
			// found at least 1 digit - set digit_ok
			digit_ok = true;
		}else if(((ch_code >= 65)&&(ch_code <= 90))||((ch_code >= 97)&&(ch_code <= 122))){
			// found A-Z or a-z
			letter_ok = true;
		}else{
			// not a number or a letter - illegal character
			alert("Passwords MUST:\nContain at least one letter and one number\nContain no symbols or special characters\nPlease try another password.");
			return false;
		}
	}
	if((digit_ok == false)||(letter_ok == false)){
		alert("Passwords MUST:\nContain at least one letter and one number\nContain no symbols or special characters\nPlease try another password.");
		return false;
	}
	return true;	
}

function echeck(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		//alert("Checking email address = " + str);
		
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID");
		    return false;
		 }
		
		 //if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID");
		    //return false;
		 //}
		 
		 if ((str.indexOf(" ") > 0)&&(str.indexOf(" ") < lstr-1)){
		   //alert("Space in middle of address");
		    return false;
		 }
 		 return true;	
	}

function check_resetemail(){
	if(document.getElementById('useremail').value == ""){
		alert("You MUST supply your Email Address.");
		toggleLayer('pwresetform',"block");
		document.getElementById('Msg').innerHTML = "";
		return false;
	}else if(echeck(document.getElementById('useremail').value) == false){
		// doesn't look like a valid email address
		alert("That doesn't appear to be a valid Email Address.");
		toggleLayer('pwresetform',"block");
		document.getElementById('Msg').innerHTML = "";
		return false;
	}else if(document.getElementById('secret_answer') == null){
		// we're fetching the secret question
		toggleLayer('pwresetform',"none");
		document.getElementById('Msg').innerHTML = "Fetching your Secret Question, please wait...";
		return true;
	}else{
		togglepwreset();
		//document.getElementById('secretquest').innerHTML = "";
		//document.getElementById('PWResetBtn').click();
		return true;
	}
}

function check_login(){
	// checks the fields for Login
	if(document.getElementById('UserName').value == ""){
		alert("You MUST supply your Email Address.");
		if(document.getElementById('Msg') != null){
			//document.getElementById('Msg').innerHTML = "";
		}
		toggleLayer('loginform',"block");
		return false;
	}else if(echeck(document.getElementById('UserName').value) == false){
		// doesn't look like a valid email address
		alert("That doesn't appear to be a valid Email Address.");
		if(document.getElementById('Msg') != null){
			//document.getElementById('Msg').innerHTML = "";
		}
		toggleLayer('loginform',"block");
		return false;
	}else if(document.getElementById('UserPass').value == ""){
		alert("You MUST supply your password.");
		if(document.getElementById('Msg') != null){
			//document.getElementById('Msg').innerHTML = "";
		}
		toggleLayer('loginform',"block");
		return false;
	}else{
		return true;
	}
}

function check_pwreset(){
	// checks the fields for Password Reset
	if(document.getElementById('useremail').value == ""){
		alert("You MUST supply your email address.");
		document.getElementById('Msg').innerHTML = "";
		toggleLayer('pwresetform',"block");
		return false;
	}else if(echeck(document.getElementById('useremail').value) == false){
		// doesn't look like a valid email address
		alert("That doesn't appear to be a valid Email Address.");
		document.getElementById('Msg').innerHTML = "";
		toggleLayer('pwresetform',"block");
		return false;
	}else if(document.getElementById('secret_answer') != null){
		if((document.getElementById('secret_answer').value == "")&&
			 (document.getElementById('secretquest').innerHTML != "")){
			alert("You MUST enter your 'Secret Answer'");
			document.getElementById('Msg').innerHTML = "";
			toggleLayer('pwresetform',"block");
			return false;
		}
	}else{
		return true;
	}
}

function clear_medical(){
	document.getElementById('med2').checked = false;
	document.getElementById('med3').checked = false;
	document.getElementById('med4').checked = false;
	document.getElementById('med5').checked = false;
	document.getElementById('med6').checked = false;
	document.getElementById('med7').checked = false;
	document.getElementById('med8').checked = false;
	document.getElementById('med9').checked = false;
	document.getElementById('med10').checked = false;
	document.getElementById('med11').checked = false;
	document.getElementById('med12').checked = false;
}

function clear_dietary(){
	document.getElementById('dine2').checked = false;
	document.getElementById('dine3').checked = false;
	document.getElementById('dine4').checked = false;
	document.getElementById('dine5').checked = false;
	document.getElementById('dine6').checked = false;
	//document.getElementById('dine7').checked = false;
	//document.getElementById('dine8').checked = false;
	//document.getElementById('dine9').checked = false;
	//document.getElementById('dine10').checked = false;
	document.getElementById('dine11').checked = false;
	document.getElementById('dine12').checked = false;
	//document.getElementById('dine13').checked = false;
}

function check_refer_step1(){
	var url = "https://www.oliviatest.com/profile";
	if(window.location.host == "207.34.147.93"){
		// DEV Server
		url = "https://207.34.147.93/devsite/";
	}else if(window.location.host == "192.168.3.201"){
		// Jonathan DEV
		url = "https://192.168.3.201/oliviadev/";
	}
	// only checks the radio button input fields
	var isok = false;
	if(document.getElementById('btnnew').checked){
		isok = check_newreg();
		// we've just validated new registration
		// let's call QAS here
		if(isok == true){
			var tmp = prowebverify();
		}
		if(document.getElementById('newadd_verified') != null){
			if(document.getElementById('newadd_verified').value != ""){
				return true;
			}else{
				return false;
			}
		}
		return isok;
	}else if(document.getElementById('alreadyreg').checked){
		if(document.getElementById('useremail').value != ""){
			// do ID Reg Check
			return check_idreg();
		}else if(document.getElementById('userlname').value != ""){
			// do LastName/ZIP Check
			return check_zipreg();
		}else{
			// no input info - complain
			alert("You must input either Email/OliviaID or Lastname/Email/Zip information");
			document.getElementById('useremail').focus();
			return false;
		}
	}else if(document.getElementById('btnlogin').checked){
			//Take them right to the login page with a message - we'll redirect them
			// after successful login
			window.location = url + "/login.aspx?referfriend=1";
			return false;
	}
	if(isok == true){
		
	}
	return false;
}

function check_request_step1(){
	// only checks the radio button input fields
	var isok = false;
	if(document.getElementById('btnnew').checked){
		isok = check_newreg();
		// we've just validated new registration
		// let's call QAS here
		if(isok == true){
		//alert("Calling handleResponse");
			if(handleResponse() == true){
				//alert("Validated - true");
				return true;
			}else{
				//alert("Validated - false - callToServer");
				return callToServer("Form1");
			}
			//var tmp = prowebverify();
		}
		if(document.getElementById('newadd_verified') != null){
			if(document.getElementById('newadd_verified').value != ""){
				return true;
			}else{
				return false;
			}
		}
		return isok;
	}else if(document.getElementById('alreadyreg').checked){
		if(document.getElementById('useremail').value != ""){
			// do ID Reg Check
			isok = check_idreg();
		}else if(document.getElementById('userlname').value != ""){
			// do LastName/ZIP Check
			isok = check_zipreg();
		}else{
			// no input info - complain
			alert("You must input either Email/OliviaID or Lastname/Email/Zip information");
			document.getElementById('useremail').focus();
			return false;
		}
		if(isok == true){
			// if we're on House Party, ask them to confirm travel status
			var parts = document.location.href.split('/');
			var filename = parts[parts.length-1];
			if(filename.indexOf("request=houseparty") >= 0){
				var cval = confirm("Only past travelers with Olivia can host a House Party - if you've traveled with Olivia before, click OK.");
				if(cval == false){
					// clicked NO - show message
					togglerequest('maindiv');
					document.getElementById('past_travel_msg').innerHTML = "<br><center><b>We're sorry, only past travelers may host a house party.</b></center>";
					toggleLayer("houseparty","none");
					toggleLayer("req_submit_button_div","none");
					toggleLayer("step1_link_div","none");
					return false;
				}else{
					// clicked YES - carry on
					return true;
				}
			}else{
				// just return true
				return isok;
			}
		}else{
			return isok;
		}
	}else if(document.getElementById('btnlogin').checked){
			return check_login();
	}
	if(isok == true){
		
	}
	return false;
}

function check_refer(){
	if(document.getElementById('from_name') != null){
		if(document.getElementById('from_name').value == ""){
			alert("Please supply YOUR full name.");
			document.getElementById('from_name').focus();
			return false;
		}else if(document.getElementById('from_email').value == ""){
			alert("Please supply YOUR email address.");
			document.getElementById('from_email').focus();
			return false;
		}
	}
	var i = 1;
	for (i=1; i<=4; i++){
		var nameobj = "to_name_" + i;
		var emailobj = "to_email_" + i;
		var layerobj = "friend" + i;
		var lstatus = getLayerStatus(layerobj);
		//alert("Layer " + layerobj + " is now - " + lstatus);
		if(lstatus == "none"){
			// layer is hidden - skip it
		}else{
			if(document.getElementById(nameobj) != null){
				if(document.getElementById(nameobj).value == ""){
					alert("Please supply the full name of your friend in position " + i + ".");
					document.getElementById(nameobj).focus();
					return false;
				}else if(document.getElementById(emailobj).value == ""){
					alert("Please supply your friend's email address in position " + i + ".");
					document.getElementById(emailobj).focus();
					return false;
				}
			}
		}
	}
	return true;
}

function check_request(){
	// we are coming from request.aspx
	var cidval = readcookie("cid"); // are we logged in?
	var isok = false;
	if(cidval.length > 0){
		// we're logged, proceed
		isok = true;
	}else if(document.getElementById('btnnew').checked){
		isok = check_newreg();
		if(isok == true){
			// only try this if we passed the field validation
			if(document.getElementById('request_submit').value == "Submit Registration"){
				// House Party for non-traveler - perform QAS - return false here since
				// QAS will auto-submit when complete
				
				if(document.getElementById('newadd_verified') != null){
					if(document.getElementById('newadd_verified').value != ""){
						// ok QAS is done AND we have form validation
						return true;
					}else{
						// no QAS verified address yet, return false to stop submission.
						var tmp = prowebverify();
						return false;
					}
				}
			}
		}
	}else if(document.getElementById('alreadyreg').checked){
		if(document.getElementById('useremail').value != ""){
			// do ID Reg Check
			isok = check_idreg();
		}else if(document.getElementById('userlname').value != ""){
			// do LastName/ZIP Check
			isok = check_zipreg();
		}
	}else if(document.getElementById('btnlogin').checked){
			isok = check_login();
	}
	//alert(document.getElementById('request_submit').value);
	//return false;
	// did we fail on any checks above?
	if(isok == false){
		return false;
	}
	// if not, we carry on
	// now we check for required fields in the request itself
	if(document.getElementById('request_submit').value.indexOf('Reservation') >= 0){
		// let's check the Reservation fields
		if(document.getElementById('request_choice').selectedIndex < 1){
			alert("Please tell us what you are interested in.");
			//document.getElementById('reqcell').style.backgroundColor = "#FF0000";
			document.getElementById('reqcell').style.color = "#FF0000";
			document.getElementById('reqcell').style.fontWeight = "bold";
			return false;
		}else{
			document.getElementById('reqcell').style.color = "#000000";
			document.getElementById('reqcell').style.fontWeight = "normal";
		}
		if(document.getElementById('howdidyouhearcat') != null){
			if(document.getElementById('howdidyouhearcat').selectedIndex <= 0){
				alert("Please tell us how you heard about us.");
				document.getElementById('1cell').style.color = "#FF0000";
				document.getElementById('1cell').style.fontWeight = "bold";
				return false;
			}else if(document.getElementById('howdidyouhearcat').selectedIndex == 5){
				if((document.getElementById('howdidyouhearval').selectedIndex == 1)||
					(document.getElementById('howdidyouhearval').selectedIndex == 2))
				{
					// must input an Olivia ID
					if(document.getElementById('sFriendID') != null){
						if(document.getElementById('sFriendID').value == ""){
							//alert("Please supply the OliviaID of your friend.");
							//document.getElementById('1cell').style.color = "#FF0000";
							//return false;
						}else{
							var isnum = parseFloat(document.getElementById('sFriendID').value);
							if(isNaN(isnum)){
								alert("You MUST provide a numeric value for an Olivia ID.");
								document.getElementById('1cell').style.color = "#FF0000";
								document.getElementById('1cell').style.fontWeight = "bold";
								return false;
							}
						}
					}
				}else if(document.getElementById('howdidyouhearval').selectedIndex == 0){
					alert("Please tell us how you heard about us.");
					document.getElementById('1cell').style.color = "#FF0000";
					document.getElementById('1cell').style.fontWeight = "bold";
					return false;
				}
			}else if(document.getElementById('howdidyouhearcat').selectedIndex == 7){
				if(document.getElementById('sHPWho') != null){	
					if(document.getElementById('sHPWho').value == ""){
						//alert("Please supply the OliviaID of your House Party Host.");
						//document.getElementById('1cell').style.color = "#FF0000";
						//document.getElementById('1cell').style.fontWeight = "bold";
						//return false;
					}else{
						var isnum = parseFloat(document.getElementById('sHPWho').value);
						if(isNaN(isnum)){
							alert("You MUST provide a numeric value for an Olivia ID.");
							document.getElementById('1cell').style.color = "#FF0000";
							document.getElementById('1cell').style.fontWeight = "bold";
							return false;
						}
					}
				}
			}else if(document.getElementById('hhval').value == ""){
				alert("Please tell us how you heard about us.");
				document.getElementById('1cell').style.color = "#FF0000";
				document.getElementById('1cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('1cell').style.color = "#000000";
				document.getElementById('1cell').style.fontWeight = "normal";
			}
		}
		
		if(document.getElementById('RS_CONTACT_MARKETING.MAINID') != null){
			if(document.getElementById('RS_CONTACT_MARKETING.MAINID').selectedIndex < 1){
				alert("Please tell us if any of the announcements listed below influenced your decision to contact Olivia today.");
				document.getElementById('2cell').style.color = "#FF0000";
				document.getElementById('2cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('2cell').style.color = "#000000";
				document.getElementById('2cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('LUDDATA.LUDCHARVAL1') != null){
			if(document.getElementById('LUDDATA.LUDCHARVAL1').selectedIndex < 1){
				alert("Please tell us when do you plan to purchase your next vacation.");
				document.getElementById('3cell').style.color = "#FF0000";
				document.getElementById('3cell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('3cell').style.color = "#000000";
				document.getElementById('3cell').style.fontWeight = "normal";
			}
		}
		if(document.getElementById('sPC').selectedIndex < 1){
			alert("Please tell us what your preferred method of communication is.");
			document.getElementById('4cell').style.color = "#FF0000";
			document.getElementById('4cell').style.fontWeight = "bold";
			return false;
		}else{
			document.getElementById('4cell').style.color = "#000000";
			document.getElementById('4cell').style.fontWeight = "normal";
		}
		if(document.getElementById('RS_CONTACT_INFO.BEST_CALL_TIME').selectedIndex < 1){
			alert("Please tell us when the best time to call you is.");
			document.getElementById('5cell').style.color = "#FF0000";
			document.getElementById('5cell').style.fontWeight = "bold";
			return false;
		}else{
			document.getElementById('5cell').style.color = "#000000";
			document.getElementById('5cell').style.fontWeight = "normal";
		}
		//if(document.getElementById('LUDDATA.LUDCHARVAL2') != null){
		//	if(document.getElementById('LUDDATA.LUDCHARVAL2').selectedIndex < 1){
		//		alert("Please tell us the specific trip in which you are interested.");
		//		document.getElementById('5cell').style.color = "#FF0000";
		//		document.getElementById('5cell').style.fontWeight = "bold";
		//		return false;
		//	}else{
		//		document.getElementById('5cell').style.color = "#000000";
		//		document.getElementById('5cell').style.fontWeight = "normal";
		//	}
		//}
	}else if(document.getElementById('request_submit').value.indexOf('House Party') >= 0){
		if(document.getElementById('norequest').value == 0){
			if((document.getElementById('HPPARTYMONTH').selectedIndex < 1)||
				(document.getElementById('HPPARTYDAY').selectedIndex < 1)||
				(document.getElementById('HPPARTYYEAR').selectedIndex < 1))
			{
				alert("Please tell us DAY/MONTH/YEAR of your House Party.");
				document.getElementById('whpcell').style.color = "#FF0000";
				document.getElementById('whpcell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('whpcell').style.color = "#000000";
				document.getElementById('whpcell').style.fontWeight = "normal";
			}
			if(document.getElementById('HPSIZE').selectedIndex < 1){
				alert("Please tell us how many guests you plan to have.");
				document.getElementById('howcell').style.color = "#FF0000";
				document.getElementById('howcell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('howcell').style.color = "#000000";
				document.getElementById('howcell').style.fontWeight = "normal";
			}
			if(document.getElementById('HPVENUE').selectedIndex < 1){
				alert("Please tell us where you plan to host your party.");
				document.getElementById('wherecell').style.color = "#FF0000";
				document.getElementById('wherecell').style.fontWeight = "bold";
				return false;
			}else{
				document.getElementById('wherecell').style.color = "#000000";
				document.getElementById('wherecell').style.fontWeight = "normal";
			}
		}
	}else if(document.getElementById('request_submit').value.indexOf('Catalog') >= 0){
		if(document.getElementById('cbinterests').selectedIndex < 1){
			alert("Please tell us where you plan to host your party.");
			document.getElementById('treqcell').style.color = "#FF0000";
			document.getElementById('treqcell').style.fontWeight = "bold";
			return false;
		}else{
			document.getElementById('treqcell').style.color = "#000000";
			document.getElementById('treqcell').style.fontWeight = "normal";
		}
		if(document.getElementById('cbtravelwith').selectedIndex < 1){
			alert("Please tell us where you plan to host your party.");
			document.getElementById('twreqcell').style.color = "#FF0000";
			document.getElementById('twreqcell').style.fontWeight = "bold";
			return false;
		}else{
			document.getElementById('twreqcell').style.color = "#000000";
			document.getElementById('twreqcell').style.fontWeight = "normal";
		}
	}else if(document.getElementById('request_submit').value.indexOf('Waitlist') >= 0){
		//if(document.getElementById('memoNotes').value == ""){
		//	alert("Please tell us your query.");
		//	document.getElementById('wlcell').style.color = "#FF0000";
		//document.getElementById('wlcell').style.fontWeight = "bold";
		//	return false;
		//}else{
		//	document.getElementById('wlcell').style.color = "#000000";
		//	document.getElementById('wlcell').style.fontWeight = "normal";
		//}
	}
	return true;
}

function check_multino(){
	// checks for radio selection from Multi Match Reg screen
	// if they click 'No, this is me'
	if(document.getElementById('multilistradio') != null){
		if(document.getElementById('multilistradio').checked == false){
			alert("You MUST select who you are from the list.");
			return false;
		}
	}
	return true;
}

function check_idreg(){
	// checks the fields for Email/ContactID signup
	var isnum = parseFloat(document.getElementById('userid').value)
	//alert("IsNum = " + isnum);
	if(document.getElementById('useremail').value == ""){
		alert("You MUST supply your Email Address.");
		document.getElementById('useremail').focus();
		return false;
	}else if(!echeck(document.getElementById('useremail').value)){
		// doesn't look like a valid email address
		alert("That doesn't appear to be a valid Email Address.");
		document.getElementById('useremail').focus();
		return false;	
	}else if(document.getElementById('userid').value == ""){
		alert("You MUST supply your Olivia ID. This can be found on your mailing card.");
		document.getElementById('userid').focus();
		return false;
	}else if(isNaN(isnum)){
		alert("Only enter the numeric portion of your Olivia ID");
		document.getElementById('userid').focus();
		return false;
	}else{
		return true;
	}
}

function check_zipreg(){
	// checks fields for Zip/Lastname/Email signup
	if(document.getElementById('userlname').value == ""){
		alert("You MUST supply your Last Name.");
		document.getElementById('userlname').focus();
		return false;
	}else if(document.getElementById('useremail2').value == ""){
		alert("You MUST supply your Email Address.");
		document.getElementById('useremail2').focus();
		return false;
	}else if(!echeck(document.getElementById('useremail2').value)){
		// doesn't look like a valid email address
		alert("That doesn't appear to be a valid Email Address.");
		document.getElementById('useremail2').focus();
		return false;
	}else if(document.getElementById('userzip').value == ""){
		alert("You MUST supply your ZIP Code.");
		document.getElementById('userzip').focus();
		return false;
	}else{
		return true;
	}
}

function check_newreg(){
//alert("Checking new registration info");
	if(document.getElementById('btnnew') != null){
		if(document.getElementById('btnnew').checked){
			if(document.getElementById('fname').value == ""){
				alert("You MUST supply your First Name.");
				document.getElementById('fname').focus();
				return false;
			}else if(document.getElementById('lname').value == ""){
				alert("You MUST supply your Last Name.");
				document.getElementById('lname').focus();
				return false;
			}else if(document.getElementById('address1').value == ""){
				alert("You MUST supply your Address - Street/No.");
				document.getElementById('address1').focus();
				return false;
			}else if(document.getElementById('city').value == ""){
				alert("You MUST supply your Address - City.");
				document.getElementById('city').focus();
				return false;
			}else if(document.getElementById('state').value == ""){
				alert("You MUST supply your Address - State.");
				document.getElementById('state').focus();
				return false;
			}else if(document.getElementById('zip').value == ""){
				alert("You MUST supply your Address - ZIP Code.");
				document.getElementById('zip').focus();
				return false;
			}else if(document.getElementById('contactcountryddl').value == ""){
				alert("You MUST supply your Address - Country.");
				document.getElementById('contactcountryddl').focus();
				return false;
			}else if(document.getElementById('gender').value == ""){
				alert("You MUST supply your Gender.");
				document.getElementById('gender').focus();
				return false;
			}else if(document.getElementById('email') != null){
				if(document.getElementById('email').value == ""){
					alert("You MUST supply your Email Address.");
					document.getElementById('email').focus();
					return false;
				}else if(echeck(document.getElementById('email').value) == false){
					alert("Your Email Address does not look valid.");
					document.getElementById('email').focus();
					return false;
				}else if(document.getElementById('email').value != document.getElementById('email5').value){
					alert("Email Address mismatch.");
					document.getElementById('email').focus();
					return false;
				}
			}
		}
	}
	if(document.getElementById('alreadyreg') != null){
		if(document.getElementById('alreadyreg').checked){
			if(document.getElementById('useremail').value != ""){
				// do ID Reg Check
				if(check_idreg() == false){
					return false;
				}
			}else if(document.getElementById('userlname').value != ""){
				// do LastName/ZIP Check
				if(check_zipreg() == false){
					return false;
				}
			}
		}
	}
	if(document.getElementById('btnlogin') != null){
		if(document.getElementById('btnlogin').checked){
			if(check_login() == false){
				return false;
			}
		}
	}
	
	if(document.getElementById('btnnew') != null){
		// we are coming from request.aspx
		// don't check for password/secret question
		return true;
	}else{
		if(document.getElementById('password').value == ""){
			alert("You MUST supply a Password.");
			document.getElementById('password').focus();
			return false;
		}else if(document.getElementById('password').value != document.getElementById('confirm_password').value){
			alert("Your Password fields don't match - please ensure you type the same password into both fields to confirm your password.");
			document.getElementById('password').focus();
			return false;
		}else if(pass_check(document.getElementById('password').value) == false){
			return false;
		}else if(document.getElementById('secretquestion').options[document.getElementById('secretquestion').selectedIndex].value == ""){
			alert("You MUST choose a Secret Question.");
			return false;
		}else if(document.getElementById('secretanswer').value == ""){
			alert("You MUST provide an answer to your Secret Question.");
			document.getElementById('secretanswer').focus();
			return false;
		}else{
			// now call the ProWeb Verification
			//alert("Calling callToServer!");
			//var add_verify = prowebverify();
			if(handleResponse() == true){
				return true;
			}else{
				return callToServer("Form1");
			}
		}
	}
}

function check_secreg(){
	// we need to have at least 2 of the 3 questions answered
	var haveminquest = false;
	var questcount = 0;
	if(document.getElementById('passport_number') != null){
		if(document.getElementById('passport_number').value != ""){
			questcount++;
		}
	}
	if(document.getElementById('birthdate') != null){
		if(document.getElementById('birthdate').value != ""){
			questcount++;
		}
	}
	if(document.getElementById('recent_trip').value != null){
		if(document.getElementById('recent_trip').value != ""){
			questcount++;
		}
	}
	if(questcount >= 2){
		haveminquest = true;
	}
	if(haveminquest){
		// ok, now let's check the other fields
		if(document.getElementById('secpassword').value == ""){
			alert("You MUST supply a Password.");
			document.getElementById('secpassword').focus();
			return false;
		}else if(document.getElementById('secpassword').value != document.getElementById('confirm_secpassword').value){
			alert("Your Password fields don't match - please ensure you type the same password into both fields to confirm your password.");
			document.getElementById('secpassword').focus();
			return false;
		}else if(pass_check(document.getElementById('secpassword').value) == false){
			return false;
		}else if(document.getElementById('sec_secretquestion').options[document.getElementById('sec_secretquestion').selectedIndex].value == ""){
			alert("You MUST choose a Secret Question.");
			return false;
		}else if(document.getElementById('sec_secretanswer').value == ""){
			alert("You MUST provide an answer to your Secret Question.");
			document.getElementById('sec_secretanswer').focus();
			return false;
		}else{
			return true;
		}
	}else{
		alert("You MUST supply at least 2 of the following:\nPassport Number\nBirth Date\nLast Olivia Trip");
		return false;
	}	
}

function check_csecreg(){
	if(document.getElementById('clientsecaddress1').value == ""){
		alert("You MUST supply your Street Number.");
		document.getElementById('clientsecaddress1').focus();
		return false;
	}else if(document.getElementById('clientpassword').value == ""){
		alert("You MUST supply a Password.");
		document.getElementById('clientpassword').focus();
		return false;
	}else if(document.getElementById('clientpassword').value != document.getElementById('clientcpassword').value){
		alert("Your Password fields don't match - please ensure you type the same password into both fields to confirm your password.");
		document.getElementById('clientpassword').focus();
		return false;
	}else if(pass_check(document.getElementById('clientpassword').value) == false){
			return false;
	}else if(document.getElementById('clientsecretquestion').options[document.getElementById('clientsecretquestion').selectedIndex].value == ""){
		alert("You MUST choose a Secret Question.");
		return false;
	}else if(document.getElementById('clientsecretanswer').value == ""){
		alert("You MUST provide an answer to your Secret Question.");
		document.getElementById('clientsecretanswer').focus();
		return false;
	}else{
		return true;
	}
}

function check_address_submit(){
	toggleLayer('update_btn',"none");
	if(document.getElementById('address1').value == ""){
		alert("You MUST supply your Street Address");
		document.getElementById('address1').focus();
		toggleLayer('update_btn',"block");
		return false;
	}else if(document.getElementById('city').value == ""){
		alert("You MUST supply your City.");
		document.getElementById('city').focus();
		toggleLayer('update_btn',"block");
		return false;
	}else if(document.getElementById('state').value == ""){
		alert("You MUST supply your State.");
		document.getElementById('state').focus();
		toggleLayer('update_btn',"block");
		return false;
	}else if(document.getElementById('zip').value == ""){
		alert("You MUST supply your ZIP Code.");
		document.getElementById('zip').focus();
		toggleLayer('update_btn',"block");
		return false;
	}else if(document.getElementById('contactcountry').options[document.getElementById('contactcountry').selectedIndex].value == ""){
		alert("You MUST supply your Country.");
		document.getElementById('contactcountry').focus();
		toggleLayer('update_btn',"block");
		return false;
	}else{
		if(handleResponse() == true){
			return true;
		}else{
			return callToServer("Form1");
		}
	}
}

function draw_howdidyouhear(){
	var questions = new Array(
						new Array(
							new Array("Select One",""),
							new Array("CNBC","CNBC"),
							new Array("CNN","CNN"),
							new Array("ESPN","ESPN"),
							new Array("Local TV news","Local TV news"),
							new Array("LOGO TV","LOGO TV"),
							new Array("The L Word","The L Word"),
							new Array("New York Times","New York Times"),
							new Array("Regional LGBT newspaper","Regional LGBT newspaper"),
							new Array("Regional mainstream newspaper","Regional mainstream newspaper"),
							new Array("The Travel Channel","The Travel Channel"),
							new Array("Twist Radio","Twist Radio"),
							new Array("USA Today","USA Today"),
							new Array("Wall Street Journal","Wall Street Journal")
						),
						new Array(
							new Array("Select One",""),
							new Array("Olivia e-newsletter","Olivia e-newsletter"),
							new Array("Olivia entertainer","Olivia entertainer"),
							new Array("Olivia.com","Olivia.com"),
							new Array("Olivia-sponsored organization","Olivia-sponsored organization"),
							new Array("Orbitz","Orbitz"),
							new Array("Other Olivia e-mail","Other Olivia e-mail"),
							new Array("Travelocity","Travelocity"),
							new Array("Web search engine","Web search engine")
						),
						new Array(
							new Array("Select One",""),
							new Array("Advocate","Advocate"),
							new Array("Curve Magazine","Curve Magazine"),
							new Array("Damron","Damron"),
							new Array("Girlfriends","Girlfriends"),
							new Array("HRC Equality Magazine","HRC Equality Magazine"),
							new Array("Orbitz","Orbitz"),
							new Array("LOGO TV","LOGO TV"),
							new Array("Twist Radio","Twist Radio")
						),
						new Array(
							new Array("Select One",""),
							new Array("Entertainer event","Entertainer event"),
							new Array("Gay Games","Gay Games"),
							new Array("Gay & Lesbian Alliance Against Defamation Media Awards","Gay & Lesbian Alliance Against Defamation Media Awards"),
							new Array("Human Rights Campaign event / gala","Human Rights Campaign event / gala"),
							new Array("LGBT Kids and Family event","LGBT Kids and Family event"),
							new Array("LPGA event","LPGA event"),
							new Array("National Gay & Lesbian Task Force event","National Gay & Lesbian Task Force event"),
							new Array("National Center for Lesbian Rights event / gala","National Center for Lesbian Rights event / gala"),
							new Array("Pride event","Pride event"),
							new Array("Provincetown event","Provincetown event"),
							new Array("Regional event","Regional event"),
							new Array("WNBA event","WNBA event"),
							new Array("Other LGBT Non-Profit event","Other LGBT Non-Profit event")
						),
						new Array(
							new Array("Select One",""),
							new Array("Olivia traveler","Olivia traveler"),
							new Array("Friend","Friend"),
							new Array("Travel agent","Travel agent")
						),
						new Array(
							new Array("Select One",""),
							new Array("Special mailing","Special mailing"),
							new Array("Spring 2005 catalogue","Spring 2005 catalogue"),
							new Array("Summer 2005 catalogue","Summer 2005 catalogue"),
							new Array("Fall 2005 catalogue","Fall 2005 catalogue"),
							new Array("Winter / Spring 2006 catalogue","Winter / Spring 2006 catalogue"),
							new Array("Spring / Summer 2006 magalogue","Spring / Summer 2006 magalogue")
						),
						new Array(
							new Array("",""),
							new Array("",""),
							new Array("","")
						)
					);
	var obj = document.getElementById('howdidyouhearcat');
	var valobj = document.getElementById('howdidyouhearval');
	if(obj.selectedIndex == 7){
		if(document.getElementById('sHP_div') != null){
			// show the House Party ID field
			toggleLayer('sHP_div',"block");
			// hide the Friend ID field
			toggleLayer('sREF_div',"none");
			toggleLayer('howhear_div',"none");
		}
	}else{		
		if(document.getElementById('sHP_div') != null){
			// hide the House Party ID field
			toggleLayer('sHP_div',"none");
			toggleLayer('howhear_div',"block");
		}
		// populate secondary dropdown list
		fillSelectFromArray(valobj,((obj.selectedIndex == -1) ? null : questions[obj.selectedIndex-1]));
		// hide the House Party other fields
		if(document.getElementById('sREF_div') != null){
			if(obj.selectedIndex == 5){
				// ok, Referral is selected - check secondary one
				if((valobj.selectedIndex == 1)||(valobj.selectedIndex == 2)){
					// show the friend ID field
					toggleLayer('sREF_div',"block");
				}else{
					// hide the friend ID field
					toggleLayer('sREF_div',"none");
				}
			}else{
				toggleLayer('sREF_div',"none");
			}
		}
	}
}

function handle1b(){
	// handles onchange event for the secondary drop-down list
	var obj = document.getElementById('howdidyouhearcat');
	var valobj = document.getElementById('howdidyouhearval');
	//alert("Selected = " + obj.selectedIndex);
	if(obj.selectedIndex == 5){
		// ok, Referral is selected - check secondary one
		if((valobj.selectedIndex == 1)||(valobj.selectedIndex == 2)){
			// show the friend ID field
			toggleLayer('sREF_div',"block");
		}else{
			// hide the friend ID field
			toggleLayer('sREF_div',"none");
		}
		toggleLayer('sHP_div',"none");
	}else if(obj.selectedIndex == 7){
		// ok, House Party is selected - check secondary one
		// hide the friend ID field
		toggleLayer('sREF_div',"none");
		toggleLayer('sHP_div',"block");
	}else{
		// hide both fields
		toggleLayer('sREF_div',"none");
		toggleLayer('sHP_div',"none");
	}
	//alert("setting hhval = " + valobj.options[valobj.selectedIndex].value);
	document.getElementById('hhval').value = valobj.options[valobj.selectedIndex].value;
}

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
	var i, j;
	var prompt;
 	// empty existing items
 	for (i = selectCtrl.options.length; i >= 0; i--) {
 		selectCtrl.options[i] = null; 
 	}
 	prompt = (itemArray != null) ? goodPrompt : badPrompt;
 	if (prompt == null) {
 		j = 0;
 	} else {
 		selectCtrl.options[0] = new Option(prompt);
 		j = 1;
 	}
 	if (itemArray != null) {
 		// add new items
 		for (i = 0; i < itemArray.length; i++) {
 			selectCtrl.options[j] = new Option();
 			//selectCtrl.options[j] = new Option(itemArray[i][0]);
 			if (itemArray[i][1] != null) {
 				selectCtrl.options[j].text = itemArray[i][0];
 				selectCtrl.options[j].value = itemArray[i][1]; 
 			}
 			j++;
 		}
 		// select first item (prompt) for sub list
 		selectCtrl.options[0].selected = true;
 	}
}
