﻿// Javacript File
<!--

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e)
{
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) 
{
    var found = false, index = 0;
	  while(!found && index < arr.length)
	  if(arr[index] == ele)
		  found = true;
	  else
		  index++;
	  return found;
}	

function getIndex(input) 
{
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
			else i++;
		return index;
		}
		return true;
}



function openWindow( pageName, titleName, winWidth, winHeight) {
	window.open(pageName, titleName, 'height=' + winHeight + ', width=' + winWidth + ', toolbar=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, statusbar=yes, status=yes');
}

function closeWindow()
{
  window.close();
}

function applyDisplay( contID, val)
{
    document.getElementById(contID).style.display = val;
}

function redirectPage( sURL)
{
    self.location.href = sURL;
}

function getIFrameReferrer()
{
  try  {  try  {document.getElementById("txtReferrer").value  = window.top.document.referrer;}  catch(err){}  }  catch(err){}  
}

function updateRadioCover(objParking, objCoverType, objRadio, cause)
{
  try
  {
    var parking = objParking.value.replace(/^\s+|\s+$/g, '');
    var cover = objCoverType.value.replace(/^\s+|\s+$/g, '');
    
    if (( (parking == '1') || (parking == '2') || (parking == '3') || (parking == '7') ) || (cover == 'C'))
    {
      var oldIndex = objRadio.selectedIndex;
      objRadio.selectedIndex = 0;
      objRadio.disabled = "disabled";
      if (oldIndex > 0)
        if (cause == 'MP')
          alert('Sound system cover is not allowed for the selected overnight parking facility.');
        else if(cause == 'CV')
          alert('Sound system cover is not allowed for the selected cover type.');
    }
    else
    {
      objRadio.disabled = "";
    }
  }
  catch(err){}
}

function showBusinessUse()
{
      alert('Please note that this vehicle can only be insured for business use');  	  	            	            	  	           
}

function showSuburbPopup()
{
      alert('Please select the correct suburb and postal code from the confirm suburb drop down list.');  	  	            	            	  	           
}

function LicenceCheck(objLic, objLicYY, objLicMM)
{
  try
  {
    var lic = objLic.value;
    if (lic == '3')
    {
        alert('Please note that if you are a Learner Driver, you must be accompanied by a Licensed Driver when driving a motor vehicle.\n\nPlease inform us immediately upon receipt of your Driver’s Licence.');
        objLicYY.disabled = "disabled";
        objLicMM.disabled = "disabled";
				objLicYY.selectedIndex = 0;
				objLicMM.selectedIndex = 0;
    }
    else
    {
        objLicYY.disabled = "";
        objLicMM.disabled = "";
    }
  }
  catch(err){}
}

//-->


