﻿function check_values()
{
var frm=document.form1;

if(frm.txt_FirstName.value=="")
{
 alert("Please enter your First Name");
 frm.txt_FirstName.focus();
 return(false);
}
else if(frm.txt_LastName.value=="")
{
 alert("Please enter your Last Name");
 frm.txt_LastName.focus();
 return(false);
}
else if(frm.txt_UserName.value=="")
{
 alert("Please enter your User Name");
 frm.txt_UserName.focus();
 return(false);
}
else if(frm.txt_Password.value=="")
{
 alert("Please enter Password");
 frm.txt_Password.focus();
 return(false);
}
else if(frm.txt_ConfirmPassword.value=="")
{
 alert("Please Retype Password");
 frm.txt_ConfirmPassword.focus();
 return(false);
}
else if(frm.txt_ConfirmPassword.value!=frm.txt_Password.value)
{
 alert("Password and Retype password  should be same");
 frm.txt_ConfirmPassword.focus();
 return(false);
}
else if(frm.txt_Address1.value=="")
{
 alert("Please enter your address");
 frm.txt_Address1.focus();
 return(false); 
}

else if(frm.txt_City.value=="")
{
 alert("Please enter City");
 frm.txt_City.focus();
 return(false); 
}
else if( (frm.list_Country.value!="1") && (document.getElementById("txt_State").value==""))
				{
					alert("Please enter State");
					document.getElementById("txt_State").focus();
					return(false);					
				}
else if(frm.txt_ZipCode.value=="")
{
 alert("Please enter your Zip Code");
 frm.txt_ZipCode.focus();
 return(false); 
}
else if(frm.txt_Telephone.value=="")
{
 alert("Please enter your Telephone number");
 frm.txt_Telephone.focus();
 return(false); 
}
else if(frm.txtEmailId.value=="")
{
 alert("Please enter your Email address");
 frm.txtEmailId.focus();
 return(false); 
}
else if(frm.txtEmailId.value!="")
{
var email_id=document.getElementById("txtEmailId").value;
					var at,colon; 
					at=email_id.indexOf("@");
					colon=email_id.indexOf(".");
					if(at <=0 || colon<=0 || at+1==colon)
					{
						alert("Email ID is invalid");
						document.getElementById("txtEmailId").focus();
						return(false);
					}

}
else
{
 return(true);
}



}
		
function check_Shippingvalues()
{
var frm= document.form1;

	if(frm.txtShippingFirstName.value=="")
	{
		alert("Shipping - First Name cannot be empty!");
		frm.txtShippingFirstName.focus();
		return(false);
	}
	else if(frm.txtShippingLastName.value=="")
	{
		alert("Shipping - Last Name cannot be empty!");
		frm.txtShippingLastName.focus();
		return(false);
	}
	else if(frm.txtShippingPhoneNo.value=="")
	{
		alert("Shipping - Phone no cannot be empty!");
		frm.txtShippingPhoneNo.focus();
		return(false);
	}
	else if(frm.txtShippingFax.value=="")
	{
		alert("Shipping - Fax cannot be empty!");
		frm.txtShippingFax.focus();
		return(false);
	}
	else if(frm.txtShippingStreet.value=="")
	{
		alert("Shipping - Street cannot be empty!");
		frm.txtShippingStreet.focus();
		return(false);
	}
	else if(frm.txtShippingCity.value=="")
	{
		alert("Shipping - City cannot be empty!");
		frm.txtShippingCity.focus();
		return(false);
	}
	else if(frm.txtShippingZipcode.value=="")
	{
		alert("Shipping - Zip code cannot be empty!");
		frm.txtShippingZipcode.focus();
		return(false);
	}
	else if(frm.txtShippingEmailId.value=="")
	{
		alert("Shipping - Email cannot be empty!");
		frm.txtShippingEmailId.focus();
		return(false);
	}
	else if(frm.txtShippingState.value=="" && frm.listShippingCountry.value!="1")
	{
		alert("Enter State !");
		frm.txtShippingState.focus();
		return(false);
	}
	else if(frm.listShippingState.value=="OT")
	{
		if(frm.txtShippingState.value=="")
		{
alert("Shipping - Enter State !");
frm.txtShippingState.focus();
return(false);
		}
	}
	else if(frm.txtShippingEmailId.value!="")
	{
		var email_id=frm.txtShippingEmailId.value;
		var at,colon; 
		at=email_id.indexOf("@");
		colon=email_id.indexOf(".");
		if(at <=0 || colon<=0 || at+1==colon)
		{
alert("Shipping - Invalid email Id");
frm.txtShippingEmailId.focus();
return(false);
		}
	}
	else
	{
		return(true);
	}
}

function Display_ShippingAddress(id)
{
	if(id=="sh")
	{
		document.getElementById("div_shippingAddress").style.display = "block";
	}
	else if(id=="bi")
	{
		document.getElementById("div_shippingAddress").style.display = "none";
	}
}

function Display_StateControl()
{
	var frm= document.form1;
	if(document.getElementById("list_Country").value=="1")
	{
		document.getElementById("list_State").style.display = "block";
		document.getElementById("txt_State").style.display = "none";
	}
	else
	{
		document.getElementById("list_State").style.display = "none";
		document.getElementById("txt_State").style.display = "Block";
		document.getElementById("txt_State").value = "";
	}
}

function Display_ShippingStateControl()
{
	var frm= document.form1;
	if(frm.listShippingCountry.value=="1")
	{
		document.getElementById("listShippingState").style.display = "block";
		document.getElementById("txtShippingState").style.display = "none";
	}
	else
	{
		document.getElementById("listShippingState").style.display = "none";
		document.getElementById("txtShippingState").style.display = "Block";
	}
}

function check_values_Update()
{
var frm=document.form1;
alert("hai");
if(frm.txt_UserName.value=="")
{
 alert("User Name cannot be Empty!");
 frm.txt_UserName.focus();
 return(false);
}
else if(frm.txt_FirstName.value=="")
{
 alert("First Name cannot be empty");
 frm.txt_FirstName.focus();
 return(false);
}
else if(frm.txt_Address1.value=="")
{
 alert("Address1 cannot be empty");
 frm.txt_Address1.focus();
 return(false); 
}
else if( (frm.list_Country.value!="1") && (document.getElementById("txt_State").value==""))
				{
					alert("State Cannot be Empty!");
					document.getElementById("txt_State").focus();
					return(false);					
				}
else if(frm.txtEmailId.value=="")
{
 alert("Email Address cannot be empty");
 frm.txtEmailId.focus();
 return(false); 
}
else if(frm.txtEmailId.value!="")
{
var email_id=document.getElementById("txtEmailId").value;
					var at,colon; 
					at=email_id.indexOf("@");
					colon=email_id.indexOf(".");
					if(at <=0 || colon<=0 || at+1==colon)
					{
						alert("Invalid email Id");
						document.getElementById("txtEmailId").focus();
						return(false);
					}

}
else
{
 return(true);
}



}
