/* form submitted only once function */
//<![CDATA[
	counter = 0;
	function monitor() {
		counter++;
		if(counter > 1) { return false; }
		return true;
	}
//]]>

/* declare global variable to keep track of opened slide down window */
//<![CDATA[
	var current_edsubpanel = '';
//]]>

function trim(str) {
  	return str.replace(/^\s+|\s+$/g, '');
}

function webinar_submit(eventid, key, completePage) {
	var valid = true;
	
	if(trim(document.thisform.first_name.value) == "") {
		alert("First Name can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.last_name.value) == "") {
		alert("Last Name can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.company.value) == "") {
		alert("Company can not be blank.");
		valid = false;
	}

	else if(trim(document.thisform.title.value) == "") {
		alert("Title can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.email.value) == "") {
		alert("Email can not be blank.");
		valid = false;
	} 

	else if(!isEmail(document.thisform.email.value)) {
		alert("Please enter a valid email.");
		valid = false;
	}
	
	else if(trim(document.thisform.phone.value) == "") {
		alert("Phone can not be blank.");
		valid = false;
	}
	
	/*
	else if(trim(document.thisform.street.value) == "") {
		alert("Address can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.city.value) == "") {
		alert("City can not be blank.");
		valid = false;
	}
	*/
	else if(trim(document.thisform.state.value) == "") {
		alert("State can not be blank.");
		valid = false;
	}

	else if(trim(document.thisform.country.value) == "") {
		alert("Country can not be blank.");
		valid = false;
	}

	else if(trim(document.thisform.fi_q1_a.value) == "") {
		alert("Please indicate where you heard about the webinar.");
		valid = false;
	}

	else if(trim(document.thisform.agents.value) == "") {
		alert("Please indicate how many agents you have across all call centers.");
		valid = false;
	}
	
	/*
	else if(trim(document.thisform.zip.value) == "") {
		alert("Zip can not be blank.");
		valid = false;
	}
	*/
		
	if(valid) {
		var f = document.thisform.first_name.value;
		var l = document.thisform.last_name.value;
		var e = document.thisform.email.value;
		var c = document.thisform.company.value;
		document.thisform.target = "_blank";
		if(eventid != "") {	
			document.thisform.retURL.value = "https://event.on24.com/interface/registration/autoreg/index.html?eventid="+eventid+"&sessionid=1&key="+key+"&firstname="+f+"&lastname="+l+"&email="+e+"&company="+c;
		}
		document.thisform.submit();

		if (completePage != '') {
			parent.iframewebinar.location.href = completePage + "?eventid="+eventid+"&key="+key+"&fname="+f+"&lname="+l+"&email="+e+"&comp="+c;
		}
	}
}

function roundtable_submit() {
	var valid = true;

	if(trim(document.thisform.first_name.value) == "") {
		alert("First Name can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.last_name.value) == "") {
		alert("Last Name can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.title.value) == "") {
		alert("Title can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.company.value) == "") {
		alert("Company can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.email.value) == "") {
		alert("Email can not be blank.");
		valid = false;
	} 

	else if(!isEmail(document.thisform.email.value)) {
		alert("Please enter a valid email.");
		valid = false;
	}
	
	else if(trim(document.thisform.phone.value) == "") {
		alert("Phone can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.street.value) == "") {
		alert("Address can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.city.value) == "") {
		alert("City can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.state.value) == "") {
		alert("State can not be blank.");
		valid = false;
	}
	
	else if(trim(document.thisform.zip.value) == "") {
		alert("Zip can not be blank.");
		valid = false;
	}
		
	if(valid) {
		document.thisform.submit();
	}
}

