// JavaScript Document Created by Loganathan N, <logudotcom@yahoo.com> On 10-December-2004.

// basic function to validate the form fields
function validate_form() {	
	// Name
	if (document.frmfirm.txtfname.value == ""){
		alert("Please enter your Organization/Company Name!");
		document.frmfirm.txtfname.focus();
		return false;
	}
	// We
	if (document.frmfirm.txtwe.value == ""){
		alert("Please enter your Organization/Company Details!");
		document.frmfirm.txtwe.focus();
		return false;
	}
	
	// Address
	if (document.frmfirm.txtaddress.value == ""){
		alert("Please enter your Address!");
		document.frmfirm.txtaddress.focus();
		return false;
	}
	
	// Phone
	if (document.frmfirm.txtphone.value == ""){
		alert("Please enter your Phone!");
		document.frmfirm.txtphone.focus();
		return false;
	}
	
	// Email
	if (document.frmfirm.txtemail.value == ""){
		alert("Please enter Email.");
		document.frmfirm.txtemail.focus();
		return false;
	} else if (document.frmfirm.txtemail.value.indexOf("@") < 2 || document.frmfirm.txtemail.value.indexOf(".") < 0 ) {
		alert ("Please enter valid Email!");
		document.frmfirm.txtemail.focus();
		return false;
	}
	// Retype Email	
	if (document.frmfirm.txtemail.value != document.frmfirm.txtcemail.value){
		alert("'E-mail' and 'Re-type Email' should be same!");
		document.frmfirm.txtcemail.focus();
		return true;
	}
	// Verify Email
	if (document.frmfirm.txtemail.value == document.frmfirm.txtaltmail.value){
		alert("'E-mail' and 'Alternative Email' should not be the same!");
		document.frmfirm.txtaltmail.focus();
		return true;
	}
	// Password
	if (document.frmfirm.txtpwd.value == ""){
		alert("Please enter your Password!");
		document.frmfirm.txtpwd.focus();
		return false;
	}
	// Retype Password	
	if (document.frmfirm.txtpwd.value != document.frmfirm.txtcpwd.value){
		alert("'Password' and 'Re-type Password' should be the same!");
		document.frmfirm.txtpwd.focus();
		return true;
	}
	// Secret Question
	if (document.frmfirm.txtsq.value == '') {
		alert("Please enter your Secret Question?");
		document.frmfirm.txtsq.focus();
		return false;
	}
	// Secret Word
	if (document.frmfirm.txtcw.value == '') {
		alert("Please enter your Secret Word?");
		document.frmfirm.txtcw.focus();
		return false;
	}	
	// Product Services
	if (document.frmfirm.txtprodserdesc.value == ""){
		alert("Please enter about your Product and Services!");
		document.frmfirm.txtprodserdesc.focus();
		return false;
	}
	
	// submit  the form
	document.frmfirm.submit();
	return true;
}
// ends common  validation

// For Modify  Profile Details 
function validate_form_modify() {	
	// Name
	if (document.frmfirm.txtfname.value == ""){
		alert("Please enter your Organization/Company Name!");
		document.frmfirm.txtfname.focus();
		return false;
	}
	// We
	if (document.frmfirm.txtwe.value == ""){
		alert("Please enter your Organization/Company Details!");
		document.frmfirm.txtwe.focus();
		return false;
	}
	
	// Address
	if (document.frmfirm.txtaddress.value == ""){
		alert("Please enter your Address!");
		document.frmfirm.txtaddress.focus();
		return false;
	}
	
	// Phone
	if (document.frmfirm.txtphone.value == ""){
		alert("Please enter your Phone!");
		document.frmfirm.txtphone.focus();
		return false;
	}
	
	// Product Services
	if (document.frmfirm.txtprodserdesc.value == ""){
		alert("Please enter about your Product and Services!");
		document.frmfirm.txtprodserdesc.focus();
		return false;
	}
	
	// submit  the form
	document.frmfirm.submit();
	return true;
}
// ends common  validation




function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

function taCount(textname,no) { 
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	document.frmfirm.elements[textname].value=taObj.value.length;
	if(taObj.value.length==taObj.maxLength*1) alert("You can enter only "+no+" characters");
}


