// JavaScript Document

// this is function for login validation

function ValidLogin()
{
	var obj = document.lgnfrm;
	res = fieldBlank(obj.userEmail,'Please enter the email ID.');
	if(!res)
	{
		return res;
	}
	res = validEmail(obj.userEmail,'Please enter valid email ID.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.userPassword,'Please enter the password.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cusType,'Please select the user type.');
	if(!res)
	{
		return res;
	}
}	
// function for registration validation.
function ValidAddProfile()
{
	var obj = document.add_profile;
	
	
	
	res = fieldBlank(obj.profile_email,'Please enter the email.');
	if(!res)
	{
		return res;
	}
	res = validEmail(obj.profile_email,'Please enter the valid email.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_pass,'Please enter the password.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_name,'Please enter the profile name.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_address1,'Please enter the address1.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.country1,'Please select the country.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.stateId1,'Please select the state.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cityId1,'Please select the city.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_postal,'Please enter the postal code.');
	if(!res)
	{
		return res;
	}
	
	/*res = fieldBlank(obj.profile_phone,'Please enter the phone.');
	if(!res)
	{
		return res;
	}*/
	res = fieldBlank(obj.ph_country,'Please enter the country code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_area,'Please enter the area code for phone.');
	if(!res)
	{
		return res;
	}
	res = validInteger(obj.ph_area,'Please enter the valid area code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_no,'Please enter the phone number.');
	if(!res)
	{
		return res;
	}
	
	res = validInteger(obj.ph_no,'Please enter the Valid phone number.');
	if(!res)
	{
		return res;
	}
	
	
	/*
	var flag2=0;
	var chID=document.getElementsByid('profile_language');
	for (var i=0; i < chID.length; i++)
	   {
		if(document.chID[i].checked==true)
		  {
			 //var rad_valot = document.add_profile.profile_language[i].value;
			  flag2=1;
		 } 
	}
	if(flag2==0){
		alert("Please select at least one language option" );
		return false;
	}
	
	*/
	if(document.getElementById("profile_language8").checked==true)
	{
		res = fieldBlank(obj.profile_other_language,'Please enter the other language name.');
		if(!res)
		{
			return res;
		}
		
	}
	
	res = fieldBlank(obj.profile_about_my_business,'Please enter the about my business.');
	if(!res)
	{
		return res;
	}
	if(obj.profile_about_my_business.value.length > 20000) {
		alert("Your business description should be less than 20,000 characters.");
		obj.profile_about_my_business.focus();
		return false;
	}
	
	
	
	
		///////////////////////.....................................
	if(obj.profile_keyword1.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword1,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	
	if(obj.profile_keyword2.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword2,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	if(obj.profile_keyword3.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword3,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	if(obj.profile_keyword4.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword4,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	if(obj.profile_keyword5.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword5,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	res = fieldBlank(obj.cateId1,'Please select the category.');
	if(!res)
	{
		return res;
	}
	
	/*res = fieldBlank(obj.subcateId1,'Please select the sub-category.');
	if(!res)
	{
		return res;
	}*/
	
	
	
	
	///////////////////////.....................................
	
	
	captch = document.getElementById('6_letters_code').value;
	if(captch=="")
	{
		alert("Please Enter Validation code");
		return false;
	}
	captchv = document.getElementById('6_letters_code').value.length;
	if(captchv!=6)
	{
		alert("Please Enter valid Validation code");
		return false;
	}
	
	
	
	if(obj.profile_website.value!=''){
		res = validURL(obj.profile_website,'Please enter the Valid URL.');
		if(!res)
		{
			return res;
		}
	
	}
}


// function for registration validation.
function ValidAddPremiumProfile()
{
	var obj = document.add_profile;
	
	
	
	res = fieldBlank(obj.profile_email,'Please enter the email.');
	if(!res)
	{
		return res;
	}
	res = validEmail(obj.profile_email,'Please enter the valid email.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_pass,'Please enter the password.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_name,'Please enter the profile name.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_address1,'Please enter the address1.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.country1,'Please select the country.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.stateId1,'Please select the state.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cityId1,'Please select the city.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_postal,'Please enter the postal code.');
	if(!res)
	{
		return res;
	}
	
	/*res = fieldBlank(obj.profile_phone,'Please enter the phone.');
	if(!res)
	{
		return res;
	}*/
	res = fieldBlank(obj.ph_country,'Please enter the country code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_area,'Please enter the area code for phone.');
	if(!res)
	{
		return res;
	}
	res = validInteger(obj.ph_area,'Please enter the valid area code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_no,'Please enter the phone number.');
	if(!res)
	{
		return res;
	}
	
	res = validInteger(obj.ph_no,'Please enter the valid phone number.');
	if(!res)
	{
		return res;
	}
	
	if(document.getElementById("profile_language8").checked==true)
	{
		res = fieldBlank(obj.profile_other_language,'Please enter the other language name.');
		if(!res)
		{
			return res;
		}
		
	}
	
	
	
	captch = document.getElementById('6_letters_code').value;
	if(captch=="")
	{
		alert("Please enter the validation code");
		return false;
	}
	captchv = document.getElementById('6_letters_code').value.length;
	if(captchv!=6)
	{
		alert("Please enter the valid validation code");
		return false;
	}
	
}


// function for registration validation.
function ValidEditProfile()
{
	var obj = document.add_profile;
	
	
	/*res = fieldBlank(obj.subcateId1,'Please select the sub-category.');
	if(!res)
	{
		return res;
	}*/
	
	
	res = fieldBlank(obj.profile_name,'Please enter the profile name.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_address1,'Please enter the address1.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.country1,'Please select the country.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.stateId1,'Please select the state.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cityId1,'Please select the city.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_postal,'Please enter the postal code.');
	if(!res)
	{
		return res;
	}
	
	res = fieldBlank(obj.ph_country,'Please enter the country code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_area,'Please enter the area code for phone.');
	if(!res)
	{
		return res;
	}
	res = validInteger(obj.ph_area,'Please enter the valid area code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_no,'Please enter the phone number.');
	if(!res)
	{
		return res;
	}
	
	res = validInteger(obj.ph_no,'Please enter the Valid phone number.');
	if(!res)
	{
		return res;
	}
	var flag2=0;
	//var chID=document.getElementsByid('profile_language');
	/*for (var i=0; i < chID.length; i++)
	   {
		if(document.chID[i].checked==true)
		  {
			 //var rad_valot = document.add_profile.profile_language[i].value;
			  flag2=1;
		 } 
	}*/
	if(flag2==1){
		alert("Please select at least one language option" );
		return false;
	}
	if(document.getElementById("profile_language8").checked==true)
	{
		res = fieldBlank(obj.profile_other_language,'Please enter the other language name.');
		if(!res)
		{
			return res;
		}
		
	}
	res = fieldBlank(obj.profile_about_my_business,'Please enter the about your business.');
	if(!res)
	{
		return res;
	}
	if(obj.profile_about_my_business.value.length > 20000) {
		alert("Your business description should be less than 20,000 characters.");
		obj.profile_about_my_business.focus();
		return false;
	}
	if(obj.profile_keyword1.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword1,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	
	if(obj.profile_keyword2.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword2,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	if(obj.profile_keyword3.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword3,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	if(obj.profile_keyword4.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword4,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	if(obj.profile_keyword5.value!='')
	{
		res = validAlphaNumeric(obj.profile_keyword5,'Please enter the only alphanumeric characters for Keyword.');
		if(!res)
		{
			return res;
		}
	}
	res = fieldBlank(obj.cateId1,'Please select the category.');
	if(!res)
	{
		return res;
	}
	
	if(obj.profile_website.value!=''){
		res = validURL(obj.profile_website,'Please enter the valid URL.');
		if(!res)
		{
			return res;
		}
	
	}
}


// function for Buyer Submission.
function ValidBuyerSubmission()
{
	var obj = document.add_buyer;
	
	
	
	res = fieldBlank(obj.profile_email,'Please enter the email.');
	if(!res)
	{
		return res;
	}
	res = validEmail(obj.profile_email,'Please enter the valid email.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_pass,'Please enter the password.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_name,'Please enter the Buyer name.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_address1,'Please enter the address1.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.country1,'Please select the country.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.stateId1,'Please select the state.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cityId1,'Please select the city.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_postal,'Please enter the postal code.');
	if(!res)
	{
		return res;
	}
	
	res = fieldBlank(obj.ph_country,'Please enter the country code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_area,'Please enter the area code for phone.');
	if(!res)
	{
		return res;
	}
	res = validInteger(obj.ph_area,'Please enter the valid area code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_no,'Please enter the phone number.');
	if(!res)
	{
		return res;
	}
	
	res = validInteger(obj.ph_no,'Please enter the Valid phone number.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.want_title,'Please enter the want title.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.desc,'Please enter the description.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cateId1,'Please select the category.');
	if(!res)
	{
		return res;
	}
	
	/*res = fieldBlank(obj.subcateId1,'Please select the sub-category.');
	if(!res)
	{
		return res;
	}*/
	
	///////////////////////.....................................
	
	
	captch = document.getElementById('6_letters_code').value;
	if(captch=="")
	{
		alert("Please Enter Validation code");
		return false;
	}
	captchv = document.getElementById('6_letters_code').value.length;
	if(captchv!=6)
	{
		alert("Please Enter valid validation code");
		return false;
	}
	
	
	
	
}

// function for Buyer Want Submission.
function ValidBuyerWantSubmission()
{
	var obj = document.add_buyer;
	res = fieldBlank(obj.want_title,'Please enter the want title.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.desc,'Please enter the description.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cateId1,'Please select the category.');
	if(!res)
	{
		return res;
	}
	
    /*res = fieldBlank(obj.subcateId1,'Please select the sub-category.');
	if(!res)
	{
		return res;
	}*/
}
// function for Buyer Want Edit.
function ValidEditBuyerWant()
{
	var obj = document.add_buyer;
	res = fieldBlank(obj.want_title,'Please enter the want title.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.desc,'Please enter the description.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cateId1,'Please select the category.');
	if(!res)
	{
		return res;
	}
	
    /*res = fieldBlank(obj.subcateId1,'Please select the sub-category.');
	if(!res)
	{
		return res;
	}*/
}
// function for Buyer Submission.
function ValidEditBuyer()
{
	var obj = document.add_buyer;
	
	
	res = fieldBlank(obj.profile_name,'Please enter the Buyer name.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_address1,'Please enter the address1.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.country1,'Please select the country.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.stateId1,'Please select the state.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.cityId1,'Please select the city.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.profile_postal,'Please enter the postal code.');
	if(!res)
	{
		return res;
	}
	
	res = fieldBlank(obj.ph_country,'Please enter the country code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_area,'Please enter the area code for phone.');
	if(!res)
	{
		return res;
	}
	res = validInteger(obj.ph_area,'Please enter the valid area code for phone.');
	if(!res)
	{
		return res;
	}
	res = fieldBlank(obj.ph_no,'Please enter the phone number.');
	if(!res)
	{
		return res;
	}
	
	res = validInteger(obj.ph_no,'Please enter the valid phone number.');
	if(!res)
	{
		return res;
	}
	
}

// This is function for show characters
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
	else
		cntfield.value = maxlimit - field.value.length;
	}
	
	
	
	



function agreesubmit(el){
if(document.getElementById("agreecheck").checked==false
|| document.getElementById("agreecheck1").checked==false){
document.getElementById("commit").disabled=true;	
}
else{
	document.getElementById("commit").disabled=false;
}

}


	
	
	