/////////////////////////////main.js/04/10/2011/////////////////
function sendPolicyEmail(divid, email_add, policy_no){
	var divid = escape($('#'+divid).html());
	var email_add=prompt("Please enter Recipient's Email Address",email_add);
if (email_add!=null && email_add!="")
  {
	$.ajax({ 
			   type: "POST", 
			   url: "utilities.php", 
		   		data: "op=dosendPolicyEmail&em_content="+divid+"&email_add="+email_add+"&policy_no="+policy_no, 
		    
			   success: function(msg){ 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				 if(msg){
					 
				 alert("Policy sent to the Email address provided successfully!!")
				 //doSearch("transferall_trans.php")
				 }
				 //$("#display_message").html("");
			   } 
			 });
  }
}
/////////////////////////////////////////////////////////

function transferTrans(secNo,agentId){
	var agentId=prompt("Please enter Processor username",agentId);
if (agentId!=null && agentId!="")
  {
	$.ajax({ 
			   type: "POST", 
			   url: "utilities.php", 
		   		data: "op=transferTrans&secNo="+secNo+"&agentId="+agentId, 
		    
			   success: function(msg){ 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				 if(msg > 0){
				 alert("Policy Transfer Completed!!")
				 doSearch("transferall_trans.php")
				 }
				 //$("#display_message").html("");
			   } 
			 });
	}
}

function checkbox(obj){
	if(obj.checked){
		//alert('yes');
		//$("#referers_code").val() = '';
		//$("#referers_code").attr('disabled','disabled');
		//$('#referers_com_percent') 
	}else{
		
		//$('#referers_code').attr('disabled','');
		
	}
	
}

