//JavaScript



var lastErrorDiv='';

/**
 *This
 *
 **/

function validateForm(thisForm)

{
	if(lastErrorDiv!='')
	setInnerHTMLById(lastErrorDiv,'');
	var phone=thisForm.number;
	if((!CheckPhoneNumber(phone.value)) || phone.value==''){
		lastErrorDiv='phone_alert';
		setInnerHTMLById('phone_alert','Invalid Mobile Number');
		phone.focus();
		phone.select();
		return false;
		
	}
	
	if(thisForm.password.value=='' && thisForm.conf_passwd.value=='' ){
		setInnerHTMLById('passwd_alert','Password can\'t left blank.');
		lastErrorDiv='passwd_alert';
		thisForm.password.focus();
		return false;
		}
		
	if(thisForm.password.value != thisForm.conf_passwd.value){
		setInnerHTMLById('passwd_alert','Password did\'t matched');
		thisForm.password.value='';
		thisForm.conf_passwd.value='';
		lastErrorDiv='passwd_alert';
		thisForm.password.focus();
		return false;
		}
		
	if(thisForm.userName.value==''){
		setInnerHTMLById('username_alert','User name can\'t left blank.');
		thisForm.userName.focus();
		lastErrorDiv='username_alert';
		return false;
	}
	
	if(!isValidEmail(thisForm.email.value)){
		setInnerHTMLById('email_alert','Invalid E-mail Address');
		thisForm.email.focus();
		thisForm.email.select();
		lastErrorDiv='email_alert';
		return false;
	}
	
	if(getById('countryDiv1').style.display=='block' && thisForm.country.selectedIndex==0){
		setInnerHTMLById('country_alert','Please choose one country.');
		thisForm.country.focus();
		lastEditErrorDiv='country_alert';
		return false;
	}else if(getById('countryDiv1').style.display=='none' && thisForm.country_textbox.value==''){
		setInnerHTMLById('country_alert','Please insert new country name.');
		thisForm.country_textbox.focus();
		lastEditErrorDiv='country_alert';
		return false;
	}
	
	if(getById('stateDiv1').style.display=='block' && thisForm.state.selectedIndex==0){
		setInnerHTMLById('state_alert','Please choose one state.');
		thisForm.state.focus();
		lastEditErrorDiv='state_alert';
		return false;
	}else if(getById('stateDiv1').style.display=='none' && thisForm.state_textbox.value==''){
		setInnerHTMLById('state_alert','Please insert new state name.');
		thisForm.state_textbox.focus();
		lastEditErrorDiv='state_alert';
		return false;
	}
	
	
	if(getById('cityDiv1').style.display=='block' && thisForm.city.selectedIndex==0){
		setInnerHTMLById('city_alert','Please choose one city.');
		thisForm.city.focus();
		lastEditErrorDiv='city_alert';
		return false;
	}else if(getById('cityDiv1').style.display=='none' && thisForm.city_textbox.value==''){
		setInnerHTMLById('city_alert','Please insert new city name.');
		thisForm.city_textbox.focus();
		lastEditErrorDiv='city_alert';
		return false;
	}
	
	
	
	
	
			
	if(thisForm.zip.value==''){
		setInnerHTMLById('zip_alert','ZIP code can\'t left blank.');
		thisForm.zip.focus();
		thisForm.zip.select();
		lastErrorDiv='zip_alert';
		return false;
	}
	
	
	if(thisForm.address.value==''){
		setInnerHTMLById('address_alert','Please type your address you can\'t left it blank.');
		thisForm.address.focus();
		thisForm.address.select();
		lastErrorDiv='address_alert';
		return false;
	}
	
	if(thisForm.fName.value==''){
		setInnerHTMLById('fname_alert','Please specify your first name.');
		thisForm.fName.focus();
		thisForm.fName.select();
		lastErrorDiv='fname_alert';
		return false;
	}
	
	if(thisForm.lName.value==''){
		setInnerHTMLById('lname_alert','Please specify your last name.');
		thisForm.lName.focus();
		thisForm.lName.select();
		lastErrorDiv='lname_alert';
		return false;
	}
	
	
	if(thisForm.companyName.value==''){
		setInnerHTMLById('cname_alert','Please specify your company name.');
		thisForm.companyName.focus();
		thisForm.companyName.select();
		lastErrorDiv='cname_alert';
		return false;
	}
	
	if(getById('agree').checked==false){
		setInnerHTMLById('confirm_alert','Please accept the agreement to register yourself.');
		thisForm.companyName.focus();
		lastErrorDiv='confirm_alert';
		return false;
	}
	
	
	return true;	
}


/**
 *
 *Function for Country State City Ensble Disable functionality
 */



function showHide(me,comboDiv,textDiv,combo,text){
	var me_dom=document.getElementById(me);
	var combo_dom=document.getElementById(comboDiv);
	var text_dom=document.getElementById(textDiv);
	if(me_dom.checked==true)
	{
	getById(combo).selectedIndex='0';
	combo_dom.style.display='none';
	text_dom.style.display='block';
	getById(text).focus();
	}
	else{
	combo_dom.style.display='block';
	getById(text).value='';
	text_dom.style.display='none';
	}
	
	if(me=='country_checkId' && me_dom.checked==true)
	{
		
		getById('state_comboId').selectedIndex='0';
		hide('stateDiv1');
		getById('state_checkId').checked=false;
		hide('state_checkDiv');
		show('stateDiv2');
		
		
		getById('city_comboId').selectedIndex='0';
		hide('cityDiv1');
		getById('city_checkId').checked=false;
		hide('city_checkDiv');
		show('cityDiv2');
	}
	else if(me=='country_checkId' && me_dom.checked==false){
		show('stateDiv1');
		show('state_checkDiv');
		getById('state_textboxId').value='';
		hide('stateDiv2');
		
		show('cityDiv1');
		show('city_checkDiv');
		getById('city_textboxId').value='';
		hide('cityDiv2');
	}
	
	if(me=='state_checkId' && me_dom.checked==true)
	{
		getById('city_comboId').selectedIndex='0';
		hide('cityDiv1');
		getById('city_checkId').checked=false;
		hide('city_checkDiv');
		show('cityDiv2');
	}
	else if(me=='state_checkId' && me_dom.checked==false){
		show('cityDiv1');
		show('city_checkDiv');
		getById('city_textboxId').value='';
		hide('cityDiv2');	
	}
	
	
}


