// JavaScript Document
function RvalidateRegistration()
{

	////email validation
	if(!rRequireInput(rGetEle('email'),'Please Enter Email.')){	return false;}
	if(!rValidateEmail(rGetEle('email'),'Please Enter Valid Email.')){	return false;}
	
	////password validation
	if(!rRequireInput(rGetEle('password'),'Please Enter Password.')){	return false;}
	if(!rReqAlphaNum(rGetEle('password'),'Please Enter only alphanumeric as Password.')){	return false;	}
	if(!rMinLen(rGetEle('password'),'6','Password Minimum Length should be 6 characters.')){	return false;	}
	if(!rMaxLen(rGetEle('password'),'20','Password Maximum Length should be 20 characters.')){	return false;	}
	if(!rRequireInput(rGetEle('cpassword'),'Please Enter Confirm Password.')){	return false;}
	if(!rReqAlphaNum(rGetEle('cpassword'),'Please Enter only alphanumeric as Confirm Password.')){	return false;	}
	if(trim(rGetEle('password').value) != trim(rGetEle('cpassword').value)){	alert('Password Should match with confirm password');	return false;	}
	
	////first name, last name, org name, org type and designation validation
	if(!rRequireInput(rGetEle('fname'),'Please Enter First Name.')){	return false;}
	if(!rReqAlphaOnly(rGetEle('fname'),'Please Enter Only Alphabets ( not even space ) as First Name.')){	return false;}
	if(!rRequireInput(rGetEle('lname'),'Please Enter Last Name.')){	return false;}
	if(!rReqAlphaOnly(rGetEle('lname'),'Please Enter Only Alphabets ( not even space ) as Last Name.')){	return false;}
	if(!rRequireInput(rGetEle('org_name'),'Please Enter Your Organization Name.')){	return false;}
	if(!rRequireInput(rGetEle('org_type'),'Please Enter Your Organization Type.')){	return false;}
	if(!rRequireInput(rGetEle('designation'),'Please Enter Your Designation Or Roll in your organization.')){	return false;}
	
	////phone number validation
	if(!rRequireInput(rGetEle('phone'),'Please Enter Your Work Phone.')){	return false;}
	if(!rReqNumOnly(rGetEle('phone'),'Please Enter Your Work Phone as numeric only.')){	return false;}		
	
	////web url validation
	if(trim(rGetEle('web_url').value) !=''){ if(!rValidateURL(rGetEle('web_url'),'Please Enter Valid URL.')){	return false;}}
	////country validation
	if(!rRequireInput(rGetEle('country_id'),'Please Select Country.')){	return false;}
	
	////captcha code validation
	if(!rRequireInput(rGetEle('NewCapthc'),'Please Enter \n"'+rGetEle('Chkval').value+'"\n Code in last CAPTCHA field.')){	return false;}	
	return true;
}
function RvalidateAccoutUpdate()
{
	password = rGetEle('password');	
	
	////email validation
	if(!rRequireInput(rGetEle('email'),'Please Enter Email.')){	return false;}
	if(!rValidateEmail(rGetEle('email'),'Please Enter Valid Email.')){	return false;}
	
	////password validation
	if(password.value != "")
	{
		if(!rRequireInput(rGetEle('password'),'Please Enter Password.')){	return false;}
		if(!rReqAlphaNum(rGetEle('password'),'Please Enter only alphanumeric as Password.')){	return false;	}
		if(!rMinLen(rGetEle('password'),'6','Password Minimum Length should be 6 characters.')){	return false;	}
		if(!rMaxLen(rGetEle('password'),'20','Password Maximum Length should be 20 characters.')){	return false;	}
		if(!rRequireInput(rGetEle('cpassword'),'Please Enter Confirm Password.')){	return false;}
		if(!rReqAlphaNum(rGetEle('cpassword'),'Please Enter only alphanumeric as Confirm Password.')){	return false;	}
		if(trim(rGetEle('password').value) != trim(rGetEle('cpassword').value)){	alert('Password Should match with confirm password');	return false;	}
	}
	
	////first name, last name, org name, org type and designation validation
	if(!rRequireInput(rGetEle('fname'),'Please Enter First Name.')){	return false;}
	if(!rReqAlphaOnly(rGetEle('fname'),'Please Enter Only Alphabets ( not even space ) as First Name.')){	return false;}
	if(!rRequireInput(rGetEle('lname'),'Please Enter Last Name.')){	return false;}
	if(!rReqAlphaOnly(rGetEle('lname'),'Please Enter Only Alphabets ( not even space ) as Last Name.')){	return false;}
	if(!rRequireInput(rGetEle('org_name'),'Please Enter Your Organization Name.')){	return false;}
	if(!rRequireInput(rGetEle('org_type'),'Please Enter Your Organization Type.')){	return false;}
	if(!rRequireInput(rGetEle('designation'),'Please Enter Your Designation Or Roll in your organization.')){	return false;}
	
	////phone number validation
	if(!rRequireInput(rGetEle('phone'),'Please Enter Your Work Phone.')){	return false;}
	if(!rReqNumOnly(rGetEle('phone'),'Please Enter Your Work Phone as numeric only.')){	return false;}
	
	////web url validation
	if(trim(rGetEle('web_url').value) !=''){ if(!rValidateURL(rGetEle('web_url'),'Please Enter Valid URL.')){	return false;}}
	
	////captcha code validation
	if(!rRequireInput(rGetEle('NewCapthc'),'Please Enter \n"'+rGetEle('Chkval').value+'"\n Code in last CAPTCHA field.')){	return false;}	
	return true;
}
function RvalidateBizProfile()
{		
	////biz profile url validation
	rGetEle('url').value=rGetEle('url').value.replace(/^\s+|\s+$/g,"");
	if(!rRequireInput(rGetEle('url'),'Please enter your business URL name.')){	return false;	}
	if(rGetEle('url').value.search(/[^\w-_]/)>0){		alert('Invalid Profile URL\n\nValid characters are A to Z, a to z, 0 to 9, dash(minus) and underscore');	return false;	}
	if(!rMinLen(rGetEle('url'),6,'Profile URL should be of minimum 6 characters.')){	rGetEle('dupResShow').innerHTML = '';	return false;	}
	if(!rMaxLen(rGetEle('url'),20,'Profile URL should be of maximum 20 characters.')){	rGetEle('dupResShow').innerHTML = '';	return false;	}
	
	////biz name validation
	if(!rRequireInput(rGetEle('name'),'Please Enter Business Name.')){	return false;}
	if(!rReqAlphaNumAndSpace(rGetEle('name'),'Please Enter only alphanumeric as Business Name.')){	return false;	}
	
	////email validation
	if(!rRequireInput(rGetEle('email'),'Please Enter Email.')){	return false;}
	if(!rValidateEmail(rGetEle('email'),'Please Enter Valid Email.')){	return false;}
	
	////overview validation
	if(!rRequireInput(rGetEle('overview'),'Please Enter Short Overview.')){	return false;}
	if(!rRequireInput(rGetEle('tag_name'),'Please Enter Comma Separated Tag List.')){	return false;}
	
	////profile home page validation
	if(trim(rGetEle('full_overview').value) !=''){if(!rMaxLen(rGetEle('full_overview'),5000,'Full Overview should be of maximum 5000 characters.')){	return false;	}}
	if(trim(rGetEle('web_url').value) !=''){ if(!rValidateURL(rGetEle('web_url'),'Please Enter Valid URL.')){	return false;}}
	
	////biz contact detail validation
	if(trim(rGetEle('phone').value) !=''){if(!rMaxLen(rGetEle('phone'),20,'Phone Number should be of maximum 20 characters.')){	return false;	}}
	if(trim(rGetEle('fax').value) !=''){if(!rMaxLen(rGetEle('fax'),20,'Fax Number should be of maximum 20 characters.')){	return false;	}}
	if(!rRequireInput(rGetEle('country_id'),'Please select your business country name.')){	return false;	}
	if(!rRequireInput(rGetEle('state_id'),'Please select your business State name.')){	return false;	}
	if(!rRequireInput(rGetEle('city_id'),'Please select your business City name.')){	return false;	}
	if(trim(rGetEle('zip').value) !=''){if(!rMaxLen(rGetEle('zip'),20,'Zip/PinCode should be of maximum 20 characters.')){	return false;	}}
	if(trim(rGetEle('address1').value) !=''){if(!rMaxLen(rGetEle('address1'),50,'Address Line 1 should be of maximum 50 characters.')){	return false;	}}
	if(trim(rGetEle('address2').value) !=''){if(!rMaxLen(rGetEle('address2'),50,'Address Line 2 should be of maximum 50 characters.')){	return false;	}}
	
	////captcha code validation

	if(!rRequireInput(rGetEle('NewCapthc'),'Please Enter \n"'+rGetEle('Chkval').value+'"\n Code in last CAPTCHA field.')){	return false;}	
	
	return true;
}
// ADMIN BIZ PROFILE VALIDATION 
function RvalidateBizProfileAdmin(edt)
{		
	////biz profile url validation
	if(!rRequireInput(rGetEle('user_id'),'Please Select User.')){	return false;	}
	if(edt == 1) 
	{
		rGetEle('url').value=rGetEle('url').value.replace(/^\s+|\s+$/g,"");	
		if(!rRequireInput(rGetEle('url'),'Please enter your business URL name.')){	return false;	}	
		if(rGetEle('url').value.search(/[^\w-_]/)>0){		alert('Invalid Profile URL\n\nValid characters are A to Z, a to z, 0 to 9, dash(minus) and underscore');	return false;	}	
		if(!rMinLen(rGetEle('url'),6,'Profile URL should be of minimum 6 characters.')){	rGetEle('dupResShow').innerHTML = '';	return false;	}
			if(!rMaxLen(rGetEle('url'),20,'Profile URL should be of maximum 20 characters.')){	rGetEle('dupResShow').innerHTML = '';	return false;	}
	}
	////biz name validation
	if(!rRequireInput(rGetEle('name'),'Please Enter Business Name.')){	return false;}
	if(!rReqAlphaNumAndSpace(rGetEle('name'),'Please Enter only alphanumeric as Business Name.')){	return false;	}
	
	////email validation
	if(!rRequireInput(rGetEle('email'),'Please Enter Email.')){	return false;}
	if(!rValidateEmail(rGetEle('email'),'Please Enter Valid Email.')){	return false;}
	
	////overview validation
	if(!rRequireInput(rGetEle('overview'),'Please Enter Short Overview.')){	return false;}
	if(!rRequireInput(rGetEle('tag_name'),'Please Enter Comma Separated Tag List.')){	return false;}
	
	////profile home page validation
	if(trim(rGetEle('full_overview').value) !=''){if(!rMaxLen(rGetEle('full_overview'),5000,'Full Overview should be of maximum 5000 characters.')){	return false;	}}

	if(trim(rGetEle('web_url').value) !=''){ if(!rValidateURL(rGetEle('web_url'),'Please Enter Valid URL.')){	return false;}}
	
	////biz contact detail validation
	if(trim(rGetEle('phone').value) !=''){if(!rMaxLen(rGetEle('phone'),20,'Phone Number should be of maximum 20 characters.')){	return false;	}}
	if(trim(rGetEle('fax').value) !=''){if(!rMaxLen(rGetEle('fax'),20,'Fax Number should be of maximum 20 characters.')){	return false;	}}
	if(!rRequireInput(rGetEle('country_id'),'Please select your business country name.')){	return false;	}
	if(!rRequireInput(rGetEle('state_id'),'Please select your business State name.')){	return false;	}
	if(!rRequireInput(rGetEle('city_id'),'Please select your business City name.')){	return false;	}
	if(trim(rGetEle('zip').value) !=''){if(!rMaxLen(rGetEle('zip'),20,'Zip/PinCode should be of maximum 20 characters.')){	return false;	}}
	if(trim(rGetEle('address1').value) !=''){if(!rMaxLen(rGetEle('address1'),50,'Address Line 1 should be of maximum 50 characters.')){	return false;	}}
	if(trim(rGetEle('address2').value) !=''){if(!rMaxLen(rGetEle('address2'),50,'Address Line 2 should be of maximum 50 characters.')){	return false;	}}
	
	////captcha code validation	
	
	return true;
}

	// ############if(document.submitBizProfileForm.NewCapthc.value != "")
	