function selRegType(){
var theName = $("#role_id").attr('value');	
//alert(theName);
	if(theName == '005'){
		
		$("#username").attr('value',$("#id").val());
		$("#username").attr('readonly','readonly');
		$("#username").attr('style','background-color:#CCCC33');
		
		$("#user").html('Username');
		$("#pass").html('Password');
		$("#confirm_pass").html('Confirm Password');
		
		
		$("#AgentReg").attr('style','display:');
		$("#EmbReg").attr('style','display:none;');
		$("#HygeaReg").attr('style','display:none;');
		$("#AdminUser").attr('style','display:none;');
		
		$('#embaddress').attr('class','') ; 
		//$('#nation_code#').attr('class','') ; 
		//$('#embname').attr('class','') ;
		$('#dest_grp').attr('class','');
		
		
		
		$('#id').attr('class','required-text') ;
		$('#addy').attr('class','required-text') ;
		$('#sex').attr('class','required-text') ;
		$('#location').attr('class','required-text') ;
		$('#occupation').attr('class','required-text') ;
		$('#comp_addr').attr('class','required-text') ;
		$('#state').attr('class','required-text') ;
		$('#idno').attr('class','required-text') ;
		$('#nextofkin').attr('class','required-text') ;
		$('#nextofkinaddr').attr('class','required-text') ;
		$('#dob').attr('class','required-text') ;
		$('#nextofkinoccupation').attr('class','required-text') ;
		$('#referer_percent').attr('class','required-text') ;
		$('#refer_code').attr('class','required-text') ;
		$('#discounted').attr('class','required-text') ;
		$('#agent_percent').attr('class','required-text') ;
		$('#agent_type').attr('class','required-text') ;
		
		
		
		
		
		
	}else if(theName == '006'){
		
		$("#username").attr('value',$("#embname").val());
		//$("#username").attr('readonly','');
		$("#username").attr('style','background-color:#CCCC33');
		
		$("#user").html('Embassy Name');
		$("#pass").html('Embassy Code');
		$("#confirm_pass").html('Confirm Embassy Code');
		
		$("#AgentReg").attr('style','display:none;');
		$("#EmbReg").attr('style','display:');
		$("#HygeaReg").attr('style','display:none;');
		$("#AdminUser").attr('style','display:none;');
		
		
		$('#embaddress').attr('class','required-text') ; 
		//$('#nation_code#').attr('class','required-text') ; 
		//$('#embname').attr('class','required-text') ;
		$('#dest_grp').attr('class','required-text');
		
		
		$('#id').attr('class','') ;
		$('#addy').attr('class','') ;
		$('#sex').attr('class','') ;
		$('#location').attr('class','') ;
		$('#occupation').attr('class','') ;
		$('#comp_addr').attr('class','') ;
		$('#state').attr('class','') ;
		$('#idno').attr('class','') ;
		$('#nextofkin').attr('class','') ;
		$('#nextofkinaddr').attr('class','') ;
		$('#dob').attr('class','') ;
		$('#nextofkinoccupation').attr('class','') ;
		$('#referer_percent').attr('class','') ;
		$('#refer_code').attr('class','') ;
		$('#discounted').attr('class','') ;
		$('#agent_percent').attr('class','') ;
		$('#agent_type').attr('class','') ;
		
		
		
		
	}else if(theName == '007'){
		
		//$("#username").attr('value','');
		$("#username").attr('readonly','');
		$("#username").attr('style','background-color:none');
		
		$("#AgentReg").attr('style','display:none;');
		$("#EmbReg").attr('style','display:none;');
		$("#HygeaReg").attr('style','display:');
		$("#AdminUser").attr('style','display:none;');
		
		$("#user").html('Username');
		$("#pass").html('Password');
		$("#confirm_pass").html('Confirm Password');
		
	}else if(theName == '010'){
		
		//$("#username").attr('value','');
		$("#username").attr('readonly','');
		$("#username").attr('style','background-color:none');
		
		$("#user").html('Username');
		$("#pass").html('Password');
		$("#confirm_pass").html('Confirm Password');
		
		$("#AgentReg").attr('style','display:none;');
		$("#EmbReg").attr('style','display:none;');
		$("#HygeaReg").attr('style','display:none;');
		$("#AdminUser").attr('style','display:');
		
		
		
		$('#embaddress').attr('class','') ; 
		//$('#nation_code#').attr('class','') ; 
		//$('#embname').attr('class','') ;
		$('#dest_grp').attr('class','');
		
		$('#id').attr('class','') ;
		$('#addy').attr('class','') ;
		$('#sex').attr('class','') ;
		$('#location').attr('class','') ;
		$('#occupation').attr('class','') ;
		$('#comp_addr').attr('class','') ;
		$('#state').attr('class','') ;
		$('#idno').attr('class','') ;
		$('#nextofkin').attr('class','') ;
		$('#nextofkinaddr').attr('class','') ;
		$('#dob').attr('class','') ;
		$('#nextofkinoccupation').attr('class','') ;
		$('#referer_percent').attr('class','') ;
		$('#refer_code').attr('class','') ;
		$('#discounted').attr('class','') ;
		$('#agent_percent').attr('class','') ;
		$('#agent_type').attr('class','') ;
		
		
		
	}else {
		
		$("#user").html('Username');
		$("#pass").html('Password');
		$("#confirm_pass").html('Confirm Password');
		
		//$("#username").attr('value','');
		$("#username").attr('readonly','');
		$("#username").attr('style','background-color:none');
		
		$("#AgentReg").attr('style','display:none;');
		$("#EmbReg").attr('style','display:none;');
		$("#HygeaReg").attr('style','display:none;');
		$("#AdminUser").attr('style','display:none;');
		
		
		
		$('#embaddress').attr('class','') ; 
		$('#nation_code#').attr('class','') ; 
		$('#embname').attr('class','') ;
		$('#dest_grp').attr('class','');
		
		
		$('#id').attr('class','') ;
		$('#addy').attr('class','') ;
		$('#sex').attr('class','') ;
		$('#location').attr('class','') ;
		$('#occupation').attr('class','') ;
		$('#comp_addr').attr('class','') ;
		$('#state').attr('class','') ;
		$('#idno').attr('class','') ;
		$('#nextofkin').attr('class','') ;
		$('#nextofkinaddr').attr('class','') ;
		$('#dob').attr('class','') ;
		$('#nextofkinoccupation').attr('class','') ;
		$('#referer_percent').attr('class','') ;
		$('#refer_code').attr('class','') ;
		$('#discounted').attr('class','') ;
		$('#agent_percent').attr('class','') ;
		$('#agent_type').attr('class','') ;
		
		
		
		
	}
	
}




