<!--

function getFormType(name)
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function initForm()
{
	document.getElementById("header1").style.display="inline";
	document.getElementById("header2").style.display="none";
	document.getElementById("form-tab1").style.display="inline";
	document.getElementById("form-tab2").style.display="none";
	document.getElementById("form-tab3").style.display="none";
	document.getElementById("form-button1").style.display="inline";
	document.getElementById("form-button2").style.display="none";
	document.getElementById("form-button3").style.display="none";
	document.getElementById("form_type").value="short";
	initSetErrors();
}

function fullFormPage1()
{
	_hbPageView('SUBSCRIBE_PREVIOUS1', '/ciscolivevirtual_veplatform/REGISTRATION/');
	document.getElementById("header1").style.display="inline";
	document.getElementById("header2").style.display="none";
	document.getElementById("form-tab1").style.display="inline";
	document.getElementById("form-tab2").style.display="inline";
	document.getElementById("form-tab3").style.display="none";
	document.getElementById("form-button1").style.display="none";
	document.getElementById("form-button2").style.display="inline";
	document.getElementById("form-button3").style.display="none";
	document.getElementById("form_type").value="long";
	initSetErrors();
}

function fullFormPage2(theForm)
{
	_hbPageView('SUBSCRIBE_CONTINUE1', '/ciscolivevirtual_veplatform/REGISTRATION/');
	var f = 0;
	if (!validateSection1(theForm)) { f++; }
	if (f == 0)
	{
		if (!checkEmail()) { f++; }
		if (!checkPassword()) { f++; }
		if (!checkPasswordMatch()) { f++; }
	}
	if (!validateSection2(theForm)) { f++; }
	if (f == 0)
	{
		document.getElementById("header1").style.display="none";
		document.getElementById("header2").style.display="inline";
		document.getElementById("form-tab1").style.display="none";
		document.getElementById("form-tab2").style.display="none";
		document.getElementById("form-tab3").style.display="inline";
		document.getElementById("form-button1").style.display="none";
		document.getElementById("form-button2").style.display="none";
		document.getElementById("form-button3").style.display="inline";
		moveToTop();
	}
}

function submitForm(theForm)
{
	var f = 0;
	
	if (!validateSection1(theForm)) { f++; }
	if (f == 0)
	{
		if (!checkEmail()) { f++; }
		if (!checkPassword(theForm)) { f++; }
		if (!checkPasswordMatch(theForm)) { f++; }
	}
	
	if (theForm.form_type.value == "long")
	{
		if (!validateSection2(theForm)) { f++; }
		if (!validateSection3(theForm)) { f++; }
	}
	
	if (f == 0) { return true; } else { return false; }
}

