// JavaScript Document
function ValidateSmartvueProductForm(Form)
{	
	var errortext = '';
	var emptytext = 'Please provide information for ';	
	document.getElementById('errdisp').innerHTML = '';	
	var focused = false;
	
	//Name	
	document.frm.txtName.value = trim(document.frm.txtName.value);
	if(document.frm.txtName.value == ''){
		errortext +=  ("Please enter name.\n");
		if (!focused) document.frm.txtName.focus();
		focused = true;
		document.getElementById('ename').style.color='red';
	}
	else if( document.frm.txtName.value != '' && (! ValidateName(document.frm.txtName.value))){
		errortext +=  ("Please specify valid name.\n");		
		if (!focused) document.frm.txtName.focus();
		focused = true;
		document.getElementById('ename').style.color='red';
	}
	else{
		document.getElementById('ename').style.color='black';
	}
	
	//Organization
	document.frm.txtOrg.value = trim(document.frm.txtOrg.value);
	if(document.frm.txtOrg.value == ''){
		errortext +=  ("Please enter organization.\n");
		if (!focused) document.frm.txtOrg.focus();
		focused = true;
		document.getElementById('eorg').style.color='red';
	}
	else if( document.frm.txtOrg.value != '' && (! ValidateCompany(document.frm.txtOrg.value))){
		errortext +=  ("Please specify valid organization.\n");		
		if (!focused) document.frm.txtOrg.focus();
		focused = true;
		document.getElementById('eorg').style.color='red';
	}
	else{
		document.getElementById('eorg').style.color='black';
	}
	
	//City
	document.frm.txtCity.value = trim(document.frm.txtCity.value);
	if(document.frm.txtCity.value == ''){
		errortext +=  ("Please enter city.\n");
		if (!focused) document.frm.txtCity.focus();
		focused = true;
		document.getElementById('ecity').style.color='red';
	}
	else if( document.frm.txtCity.value != '' && (! ValidateCompany(document.frm.txtCity.value))){
		errortext +=  ("Please specify valid city.\n");		
		if (!focused) document.frm.txtCity.focus();
		focused = true;
		document.getElementById('ecity').style.color='red';
	}
	else{
		document.getElementById('ecity').style.color='black';
	}
	
	//Phone
	document.frm.txtPhone.value = trim(document.frm.txtPhone.value);
	if(document.frm.txtPhone.value == ''){
		errortext +=  ("Please enter phone no.\n");
		if (!focused) document.frm.txtPhone.focus();
		focused = true;
		document.getElementById('ephone').style.color='red';
	}
	else if( document.frm.txtPhone.value != '' && (! ValidatePhone(document.frm.txtPhone.value))){
		errortext +=  ("Please specify valid phone no.\n");		
		if (!focused) document.frm.txtPhone.focus();
		focused = true;
		document.getElementById('ephone').style.color='red';
	}
	else{
		document.getElementById('ephone').style.color='black';
	}	
	
	//Email
	document.frm.txtEmail.value = trim(document.frm.txtEmail.value);
	if(document.frm.txtEmail.value == ''){
		errortext +=  ("Please enter Email.\n");
		if (!focused) document.frm.txtEmail.focus();
		focused = true;
		document.getElementById('eemail').style.color='red';
	}
	else if( document.frm.txtEmail.value != '' && (! ValidateEmail(document.frm.txtEmail.value))){
		errortext +=  ("Please specify valid Email.\n");		
		if (!focused) document.frm.txtEmail.focus();
		focused = true;
		document.getElementById('eemail').style.color='red';
	}
	else{
		document.getElementById('eemail').style.color='black';
	}	
	
	//Target Market
	document.frm.cbotm.value = trim(document.frm.cbotm.value);
	if(document.frm.cbotm.value == ''){
		errortext +=  ("Please select Target Market.\n");
		if (!focused) document.frm.cbotm.focus();
		focused = true;
		document.getElementById('etm').style.color='red';
	}	
	else{
		document.getElementById('etm').style.color='black';
	}		
	
	//Enquiry / Comments
	/*
	document.frm.txtComments.value = trim(document.frm.txtComments.value);
	if(document.frm.txtComments.value == ''){
		errortext +=  ("Please enter Comments.\n");
		if (!focused) document.frm.txtComments.focus();
		focused = true;
		document.getElementById('ecomments').style.color='red';
	}	
	else{
		document.getElementById('ecomments').style.color='black';
	}	
	*/
	
	//Hear Type
	document.frm.cboht.value = trim(document.frm.cboht.value);
	if(document.frm.cboht.value == ''){
		errortext +=  ("Please select Hear type.\n");
		if (!focused) document.frm.cboht.focus();
		focused = true;
		document.getElementById('eht').style.color='red';
	}	
	else{
		document.getElementById('eht').style.color='black';
	}		
		
	//Security Code
	document.frm.security_code.value = trim(document.frm.security_code.value);
	if(document.frm.security_code.value == ''){
		errortext +=  ("Please enter Security Code.\n");		
		if (!focused) document.frm.security_code.focus();
		focused = true;
		document.getElementById('scode').style.color='red';
	}
	else if( document.frm.security_code.value != '' && (! ValidateSCode(document.frm.security_code.value))){
		errortext +=  ("Please specify valid Security Code.\n");		
		if (!focused) document.frm.security_code.focus();
		focused = true;
		document.getElementById('scode').style.color='red';
	}
	else{
		document.getElementById('scode').style.color='black';
	}
		
		
	if( errortext == '')
	{
		return true;
	}
	else
	{
		alert(errortext);		
		document.getElementById('errdisp').innerHTML =	'&nbsp;&nbsp;Please provide valid information for all the required fields marked in \'Red\'<br>&nbsp;';
		window.scroll(0, 0);		
		return false;
		
	}
}