function doQualify(url,ans)
{
	
	
	//var data = getdata();
	//var nam = "input[name=check"+url+"]:radio";
	//var ans = $(nam).attr('value');
	var data = url+"&ans="+ans;
	//alert(data);
	
	$.blockUI({ message:'<img src="images/loading.gif" alt=""/><br />processing request please wait . . .'});
	$.ajax({ 
			   type: "POST", 
			   url: "utilities.php", 
		   		data: "op=doQualify&member_no="+data, 
		    
			   success: function(msg){ 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				 $("#display_message").html(msg);
				 $("#display_message").show("fast");
				 $.unblockUI();
				 //$("#display_message").html("");
			   } 
			 });
	
	//getpage(url+'?'+data,'content');
}






function checkboxVal(obj){
	if(obj.checked){
		//alert('yes');
		$('#sub').attr('disabled','');
		
	}else{
		$('#sub').attr('disabled','disabled');
		
	}
	
	
	
	
}

function getClientDest(str){

	var data = $('#dest_grp').val();
	//alert(data);
			if(data == ''){
			$('#destin').html('');	
			}else{
		   $.ajax({ 
		   type: "POST", 
		   url: "utilities.php", 
		   data: "op=clientdest&dest="+data+"&condest="+str, 
		   success: function(msg){
			 //alert(msg);
			 $('#destin').html(msg);
			   
		    } 
		 });
			}
}

function AgentRadioType(agent){
agent = '#'+agent;
var agent = $(agent).attr('title');
//alert(agent);

$('#agent_radio').attr('value',agent);

}




function checklogin(formurl,formurlconvert){
		//alert('yes');

		$('#error_label_login').ajaxStart(function(){
		//$('#error_label_login').css({background-image: "url(../images/progress_bar.gif)"});
		$('#error_label_login').html('<img src="images/loading.gif" alt="" />loading please wait . . .');
		});
	
		var data = $("#userid").val();
		var data2 = $("#userpassword").val();
		var data3 = $("#agent_radio").val();
		//alert(data+":"+data2);
		//error_label_login
		$.ajax({ 
		   type: "POST", 
		   url: "utilities.php", 
		   data: "op=checklogin&username="+data+"&password="+data2+"&agent_radio="+data3, 
		   success: function(msg){  
			 
	//alert(msg); 
			 $("#error_label_login").html('logging you in ...').show();
				if(msg==''){
					$("#error_label_login").html('Please enter a valid Username and Password').show();
				}
				else if(msg=='0'){
					$("#error_label_login").html('Invalid username or password').show();
				}
				else if(msg=='E01'){
					$("#error_label_login").html('Sorry, you DO NOT have Permission to view this Page!!!').show();
				}
				else if(msg=='E02'){
					$("#error_label_login").html('Please Select Login Category!!!').show();
				}
				else if(msg=='1'){	
					$("#member_data").val(msg);
					//alert($("#member_data").val());
				 $("#form1").attr("action",formurl);
				 $("#form1").submit();
				}
				else if(msg=='101'){	
					$("#member_data").val(msg);
					//alert($("#member_data").val());
				 $("#form1").attr("action",formurlconvert);
				 $("#form1").submit();
				}
				else if(msg=='2'){
					$("#error_label_login").html('Your user profile has been disabled').show();
				}
				else if(msg=='3'){
					$("#error_label_login").html('Your user profile has been locked').show();
				}
				else if(msg=='4'){
					$("#error_label_login").html('You are not allowed to login on Sunday').show();
				}
				else if(msg=='5'){
					$("#error_label_login").html('You are not allowed to login on Monday').show();
				}
				else if(msg=='6'){
					$("#error_label_login").html('You are not allowed to login on Tuesday').show();
				}
				else if(msg=='7'){
					$("#error_label_login").html('You are not allowed to login on Wednesday').show();
				}
				else if(msg=='8'){
					$("#error_label_login").html('You are not allowed to login on Thursday').show();
				}
				else if(msg=='9'){
					$("#error_label_login").html('You are not allowed to login on Friday').show();
				}
				else if(msg=='10'){
					$("#error_label_login").html('You are not allowed to login on Saturday').show();
				}
				else if(msg=='11'){
					$("#error_label_login").html('You are not allowed to login at this time <br> The time is not within the working hours').show();
				}
				else if(msg=='12'){
					$("#error_label_login").html('Your profile has been Locked, please contact Administrator').show();
				}
				else if(msg=='13'){
					$("#error_label_login").html("Your password has expired, <br><a href='#' onclick=\"getpage('change_password_exp.php?id="+data+"','miniconbody')\"> click here to change password </a>").show();
				}
				else if(msg=='14'){
					$("#error_label_login").html("You are required to change your password, <br><a href='#' onclick=\"getpage('change_password_logon.php?id="+data+"','miniconbody')\"> click here to change password </a>").show();
				}
				else{
					$("#error_label_login").html('Invalid username or password').show();
				}
		   } 
		 });
		//alert(data);
		return false;
}