function RvalidatePR()
{
	//PR name validation
	if(!rRequireInput(rGetEle('headline'),'Please Enter Headline.')){	return false;}
	if(trim(rGetEle('headline').value) !=''){if(!rMaxLen(rGetEle('headline'),100,'Headline should be of maximum 100 characters.')){	return false;	}}
	
	////captcha code validation
	if(!rRequireInput(rGetEle('NewCapthc'),'Please Enter \n"'+rGetEle('Chkval').value+'"\n Code in last CAPTCHA field.')){	return false;}	
	
	return true;
}
function RvalidatePR2()
{
	//PR headline validation
	if(!rRequireInput(rGetEle('headline'),'Please Enter Headline.')){	return false;}
	if(trim(rGetEle('headline').value) !=''){if(!rMaxLen(rGetEle('headline'),100,'Headline should be of maximum 100 characters.')){	return false;	}}
	
	if(!rRequireInput(rGetEle('summary'),'Please Enter Press Release Summary.')){	return false;}
	if(trim(rGetEle('summary').value) !=''){if(!rMaxLen(rGetEle('summary'),255,'Press Release Summary should be of maximum 255 characters.')){	return false;	}}
	
	if(!rRequireInput(rGetEle('body'),'Please Enter Press Release Body.')){	return false;}
	if(trim(rGetEle('body').value) !=''){if(!rMaxLen(rGetEle('body'),8000,'Press Release Body should be of maximum 8000 characters.')){	return false;	}}
	
	////captcha code validation
	if(!rRequireInput(rGetEle('NewCapthc'),'Please Enter \n"'+rGetEle('Chkval').value+'"\n Code in last CAPTCHA field.')){	return false;}	
	
	return true;
}
/*--------------- THAI FUNCTIONS START----------------------------------------*/
function RvalidateRegister()
{		
	if(!rRequireInput(rGetEle('fullname'),'Please Enter Your Name(First and Last).')){	return false;}	
	if(!rRequireInput(rGetEle('remail'),'Please Enter Email Address.')){	return false;}
	if(!rValidateEmail(rGetEle('remail'),'Please Enter Valid Email Address.')){	return false;}
	if(!rRequireInput(rGetEle('cemail'),'Please Enter Confirm Email Address.')){	return false;}
	if(!rValidateEmail(rGetEle('cemail'),'Please Enter Valid Confirm Email Address.')){	return false;}
	if(rGetEle('remail').value != rGetEle('cemail').value) { alert("Confirm Email Address not match"); return false; }
	
	if(!rRequireInput(rGetEle('rpass'),'Please Enter Password.')){	return false;}			
	if(!rMinLen(rGetEle('rpass'),6,'Password should be of minimum 6 characters.')){ return false;	}	
	if(!rRequireInput(rGetEle('cpass'),'Please Enter Confirm Password.')){	return false;}	
	if(rGetEle('cpass').value != rGetEle('rpass').value) { alert("Confirm Password not match"); return false; }
	
	rGetEle('frmRegister').submit();
}