/* method for validating dealers form */
function ValidateSmartvueDealerForm(Form)
{
	var errortext = '';
	var emptytext = 'Please provide information for ';	
	document.getElementById('errdisp').innerHTML = '';	
	var focused = false;
	
	//Name	
	document.frm.txtName.value = trim(document.frm.txtName.value);
	if(document.frm.txtName.value == ''){
		errortext +=  ("Please enter name.\n");
		if (!focused) document.frm.txtName.focus();
		focused = true;
		document.getElementById('ename').style.color='red';
	}
	else if( document.frm.txtName.value != '' && (! ValidateName(document.frm.txtName.value))){
		errortext +=  ("Please specify valid name.\n");		
		if (!focused) document.frm.txtName.focus();
		focused = true;
		document.getElementById('ename').style.color='red';
	}
	else{
		document.getElementById('ename').style.color='black';
	}
	
	//Organization
	document.frm.txtOrg.value = trim(document.frm.txtOrg.value);
	if(document.frm.txtOrg.value == ''){
		errortext +=  ("Please enter organization.\n");
		if (!focused) document.frm.txtOrg.focus();
		focused = true;
		document.getElementById('eorg').style.color='red';
	}
	else if( document.frm.txtOrg.value != '' && (! ValidateCompany(document.frm.txtOrg.value))){
		errortext +=  ("Please specify valid organization.\n");		
		if (!focused) document.frm.txtOrg.focus();
		focused = true;
		document.getElementById('eorg').style.color='red';
	}
	else{
		document.getElementById('eorg').style.color='black';
	}
	
	//City
	document.frm.txtCity.value = trim(document.frm.txtCity.value);
	if(document.frm.txtCity.value == ''){
		errortext +=  ("Please enter city.\n");
		if (!focused) document.frm.txtCity.focus();
		focused = true;
		document.getElementById('ecity').style.color='red';
	}
	else if( document.frm.txtCity.value != '' && (! ValidateCompany(document.frm.txtCity.value))){
		errortext +=  ("Please specify valid city.\n");		
		if (!focused) document.frm.txtCity.focus();
		focused = true;
		document.getElementById('ecity').style.color='red';
	}
	else{
		document.getElementById('ecity').style.color='black';
	}
	
	//Phone
	document.frm.txtPhone.value = trim(document.frm.txtPhone.value);
	if(document.frm.txtPhone.value == ''){
		errortext +=  ("Please enter phone no.\n");
		if (!focused) document.frm.txtPhone.focus();
		focused = true;
		document.getElementById('ephone').style.color='red';
	}
	else if( document.frm.txtPhone.value != '' && (! ValidatePhone(document.frm.txtPhone.value))){
		errortext +=  ("Please specify valid phone no.\n");		
		if (!focused) document.frm.txtPhone.focus();
		focused = true;
		document.getElementById('ephone').style.color='red';
	}
	else{
		document.getElementById('ephone').style.color='black';
	}	
	
	//Email
	document.frm.txtEmail.value = trim(document.frm.txtEmail.value);
	if(document.frm.txtEmail.value == ''){
		errortext +=  ("Please enter Email.\n");
		if (!focused) document.frm.txtEmail.focus();
		focused = true;
		document.getElementById('eemail').style.color='red';
	}
	else if( document.frm.txtEmail.value != '' && (! ValidateEmail(document.frm.txtEmail.value))){
		errortext +=  ("Please specify valid Email.\n");		
		if (!focused) document.frm.txtEmail.focus();
		focused = true;
		document.getElementById('eemail').style.color='red';
	}
	else{
		document.getElementById('eemail').style.color='black';
	}	
	
	//Desired dealership region
	document.frm.txtDDR.value = trim(document.frm.txtDDR.value);
	if(document.frm.txtDDR.value == ''){
		errortext +=  ("Please enter Desired Dealership Region details.\n");
		if (!focused) document.frm.txtDDR.focus();
		focused = true;
		document.getElementById('eddr').style.color='red';
	}	
	else if( document.frm.txtDDR.value != '' && (! ValidateCompany(document.frm.txtDDR.value))){
		errortext +=  ("Please specify valid Desired Dealership Region.\n");		
		if (!focused) document.frm.txtDDR.focus();
		focused = true;
		document.getElementById('eddr').style.color='red';
	}
	else{
		document.getElementById('eddr').style.color='black';
	}		
	
	//Existing Products Portfolio
	document.frm.txtEPP.value = trim(document.frm.txtEPP.value);
	if(document.frm.txtEPP.value == ''){
		errortext +=  ("Please enter Existing Products Portfolio.\n");
		if (!focused) document.frm.txtEPP.focus();
		focused = true;
		document.getElementById('eEPP').style.color='red';
	}	
	else if( document.frm.txtEPP.value != '' && (! ValidateCompany(document.frm.txtEPP.value))){
		errortext +=  ("Please specify valid Existing Products Portfolio.\n");		
		if (!focused) document.frm.txtEPP.focus();
		focused = true;
		document.getElementById('eEPP').style.color='red';
	}
	else{
		document.getElementById('eEPP').style.color='black';
	}		
	
	//Enquiry / Comments
	/*
	document.frm.txtComments.value = trim(document.frm.txtComments.value);
	if(document.frm.txtComments.value == ''){
		errortext +=  ("Please enter Comments.\n");
		if (!focused) document.frm.txtComments.focus();
		focused = true;
		document.getElementById('ecomments').style.color='red';
	}	
	else{
		document.getElementById('ecomments').style.color='black';
	}	
	*/
	
	//Hear Type
	document.frm.cboht.value = trim(document.frm.cboht.value);
	if(document.frm.cboht.value == ''){
		errortext +=  ("Please select Hear type.\n");
		if (!focused) document.frm.cboht.focus();
		focused = true;
		document.getElementById('eht').style.color='red';
	}	
	else{
		document.getElementById('eht').style.color='black';
	}		
		
	//Security Code
	document.frm.security_code.value = trim(document.frm.security_code.value);
	if(document.frm.security_code.value == ''){
		errortext +=  ("Please enter Security Code.\n");		
		if (!focused) document.frm.security_code.focus();
		focused = true;
		document.getElementById('scode').style.color='red';
	}
	else if( document.frm.security_code.value != '' && (! ValidateSCode(document.frm.security_code.value))){
		errortext +=  ("Please specify valid Security Code.\n");		
		if (!focused) document.frm.security_code.focus();
		focused = true;
		document.getElementById('scode').style.color='red';
	}
	else{
		document.getElementById('scode').style.color='black';
	}
		
		
	if( errortext == '')
	{
		return true;
	}
	else
	{
		alert(errortext);		
		document.getElementById('errdisp').innerHTML =	'&nbsp;&nbsp;Please provide valid information for all the required fields marked in \'Red\'<br>&nbsp;';
		window.scroll(0, 0);		
		return false;
		
	}
}