function chkpassword(opt){
	if($("#userpassword").val()!= $("#confirm_userpassword").val()){
		$("#display_message").html('Passwords do not match');
		//$('#postbtn').attr("disabled","disabled");
	}else{
		callpage(opt);
	}
}
///////////// END SCRIPTS BY ABBEY ///////////////////////
function show_hide_div(objid,divid)
{
	//alert(obj.value());
	var id = $('#'+objid).val();
	if(id=='0'){
		$('#'+divid).hide();
	}
	else if(id=='1'){
		$('#'+divid).show();
	}
}

function getdata()
{
	var data = "";
	$("#form1").serialize();
	$.each($("input, select, textarea"), function(i,v) {
    var theTag = v.tagName;
    var theElement = $(v);
	var theName = theElement.attr('name');
    var theValue = escape(theElement.val());
	var classname = theElement.attr('class');
	//alert('name : '+theName+"   value :"+theValue+"  class :"+classname);
	if(classname=='required-text')
	{
		if(!check_textvalues(theElement)) data = "error";
	}
	if(classname=='required-number')
	{
		if(!check_numbers(theElement)) data = "error";
	}
	if(classname=='required-email')
	{
		if(!check_email(theElement)) data = "error";
	}
	if(classname=='not-required-email')
	{
		if(!check_email(theElement)) data = "error";
	}
	if(classname=='required-alphanumeric')
	{
		if(!check_password_aplhanumeric(theElement)) data = "error";
	}
	if(data!='error')
	{
		data = data+theName+"="+theValue+"&";
	}
	});
	//alert(data);
	return data;
}

