/*-----------------------------------------------------------------------
Created by: Kalpesh
Created date: 25th Feb 2008
File description: Affiliate Registration - Validation
Special instructions-notes:Java script Validation
Tables used:None
Stored procedures:None
Triggers used:None
-----------------------------------------------------------------------*/

function addAffiliate(theForm)
{
	if(isWhitespace(theForm.affiliate_name.value))
	{
		alert("Please provide your Name.");
		 theForm.affiliate_name.focus();
		 return false;
	}
	/*if(isWhitespace(theForm.title.value))
	{
		alert("Please provide the title");
		theForm.title.focus();
		return false;
	}*/
	if(isWhitespace(theForm.company_name.value))
	{
		alert("Please provide your company name");
		theForm.company_name.focus();
		return false;
	}
	if(isWhitespace(theForm.addr1.value))
	{
		alert("Please provide Address.");
		theForm.addr1.focus();
		return false;
	}
	
	if(isWhitespace(theForm.city.value))
	{
		alert("Please provide City.");
		theForm.city.focus();
		return false;
	}
	if(isWhitespace(theForm.state.value))
	{
		alert("Please select State.");
		theForm.state.focus();
		return false;
	}
	if(isWhitespace(theForm.zipcode.value))
	{
		alert("Please provide Zip Code.");
		theForm.zipcode.focus();
		return false;
	}
	if(isZip(theForm.zipcode.value)==false)
	{
		//alert("Please provide numeric value for Zip Code")
		theForm.zipcode.focus();
		return false;
	}
	/*if(theForm.country[theForm.country.selectedIndex].text=="Select Country")
	{
		alert("Please select country");
		theForm.country.focus();
		return false;
	}*/
	if(isWhitespace(theForm.phone.value))
	{	
		alert("Please provide phone number")
		theForm.phone.focus();
		return false;
	}
	if(isNaN(theForm.phone.value)==true)
	{
		alert("Please provide numeric value for Phone.")
		theForm.phone.focus();
		return false;
	}
	
	if(isWhitespace(theForm.email.value))
	{
		alert("Please provide email address")
		theForm.email.focus();
		return false;
	}
	if(!isEmail(theForm.email.value))
	{
		alert("Please provide valid main email address.")
		theForm.email.focus();
		return false;
	}
	/*if(isWhitespace(theForm.confirm_email.value))
	{
		alert("Please provide confirm email address")
		theForm.confirm_email.focus();
		return false;
	}
	if(!isEmail(theForm.confirm_email.value))
	{
		alert("Please provide valid confirm email address.")
		theForm.confirm_email.focus();
		return false;
	}*/
	
	
	if(isWhitespace(theForm.paytoname.value))
	{
		alert("Please provide Pay To Name.");
		theForm.paytoname.focus();
		return false;
	}
	if(isWhitespace(theForm.addr3.value))
	{
		alert("Please provide payees Address.");
		theForm.addr3.focus();
		return false;
	}
	if(isWhitespace(theForm.city1.value))
	{
		alert("Please provide payees City.");
		theForm.city1.focus();
		return false;
	}

	if(isWhitespace(theForm.state1.value))
	{
		alert("Please select payees State.");
		theForm.state1.focus();
		return false;
	}
	if(isWhitespace(theForm.zipcode1.value))
	{
		alert("Please provide value for Zip Code.");
		theForm.zipcode1.focus();
		return false;
	}
	if(!isZip(theForm.zipcode1.value))
	{
		//alert("Please provide numeric value for Zip Code");
		theForm.zipcode1.focus();
		return false;
	}
	if(theForm.country1[theForm.country1.selectedIndex].text=="Select Country")
	{
		alert("Please provide value for Pay to Country.")
		theForm.country1.focus();
		return false;
	}
	if(isWhitespace(theForm.desired_username.value))
	{	
		alert("Please provide Desired Username.");
		theForm.desired_username.focus();
		return false;
	}
	if(!checkUserName(theForm.desired_username.value))
	{
		alert("Desired Username contains invalid characters.");
		theForm.desired_username.focus();
		return false;
	}
	if(theForm.desired_username.value.length>8)
	{
		alert("Please choose Desired Username maximum of 8 characters in length.");
		theForm.desired_username.focus();
		return false;
	}
	if(isWhitespace(theForm.desired_pwd.value))
	{
		alert("Please provide Desired Password.");
		theForm.desired_pwd.focus();
		return false;
	}
	if(theForm.desired_pwd.value.length>8)
	{
		alert("Please choose Desired Password maximum of 8 characters in length.");
		theForm.desired_pwd.focus();
		return false;
	}
	if(theForm.confirm_pwd.value.length>8)
	{
		alert("Please choose confirm Password maximum of 8 characters in length.");
		theForm.confirm_pwd.focus();
		return false;
	}
	if(!isAlphaNumeric(theForm.desired_pwd.value))
	{
		alert("Please enter alphanumeric Desired Password.")
		theForm.desired_pwd.focus();
		return false;
	}
	if(isWhitespace(theForm.confirm_pwd.value))
	{
		alert("Confirm Password cannot be blank.");
		theForm.confirm_pwd.focus();
		return false;
	}
	if(theForm.desired_pwd.value!=theForm.confirm_pwd.value)
	{
		alert("Desired Password and Confirm Password mismatched.");
		theForm.desired_pwd.focus();
		return false;
	}
	
	if(theForm.agree.checked==false)
	{
		alert("You have to agree Terms and Conditions to be an affiliate.");	
		theForm.agree.focus();
		return false;
	}
		
	document.form1.insertAffiliate.value = "Add";	
}

function copyVal(theForm)
{	

	if(theForm.fill.checked==true)
	{
		theForm.paytoname.value			=theForm.affiliate_name.value;
		theForm.addr3.value				=theForm.addr1.value;
		theForm.addr4.value				=theForm.addr2.value;
		theForm.city1.value				=theForm.city.value;
		theForm.state1.selectedIndex	=theForm.state.selectedIndex;
		theForm.zipcode1.value			=theForm.zipcode.value;
		theForm.country1.selectedIndex	=theForm.country.selectedIndex;	
	}
	else
	{
		theForm.paytoname.value				="";		
		theForm.addr3.value					="";
		theForm.addr4.value					="";
		theForm.city1.value					="";
		theForm.state1.selectedIndex		="";
		theForm.zipcode1.value				="";
		theForm.country1.value				="1";
	}
			
}