function validateSection1(theForm)
{
	var f = 0;
	if (theForm.firstname.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-firstname").style.display="inline"; theForm.firstname.focus(); f++; } else { document.getElementById("error-firstname").style.display="none"; }
	if (theForm.lastname.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-lastname").style.display="inline"; theForm.lastname.focus(); f++; } else { document.getElementById("error-lastname").style.display="none"; }
	if (theForm.email.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-email").style.display="inline"; theForm.email.focus(); f++; } else { document.getElementById("error-email").style.display="none"; }
	if (theForm.password.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-password").style.display="inline"; theForm.password.focus(); f++; } else { document.getElementById("error-password").style.display="none"; }
	if (theForm.password_confirm.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-password_confirm").style.display="inline"; theForm.password_confirm.focus(); f++; } else { document.getElementById("error-password_confirm").style.display="none"; }
	if (theForm.company.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-company").style.display="inline"; theForm.company.focus(); f++; } else { document.getElementById("error-company").style.display="none"; }
	if (theForm.title.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-title").style.display="inline"; theForm.title.focus(); f++; } else { document.getElementById("error-title").style.display="none"; }
	if (f == 0) { return true; } else { return false; }
}

function validateSection2(theForm)
{
	var f = 0;
	if (theForm.address1.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-address1").style.display="inline"; theForm.address1.focus(); f++; } else { document.getElementById("error-address1").style.display="none"; }
	if (theForm.city.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-city").style.display="inline"; theForm.city.focus(); f++; } else { document.getElementById("error-city").style.display="none"; }
	//if (theForm.state.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-state").style.display="inline"; theForm.state.focus(); f++; } else { document.getElementById("error-state").style.display="none"; }
	if (theForm.postal_code.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-postal_code").style.display="inline"; theForm.postal_code.focus(); f++; } else { document.getElementById("error-postal_code").style.display="none"; }
	if (theForm.country.value.replace(/^\s*|\s*$/g, "") == "") { document.getElementById("error-country").style.display="inline"; theForm.country.focus(); f++; } else { document.getElementById("error-country").style.display="none"; }
	if (f == 0) { return true; } else { return false; }
}

function validateSection3(theForm)
{
	var f = 0;
	//if (theForm.rolewithnetwork.value == "") { document.getElementById("error-rolewithnetwork").style.display="inline"; theForm.rolewithnetwork.focus(); f++; } else { document.getElementById("error-rolewithnetwork").style.display="none"; }
	//if (theForm.joblevel.value == "") { document.getElementById("error-joblevel").style.display="inline"; theForm.joblevel.focus(); f++; } else { document.getElementById("error-joblevel").style.display="none"; }
	//if (theForm.numpeoplereporting.value == "") { document.getElementById("error-numpeoplereporting").style.display="inline"; theForm.numpeoplereporting.focus(); f++; } else { document.getElementById("error-numpeoplereporting").style.display="none"; }
	if (theForm.job_function.value == "") { document.getElementById("error-job_function").style.display="inline"; theForm.job_function.focus(); f++; } else { document.getElementById("error-job_function").style.display="none"; }
	if (theForm.company_industry.value == "") { document.getElementById("error-company_industry").style.display="inline"; theForm.company_industry.focus(); f++; } else { document.getElementById("error-company_industry").style.display="none"; }
	//if (theForm.company_size.value == "") { document.getElementById("error-company_size").style.display="inline"; theForm.company_size.focus(); f++; } else { document.getElementById("error-company_size").style.display="none"; }
	//if (theForm.nextprojectdate.value == "") { document.getElementById("error-nextprojectdate").style.display="inline"; theForm.nextprojectdate.focus(); f++; } else { document.getElementById("error-nextprojectdate").style.display="none"; }
	//if (theForm.approxbudget.value == "") { document.getElementById("error-approxbudget").style.display="inline"; theForm.approxbudget.focus(); f++; } else { document.getElementById("error-approxbudget").style.display="none"; }
	//if (theForm.projectfocus.value == "") { document.getElementById("error-projectfocus").style.display="inline"; theForm.projectfocus.focus(); f++; } else { document.getElementById("error-projectfocus").style.display="none"; }
	//if (theForm.purchasingrole.value == "") { document.getElementById("error-purchasingrole").style.display="inline"; theForm.purchasingrole.focus(); f++; } else { document.getElementById("error-purchasingrole").style.display="none"; }
	//if (theForm.environment.value == "") { document.getElementById("error-environment").style.display="inline"; theForm.environment.focus(); f++; } else { document.getElementById("error-environment").style.display="none"; }
	if (f == 0) { return true; } else { return false; }
}

function checkEmail()
{
	email = document.getElementById("email").value;
	if (validateEmail(email))
	{
		document.getElementById("error-email_format").style.display="none";
		return true;
	} else {
		document.getElementById("error-email_format").style.display="inline";
		return false;
	}
}

function validateEmail(email)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
	{
		return true;
	} else {
		return false;
	}
}

function checkPassword()
{
	pwd = document.getElementById("password").value;
	if (validatePassword(pwd))
	{
		document.getElementById("error-password_format").style.display="none";
		return true;
	} else {
		document.getElementById("error-password_format").style.display="inline";
		return false;
	}
}

function checkPasswordMatch()
{
	pwd = document.getElementById("password").value;
	pwd2 = document.getElementById("password_confirm").value;
	if (pwd == pwd2)
	{
		document.getElementById("error-password_confirm_format").style.display="none";
		return true;
	} else {
		document.getElementById("error-password_confirm_format").style.display="inline";
		return false;
	}
}

function validatePassword(pwd) 
{
	var invalid = " "; // Invalid character is a space
	var minLength = 6; // Minimum length
	// check for minimum length
	if (pwd.length < minLength) 
	{
		return false;
	}
	// check for spaces
	else if (pwd.indexOf(invalid) > -1) 
	{
		return false;
	}
	else 
	{
		return true;
	}
}

function initSetErrors()
{
	document.getElementById("error-firstname").style.display="none";
	document.getElementById("error-lastname").style.display="none";
	document.getElementById("error-email").style.display="none";
	document.getElementById("error-email_format").style.display="none";
	document.getElementById("error-password").style.display="none";
	document.getElementById("error-password_confirm").style.display="none";
	document.getElementById("error-company").style.display="none";
	document.getElementById("error-title").style.display="none";
	document.getElementById("error-address1").style.display="none";
	document.getElementById("error-city").style.display="none";
	document.getElementById("error-state").style.display="none";
	document.getElementById("error-postal_code").style.display="none";
	document.getElementById("error-country").style.display="none";
	
	//document.getElementById("error-rolewithnetwork").style.display="none";
	//document.getElementById("error-joblevel").style.display="none";
	//document.getElementById("error-numpeoplereporting").style.display="none";
	document.getElementById("error-job_function").style.display="none";
	document.getElementById("error-company_industry").style.display="none";
	//document.getElementById("error-company_size").style.display="none";
	//document.getElementById("error-nextprojectdate").style.display="none";
	//document.getElementById("error-approxbudget").style.display="none";
	//document.getElementById("error-projectfocus").style.display="none";
	//document.getElementById("error-purchasingrole").style.display="none";
	//document.getElementById("error-environment").style.display="none";
	//document.getElementById("error-contactcentercustomer").style.display="none";
	
	document.getElementById("error-email_format").style.display="none";
	document.getElementById("error-password_format").style.display="none";
	document.getElementById("error-password_confirm_format").style.display="none";
}

function hidePasswords()
{
	document.getElementById("form-password").style.display="none";
}

function moveToTop()
{
    if (location.href.indexOf("#TOP") > 0)
    {
        location.href  = location.href;
    } else {
        location.href  = location.href + "#TOP";
    }
}

function formAlert()
{
	alert("Test: " + document.getElementById("form_type").value)
}

//-->