function callpage(page)
{
	
	//alert(page);
var data = getdata();

	if(data!='error')
	{
		
		//$("#display_message").ajaxStart(function(){
			$.blockUI({ message:'<img src="images/loading.gif" alt=""/><br />processing request please wait . . .'});
		//});

		$.ajax({ 
		   type: "POST", 
		   url: "utilities.php", 
		   data: "op="+page+"&"+data, 
		  
		   success: function(msg){ 
		   //alert(data);
			 //alert( "Data Saved: " + msg ); 
			// alert(msg);
			$.unblockUI();
			 	if(msg == 1){
					//alert('we');
			$("#display_message").html("Login Successful");
			 $("#display_message").show("fast");
				
					 //getpage('reg_confirmation.php','main_body');
					 $("#form1").attr("action","home.php");
				 $("#form1").submit();
				}else if(msg == 404){
					//alert('we');
			$("#display_message").html("Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('epayment_user_particularsDCLT.php','content');
					}else if(msg == 405){
					//alert('we');
			$("#display_message").html("Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('epayment_agent_particulars.php','content');
					}
					else if(msg == 404405){
					//alert('we');
			$("#display_message").html("Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('travel_certs_ok.php','content');
					
					}
					else if(msg == 801)
					{
					//alert('we');
			$("#display_message").html("lOADING... Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('verify_travel_cert.php','content');
					
					
					
					}else if(msg == 901)
					{
					//alert('we');
			$("#display_message").html("lOADING... Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('PayDateChange.php','content');
					
					
					
					}else if(msg == 'R101'){
					//alert('we');
			$("#regbody").html("User detail has been successfully saved You can now <a href='index.php'>login</a> to continue");
			 $("#regbody").show("fast");
					}else if(msg == 909090){
					//alert('we');
			$("#content").html("User data has been successfully Updated!!!");
			 $("#content").show("fast");
			 
			 
			 }else if(msg == 90909090){
					//alert('we');
			
			$("#content").html("Travel Insurance Form Submitted Successfully!!!");
			 $("#content").show("fast"); 
			 
			 
					}
					else {
			$("#display_message").html(msg);
			 $("#display_message").show("fast");
					 $("#display_message").click();
				}
				//}
		   } 
		 });
		//alert('yes');
	}
}

function callpage1(page)
{
	
	//alert(page);
var data = getdata();

	if(data!='error')
	{
		
		//$("#display_message").ajaxStart(function(){
			$.blockUI({ message:'<img src="images/loading.gif" alt=""/><br />processing request please wait . . .'});
		//});

		$.ajax({ 
		   type: "POST", 
		   url: "utilities.php", 
		   data: "op="+page+"&"+data, 
		  
		   success: function(msg){ 
		   //alert(data);
			 //alert( "Data Saved: " + msg ); 
			// alert(msg);
			$.unblockUI();
			 	if(msg == 1){
					//alert('we');
			$("#display_message").html("Login Successful");
			 $("#display_message").show("fast");
				
					 //getpage('reg_confirmation.php','main_body');
					 $("#form1").attr("action","home.php");
				 $("#form1").submit();
				}else if(msg == 404){
					//alert('we');
			$("#display_message").html("Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('epayment_user_particularsDCLT.php','content');
					}else if(msg == 405){
					//alert('we');
			$("#display_message").html("Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('epayment_agent_particulars.php','content');
					}
					else if(msg == 404405){
					//alert('we');
			$("#display_message").html("Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('travel_certs_ok.php','content');
					
					}
					else if(msg == 801)
					{
					//alert('we');
			$("#display_message").html("lOADING... Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('verify_travel_cert.php','content');
					
					
					
					}else if(msg == 901)
					{
					//alert('we');
			$("#display_message").html("lOADING... Please Wait!!!");
			 $("#display_message").show("fast");
				
					 getpage('PayDateChange.php','content');
					
					
					
					}else if(msg == 'R101'){
					//alert('we');
			$("#regbody").html("User detail has been successfully saved You can now <a href='index.php'>login</a> to continue");
			 $("#regbody").show("fast");
					}else if(msg == 909090){
					//alert('we');
			$("#content").html("User data has been successfully Updated!!!");
			 $("#content").show("fast");
			 
			 
			 }else if(msg == 90909090){
					//alert('we');
			
			//$("#content").html("Travel Insurance Form Submitted Successfully!!!");
			 //$("#content").show("fast"); 
			 getpage('travel_certs_ok.php','content');
			 
					}
					else {
			$("#display_message").html(msg);
			 $("#display_message").show("fast");
					 $("#display_message").click();
				}
				//}
		   } 
		 });
		//alert('yes');
	}
}






function check_textvalues(formElement)
{
	if(triminput(formElement.val())==''){
		$("#display_message").html('please enter value for :'+formElement.attr('title'));
		$("#display_message").show('fast');
		formElement.focus();
		$("#display_message").click();
		return false;
	}else return true;
}

function check_numbers(formElement)
{
		if(triminput(formElement.val())==''){
			$("#display_message").html('please enter number for : '+formElement.attr('title'));
			$("#display_message").show('fast');
			formElement.focus();
			$("#display_message").click();
			return false;
		}
		if(isNaN(formElement.val())){
			$("#display_message").html('please enter number for : '+formElement.attr('title'));
			$("#display_message").show('fast');
			formElement.focus();
			$("#display_message").click();
			return false;
		}else return true;	
}

function check_email(formElement)
{
	var emails = formElement.val();
	emailRegEx = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	if (emails=="")return true;
	if((formElement.val()).search(emailRegEx) == -1)
	{
		$("#display_message").html('please enter valid email for : '+formElement.attr('title'));
		$("#display_message").show('fast');
		formElement.focus();
		$("#display_message").click();
		return false;
	}
	else return true;
}

function check_password_aplhanumeric(formElement)
{
		var f1 = /[A-Z]/
		var f2 = /[a-z]/
		var f3 = /[0-9]/
		
		if((f1.test(formElement.val()) || f2.test(formElement.val())) && f3.test(formElement.val())){
		//alert('passed');
        return true;
		}else {
		$("#display_message").html('please enter alphanumeric as password');
		$("#display_message").show('fast');
		//alert('failed');
		formElement.focus();
		$("#display_message").click();
		return false;
		}
		
}

function triminput(inputString) 
{
	var removeChar = ' ';
	var returnString = inputString;

	if (removeChar.length)
	{
	  while(''+returnString.charAt(0)==removeChar)
		{
		  returnString=returnString.substring(1,returnString.length);
		}

		while(''+returnString.charAt(returnString.length-1)==removeChar)

	  {

	    returnString=returnString.substring(0,returnString.length-1);

	  }

	}

	return returnString;
}

function checkOption(obj)
{
	if(obj.checked){
		obj.value='1';
	}else{
		obj.value='0';
		obj.checked=false;
		//alert(obj.value);
	}
}

function ttoggleOption()
{
	$.each($('input:checkbox'), function(i,v) {
		  if ($(this).is(':checked')){
			   $(this).val('1');
		  }else{
			   $(this).val('0');
		  }
	});
}

function trapSession(){


var Snew_date = $('#Snew_date').val();
			//alert(Snew_date);						 

var data = "Snew_date="+Snew_date;
	//alert(data);
	
	//$.blockUI({ message:'<img src="images/loading.gif" alt=""/><br />processing request please wait . . .'});
	$.ajax({ 
			   type: "POST", 
			   url: "utilities.php", 
		   		data: "op=reschedule_session_trap&"+data,
		    
			   success: function(msg){ 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				 
				// $("#display_message").html(msg);
				 //$("#display_message").show("fast");
				 //$.unblockUI();
				 //$("#display_message").html("");
			   } 
			 });
		
}

function callpagepost(str,divid){
//	 $("#form1").attr("target","");
	// $("#form1").attr("action",returnpage);
	 //$("#form1").submit();

 
	var data = getdata();
	
	if(data!='error')
	{
		
		//$("#display_message").ajaxStart(function(){
			$.blockUI({ message:'<img src="images/loading.gif" alt=""/><br />processing request please wait . . .'});
		//});

	//alert(data);
			/*
			$(divid).ajaxStart(function(){
			$(divid).html('');
			$(divid).html('<img src="images/loading.gif" alt="" />loading please wait . . .');
			});
			*/
			if(str!='#'){
				//trapSession();
				
				
				$.blockUI({ message:'<img src="images/loading.gif" alt=""/>loading please wait . . .'});
				//$("#display_message").html('<img src="images/loading.gif" alt="" />loading please wait . . .');
				
			$.ajax({ 
			   type: "POST", 
			   url: str, 
			   data: data, 
			   success: function(msg){ 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				 
				 
				 
				 $('#'+divid).html(msg);
				 $.unblockUI();
				 //$("#display_message").html("");
			   } 
			 });
			/*	
			 $(divid).ajaxComplete(function(){ 
				$(divid).html(""); 
			 });
			*/
			}// end if


	}

}

function getpagespecial(str1,str2,dval,divid) 
{ 
//alert(str1);
//alert(str2);
//alert(dval);
//alert(divid);
	var data = dval;
//	alert(data);
			/*
			$(divid).ajaxStart(function(){
			$(divid).html('');
			$(divid).html('<img src="images/loading.gif" alt="" />loading please wait . . .');
			});
			*/
			
			
			
			if(str1!='#'){
				$.blockUI({ message:'<img src="images/loading.gif" alt=""/>loading please wait . . .'});
				//$("#display_message").html('<img src="images/loading.gif" alt="" />loading please wait . . .');
				
			$.ajax({ 
			   type: "POST", 
			   url: "utilities.php", 
		   		data: "op=checkpayment&"+data,
		    
			   success: function(msg){ 
				 
				 if(msg == 10001){
				 getpage(str2,divid);
				 }else if(msg == 10101){
					getpage(str1,divid);
				//$.unblockUI();
				}
				 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				// $("#display_message").html(msg);
				 //$("#display_message").show("fast");
				 $.unblockUI();
				 //$("#display_message").html("");
			   } 
			 });
			/*	
			 $(divid).ajaxComplete(function(){ 
				$(divid).html(""); 
			 });
			*/
			}// end if
}

function getpagespecial1(str,dval,divid) 
{ 
//alert(str1);
//alert(str2);
//alert(dval);
//alert(divid);
	var data = dval;
	//alert(data);
	//alert(dval);
			/*
			$(divid).ajaxStart(function(){
			$(divid).html('');
			$(divid).html('<img src="images/loading.gif" alt="" />loading please wait . . .');
			});
			*/
			if(str!='#'){
				$.blockUI({ message:'<img src="images/loading.gif" alt=""/>loading please wait . . .'});
				//$("#display_message").html('<img src="images/loading.gif" alt="" />loading please wait . . .');
				
			$.ajax({ 
			   type: "POST", 
			   url: "utilities.php",
		   		data: "op=checkpayment&"+data,
		    
			   success: function(msg){ 
				 
				 if(msg == 10001){
					 
						getpage(str,divid);
			
				 }else if(msg == 10101){
					
						  alert('Please... Complete Payment on this Transaction First!!!.');
				
				//$.unblockUI();
				}
				 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				// $("#display_message").html(msg);
				 //$("#display_message").show("fast");
				 $.unblockUI();
				 //$("#display_message").html("");
			   } 
			 });
			/*	
			 $(divid).ajaxComplete(function(){ 
				$(divid).html(""); 
			 });
			*/
			}// end if
}


function getpage1(str,divid) 
{ 
	var data = getdata();
	//alert(data);
			/*
			$(divid).ajaxStart(function(){
			$(divid).html('');
			$(divid).html('<img src="images/loading.gif" alt="" />loading please wait . . .');
			});
			*/
			if(str!='#'){
				$.blockUI({ message:'<img src="images/loading.gif" alt=""/>loading please wait . . .'});
				//$("#display_message").html('<img src="images/loading.gif" alt="" />loading please wait . . .');
				
			$.ajax({ 
			   type: "POST", 
			   url: str+'?'+data, 
			   data: '', 
			   success: function(msg){ 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				 $('#'+divid).html(msg);
				 $.unblockUI();
				 //$("#display_message").html("");
			   } 
			 });
			/*	
			 $(divid).ajaxComplete(function(){ 
				$(divid).html(""); 
			 });
			*/
			}// end if
}  

function getpage(str,divid) 
{ 
	//var data = getdata();
	//alert(data);
			/*
			$(divid).ajaxStart(function(){
			$(divid).html('');
			$(divid).html('<img src="images/loading.gif" alt="" />loading please wait . . .');
			});
			*/
			if(str!='#'){
				$.blockUI({ message:'<img src="images/loading.gif" alt=""/>loading please wait . . .'});
				//$("#display_message").html('<img src="images/loading.gif" alt="" />loading please wait . . .');
				
			$.ajax({ 
			   type: "POST", 
			   url: str, 
			   data: '', 
			   success: function(msg){ 
				 //alert( "Data Saved: " + msg ); 
				 //alert(msg);
				 $('#'+divid).html(msg);
				 $.unblockUI();
				 //$("#display_message").html("");
			   } 
			 });
			/*	
			 $(divid).ajaxComplete(function(){ 
				$(divid).html(""); 
			 });
			*/
			}// end if
}

function doSearch(url)
{
	//alert('Got here');
	//$("#form1").submit();
	var data = getdata();
	//alert("@ Search : "+data);
	//loadpage('branch_list.php',data,'page');
	getpage(url+'?'+data,'content');
}

function goFirst(dpage)
{
	var lpage = parseInt($("#tpages").val());
	var fpage = parseInt($("#fpage").val());
	if(fpage!=1){
		$("#fpage").get(0).value = '1';
		$("#pageNo").get(0).value = 1;
		doSearch(dpage);
	}else{
		return false;
	}
}

function goLast(dpage)
{
	var lpage = parseInt($("#tpages").val());
	var fpage = parseInt($("#fpage").val());
	if(lpage!=fpage){
		$("#fpage").get(0).value = lpage;
		$("#pageNo").get(0).value = lpage;
		doSearch(dpage);
	}else{
		return false;
	}

}

function goPrevious(dpage)
{
	var lpage = parseInt($("#tpages").val());
	var fpage = parseInt($("#fpage").val());
	if(fpage !=1){
		$("#fpage").get(0).value = fpage-1;
		$("#pageNo").get(0).value = fpage-1;
		doSearch(dpage);
	}else{
		return false;
	}

}

function goNext(dpage)
{
	var lpage = parseInt($("#tpages").val());
	var fpage = parseInt($("#fpage").val());
	if((lpage > fpage)){
		$("#fpage").get(0).value = fpage+1;
		$("#pageNo").get(0).value = fpage+1;
		doSearch(dpage);
	}else{
		return false;
	}

}

function doClickAll(form) 
{
	var form = document.getElementById("form1");
	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "checkbox") {
			if ( !form.elements[i].checked ) { form.elements[i].click();
			}
		}
    }
	return true;
}

function doUnClickAll(form) 
{
	for (var i = 0; i < form.elements.length; i++) {
		if ( form.elements[i].type == "checkbox") {
			if (  form.elements[i].checked ) { form.elements[i].checked = false;
			}
		}
	}
	return true;
  }
  
function checkSelected(form, url)
{
  //var form = document.forms[0];
  var parString = "";
  var delcount = 0;
  for(var i = 0; i < form.elements.length; ++i)
   if(form.elements[i].type == "checkbox" & form.elements[i].name == 'chkopt')
    if(form.elements[i].checked == true){
    	delcount++;
      parString =  parString + "-" + form.elements[i].value+"-, ";
      }

  if(parString == "") {
   window.alert("Select record(s) to continue...");
   return (false);
  }
  else {
	//delcount = delcount - 1;
	form.var1.value = parString;
	form.op.value = 'del';
  	ans=window.confirm("You have selected " + delcount + " record(s), Are your sure ?")
  	if (ans == 1){doSearch(url);
	return false;
	}
	else return false;
   }
  }
  
function printDiv(seldiv)
{
  var divToPrint=document.getElementById(seldiv);
  var newWin=window.open('','Print-Window');
  newWin.document.open();
  newWin.document.write('<html><link rel="stylesheet" type="text/css" href="css/main.css"><body>'+divToPrint.innerHTML+'</body></html>');
  newWin.document.close();
  //setTimeout(function(){newWin.close();},20);
}

function blockUIDiv(divid)
{
	//$('#'+divid).click(function() { 
        $.blockUI({ message: $('#'+divid) }); 
 
        //setTimeout($.unblockUI, 2000); 
    //}); 
}
function calldialog(divid){
//$('#'+divid).dialog();
$.blockUI({ message: $('#'+divid) });
setTimeout($.unblockUI, 5000);
}

function loadroles(){
	var data = escape($('#menu_id').val());
   $.ajax({ 
	   type: "POST", 
	   url: "utilities.php", 
	   data: "op=getnonexistrole&menu_id="+data, 
	   success: function(msg){ 
		 //alert( "Data Saved: " + msg ); 
		 //alert(data);
		 $("#non_exist_role").html(msg);
		 //$("#display_message").show("fast");
	   } 
  });
   // for existing roles
   $.ajax({ 
	   type: "POST", 
	   url: "utilities.php", 
	   data: "op=getexistrole&menu_id="+data, 
	   success: function(msg){ 
		 //alert( "Data Saved: " + msg ); 
		 //alert(data);
		 $("#exist_role").html(msg);
		 //$("#display_message").show("fast");
	   } 
  });  
}


  
  
function addrole(){
	return !$('#non_exist_role option:selected').remove().appendTo('#exist_role'); 
}
function removerole(){
	return !$('#exist_role option:selected').remove().appendTo('#non_exist_role');
}
function selectalldata(){
	$("#exist_role *").attr("selected","selected");
}










function confirmcode()
{
	$.blockUI({ message:'<img src="images/loading.gif" alt=""/>loading please wait . . .'});
	var data = escape($('#confirm_code').val());
   $.ajax({ 
	   type: "POST", 
	   url: "utilities.php", 
	   data: "op=getpaycode&confirm_code="+data, 
	   success: function(msg){
		   //alert(msg);
			 if(msg=='1'){
			 $("#plate_no_div").show("fast");
			 $.unblockUI();
			 }
			 else if(msg=='2'){
			 $("#display_message").html("Confirmation code amount is lower than NVMA Form");
			 $("#display_message").show('fast');
			 $("#display_message").click();
			 }
			 else if(msg=='3'){
			 $("#display_message").html("Confirmation code amount is greater than NVMA Form");
			 $("#display_message").show('fast');
			 $("#display_message").click();
			 }
			 else if(msg=='4'){
			 $("#display_message").html("Confirmation code does not exist");
			 $("#display_message").show('fast');
			 $("#display_message").click();
			 }
			 else{
			 $("#display_message").html("Confirmation code does not exist");
			 $("#display_message").show('fast');
			 $("#display_message").click();
			 }
			 //$.unblockUI();
	   } 
  });
}






function Resize(imgId,division_1, division_2)
{
  var img = document.getElementById(imgId);
  var w = img.width, h = img.height;
  w /= division_1; h /= division_2;
  img.width = w; img.height = h;
}






