function chack_validation(val)
{
	var alpha="+-01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`'\"()";
	var found=false;
	for(i=0;i<val.length;i++)
	{
		if(alpha.indexOf(val.charAt(i),0)!=-1)
		 {
			found=true;
			break;
		 }
	}
	
	if(found)
		return false;
	else
		return true;
}

function contact_us_validation()
{
   if(frm.email.value=="") 
	{
		alert("Please enter the E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",1)==-1) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",1)==0) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",frm.email.value.indexOf("@",1)+1)>-1) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf(".",frm.email.value.indexOf("@",1)+2)==-1)	
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.name.value=="") 
	{
		alert("Please enter the name");
		frm.name.focus();
		return false;
	}
	
	if(frm.data.value=="") 
	{
		alert("Please enter the data");
		frm.data.focus();
		return false;
	}
	
	if(frm.authentication_number.value=="") 
	{
		alert("Please enter the authentication number");
		frm.authentication_number.focus();
		return false;
	}	
}

//-----------------Admin Account------------------
function admin_account_validation()
{
	if(frm.username.value=="")
	 {
		alert("Please enter the user name");
		frm.username.focus();
		return false;
	 }
	
	if(frm.old_password.value=="")
	 {
		alert("Please enter the old password");
		frm.old_password.focus();
		return false;
	 }
	 
	if(frm.new_password.value=="")
	 {
		alert("Please enter the new password");
		frm.new_password.focus();
		return false;
	 }
	
	if(frm.confirm_password.value=="")
	 {
		alert("Please retype your password");
		frm.confirm_password.focus();
		return false;
	 }
	 	
	if(frm.new_password.value!="" && frm.confirm_password.value!="" && frm.confirm_password.value!=frm.new_password.value)
	 {
		alert("The confirmation password doesn't match the origin one");
		frm.confirm_password.value="";
		frm.confirm_password.focus();
		return false;
	 }
}

//-------------- WebSite Configuration ---------------
function website_configurations()
{
	if(frm.website_url.value=="")
	 {
		alert("Please enter the Website URL");
		frm.website_url.focus();
		return false;
	 }
	 
	 if(frm.website_name.value=="")
	 {
		alert("Please enter the Website name");
		frm.website_name.focus();
		return false;
	 }
	 
	 if(frm.title_bar.value=="")
	 {
		alert("Please enter the Title Bar Caption");
		frm.title_bar.focus();
		return false;
	 }
	 
	 if(frm.administrator_email.value=="")
	 {
		alert("Please enter the Administrator E-mail");
		frm.administrator_email.focus();
		return false;
	 }
	 
	if(frm.administrator_email.value.indexOf("@",1)==-1) 
	{
		alert("Invalid Administrator E-mail address");
		frm.administrator_email.focus();
		return false;
	}
	
	if(frm.administrator_email.value.indexOf("@",1)==0) 
	{
		alert("Invalid Administrator E-mail address");
		frm.administrator_email.focus();
		return false;
	}
	
	if(frm.administrator_email.value.indexOf("@",frm.administrator_email.value.indexOf("@",1)+1)>-1) 
	{
		alert("Invalid Administrator E-mail address");
		frm.administrator_email.focus();
		return false;
	}
	
	if(frm.administrator_email.value.indexOf(".",frm.administrator_email.value.indexOf("@",1)+2)==-1)	
	{
		alert("Invalid Administrator E-mail address");
		frm.administrator_email.focus();
		return false;
	}
	
	if(frm.contact_email.value=="")
	 {
		alert("Please enter the Contact E-mail");
		frm.contact_email.focus();
		return false;
	 }
	 
	if(frm.contact_email.value.indexOf("@",1)==-1) 
	{
		alert("Invalid Contact E-mail address");
		frm.contact_email.focus();
		return false;
	}
	
	if(frm.contact_email.value.indexOf("@",1)==0) 
	{
		alert("Invalid Contact E-mail address");
		frm.contact_email.focus();
		return false;
	}
	
	if(frm.contact_email.value.indexOf("@",frm.contact_email.value.indexOf("@",1)+1)>-1) 
	{
		alert("Invalid Contact E-mail address");
		frm.contact_email.focus();
		return false;
	}
	
	if(frm.contact_email.value.indexOf(".",frm.contact_email.value.indexOf("@",1)+2)==-1)	
	{
		alert("Invalid Contact E-mail address");
		frm.contact_email.focus();
		return false;
	}
	 
	 /*if(frm.website_footer.value=="")
	 {
		alert("Please enter the Website Footer");
		frm.website_footer.focus();
		return false;
	 }
	 */
	 if(frm.page_result.value=="")
	 {
		alert("Please enter the Main Result Per Page");
		frm.page_result.focus();
		return false;
	 }
	 
	if(isNaN(frm.page_result.value) || frm.page_result.value<1) 
	{
		alert("Invalid Main Result Per Page value, It must be integer over zero value");
		frm.page_result.focus();
		return false;
	}
	 
	 if(frm.box_result.value=="")
	 {
		alert("Please enter the Main Result Per Box");
		frm.box_result.focus();
		return false;
	 }
	 
	if(isNaN(frm.box_result.value) || frm.box_result.value<1) 
	{
		alert("Invalid Main Result Per Box value, It must be integer over zero value");
		frm.box_result.focus();
		return false;
	}
}