//==== AMULET WANTED ADD
function RvalidateWanted()
{			
	if(!rRequireInput(rGetEle('type'),'Please Select Amulet Type.')){	return false;}
	if(!rRequireInput(rGetEle('description'),'Please Enter Description about amulet.')){	return false;}				
	rGetEle('frmWantedAmulet').submit();
}

function RvalidateEditProfile()
{		
	
	if(!rRequireInput(rGetEle('fullname'),'Please Enter Your Name(First and Last).')){	return false;}	
	if(!rRequireInput(rGetEle('remail'),'Please Enter Email Address.')){	return false;}
	if(!rValidateEmail(rGetEle('remail'),'Please Enter Valid Email Address.')){	return false;}
	if(!rRequireInput(rGetEle('cemail'),'Please Enter Confirm Email Address.')){	return false;}
	if(!rValidateEmail(rGetEle('cemail'),'Please Enter Valid Confirm Email Address.')){	return false;}
	if(rGetEle('remail').value != rGetEle('cemail').value) { alert("Confirm Email Address not match"); return false; }
	
	if(!rRequireInput(rGetEle('rpass'),'Please Enter Password.')){	return false;}			
	if(!rMinLen(rGetEle('rpass'),6,'Password should be of minimum 6 characters.')){ return false;	}	
	if(!rRequireInput(rGetEle('cpass'),'Please Enter Confirm Password.')){	return false;}	
	if(rGetEle('cpass').value != rGetEle('rpass').value) { alert("Confirm Password not match"); return false; }
	
	
	if(!rRequireInput(rGetEle('phone'),'Please Enter Phone.')){	return false;}	
	if(!rReqNumOnly(rGetEle('phone'),'Please Enter Your Phone as numeric only.')){	return false;}			
	
	if(!rRequireInput(rGetEle('address1'),'Please Enter Address line 1.')){	return false;}
	if(!rRequireInput(rGetEle('city'),'Please Enter City.')){	return false;}
	if(!rRequireInput(rGetEle('zipcode'),'Please Enter Area code.')){	return false;}
	
	if(!rRequireInput(rGetEle('country'),'Please select Country.')){	return false;}
	if(!rRequireInput(rGetEle('sphone'),'Please Enter Phone.')){	return false;}
	if(!rReqNumOnly(rGetEle('sphone'),'Please Enter Your Phone as numeric only.')){	return false;}			
		
	rGetEle('frmRegister').submit();
}
/// FORGOT PASSWORD
function RvalidForgotPwd()
{
	if(!rRequireInput(rGetEle('email'),'Please Enter Email Address.')){	return false;}
	if(!rValidateEmail(rGetEle('email'),'Please Enter Valid Email Address.')){	return false;}
	rGetEle('frmForgotPwd').submit();
}
/// LOGIN
function RvalidateLogin()
{
	if(!rRequireInput(rGetEle('email'),'Please Enter Email Address.')){	return false;}
	if(!rValidateEmail(rGetEle('email'),'Please Enter Valid Email Address.')){	return false;}
	if(!rRequireInput(rGetEle('pass'),'Please Enter Password.')){	return false;}
	rGetEle('frmLogin').submit();
}

