﻿ // JScript File
//*************************************************************************************************
//********************Function to validate insurance form*****************************************
//*************************************************************************************************
function premiumcalculation()
{
             try
             {
                    var depdate =document.getElementById("txtdepdate").value ;
				    var retdate =document.getElementById("txtretdate").value ;
				    var dob =document.getElementById("drpInfmm").value + "/" + document.getElementById("drpInfdd").value + "/" + document.getElementById("drpInfyy").value;
				    var area=document.getElementById("cboarea").value ;
				    if (depdate == "")
				    {
				         
                         alert("Please specify departure date");
					     return ;
				    }
				    if (retdate == "")
				    {
				        
                         alert("Please specify return date");
				         return ;
				    }
				    if(document.getElementById("drpInfdd").value=="")
                   {
                       alert("Please select date of birth  ");
                       valid=false;
                        return;
                   }
                   else if(document.getElementById("drpInfmm").value=="")
                   {
                       alert("Please select date of birth  ");
                       valid=false;
                       return;
                   }
                   else if(document.getElementById("drpInfyy").value=="")
                   {
                       alert("Please select date of birth  ");
                       valid=false;
                       return;
                   }
                   else
                   {
                       if (dob == "")
				        {    
				             alert("Please select dd/mm/yyyy");
				             valid=false;
				             return;
				        }
                   }
              }
              
              catch(e)
                {
                    alert(e.message);
                }
                    ob_post.AddParam("depdate", depdate);
				    ob_post.AddParam("retdate", retdate);
				    ob_post.AddParam("dob", dob);
				    ob_post.AddParam("area", area);
				    ob_post.post(null, "SetSearchParams", Results);
				   
				    
   }
   
   
   function Results()
	{
	    //alert("hello");
		document.getElementById('divSearchBestDeal').style.display = 'none';
		ob_post.UpdatePanel("cp_premiumdetails");
	}

//function for incurancecustomer page

function insurancevalidation()
{
    valid= true;
    validateradio=fngetcheckedoption();

        if(document.getElementById("txtpassportno").value=="")
        {
            alert("Please Specify The Passport Number.");
            valid= false;
        }
        else if(document.getElementById("txtNameNominee").value=="")
        {
                alert("Please Specify The Nominee.");
                valid= false;
        }
         else if(!(document.getElementById("radterm3").checked==true))
        {
                alert("Please accept The terms and condition");
                valid= false;
                 
        }
   
  
   
       return valid;
}

function fnbook()
{
  
    valid=insurancevalidation();
    document.getElementById("hndPassportno").value=document.getElementById("txtpassportno").value;
    document.getElementById("hndNomineeName").value=document.getElementById("txtNameNominee").value;
   
    if(valid==true)
    {
            indexcnt=fngetcheckedoption();
            url="insurancecustomer.aspx?indexcnt="+(indexcnt-1);
            //alert(url);
            document.premiumpage.method="post";
            document.premiumpage.action=url;
            document.premiumpage.submit();
     }
}

function fngetcheckedoption()
 {
 //alert("hello");
 radioObj=document.forms['premiumpage'].elements['radplan'];
	            if(!radioObj)
		            return "";
		            var radioLength ;
		             try
                {
                
	                radioLength = radioObj.length;
	                if(radioLength==undefined)
	                {
	           
	                    radioLength=1;
	                }
	            }
	                catch(e)
	                {
	                    radioLength = 1;
	                    //alert("2="+radioLength);
	                }
	                    if(radioLength == undefined)
		                if(radioObj.checked)
			            return radioObj.value;
		                else
		                    {
			                    return "";
			                }
			        if(radioLength==1)
			        {
	                    return 1;
	                }
	                else
	                {
	                    for(var i = 0; i < radioLength; i++)
	                    {
	             
		                if(radioObj[i].checked) 
		                    {
			                    //return radioObj[i].value;
			                    //alert(i+1);
			                    return i+1;
			            
		                    }
		           	      
	                     }
	                  }
	            return "";
	}
	
	

//customer page