// ------------ Client Login validation ---------------
function check_client_login_validation()
{
   if(login_frm.client_username.value=="") 
	{
		alert("Please enter your user name");
		login_frm.client_username.focus();
		return false;
	}
   else
   if(login_frm.client_password.value=="") 
	{
		alert("Please enter your password");
		login_frm.client_password.focus();
		return false;
	}
}

//------------- New Client validation--------------
function client_validation()
{
  	if(frm.username.value=="" || chack_validation(frm.username.value))
	 {
		alert("Please enter the username");
		frm.username.focus();
		return false;
	 }
	 
	if(frm.password.value=="" || chack_validation(frm.password.value))
	 {
		alert("Please enter the password");
		frm.password.focus();
		return false;
	 }
	
	if(frm.confirm_password.value=="" || chack_validation(frm.confirm_password.value))
	 {
		alert("Please retype your password");
		frm.confirm_password.focus();
		return false;
	 }
	 	
	if(frm.password.value!="" && frm.confirm_password.value!="" && frm.confirm_password.value!=frm.password.value)
	 {
		alert("The confirmation password doesn't match the origin one");
		frm.confirm_password.value="";
		frm.confirm_password.focus();
		return false;
	 }
	
	if(frm.name.value=="" || chack_validation(frm.name.value))
	 {
		alert("Please enter the name");
		frm.name.focus();
		return false;
	 }
	 	 
	if(frm.company.value=="" || chack_validation(frm.company.value)) 
	{
		alert("Please enter the company");
		frm.company.focus();
		return false;
	 }
	 
   if(frm.url.value=="" || chack_validation(frm.url.value)) 
	{
		alert("Please enter the url");
		frm.url.focus();
		return false;
	 }

	if(frm.email.value=="") 
	{
		alert("Please enter the E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",1)==-1) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",1)==0) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",frm.email.value.indexOf("@",1)+1)>-1) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf(".",frm.email.value.indexOf("@",1)+2)==-1)	
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
		
	if(frm.phone.value=="") 
	 {
		alert("Please enter the phone");
		frm.phone.focus();
		return false;
	 }
	 
}

//------------- Edit Client validation--------------
function edit_client_validation()
{
    if(frm.password.value!="")
	 {
	 	if(frm.confirm_password.value=="" || chack_validation(frm.confirm_password.value))
		 {
			alert("Please retype your password");
			frm.confirm_password.focus();
			return false;
		 }
			
		if(frm.password.value!="" && frm.confirm_password.value!="" && frm.confirm_password.value!=frm.password.value)
		 {
			alert("The confirmation password doesn't match the origin one");
			frm.confirm_password.value="";
			frm.confirm_password.focus();
			return false;
		 }
	 }
	
	if(frm.name.value=="" || chack_validation(frm.name.value))
	 {
		alert("Please enter the name");
		frm.name.focus();
		return false;
	 }
	 	 
	if(frm.company.value=="" || chack_validation(frm.company.value)) 
	{
		alert("Please enter the company");
		frm.company.focus();
		return false;
	 }
	 
   if(frm.url.value=="" || chack_validation(frm.url.value)) 
	{
		alert("Please enter the url");
		frm.url.focus();
		return false;
	 }

	if(frm.email.value=="") 
	{
		alert("Please enter the E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",1)==-1) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",1)==0) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf("@",frm.email.value.indexOf("@",1)+1)>-1) 
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}
	
	if(frm.email.value.indexOf(".",frm.email.value.indexOf("@",1)+2)==-1)	
	{
		alert("Invalid E-mail address");
		frm.email.focus();
		return false;
	}	
	if(frm.phone.value=="") 
	 {
		alert("Please enter the phone");
		frm.phone.focus();
		return false;
	 }
}

// --------- Send Client Password ---------------
function send_client_password_validation()
{
   if(forget_frm.forget_client_username.value=="") 
	{
		alert("Please enter your user name");
		forget_frm.forget_client_username.focus();
		return false;
	}
   else
   if(forget_frm.forget_client_email.value=="") 
	{
		alert("Please enter your E-mail");
		forget_frm.forget_client_email.focus();
		return false;
	}
   else
   if(forget_frm.forget_client_email.value.indexOf("@",1)==-1) 
	{
		alert("Invalid E-mail address");
		forget_frm.forget_client_email.focus();
		return false;
	}
   else
   if(forget_frm.forget_client_email.value.indexOf("@",1)==0) 
	{
		alert("Invalid E-mail address");
		forget_frm.forget_client_email.focus();
		return false;
	}
   else
   if(forget_frm.forget_client_email.value.indexOf("@",forget_frm.forget_client_email.value.indexOf("@",1)+1)>-1) 
	{
		alert("Invalid E-mail address");
		forget_frm.forget_client_email.focus();
		return false;
	}
   else
   if(forget_frm.forget_client_email.value.indexOf(".",forget_frm.forget_client_email.value.indexOf("@",1)+2)==-1)	
	{
		alert("Invalid E-mail address");
		forget_frm.forget_client_email.focus();
		return false;
	}
}

//-------------News------------------------------
function news_validation()
{
	if(frm.title.value=="")
	{
		alert("Please enter the TITLE of news");
		frm.title.focus();
		return false;
	}
	if(frm.rte1.value=="")
	{
		alert("Please enter the Description of news");
		return false;
	}
}

//-------------FAQ------------------------------
function faq_validation()
{
	if(frm.question.value=="") 
	{
		alert("Please enter the question");
		frm.question.focus();
		return false;
	}
	
   if(frm.rte1.value=="") 
	{
		alert("Please enter the answer");
		return false;
	}
}
