﻿// JScript File

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}
function getCookieVal (offset) 
   {
   var endstr = document.cookie.indexOf (";", offset);
	var v_ret;   
   if (endstr == -1)
      endstr = document.cookie.length;
      
   return unescape(document.cookie.substring(offset, endstr));
   }
 
function GetCookie (name) 
   {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   var cookieData = document.cookie.substring(0,clen);
   var endstr;
 
   // alert(cookieData + " ARG=" + name);
   
   cookieData = unescape(cookieData.replace(/\+/g, "%20"));
	  
   while (i < clen) 
      {
      var j = i + alen;
      
      // alert("[" + cookieData.substring(i, j) + "] [" + arg + "][j=" + j);
      
      if (cookieData.substring(i, j) == arg)
      {
		endstr = cookieData.indexOf (";", j);
		if (endstr == -1)
			endstr = cookieData.length;
			
         return cookieData.substring(j, endstr);
      } 
      
      i = cookieData.indexOf(" ", i) + 1;
      
      
      if (i == 0) break; 
      }
   return "";
   }
 
function fncText(lstrText) {
   window.status = lstrText;
}
function fnc_Form_Validate(thisForm)
{

strMsg = "";

  if (thisForm.fApp1DOB.value == "")
  {
    strMsg += 'Date of Birth for Applicant 1'+'\n';
  }
  
  if (thisForm.fApp2Sex.selectedIndex != 0)
  {
	  if (thisForm.fApp2DOB.value == "")
	  {
		strMsg += 'Date of Birth for Applicant 2'+'\n';
	  }
  }

  if (thisForm.fApp2Sex.selectedIndex == 0)
  {
	  if (thisForm.fApp2DOB.value != "")
	  {
		strMsg += 'Select Applicant 2 sex'+'\n';
	  }
  }

  if (thisForm.fSumAssured.value == "" && thisForm.fPremium.value == "")
  {
    strMsg += 'Amount of cover/premium required'+'\n';
  }
  
  if (thisForm.fSumAssured.value != "" && thisForm.fPremium.value != "")
  {
    strMsg += 'Either Amount of cover OR Premium required'+'\n';
  }
  
  if (thisForm.fTerm.value == "")
  {
    strMsg += 'Term of the Policy required'+'\n';
  }

  if (strMsg != "")
  {
    strMsg2 = "Please enter the following required information:"+'\n\n'+strMsg;
    alert(strMsg2);
    thisForm.fApp1DOB.focus();
    return (false);
  }

  return (true);
}

function CheckPTA()
{
	// DO nothing - AH 07-06-2006
}

function OldCheckPTA() 
{
	
	var SingleLife = window.document.inputform.fApp2Sex.selectedIndex ;
	var PolicyType = window.document.inputform.fPolicyType.selectedIndex ; 
	//alert("After Assigning Variables SingleLife = " + SingleLife + " PolicyType = " + window.document.inputform.fPolicyType.selectedIndex );
	
	if(SingleLife != 0) 
	{
	//	//Disable PTA Box and set it to No;
		window.document.inputform.fPTA.value = 'No';
		window.document.inputform.fPTA.options[1] = null;
		window.document.inputform.fPTA.selectedIndex = 0;
		//window.document.inputform.fPTA.disabled = 1;
	}
	else
	{
		//check policy type - if it has CIC, disable PTA combobox
		//var PolicyType = window.document.inputform.fPolicyType.selectedIndex ; 
		//alert("Checking PolicyType After Assigning Variables SingleLife = " + SingleLife + "PolicyType = " + PolicyType);
		if((PolicyType == 0) || (PolicyType == 6)) 
		{
			//window.document.inputform.fPTA.disabled = 0;
			window.document.inputform.fPTA.options[1] = new Option('Yes','Yes');			
			window.document.inputform.fPTA.value = 'Yes';
		}
		else
		{
			window.document.inputform.fPTA.value = 'No';
			window.document.inputform.fPTA.options[1] = null;
			window.document.inputform.fPTA.selectedIndex = 0;
			//window.document.inputform.fPTA.disabled = 1;
			
		}
	}		
}
function q(sURL, sWinName, sHeight, sWidth)
{
var sFeatures = "height=" + sHeight + ",width=" + sWidth + ",scrollbars=yes,resizable=yes,toolbar=no"
	
	window.open(sURL,sWinName, sFeatures);
}
