	//=== To check all checkboxes
	function checkAll(frm,fieldName,obj_ad) 
	{
		chkarr = frm.elements[fieldName];
		for( i=0 ; i<chkarr.length ; i++)
		{
			chkarr[i].checked = obj_ad;
		} 
	}
	
	//=== To submit the form 
	function doThis(myForm,redTo,myVal)
	{
		var frm = myForm;
		frm.action = 'application.php?p='+redTo+'&limit='+myVal;
		frm.submit();
	}
	
	//=== To check validation
	function validateMe(frmName,fieldArr,fieldCnt)
	{
		var i;
		var myFrm = frmName;
		var flag = true;
		for(i=0;i<=fieldCnt;i++)
		{
			var allFields = fieldArr.split(",");
			if(frmName.elements[allFields[i]].value == "" )
				flag = false;
		}
		
		if(flag == false)
		{
			alert('* All fields are required. Please Check that you have entered all fields correctly');
			return false;
		}
		else
			return true;
	}
	
	//=== To redirect page
	function goHere(loc,type)
	{
		if(type == 1)
			var newUrl = loc;
		else if(type == 2)
			var newUrl = "application.php?p="+loc;
		setTimeout(function(){window.location = newUrl;}, 0);
	}
	
	//=== Secure login
	function logMeIn(errDiv,username,password)
	{
		
		var errBox = $("#"+errDiv)
		
		$(function(){
			//alert('yes');
			//remove all the class add the messagebox classes and start fading
			errBox.removeClass().addClass('messagebox_login').text('Validating Login details...').fadeIn(1000);
			//check the username exists or not from ajax
			$.post("chkLogin.php",{ 'fields[]':[$('input#'+username).val(),$('input#'+password).val()],rand:Math.random() } ,function(data)
			{
			  var GetData = data;
			  //alert(GetData);
			  if(GetData == '1') //if correct login detail
			  {
				errBox.fadeTo(200,0.1,function()  //start fading the messagebox
				{ 
				  //add message and change the class of the box and start fading
				  $(this).html('Logging in..').addClass('messageboxok_login').fadeTo(900,1,
					  function()
					  { 
						 //redirect to secure page
						 document.location = 'my-account.php';
					  });
				  });
			  }
			  else if(GetData == '2')
			  {
				errBox.fadeTo(200,0.1,function() //start fading the messagebox
				{ 
				  //add message and change the class of the box and start fading
				  $(this).html(' Oops! your account is deactivited').addClass('messageboxerror_login').fadeTo(900,1);
				});		
			  }
			  else 
			  {
				errBox.fadeTo(200,0.1,function() //start fading the messagebox
				{ 
				  //add message and change the class of the box and start fading
				  $(this).html(' Incorrect Login details !').addClass('messageboxerror_login').fadeTo(900,1).removeClass();
				});		
			  }
			});
			return false; //not to post the form physically
		});
	}
	
	function jqHandle(getDiv)
	{
		$(function(){
				$("#"+getDiv).fadeIn(3000);
		});
	}
	
	function closeBox()
	{
		$(function(){
			$("#errBox").fadeOut(1000);
		});
	}
