// this function is used for treaming the values in textbox
function AllTrim(sStr)
{ 
	while (sStr.substring(0,1) == ' ')
	{
		sStr = sStr.substring(1, sStr.length);
	}
	while (sStr.substring(sStr.length-1, sStr.length) == ' ')
	{
		sStr = sStr.substring(0,sStr.length-1);
	}
	return sStr;
}

function logins(opertationtype)
{

	switch(opertationtype)
	{
		
		case 'checks':
			username=AllTrim(document.adminlogin.usernametxt.value);
			document.adminlogin.usernametxt.value=username;
			passwords=AllTrim(document.adminlogin.passwordtxt.value);
			document.adminlogin.passwordtxt.value=passwords;
			if (username=="")
			{
					alert("Please enter user name");
					document.adminlogin.usernametxt.focus();
					return false;
			}
			if (passwords=="")
			{
					alert("Please enter passwords");
					document.adminlogin.passwordtxt.focus();
					return false;
			}
			break;
	}
return true;
	
}




function ShowDiv()
{
	if(document.registration_content.usertype.selectedIndex==2)
		{
			document.getElementById("servicediv").style.display = "block";
			strservice=AllTrim(document.registration_content.service.value);
	
				if(strservice=="")
				{
					alert("Please Enter Service You Need");
					document.registration_content.service.focus();
					return false;
				}
		}
    else
        {
			
            document.getElementById("servicediv").style.display = "none";
        }
	return true;
}


function resetfrm()
{
	document.registration_content.txtusername.value="";
	document.registration_content.txtpassword.value="";
	document.registration_content.txtconfirmpass.value="";
	document.registration_content.txtfname.value="";
	document.registration_content.txtlname.value="";
	document.registration_content.residence_country.selectedIndex=0;
	document.registration_content.residence_state.selectedIndex=0;
	document.registration_content.residence_city.selectedIndex=0;
	document.registration_content.txtresidence_pincode.value="";
	document.registration_content.txtresidence_phone.value="";
	document.registration_content.txtresidence_cell_1.value="";
	document.registration_content.txtresidence_cell_2.value="";
	document.registration_content.txtoffice_pincode2.value="";
	document.registration_content.office_country.selectedIndex=0;
	document.registration_content.txtoffice_phone.value="";
	document.registration_content.txtoffice_fax.value="";
	document.registration_content.txtoffice_cell_1.value="";
	document.registration_content.txtoffice_cell_2.value="";
	document.registration_content.email.value="";
	document.registration_content.service.value="";
	return true;
}




function validate_registration()
{
	username=AllTrim(document.registration_content.txtusername.value);
	userpass=AllTrim(document.registration_content.txtpassword.value);
    confirmpass=AllTrim(document.registration_content.txtconfirmpass.value);
	
	if(username=="")
	{
		alert("Please Enter Username");
		document.registration_content.txtusername.focus();
		return false;
	}
	
	if(userpass=="")
	{
		alert("Please Enter Password");
		document.registration_content.txtpassword.focus();
		return false;
	}
	if(confirmpass=="")
	{
		alert("Please Confirm Password");
		document.registration_content.txtconfirmpass.focus();
		return false;
	}
	
	if(userpass!=confirmpass)
	{
		alert("Invalid Password");
		document.registration_content.txtpassword.value="";
		document.registration_content.txtconfirmpass.value="";
		document.registration_content.txtpassword.focus();
		return false;
	}
	
	fname=AllTrim(document.registration_content.txtfname.value);
	if(fname=="")
	{
		alert("Please Enter First Name");
		document.registration_content.txtfname.focus();
		return false;
	}
	
	lname=AllTrim(document.registration_content.txtlname.value);
	if(lname=="")
	{
		alert("Please Enter Last Name");
		document.registration_content.txtlname.focus();
		return false;
	}
	
	if(document.registration_content.residence_country.selectedIndex==0)
	{
		alert("Please Select Country");
		document.registration_content.residence_country.focus();
		return false;	
	}
	
	if(document.registration_content.residence_state.selectedIndex==0)
	{
		alert("Please Select State");
		document.registration_content.residence_state.focus();
		return false;	
	}
	
	if(document.registration_content.residence_city.selectedIndex==0)
	{
		alert("Please Select City");
		document.registration_content.residence_city.focus();
		return false;	
	}
	
	res_pincode=AllTrim(document.registration_content.txtresidence_pincode.value);
	if(res_pincode=="")
	{
		alert("Please Enter Pincode");
		document.registration_content.txtresidence_pincode.focus();
		return false;
	}
	
	res_phone=AllTrim(document.registration_content.txtresidence_phone.value);
	if(res_phone=="")
	{
		alert("Please Enter Phone No.");
		document.registration_content.txtresidence_phone.focus();
		return false;
	}
	
	
	
	return true;
}