function customerdetailsvalidation()
{
                 valid= true;
                 if(document.getElementById("txttitle").value=="0")
                      {
                        alert("Please Specify Title.");
                        valid=false;
                        return valid;
                      }
                    else if(document.getElementById("txtfname").value=="")
                        {
                            alert("Please Specify First Name.");
                            valid=false;
                            return valid;
                        }
                     else if(document.getElementById("txtsname").value=="")
                        {
                            alert("Please Specify Sur Name.");
                            valid=false;
                            return valid;
                        }
                       else if(document.getElementById("txtstatus").value=="0")
                        {
                            alert("Please Specify Marital Staus.");
                            valid=false;
                            return valid;
                        }
                         valid= true;
                         validmail=document.getElementById("txtemailid").value;
                       if(validmail=="")
                            {
                                alert("Please Specify The EmailId.");
                                valid=false;
                                    return valid;
                            }
                            
                         else if(emailcheck(validmail)==false)
                                {
                                    alert("Please Specify Valid Email Address.");
                                    valid=false;
                                    return valid;
                                 }
                                 
                           else if(document.getElementById("textmobile").value=="")
                              {
                                     alert("Please Specify Mobile Number.");
                                     valid=false;
                                     return valid;
                               }
                        
                           else if(document.getElementById("txthouse").value=="")
                           {
                                alert("Please Specify Housing/Buliding.");
                                valid=false;
                                return valid;
                            }
                                else if(document.getElementById("txtstname").value=="")
                                {
                                    alert("Please Specify Street Name.");
                                    valid=false;
                                    return valid;
                                }
                                else if(document.getElementById("textregion").value=="")
                                {
                                    alert("Please Specify the country.");
                                    valid=false;
                                    return valid;
                                }
                                
                              else if(document.getElementById("ddlBillstate").value=="")
                                        {
                                            alert("Please Specify State.");
                                            //document.getElementById("ddlBillstate").focus();
                                           valid=false;
                                            return valid;
                                        }
                               
                              else if(document.getElementById("txtBillCity").value=="")
                                        {
                                            alert("Please Specify Sub Area/City.");
                                            //document.getElementById("txtBillCity").focus();
                                            valid=false;
                                            return valid;
                                        }
                                valid= true;
                                validpincode=document.getElementById("txtpcode").value;
                                if(validpincode=="")
                                        {
                                            alert("Please Specify Pin Code.");
                                            valid=false;
                                            return valid;
                                        }
                                        
                                else if(validpincode.length<6)
                                        {
                                            
                                            alert("Please Specify valid Pin Code.");
                                            valid=false;
                                            return valid;
                                        }
                                        
                                  
                              else if(document.getElementById("TxtHousinBuildinDel").value=="")
                                       {
                                            alert("Please Specify Delivery Housing/Buliding.");
                                            //document.getElementById("TxtHousinBuildinDel").focus();
                                            valid=false;
                                            return valid;
                                        }
                                
                                 else if(document.getElementById("TxtStrNmDel").value=="")
                                        {
                                            alert("Please Specify Delivery Street Name.");
                                            //document.getElementById("TxtStrNmDel").focus();
                                            valid=false;
                                            return valid;
                                        }
                                        else if(document.getElementById("txtBillCityDel").value=="")
                                        {
                                            alert("Please Specify Delivery City.");
                                           // document.getElementById("txtBillCityDel").focus();
                                            valid=false;
                                            return valid;
                                        }
                                 
                                        
                                  else if(document.getElementById("ddlBillstateDel").value=="Select")
                                        {
                                            alert("Please Specify the State.");
                                            //document.getElementById("ddlBillstateDel").focus();
                                            valid=false;
                                            return valid;
                                        }
                                          valid= true;
                                         validdelpincode=document.getElementById("TxtPinCodeDel").value;
                                         if(validdelpincode=="")
                                        {
                                            alert("Please Specify Delivery PinCode.");
                                            //document.getElementById("TxtPinCodeDel").focus();
                                            valid=false;
                                            return valid;
                                        }
                                        else if(validdelpincode.length<6)
                                        {
                                            
                                            alert("Please Specify valid delivery Pin Code.");
                                            valid=false;
                                            return valid;
                                        }
                                         else if(document.getElementById("txtcountry").value=="")
                                        {
                                            alert("Please Specify Delivery Country.");
                                            //document.getElementById("TxtPinCodeDel").focus();
                                            valid=false;
                                            return valid;
                                        }
                                   else if(!(document.getElementById("chkTermsCondition").checked==true))
                                            {
                                                alert("Please accept The terms and condition");
                                                valid=false;
                                                return valid;
                                            }
                                  return valid;
                   }