/// check all function

function checkall(domId,referDom)
{	
	var dom = document.manage;
	if(referDom.checked == true)
	{
		for(i=0;i<dom.length;i++)
		{
			if(dom.elements[i].type == "checkbox")
			{
				var chkname=dom.elements[i].id;
				if(chkname.substr(0,12)==domId)
				{
					dom.elements[i].checked = true;
				}
			}
		}
	}
	else
	{
		for(i=0;i<dom.length;i++)
		{
			if(dom.elements[i].type == "checkbox")
			{
				var chkname=dom.elements[i].id;
				if(chkname.substr(0,12)==domId)
				{
					dom.elements[i].checked = false;
				}
			}
		}
	}
}

// contact form validation

function RContactValidation()
{			

	if(!rRequireInput(rGetEle('name'),'Please Enter Your Name.')){	return false;}
	if(!rReqAlphaNumAndSpace(rGetEle('name'),'Please Enter only alphanumeric as Your Name.')){	return false;	}
	
	////email validation
	if(!rRequireInput(rGetEle('email'),'Please Enter Your Email.')){	return false;}
	if(!rValidateEmail(rGetEle('email'),'Please Enter Valid Email.')){	return false;}
	
	////overview validation
	//if(!rRequireInput(rGetEle('address'),'Please Enter Address.')){	return false;}	
	if(!rRequireInput(rGetEle('type'),'Please Select Subject.')){	return false;}	
	if(!rRequireInput(rGetEle('enquiry'),'Please Enter Enquiry.')){	return false;}	
	
	////captcha code validation

	/*if(!rRequireInput(rGetEle('NewCapthc'),'Please Enter \n"'+rGetEle('Chkval').value+'"\n Code in last CAPTCHA field.')){	return false;}	*/
	//rGetEle('frmContact').submit();	
	return true;
}

