﻿function isNumber(value) {
	for (var i=0; i < value.length; i++) {
		a = parseInt(value.charAt(i));
		if (isNaN(a)) {
			return false;
			break;
		}
	}
	return true;
}
function isDecimal(value) {
	for (var i=0; i < value.length; i++) {
		a = parseInt(value.charAt(i));
		if (isNaN(a))
		{
			if (value.charAt(i) != '$' && value.charAt(i) != '.')
			{
			return false;
			break;
			}
		}
	}
	return true;
}
function clearText(thefield){
		thefield.style.backgroundColor = 'white';

		if (thefield.defaultValue==thefield.value){
			thefield.value = "";
		}	
	} 

	function fn(id){
		return document.getElementById(id);
	}

	function contact_validate(make_contact){ 
		var err = true;			
		if(document.make_contact.profile_firstname.value == '' || document.make_contact.profile_firstname.value == 'First Name*'){
			document.make_contact.profile_firstname.style.backgroundColor = '#DDE658';
			err = false;
		}else{
				if(isNumber(document.make_contact.profile_firstname.value))
					{
					document.make_contact.profile_firstname.style.backgroundColor = '#DDE658';
					err = false;
					}
			}
		if(document.make_contact.profile_lastname.value == '' || document.make_contact.profile_lastname.value == 'Last Name*'){
			document.make_contact.profile_lastname.style.backgroundColor = '#DDE658';
			err = false;
		}else{
				if(isNumber(document.make_contact.profile_lastname.value))
					{
					document.make_contact.profile_lastname.style.backgroundColor = '#DDE658';
					err = false;
					}
			}
			
			
			
		if(document.make_contact.profile_jobtitle.value == '' || document.make_contact.profile_jobtitle.value == 'Job Title*'){
			document.make_contact.profile_jobtitle.style.backgroundColor = '#DDE658';
			err = false;
			}else{
				document.make_contact.profile_jobtitle.style.backgroundColor = '#FFFFFF';
			}
			
		    
			if(document.make_contact.level.value == 'Select Level*'){
			document.make_contact.level.style.backgroundColor = '#DDE658';
			err = false;
			}else{
				document.make_contact.level.style.backgroundColor = '#FFFFFF';
			}
			
			if(document.make_contact.profile_company.value == '' || document.make_contact.profile_company.value == 'Company*'){
			document.make_contact.profile_company.style.backgroundColor = '#DDE658';
			err = false;
			}else{
				document.make_contact.profile_company.style.backgroundColor = '#FFFFFF';
			}
			
			if(document.make_contact.company_size.value == 'Company Size*'){
			document.make_contact.company_size.style.backgroundColor = '#DDE658';
			err = false;
			}else{
				document.make_contact.company_size.style.backgroundColor = '#FFFFFF';
			}
			
			if(document.make_contact.industry.value == 'Select Industry*'){
			document.make_contact.industry.style.backgroundColor = '#DDE658';
			err = false;
			}else{
				document.make_contact.industry.style.backgroundColor = '#FFFFFF';
			}
			
			if(document.make_contact.profile_timezone.value == 'Select Timezone*'){
			document.make_contact.profile_timezone.style.backgroundColor = '#DDE658';
			err = false;
			}else{
				document.make_contact.profile_timezone.style.backgroundColor = '#FFFFFF';
			}
			
			if(document.make_contact.profile_country.value == 'Select Country*'){
			document.make_contact.profile_country.style.backgroundColor = '#DDE658';
			err = false;
			}else{
				document.make_contact.profile_country.style.backgroundColor = '#FFFFFF';
			}
			
			if(document.make_contact.mail.value =='Email*' || document.make_contact.mail.value =='')
				{
				document.make_contact.mail.style.backgroundColor = '#DDE658';
				err = false;
				}else 
				{
					var reg =/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/

					if (!reg.test(document.make_contact.mail.value))
					{
						document.make_contact.mail.style.backgroundColor = '#DDE658';
						err = false;
					}
					else
					{
						document.make_contact.mail.style.backgroundColor = '#FFFFFF';
					}
				}
			if(document.make_contact.profile_telephone.value =='Telephone*' || document.make_contact.profile_telephone.value == '')
			{
			//alert("nullss");
			document.make_contact.profile_telephone.style.backgroundColor = '#DDE658';
			err = false;
			}
		else
			if (!isNumber(document.make_contact.profile_telephone.value))
			{
			//alert("num error");
				document.make_contact.profile_telephone.style.backgroundColor = '#DDE658';
				err = false;
			}
				

/*if(document.make_contact.pass.value == '' || document.make_contact.pass.value == 'Password*'){
			document.make_contact.pass.style.backgroundColor = '#DDE658';
			err = false;
		}else{
				document.make_contact.pass.style.backgroundColor = '#FFFFFF';
			}	

if(document.make_contact.passconfirm.value == '' || document.make_contact.passconfirm.value == 'CPassword*'){
			document.make_contact.passconfirm.style.backgroundColor = '#DDE658';
			err = false;
		}else{
				document.make_contact.passconfirm.style.backgroundColor = '#FFFFFF';
			}	*/
     // alert(document.make_contact.pass.value);
	 
	 var passerror = true;
	 
		if(document.make_contact.pass.value == '' || document.make_contact.pass.value == 'Password*'){
			document.make_contact.pass.style.backgroundColor = '#DDE658';
			err = false;
			passerror= false;
		}
		if(document.make_contact.passconfirm.value == '' || document.make_contact.passconfirm.value == 'CPassword*'){
			document.make_contact.passconfirm.style.backgroundColor = '#DDE658';
			err = false;
			passerror= false;
		}
		
		if(passerror)
		{
		if(document.make_contact.pass.value != document.make_contact.passconfirm.value){
			document.make_contact.passconfirm.style.backgroundColor = '#DDE658';
			document.make_contact.pass.style.backgroundColor = '#DDE658';
			err = false;
		}else{
				document.make_contact.passconfirm.style.backgroundColor = '#FFFFFF';
				document.make_contact.pass.style.backgroundColor = '#FFFFFF';
			}	
		}
		
				
		
		if(!err){
			//document.getElementById('err_text').innerHTML = ' <font class="formtextError">Please fill out required fields</font>';
			return false;
		}
		else{
		document.make_contact.submit();
		pageTracker._trackPageview("/LiveWebcast/AutoBidRegister");
		}
	}