function setFocus(cid)
{
	document.getElementById(cid).focus();
}

function validateUserLoginForm()
{
	  frm=document.frm_user_login;
	  var req = new Array("txt_username","txt_password");
	  var email = new Array();
	  var digits = new Array();
	  var currs = new Array();
		
	  if(validate(req,email,digits,currs)==true)
	  {
			//getData(method,target_file,parameters,target_element_id_param,show_processing_image_param);
			var method="POST";
			var target_file="ajx_chk_login.php";
			
			if(frm.rad_remember.checked==true)
			{			
				var parameters="uid="+frm.txt_username.value+"&pwd="+frm.txt_password.value+"&rem_me=1";
			}
			else
			{
				var parameters="uid="+frm.txt_username.value+"&pwd="+frm.txt_password.value+"&rem_me=0";
			}						
			
			var target_element_id_param="id_proc_img";
			var show_processing_image_param="1";
			var chk_user = getData(method,target_file,parameters,target_element_id_param,show_processing_image_param);
		
			frm.txt_username.value="";
			frm.txt_password.value="";
			document.getElementById("txt_username").style.border="1px solid #E5E5E5";
			document.getElementById("txt_password").style.border="1px solid #E5E5E5";
			
			return false;
	}
	else
		return false;		
}

function validateForgotPwdForm()
{

	  frm=document.frm_user_login;
	  var req = new Array("txt_username");
	  var email = new Array();
	  var digits = new Array();
	  var currs = new Array();
		
	  return validate(req,email,digits,currs);
}

 function validateEditProfileForm()
 {

	  frm=document.frm_edit_user;

	  var req = new Array();
	  var email = new Array();
	  var digits = new Array();
	  var currs = new Array();
	  
	  if(validate(req,email,digits,currs)==true)
	  {
			if(frm.fname_is_manditory.value=='1')
			{	
				if(frm.txt_fname.value=="")
				{
					alert(frm.txt_fname.title);
					frm.txt_fname.focus();
					frm.txt_fname.style.border="1px solid #FF0000";
					return false;
				}	
			}
			if(frm.lname_is_manditory.value=='1')
			{	
				if(frm.txt_lname.value=="")
				{
					alert(frm.txt_lname.title);
					frm.txt_lname.focus();
					frm.txt_lname.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.address_is_manditory.value=='1')
			{	
				if(frm.txt_address.value=="")
				{
					alert(frm.txt_address.title);
					frm.txt_address.focus();
					frm.txt_address.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.city_is_manditory.value=='1')
			{	
				if(frm.txt_city.value=="")
				{
					alert(frm.txt_city.title);
					frm.txt_city.focus();
					frm.txt_city.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.country_is_manditory.value=='1')
			{	
				if(frm.sel_country.value=="")
				{
					alert(frm.sel_country.title);
					return false;
				}	
			}

			if(frm.zipcode_is_manditory.value=='1')
			{	
				if(frm.txt_zip.value=="")
				{
					alert(frm.txt_zip.title);
					frm.txt_zip.focus();
					frm.txt_zip.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.phone_is_manditory.value=='1')
			{	
				if(frm.txt_phone.value=="")
				{
					alert(frm.txt_phone.title);
					frm.txt_phone.focus();
					frm.txt_phone.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.fax_is_manditory.value=='1')
			{	
				if(frm.txt_fax.value=="")
				{
					alert(frm.txt_fax.title);
					frm.txt_fax.focus();
					frm.txt_fax.style.border="1px solid #FF0000";
					return false;
				}	
			}
			
			if(frm.hid_pay_field_allowed && frm.hid_pay_field_allowed.value=='1')
			{			
				if(frm.txt_pay_acct.value=="")
				{
					if(frm.paypal_is_manditory.value=='1')
					{
						alert("Please fill up your paypal account");
						frm.txt_pay_acct.focus();
						frm.txt_pay_acct.style.border="1px solid #FF0000";
						return false;
					}
				}
				else 
				if (!isEmail(trim(frm.txt_pay_acct.value)))
				{
					alert("Please fill up valid paypal account");
					frm.txt_pay_acct.focus();
					frm.txt_pay_acct.style.border="1px solid #FF0000";
					return false;

				}
			}

			if(frm.hid_cb_id_allowed && frm.hid_cb_id_allowed.value=='1')
			{			
				if(frm.txt_cb_aff_id.value=="")
				{
					if(frm.cb_id_is_manditory.value=='1')
					{
						alert("Please fill up your clickbank affiliate ID");
						frm.txt_cb_aff_id.focus();
						frm.txt_cb_aff_id.style.border="1px solid #FF0000";
						return false;
					}
				}	
			}

			//Validate user fisrt name
			if(frm.txt_fname && frm.txt_fname.value != "" && isValidName("txt_fname")==false)							
			return false;

			//Validate user last name
			if(frm.txt_lname && frm.txt_lname.value != "" && isValidName("txt_lname")==false)							
			return false;
			
			//Validate user city name
			if(frm.txt_city && frm.txt_city.value != "" && isValidName("txt_city")==false)							
			return false;

			/*if(frm.txt_zip && frm.txt_zip.value != "" && !checkZip(frm.txt_zip))
			{
				return false;
			}
			
			if(frm.txt_phone && frm.txt_phone.value != "" && !checkPhone(frm.txt_phone))
			{
				return false;
			}*/
			
			return true;
	}
	else
		return false;		
 }

function validateChgPwdForm()
{

	  frm=document.frm_change_pwd;
	  var req = new Array("txt_currpwd","txt_newpwd","txt_confpwd");
	  var email = new Array();
	  var digits = new Array();
	  var currs = new Array();
		
	  if(validate(req,email,digits,currs)==true)
	  {

			if(frm.txt_newpwd.value.length < 6 )
			{
				alert("Password must contain at least 6 characters in it.");
				frm.txt_newpwd.value="";
				frm.txt_newpwd.focus();
				frm.txt_newpwd.style.border="1px solid #FF0000";
				return false;
			}
			
			if(frm.txt_newpwd.value != frm.txt_confpwd.value)
			{
				alert("New password and confirm password must be same.");
				frm.txt_newpwd.value="";
				frm.txt_confpwd.value="";
				frm.txt_newpwd.focus();
				frm.txt_newpwd.style.border="1px solid #FF0000";
				frm.txt_confpwd.focus();
				frm.txt_confpwd.style.border="1px solid #FF0000";

				return false;
			}	
			
			return true;		
			
	}
	else
	{
		return false;	
	}
		
}

function checkPayOptionForm(form)
{
	var chk_list = document.frm_sales.chk_package.length;
	var selected = false;
	if(chk_list > 0)
	{
		for(i=0;i<chk_list;i++)
		{
			if(document.frm_sales.chk_package[i].checked==true)
			{
				selected = true;
			}//if
		}//for
	}
	else
	{
			if(document.frm_sales.chk_package.checked==true)
			{
				selected = true;
			}//if
	}
	 if (!selected)
	 {
		  alert('Please select a payment option');
		  return false;
	 }
		 
 return true;
}

 /*function validateRegistrationform()
 {

	  frm=document.frm_user_registration;
	  
	  var req = new Array("txt_email","txt_password","txt_confpassword","txt_fname","txt_lname","txt_address","txt_city","sel_country","txt_zip");
	  var email = new Array("txt_email");
	  var digits = new Array();
	  var currs = new Array();

	  if(validate(req,email,digits,currs)==true)
	  {

			if(frm.hid_pay_field_allowed && frm.hid_pay_field_allowed.value=='1')
			{			
				if(frm.txt_pay_acct.value=="")
				{
					alert("Please fill up your paypal account");
					frm.txt_pay_acct.focus();
					frm.txt_pay_acct.style.border="1px solid #FF0000";
					return false;
				}	
				else 
				if (!isEmail(trim(frm.txt_pay_acct.value)))
				{
					alert("Please fill up valid paypal account");
					frm.txt_pay_acct.focus();
					frm.txt_pay_acct.style.border="1px solid #FF0000";
					return false;

				}

			}

			if(frm.hid_coupon_allowed && frm.hid_coupon_allowed.value=='1')
			{	
				if(frm.txt_coupon_code.value=="")
				{
					alert("Please fill up your coupon code");
					frm.txt_coupon_code.focus();
					frm.txt_coupon_code.style.border="1px solid #FF0000";
					return false;
				}	
			}
			
			if(frm.hid_custom_19 && frm.hid_custom_19.value=='1')
			{	
				if(frm.txt_custom_19.value=="")
				{
					alert(frm.txt_custom_19.title);
					frm.txt_custom_19.focus();
					frm.txt_custom_19.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.hid_custom_20 && frm.hid_custom_20.value=='1')
			{	
				if(frm.txt_custom_20.value=="")
				{
					alert(frm.txt_custom_20.title);
					frm.txt_custom_20.focus();
					frm.txt_custom_20.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.hid_custom_21 && frm.hid_custom_21.value=='1')
			{	
				if(frm.txt_custom_21.value=="")
				{
					alert(frm.txt_custom_21.title);
					frm.txt_custom_21.focus();
					frm.txt_custom_21.style.border="1px solid #FF0000";
					return false;
				}	
			}			

			if(frm.hid_captcha_allowed && frm.hid_captcha_allowed.value!="")
			{	
				if(frm.txt_touringno.value=="")
				{
					alert("Please type the code as shown");
					frm.txt_touringno.focus();
					frm.txt_touringno.style.border="1px solid #FF0000";
					return false;
				}
				else 
				if(frm.hid_captcha_allowed.value!=frm.txt_touringno.value)
				{
					alert("Please type the code as shown");
					frm.txt_touringno.focus();
					frm.txt_touringno.style.border="1px solid #FF0000";
					return false;
				}
			}

			if(frm.txt_password.value.length < 6 )
			{

				alert("Password must have at least 6 characters in it");
				frm.txt_password.value="";
				frm.txt_password.focus();
				frm.txt_password.style.border="1px solid #FF0000";
								
				return false;
			}
			
			if(frm.txt_password.value != frm.txt_confpassword.value)
			{
				alert("Password and confirm pasword must be same");
				frm.txt_confpassword.value="";
				frm.txt_confpassword.focus();
				frm.txt_confpassword.style.border="1px solid #FF0000";
				return false;
			}
			
			//Validate user fisrt name
			if(isValidName("txt_fname")==false)							
			return false;

			//Validate user last name
			if(isValidName("txt_lname")==false)							
			return false;

			if(!checkZip(frm.txt_zip))
			{
				return false;
			}
			
			if(frm.txt_phone.value!="" && !checkPhone(frm.txt_phone))
			{
				return false;
			}
			
			if(document.getElementById("chk_terms_cond").checked==false) 
			{
				alert("Please accept terms and conditions");
				document.getElementById("chk_terms_cond").focus();
				return false;
			}
			
			return true;
	}
	else
		return false;		
 }*/
 
 function validateRegistrationform()
 {

	  frm=document.frm_user_registration;
	  
	  var req = new Array("txt_email","txt_password","txt_confpassword");
	  var email = new Array("txt_email");
	  var digits = new Array();
	  var currs = new Array();

	  if(validate(req,email,digits,currs)==true)
	  {

			if(frm.fname_is_manditory.value=='1')
			{	
				if(frm.txt_fname.value=="")
				{
					alert(frm.txt_fname.title);
					frm.txt_fname.focus();
					frm.txt_fname.style.border="1px solid #FF0000";
					return false;
				}	
			}
			if(frm.lname_is_manditory.value=='1')
			{	
				if(frm.txt_lname.value=="")
				{
					alert(frm.txt_lname.title);
					frm.txt_lname.focus();
					frm.txt_lname.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.address_is_manditory.value=='1')
			{	
				if(frm.txt_address.value=="")
				{
					alert(frm.txt_address.title);
					frm.txt_address.focus();
					frm.txt_address.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.city_is_manditory.value=='1')
			{	
				if(frm.txt_city.value=="")
				{
					alert(frm.txt_city.title);
					frm.txt_city.focus();
					frm.txt_city.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.country_is_manditory.value=='1')
			{	
				if(frm.sel_country.value=="")
				{
					alert(frm.sel_country.title);
					return false;
				}	
			}

			if(frm.zipcode_is_manditory.value=='1')
			{	
				if(frm.txt_zip.value=="")
				{
					alert(frm.txt_zip.title);
					frm.txt_zip.focus();
					frm.txt_zip.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.phone_is_manditory.value=='1')
			{	
				if(frm.txt_phone.value=="")
				{
					alert(frm.txt_phone.title);
					frm.txt_phone.focus();
					frm.txt_phone.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.fax_is_manditory.value=='1')
			{	
				if(frm.txt_fax.value=="")
				{
					alert(frm.txt_fax.title);
					frm.txt_fax.focus();
					frm.txt_fax.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.hid_custom_19 && frm.hid_custom_19.value=='1')
			{	
				if(frm.txt_custom_19.value=="")
				{
					alert(frm.txt_custom_19.title);
					frm.txt_custom_19.focus();
					frm.txt_custom_19.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.hid_custom_20 && frm.hid_custom_20.value=='1')
			{	
				if(frm.txt_custom_20.value=="")
				{
					alert(frm.txt_custom_20.title);
					frm.txt_custom_20.focus();
					frm.txt_custom_20.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.hid_custom_21 && frm.hid_custom_21.value=='1')
			{	
				if(frm.txt_custom_21.value=="")
				{
					alert(frm.txt_custom_21.title);
					frm.txt_custom_21.focus();
					frm.txt_custom_21.style.border="1px solid #FF0000";
					return false;
				}	
			}

			if(frm.hid_pay_field_allowed && frm.hid_pay_field_allowed.value=='1')
			{			
				if(frm.txt_pay_acct.value=="")
				{
					if(frm.paypal_is_manditory.value=='1')
					{
						alert("Please fill up your paypal account");
						frm.txt_pay_acct.focus();
						frm.txt_pay_acct.style.border="1px solid #FF0000";
						return false;
					}
				}	
				else 
				if (!isEmail(trim(frm.txt_pay_acct.value)))
				{
					alert("Please fill up valid paypal account");
					frm.txt_pay_acct.focus();
					frm.txt_pay_acct.style.border="1px solid #FF0000";
					return false;

				}
			}

			if(frm.hid_cb_id_allowed && frm.hid_cb_id_allowed.value=='1')
			{			
				if(frm.txt_cb_aff_id.value=="")
				{
					if(frm.cb_id_is_manditory.value=='1')
					{
						alert("Please fill up your clickbank affiliate ID");
						frm.txt_cb_aff_id.focus();
						frm.txt_cb_aff_id.style.border="1px solid #FF0000";
						return false;
					}
				}	
			}

			/*if(frm.hid_coupon_allowed && frm.hid_coupon_allowed.value=='1')
			{	
				if(frm.txt_coupon_code.value=="")
				{
					alert("Please fill up your coupon code");
					frm.txt_coupon_code.focus();
					frm.txt_coupon_code.style.border="1px solid #FF0000";
					return false;
				}	
			}*/

			if(frm.hid_captcha_allowed && frm.hid_captcha_allowed.value!="")
			{	
				if(frm.txt_touringno.value=="")
				{
					alert("Please type the code as shown");
					frm.txt_touringno.focus();
					frm.txt_touringno.style.border="1px solid #FF0000";
					return false;
				}
				else 
				if(frm.hid_captcha_allowed.value!=frm.txt_touringno.value)
				{
					alert("Please type the code as shown");
					frm.txt_touringno.focus();
					frm.txt_touringno.style.border="1px solid #FF0000";
					return false;
				}
			}

			if(frm.txt_password.value.length < 6 )
			{

				alert("Password must have at least 6 characters in it");
				frm.txt_password.value="";
				frm.txt_password.focus();
				frm.txt_password.style.border="1px solid #FF0000";
								
				return false;
			}
			
			if(frm.txt_password.value != frm.txt_confpassword.value)
			{
				alert("Password and confirm pasword must be same");
				frm.txt_confpassword.value="";
				frm.txt_confpassword.focus();
				frm.txt_confpassword.style.border="1px solid #FF0000";
				return false;
			}
			
			//Validate user fisrt name
			if(frm.txt_fname && frm.txt_fname.value != "" && isValidName("txt_fname")==false)							
			return false;

			//Validate user last name
			if(frm.txt_lname && frm.txt_lname.value != "" && isValidName("txt_lname")==false)							
			return false;
			
			//Validate user city name
			if(frm.txt_city && frm.txt_city.value != "" && isValidName("txt_city")==false)							
			return false;

			/*if(frm.txt_zip && frm.txt_zip.value != "" && !checkZip(frm.txt_zip))
			{
				return false;
			}
			
			if(frm.txt_phone && frm.txt_phone.value != "" && !checkPhone(frm.txt_phone))
			{
				return false;
			}*/
			
			if(document.getElementById("chk_terms_cond").checked==false) 
			{
				alert("Please accept terms and conditions");
				document.getElementById("chk_terms_cond").focus();
				return false;
			}
			
			return true;
	}
	else
		return false;		
 }
 
 function chkForSubscribe()
 {
		
	if(document.getElementById("chk_email_subscribe").checked==true) 
	{
		document.getElementById("hid_chk_email_subscribe").value=1;
	}
	else
	{
		document.getElementById("hid_chk_email_subscribe").value=0;
	}
 }
 
 //########-- For copying data on clipboard ---###########
 
 function copy_clip(meintext)
	{
	   if (window.clipboardData) 
	   {
		window.clipboardData.setData("Text", meintext);
	   }
	   else if (window.netscape) 
	   { 
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
			var clip = Components.classes['@mozilla.org/widget/clipboard;1']
					  .createInstance(Components.interfaces.nsIClipboard);
			if (!clip) return;
		
			var trans = Components.classes['@mozilla.org/widget/transferable;1']
					   .createInstance(Components.interfaces.nsITransferable);
			if (!trans) return;
		
			trans.addDataFlavor('text/unicode');
		
			var str = new Object();
			var len = new Object();
			
			var str = Components.classes["@mozilla.org/supports-string;1"]
						 .createInstance(Components.interfaces.nsISupportsString);
			
			var copytext=meintext;
		
			str.data=copytext;
		   
			trans.setTransferData("text/unicode",str,copytext.length*2);
			
			var clipid=Components.interfaces.nsIClipboard;
			
			if (!clip) return false;
			
			clip.setData(trans,null,clipid.kGlobalClipboard);
	   	}
		else
	 	{
			//for opera
		   //alert ("inside");
		   //Copied = meintext.createTextRange();
		   //Copied.execCommand("Copy");
		}
	   //alert("Following info was copied to your clipboard:\n\n" + meintext);
	   return false;
	}  


	function ClipBoard() 
	{
			document.frm_db_installed.txt_access_code.focus();
			document.frm_db_installed.txt_access_code.select();
			var text_to_copy = document.frm_db_installed.txt_access_code.value;

			copy_clip(text_to_copy);
	}	
	
   //########-- For copying data on clipboard ---###########
   
   
   //########-- For validating isntallation form -- ##########

	function checkInstallfrm()
	{
		if(document.form1.domain.value=="")
		{
			alert("Please fill up your domain name ");
			document.form1.domain.focus();
			return false;
		}

		if(document.form1.key.value=="")
		{
			alert("Please fill up your domain key ");
			document.form1.key.focus();
			return false;
		}

		if(document.form1.db_host.value=="")
		{
			alert("Please fill up host name ");
			document.form1.db_host.focus();
			return false;
		}
	
		if(document.form1.db_name.value=="")
		{
			alert("Please fill up database name ");
			document.form1.db_name.focus();
			return false;
		}
	
		if(document.form1.db_user.value=="")
		{
			alert("Please fill up username ");
			document.form1.db_user.focus();
			return false;
		}

		if(document.form1.sitename.value=="")
		{
			alert("Please fill up Site Name");
			document.form1.sitename.focus();
			return false;
		}
	
		if(document.form1.sitepath.value=="")
		{
			alert("Please fill up Site Path");
			document.form1.sitepath.focus();
			return false;
		}

		if(document.form1.admin_name.value=="")
		{
			alert("Please fill up admin name");
			document.form1.admin_name.focus();
			return false;
		}

		if(document.form1.emailid.value=="")
		{
			alert("Please fill up admin email address");
			document.form1.emailid.focus();
			return false;
		}


		if(document.form1.paypalacct.value=="")
		{
			alert("Please fill up  paypal account");
			document.form1.paypalacct.focus();
			return false;
		}
		
		return true;
	}

   //########-- For validating isntallation form -- ##########