//// delete item from wishlist
function formWishSubmit()
{		
	var form = document.manage;		
	var len = form.feature.length;

	var j=0;		
	if(len == null) {	var len = 1;			}	
			
	for(i=0; i<len; i++)
	{					
		if(len == 1)	{
			if(form.feature.checked)
				j++;
		}	
		else	{
		if(form.feature[i].checked)
			j++;					
		}											
	}
							
	if(j==0)	{
		alert("Please select item for remove.");	return false;
	}	
	else	{						
		if(confirm('Are you sure to remove this amulet from Amulet wanted list??')){ 	document.manage.submit();}else{	return false;}
	}	
}

//// delete NOTIFICATION
function formNotificationSubmit()
{		
	var form = document.manage;		
	var len = form.feature.length;

	var j=0;		
	if(len == null) {	var len = 1;			}	
			
	for(i=0; i<len; i++)
	{					
		if(len == 1)	{
			if(form.feature.checked)
				j++;
		}	
		else	{
		if(form.feature[i].checked)
			j++;					
		}											
	}
							
	if(j==0)	{
		alert("Please select notification for remove.");	return false;
	}	
	else	{						
		if(confirm('Are you sure to remove this notification??')){ 	document.manage.submit();}else{	return false;}
	}	
}

//Search validation
function searchRequire()
{
	var str = document.frmkbsearch.kbsearch.value;	
	if(str == "Search..")	{
		alert("Please enter search text.");
		document.frmkbsearch.kbsearch.focus();
		return false;
	}
	return true;	
}