//Validation for insurance customer page//
	function FillInDetails()
{
    if(document.getElementById("Checkbox1").checked==true)
    {
        document.getElementById("TxtHousinBuildinDel").value=document.getElementById("txthouse").value;
        document.getElementById("TxtStrNmDel").value=document.getElementById("txtstname").value;
        document.getElementById("txtBillCityDel").value=document.getElementById("txtBillCity").value;
        document.getElementById("ddlBillstateDel").value=document.getElementById("ddlBillstate").value;
        document.getElementById("TxtPinCodeDel").value=document.getElementById("txtpcode").value;
        document.getElementById("txtcountry").value=document.getElementById("textregion").value;
    }
    else
    {
        document.getElementById("TxtHousinBuildinDel").value="";
        document.getElementById("TxtStrNmDel").value="";
        document.getElementById("txtBillCityDel").value="";
        document.getElementById("ddlBillstateDel").value="";
        document.getElementById("TxtPinCodeDel").value="";
        document.getElementById("txtcountry").value="";
    }
}
function emailcheck(str)
        {
            var str1=str;
            var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
            if (filter.test(str1))
            testresults=true
        else
            {
                testresults=false
            }
            return (testresults)
        }
         
    function validateEmail(emailID)
{
	if (echeck(emailID)==false)
	{
		document.getElementById("txtemailid").value="";
		document.getElementById("txtemailid").focus();
		return false
	}
 }    
 
 //**********************function to get insurance status************************************************//
function fnStatus()
    {      
       var a= document.getElementById("hdnvaluefora").value;    
      
        {
            //alert("hi");
            url="insurancestatus.aspx";
            //document.getElementById("hdnvaluej").value=j;
            //document.getElementById("hdnplancode").value=objPlanCode;
            document.customerpage.method="post";
            document.customerpage.action=url;
            document.customerpage.submit();
            
        }

       
     }
//**************************function to get insurance ends*************************************************//
//**********************function to get download the policy starts******************************************//
function fnpolicy()
    {
        var policyref=document.getElementById("policyref").value;
        //alert(policyref);
        var userid=document.getElementById("userid").value;
        //alert(userid);
        url="http://preprod.bajajallianz.com/BagicOnline/ws/dp/rangetravelpdf.do?p_policy_ref="+policyref+"&version=1&user_name="+userid+"&plocationcode=1901"
        window.open(url,"Ticket",'width=800,height=800,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
    }
//**********************function to get download the policy starts******************************************//
        
//***********************function to get the policy details*************************************************//
function fnmoredet(objPlanCode,j)
{
  document.getElementById("hdnvaluej").value=j;
  document.getElementById("hdnplancode").value=objPlanCode;
  var url="insurancedetails.aspx?plancode="+objPlanCode;
  document.home.method="post";
  document.home.action=url;
  document.home.submit();
}
function fnmoredetails(objPlanCode,j)
{
  document.getElementById("hdnvaluej").value=j;
  document.getElementById("hdnplancode").value=objPlanCode;
  var url="insurancedetails.aspx?plancode="+objPlanCode;
  document.details.method="post";
  document.details.action=url;
  document.details.submit();
}
function fnmoredetforpremium(objPlanCode,j)
{
  
  document.getElementById("hdnvaluej").value=j;
  document.getElementById("hdnplancode").value=objPlanCode;
  var url="insurancedetails.aspx?plancode="+objPlanCode;
  document.premiumpage.method="post";
  document.premiumpage.action=url;
  document.premiumpage.submit();
}

//***********************function to get the policy details*************************************************//
// function for premium page//
function fnbuy(obj)
{
    var url="";
   
    {
        url="insurancepremium.aspx?plancode="+obj;
    }
    
    document.details.method="post";
    document.details.action=url;
    document.details.submit();
}

// function for customer page//
function openretermsofusepopup()
{
//var agency=document.getElementById("agency").value;
url="termsofusepopup.aspx";
window.open(url,'','location=0,status=1,scrollbars=1,  width=780, height=768');
}

function fnSubmit()
{
   
   //alert("hi");
   var valid=customerdetailsvalidation();
    
   //alert(valid); 
   if(valid==true)
        {
            $(function($) 
            {

    function fnBlockUI() 
    {
    }
    //$('#showDialog').click(function() {
        $.blockUI({ message: $('#question'), css: { width:'575px', height:'auto' }});
    //});

    $('#yes').click(function()
    {
        // update the block message
       // $.blockUI({ message: '<h3>Continue...</h3>' });

        $.ajax({
            url: 'wait2.php', 
            cache: false,
            complete: function() {
                // unblock when remote call returns
                $.unblockUI();
            }
        });
    });

    $('#no').bind('click', $.unblockUI);

    // wire up all the demo code
    $('#demoTable code').each(function() {
        eval($(this).text());
    });
});    
        }
        return valid;
}
// function for customer page//