//Search KNOWLEDGEBASE validation
function kbSearchRequire()
{
	
	var str = document.kbsearch.kbsearch.value;		
	if(str == "")	{
		alert("Please enter search text.");
		document.kbsearch.kbsearch.focus();
		return false;
	}
	if(str.length < 3){
		alert("Please enter min 3 charaters.");
		document.kbsearch.kbsearch.focus();
		return false;
	}
	return true;	
}

//category search KNOWLEDGEBASE validation
function categorySearchRequire()
{	
	var str = document.searchByCategory.searchByCategory.value;	
	if(str == "")	{ 
		alert("Please select category.");
		document.searchByCategory.searchByCategory.focus();
		return false;
	}
	return true;	
}

function RvalidateReturnAmulet()
{				
	if(!rRequireInput(rGetEle('first_name'),'Please Enter First Name.')){	return false;}
	if(!rRequireInput(rGetEle('last_name'),'Please Enter Last Name.')){	return false;}
	if(!rRequireInput(rGetEle('address1'),'Please Enter Address Line 1.')){	return false;}
	if(!rRequireInput(rGetEle('country'),'Please Select Your Country.')){	return false;}
	if(!rRequireInput(rGetEle('state'),'Please Enter State.')){	return false;}
	if(!rRequireInput(rGetEle('city'),'Please Enter City.')){	return false;}
	if(!rRequireInput(rGetEle('zip'),'Please Enter Zip.')){	return false;}
	
	if(!rRequireInput(rGetEle('email'),'Please Enter Email.')){	return false;}
	if(!rValidateEmail(rGetEle('email'),'Please Enter Valid Email.')){	return false;}
	if(!rRequireInput(rGetEle('amulet_number'),'Please Enter Amulet Number.')){	return false;}
	if(!rRequireInput(rGetEle('amulet_name'),'Please Enter Amulet Name.')){	return false;}
	if(!rRequireInput(rGetEle('order_number'),'Please Enter Order Number.')){	return false;}
	
	if(!rRequireInput(rGetEle('NewCapthc'),'Please Enter Security Code.')){	return false;}
	return true;
}
function RConfirmDetail()
{
	if(!rRequireInput(rGetEle('FIRSTNAME'),'Please Enter Receiver Name on Shipping Detail.')){	return false;}	
	if(!rRequireInput(rGetEle('SHIPTOSTREET'),'Please Enter Shipping Address1.')){	return false;}	
	if(!rRequireInput(rGetEle('SHIPTOCITY'),'Please Enter Shipping City.')){	return false;}	
	if(!rRequireInput(rGetEle('SHIPTOSTATE'),'Please Enter Shipping State.')){	return false;}	
	if(!rRequireInput(rGetEle('SHIPTOZIP'),'Please Enter Shipping Post/Zip Code.')){	return false;}
	return true;
}
function ValidateGiftCertificate()
{
	if(!rRequireInput(rGetEle('amulet_name'),'Please Enter Amulet Name.')){	return false;}
	if(!rRequireInput(rGetEle('temple_name'),'Please Enter Temple Name.')){	return false;}
	if(!rRequireInput(rGetEle('certificate_number'),'Please Enter Certificate Number.')){	return false;}
	if(!rRequireInput(rGetEle('date_of_amulet'),'Please Enter Date Of Amulet.')){	return false;}
	if(!rRequireInput(rGetEle('date_0f_certificate_issued'),'Please Enter Date Of Certificate Issued.')){	return false;}
	return true;
}
