var ModalDialogWindow;
var ModalDialogInterval;
var ModalDialog = new Object;

ModalDialog.value = '';
ModalDialog.eventhandler = '';

var hasVB = 0;

function hasPlugin(mime,name)
{
	var plug = (navigator.mimeTypes) ? navigator.mimeTypes[mime]: 0;
	if(plug){
		if(plug.enabledPlugin)
		{
			return hasPlugin = (plug.enabledPlugin.name == name) ? 1 : 0;
		}
	}
}

if(navigator.appVersion.charAt(0)>=3){
	movimg=new Array()
	movimg[0] = new Image();movimg[0].src='images/skin/button2.gif';
	movimg[1] = new Image();movimg[1].src='images/skin/button.gif';

	movimg2=new Array()
	movimg2[0] = new Image();movimg2[0].src='Nam_CMUserFiles/Image/Homepage/Lifestyle/LIFESTYLE_477x150_03_out.gif';
	movimg2[1] = new Image();movimg2[1].src='Nam_CMUserFiles/Image/Homepage/Lifestyle/LIFESTYLE_477x150_03_in.gif';

	movimg3=new Array()
	movimg3[0] = new Image();movimg3[0].src='images/skin/Search1.gif';
	movimg3[1] = new Image();movimg3[1].src='images/skin/Search2.gif';
}

function changImg(status){
	if(navigator.appVersion.charAt(0)>=3){
		document.images["image"].src=movimg[status].src;
	}
}

function changImg2(status){
	if(navigator.appVersion.charAt(0)>=3){
		document.images["img2"].src=movimg2[status].src;
	}
}

function changImg3(status){
	if(navigator.appVersion.charAt(0)>=3){
		document.images["image1"].src=movimg3[status].src;
	}
}

//Preload images
function preloadImages()
{
	var d=document;
	if(d.images)
	{
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=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 doSearch()
{
	if (window.document.frmSearch.q.value == "")
	{
		alert("Kindly enter a search keyword!");
		window.document.frmSearch.q.focus();
	}
	else
	{
		window.document.frmSearch.submit();
	}
}

function doSearch2()
{
	if (window.document.frmSearchResult.condition[0].checked)
	{
		window.document.frmSearch.condition.value = "and"
	}
	if (window.document.frmSearchResult.condition[1].checked)
	{
		window.document.frmSearch.condition.value = "or"
	}
	window.document.frmSearch.q.value = window.document.frmSearchResult.keyword.value	
	
	if (window.document.frmSearch.q.value == "")
	{
		alert("Kindly enter a search keyword!");
		window.document.frmSearch.q.focus();
	}
	else
	{
		window.document.frmSearch.submit();
	}	
}

function openURL(sURL)
{	
	window.open(sURL, null);
}

function ModalDialogMaintainFocus(){
	  try{
	    if (ModalDialogWindow.closed){
	      window.clearInterval(ModalDialogInterval);
	      eval(ModalDialog.eventhandler);       
	      return;
	    }
	    ModalDialogWindow.focus(); 
	  }
	  catch (everything) {   }
	}
        
  function ModalDialogRemoveWatch() {
    ModalDialog.value = '';
    ModalDialog.eventhandler = '';
  }
        
 function ModalDialogShow(sURL,sWindowName,EventHandler) {
   ModalDialogRemoveWatch();
   ModalDialog.eventhandler = EventHandler;

   var args='width=800,height=600,left=325,top=300,toolbar=0,';
       args+='location=0,status=0,menubar=0,scrollbars=0,resizable=0';  

   ModalDialogWindow=window.open(sURL,sWindowName,args); 
   ModalDialogWindow.focus(); 
   ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);

 }

  function quoteClose(){
    alert('close');	
	}

	function MM_goToURL() { //v3.0
	  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}

  function submitForm(sAction,sParam1,sParam2) {  	 	
  	document.body.style.cursor="wait";
	  day = new Date();
		id = day.getTime();
		if(sAction=="login"){
			var sBaseURL = new String(window.document.location);
		  var sURL = "";		  
		  if(sBaseURL.indexOf("www.out") > 0)
		  {				
		    if (sBaseURL.indexOf("com.na") > 0)
		    {		    
					sURL = "https://www.outsurance.co.za";
				}	
				else
				{
					sURL = "https://www.outsurance.co.za";
				}
		  }
		  sURL += "/personalfacility/login.asp?";
		  //var sURL = sBaseURL + "personalfacility/login.asp";
			ModalDialogWindow = window.open(sURL,'facility','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus(); 
			//window.showModalDialog(sURL,"facility","dialogWidth:800px; dialogHeight:600px; center:Yes; help:No; resizable:No; status:No; scroll:Yes;");
		}	
		else if(sAction=="equote"){
		  var sURL = "webquote/quoteintro.asp?rnd=" + id + "&referrerId=" + sParam1 + "&referrer=" + sParam2;
		  //window.open(sURL,'eQuote','width=800,height=600,scrollbars,resizable');
      ModalDialogWindow = window.showModalDialog(sURL,"eQuote","dialogWidth:800px; dialogHeight:600px; center:Yes; help:No; resizable:No; status:No; scroll:Yes;");
		  //ModalDialogShow(sURL,'eQuote','quoteClose()');
		}
		else if(sAction=="register"){
			var sBaseURL = new String(window.document.location);
		  var sURL = "";		  
		  if(sBaseURL.indexOf("www.out") > 0)
		  {				
		    if (sBaseURL.indexOf("com.na") > 0)
		    {		    
					sURL = "https://www.outsurance.co.za";
				}	
				else
				{
					sURL = "https://www.outsurance.co.za";
				}
		  }
		  sURL += "/personalfacility/register.asp?";		  
			ModalDialogWindow = window.open(sURL,'facility','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus();
			//window.showModalDialog(sURL,"facility","dialogWidth:800px; dialogHeight:600px; center:Yes; help:No; resizable:No; status:No; scroll:Yes;");
		}
		else if(sAction=="supplier"){
		  var sURL = "supplier/login.asp?rnd=" + id;
			ModalDialogWindow = window.open(sURL,'','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			//ModalDialogWindow = window.open(sURL,'','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus();
			//window.showModalDialog(sURL,"supplier","dialogWidth:800px; dialogHeight:600px; center:Yes; help:No; resizable:No; status:No; scroll:Yes;");
		}		
		
		else if(sAction=="channel"){//same as broker. broker will be changed to channel
		  var sURL = "broker/login.asp?rnd=" + id;
			ModalDialogWindow = window.open(sURL,'channel','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus();
		}
		
		else if(sAction == "autosupplier")
		{
			var sURL, sSupplierID, sUName, sPWD, sLogin;
			var arrQueryString, arrNameValue;
			
			arrQueryString = new String(window.document.location.search).substring(1).split("&");
			sSupplierID = "";
			sUName = "";
			sPWD = "";
			sLogin = "";
			
			for(i = 0; i < arrQueryString.length; i++)
			{	
				arrNameValue = arrQueryString[i].split("=");
				
				if(arrNameValue[0] == "supplierID")
				{	
					sSupplierID = arrNameValue[1];					
				}
				
				if(arrNameValue[0] == "sUName")
				{
					sUName = arrNameValue[1];
				}
				
				if(arrNameValue[0] == "sPWD")
				{
					sPWD = arrNameValue[1];
				}
				
				if(arrNameValue[0] == "Login")
				{
					sLogin = arrNameValue[1];
				}							
			}
			
			if(sLogin == "")
			{
				sLogin = "Yes";
			}
			sURL = "supplier/login.asp?supplierID=" + sSupplierID + "&username=" + sUName + "&ps=" + sPWD + "&Login=" +  sLogin +"&rnd=" + id;
			ModalDialogWindow = window.open(sURL,'supplier','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus();
			//window.showModalDialog(sURL,"supplier","dialogWidth:800px; dialogHeight:600px; center:Yes; help:No; resizable:No; status:No; scroll:Yes;");
		}
		
		else if(sAction == "autobroker")
		{
			var sURL, sBCode, sBPWD, sLogin;
			var arrQueryString, arrNameValue;
			
			arrQueryString = new String(window.document.location.search).substring(1).split("&");
			sBCode = "";
			sBPWD = "";
			sLogin = "";
			
			for(i = 0; i < arrQueryString.length; i++)
			{	
				arrNameValue = arrQueryString[i].split("=");
				
				if(arrNameValue[0] == "bCODE")
				{	
					sBCode = arrNameValue[1];					
				}
							
				if(arrNameValue[0] == "bPWD")
				{
					sBPWD = arrNameValue[1];
				}							
			}
			
			sURL = "broker/login.asp?bCode=" + sBCode + "&bPWD=" + sBPWD + "&Login=Yes&rnd=" + id;
			ModalDialogWindow = window.open(sURL, "channel", "width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0");
			ModalDialogWindow.focus();
		}
		
		else if(sAction == "autopersonal")
		{
			var sURL, sOT, sUName, sPWD, sLogin;
			var arrQueryString, arrNameValue;
			
			arrQueryString = new String(window.document.location.search).substring(1).split("&");
			sOT = "";
			sUName = "";
			sPWD = "";
			sLogin = "";			
			
			for(i = 0; i < arrQueryString.length; i++)
			{	
				arrNameValue = arrQueryString[i].split("=");
				
				if(arrNameValue[0] == "sOT")
				{	
					sOT = arrNameValue[1];					
				}
				
				if(arrNameValue[0] == "sUName")
				{
					sUName = arrNameValue[1];
				}
				
				if(arrNameValue[0] == "sPWD")
				{
					sPWD = arrNameValue[1];
				}
							
			}			
			
			sURL = "personalfacility/login.asp?txtFacility=" + sOT + "&txtUsername=" + sUName + "&txtPassword=" + sPWD + "&Login=Yes&rnd=" + id;
			ModalDialogWindow = window.open(sURL, 'facility', 'width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus();
		}
			
		else if(sAction == "personalforgot")
		{
			sURL = "personalfacility/forgotpassword.asp?rnd=" + id;
			ModalDialogWindow = window.open(sURL,'facility','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus();
		}		
		
		else if(sAction == "supplierforgot")
		{
			sURL = "supplier/forgotpassword.asp?rnd=" + id;
			ModalDialogWindow = window.open(sURL,'supplier','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus();
		}
				
		document.body.style.cursor="default";
	}
	
	function submitMiniLogin() {
		if(validateMiniLogin()){
		  var sUsername = document.forms[0].txtUsername.value;
		  var sPassword = document.forms[0].txtPassword.value;
			day = new Date();
		  id = day.getTime();
			var sURL = "personalfacility/login.asp?sGUID="+id+id+id+id+"&Login=Yes&txtUsername="+sUsername+"&txtPassword="+sPassword+"&sRnd="+id;
			ModalDialogWindow = window.open(sURL,'facility','width=800,height=600,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
			ModalDialogWindow.focus();
			//ret = window.showModalDialog(sURL,"facility","dialogWidth:800px; dialogHeight:600px; center:Yes; help:No; resizable:Yes; status:No; scroll:Yes;");
			document.forms[0].txtUsername.value="";
			document.forms[0].txtPassword.value="";

		}	
	}
	
	function validateMiniLogin(){
	  if (document.forms[0].txtUsername.value == "") {
			sErrMsg = "Please enter your Username";
			alert(sErrMsg);
			//DisplayError(sErrMsg);
			document.forms[0].txtUsername.focus();
			return false;
		}
		if (document.forms[0].txtPassword.value == "") {
			sErrMsg = "Please enter your Password";
			alert(sErrMsg);
			//DisplayError(sErrMsg);
			document.forms[0].txtPassword.focus();
			return false;
		}
		return true;
	}
	
	function launchStaticContent(name) { 
		var day = new Date();
		var id = day.getTime();
		var sURL = "";
		var sFeatures = "";
		
		switch(name){
		  case "contact":
        sURL = "../pages/contactDetail.asp?id=" + id;
        sFeatures = "dialogWidth: 500px; dialogHeight: 500px; center: Yes; help: no; resizable: No; status:No; scroll:No;";
		    break;
		  case "disclaimer":
		    sURL = "../pages/disclaimer.asp?id=" + id;
        sFeatures = "dialogWidth: 720px; dialogHeight: 500px; center: Yes; help: no; resizable: Yes; status:No; scroll:Yes;";
		    break;
		  case "excesses":
		    sURL = "pages/excesses.asp?id=" + id;
        sFeatures = "dialogWidth: 720px; dialogHeight: 570px; center: Yes; help: no; resizable: Yes; status:No; scroll:Yes;";
		    break;    
		  case "privacy":
		    sURL = "../pages/privacySecurity.asp?id=" + id;
        sFeatures = "dialogWidth: 720px; dialogHeight: 500px; center: Yes; help: no; resizable: Yes; status:No; scroll:Yes;";
		    break;   
		}	  
		window.showModalDialog(sURL,"None",sFeatures);
	}

	function autoFocus(objEvent,nextObject,checkObject,preObject){
  	//This function is for onlineForm.asp. Makes shift/tab and tab work going forwards or backwards
  	var lKeyCode = objEvent.keyCode;
    var objInput = objEvent.srcElement;
    //alert(objInput.name);
    //Fist check whether the shift+tab key was pressed
  	if ((objEvent.shiftKey)&&(lKeyCode==9)){
  		//Check to see whether the checkObject has a value, if so, focus there if not focus on preObject
  		if(checkObject){
  			if (checkObject.value!=""){
  				checkObject.focus();
  				window.event.returnValue = false;
  			}else{
  				preObject.focus();
  				window.event.returnValue = false;
  		  }		
  	  }		
  		//objEvent.ctrlKey 
  		//objEvent.altKey 
  		return true;
    }	
    if (objInput.name=="txt_CELLNO"){
    	if((lKeyCode==9)||(lKeyCode==13)){
	  		nextObject.focus();
	  		window.event.returnValue = false;
	  	}
   	}else{	 
	  	if(((lKeyCode==9)||(lKeyCode==13)) && objInput.value==""){
	  		nextObject.focus();
	  		window.event.returnValue = false;
	  	}
	  }	
  }
  
	function showError(errMsg){
		day = new Date();
		id = day.getTime();
		window.showModalDialog("includes/errorviewer.asp?msg=" + errMsg + "&id=" + id + "","None","dialogWidth: 305px; dialogHeight: 215px; center: Yes; help: no; resizable: No; status:No; scroll:No;");
	}
  
  function swapMenu(menu){
	  
	  var mnuHome=document.getElementById("mnuHome");
	  var mnuOnline=document.getElementById("mnuOnline");
	  var mnuPersonal=document.getElementById("mnuPersonal");
	  var mnuDocuments=document.getElementById("mnuDocuments");
	  var mnuService=document.getElementById("mnuService");
	  var mnuCompany=document.getElementById("mnuCompany");
	  
	  var mnuTDHome=document.getElementById("mnuTDHome");
	  var mnuTDOnline=document.getElementById("mnuTDOnline");
	  var mnuTDPersonal=document.getElementById("mnuTDPersonal");	  
	  var mnuTDDocuments=document.getElementById("mnuTDDocuments");
	  var mnuTDService=document.getElementById("mnuTDService");
	  var mnuTDCompany=document.getElementById("mnuTDCompany");
	  var mnuTDFraud=document.getElementById("mnuTDFraud");
	  var mnuTDLinks=document.getElementById("mnuTDLinks");
	  var mnuTDSearch=document.getElementById("mnuTDSearch");
	  
	  mnuHome.style.display="none";
	  mnuOnline.style.display="none";
	  mnuPersonal.style.display="none";
	  mnuDocuments.style.display="none";	    
//	  mnuCompany.style.display="none";
	  
	  mnuTDHome.className="menuHeader2";
	  mnuTDOnline.className="menuHeader2";
	  mnuTDPersonal.className="menuHeader2";	  
	  mnuTDDocuments.className="menuHeader2";
	  mnuTDService.className="menuHeader2";
	  mnuTDCompany.className="menuHeader2";;
	  mnuTDFraud.className="menuHeader2";
	  mnuTDLinks.className="menuHeader2";
	  mnuTDSearch.className="menuHeader2";
	  
	  switch(menu){
		  case "mnuHome":
		    mnuHome.style.display="block";
		    mnuTDHome.className="menuHeaderSel";
		    break;
		  case "mnuOnline":
		    mnuOnline.style.display="block";
		    mnuTDOnline.className="menuHeaderSel";
		    break;  
		  case "mnuPersonal":
		    mnuPersonal.style.display="block";
		    mnuTDPersonal.className="menuHeaderSel";
		    break;
		  case "mnuDocuments":
		    mnuDocuments.style.display="block";
		    mnuTDDocuments.className="menuHeaderSel";
		    break;  
		  case "mnuService":		  
		    mnuTDService.className="menuHeaderSel";
		    break;
		  case "mnuCompany":
//		    mnuCompany.style.display="block";  
		    mnuTDCompany.className="menuHeaderSel";      
		    break;
		  case "mnuFraud":
		    mnuTDFraud.className="menuHeaderSel";       
		    break;   
		  case "mnuLinks":
		    mnuTDLinks.className="menuHeaderSel";       
		    break; 
		 case "mnuSearch":
		    mnuTDSearch.className="menuHeaderSel";       
		    break;   
		}  
	}
	
	function swapCaption(sCaption){
		//alert(sCaption); 
		document.getElementById("currentCaption").innerHTML = "&nbsp;" + sCaption;
	}
	
	function setDartTag(sCaption){
		//alert(sCaption); 
		document.getElementById("currentCaption").innerHTML = "&nbsp;" + sCaption;
	}
	

	function checkNumericalKey(){
  	var lKeyCode = window.event.keyCode
  	//alert(lKeyCode);
  	//48 - 58 are numerical
  	//46 = delete
  	//8 = backspace
  	//37 = backarrow 
  	//39 = forwardarrow 
    if (((lKeyCode < 48) || (lKeyCode > 58)) && (lKeyCode != 46) && (lKeyCode != 39) && (lKeyCode != 37) && (lKeyCode != 8)) {
      window.event.returnValue = false;
    }  
  }
  
  function checkCurrencyKey(){
  	var lKeyCode = window.event.keyCode
  	//alert(lKeyCode);
  	//48 - 58 are numerical
  	//46 = delete
  	//8 = backspace
  	//37 = backarrow 
  	//39 = forwardarrow 
  	//190 = fullstop
    if (((lKeyCode < 48) || (lKeyCode > 58)) && (lKeyCode != 190) && (lKeyCode != 46) && (lKeyCode != 39) && (lKeyCode != 37) && (lKeyCode != 8)) {
      window.event.returnValue = false;
    }  
  }
 
  function CheckIfNumber(PassedVal){
  	var checkOK = "0123456789";
  	var checkStr = PassedVal;
  	var allValid = true;
  	var decPoints = 0;
  	var allNum = "";
  	for (i = 0;  i < checkStr.length;  i++){
		  ch = checkStr.charAt(i);
		  for (j = 0;  j < checkOK.length;  j++) if (ch == checkOK.charAt(j)) break;
		    if (j == checkOK.length){
	  		  allValid = false;
	  		  break;
		  }
		  allNum += ch;
  	}
  	if (!allValid){
		  //alert("Please enter only numeric characters in the \"Access Account\" field.");
		  return (false);
  	}
	  else {
	    return (true);
	  }
  }
  
  function ignoreSpaces(string) {
		var temp = "";
		string = '' + string;
		splitstring = string.split(" ");
		for(i = 0; i < splitstring.length; i++)
			temp += splitstring[i];
		//***
		splitstring = temp.split("-");
		temp = "";
		for(i = 0; i < splitstring.length; i++)
			temp += splitstring[i];
		//***
		splitstring = temp.split("(");
		temp = "";
		for(i = 0; i < splitstring.length; i++)
			temp += splitstring[i];
		//***
		splitstring = temp.split(")");
		temp = "";
		for(i = 0; i < splitstring.length; i++)
			temp += splitstring[i];
		//***
		return temp;
	}
  	
  function ltrim(strTmp) {
     var strlen, cptr, lpflag, chk;

     if (strTmp != "") {
      strlen = strTmp.length;
      cptr = 0;
      lpflag = true;

      do {
        chk = strTmp.charAt(cptr);
        if (chk != " ")
          lpflag = false;
        else {
          if (cptr == strlen)
            lpflag = false;
          else
            cptr++;
        }
      } while (lpflag == true);

      if (cptr > 0)
        strTmp = strTmp.substring(cptr, strlen);
    }

    return (strTmp);
  }

  function rtrim(strTmp) {

    var strlen, cptr, lpflag, chk;

    if (strTmp != "") {
      strlen = strTmp.length;
      cptr = strlen;
      lpflag = true;

      do {
        chk = strTmp.charAt(cptr-1);
        if (chk != " ")
          lpflag = false;
        else {
          if (cptr == 0)
            lpflag = False;
          else
            cptr--;
        }
      } while (lpflag == true);

      if (cptr < strlen)
        strTmp = strTmp.substring(0,cptr);
    }
    return (strTmp);
  }

  function trim (strTmp) {
    return ltrim(rtrim(strTmp));
  }

  function left(strVal, iEnd, iNumChars) {

    var k;
    var iStart;
    var sTmp = "";

    sTmp = strVal;
    if (iEnd < 0) iEnd = 0;
    if (iEnd >= sTmp.length) iEnd = sTmp.length-1;

    iStart = iEnd - iNumChars;
    if (iStart < 0) iStart = 0;
    if (iStart > iEnd) iStart = iEnd;

    sTmp = "";
    for (k = iStart; k <= iEnd; k++)
      sTmp += strVal.charAt(k);

    return(sTmp);
  }

  function right(strVal, iStart, iNumChars) {

    var k;
    var iEnd;
    var sTmp = "";

    sTmp = strVal;
    if (iStart < 0) iStart = sTmp.length-1;    // Start at end if negative
    if (iStart >= sTmp.length) iStart = sTmp.length-1;

    iEnd = iStart + iNumChars;
    if (iEnd >= sTmp.length) iEnd = sTmp.length-1;
    if (iEnd < iStart) iEnd = iStart;

    sTmp = "";
    for (k = iStart; k <= iEnd; k++)
      sTmp += strVal.charAt(k);

    return(sTmp);
  }

  function cint(chrVal) {
    if (chrVal == '0') return(0);
    if (chrVal == '1') return(1);
    if (chrVal == '2') return(2);
    if (chrVal == '3') return(3);
    if (chrVal == '4') return(4);
    if (chrVal == '5') return(5);
    if (chrVal == '6') return(6);
    if (chrVal == '7') return(7);
    if (chrVal == '8') return(8);
    if (chrVal == '9') return(9);
    return(0);
  }

	function launchOutBonusCalculator() { 
		//Use the following id variable to ensure a non-cached window
		day = new Date();
		id = day.getTime();
		window.showModalDialog("obcalc.asp?id=" + id + "","None","dialogWidth: 300px; dialogHeight: 300px; center: Yes; help: no; resizable: No; status:No; scroll:No;");
		
	}
	
	
	/*** Add Secondary Risk ***/
  function addRisk(){
		var oRow;
		var oCell;
		var strHTML;
			
		var iRiskItems = Number(frmVehicle2.riskItems.value);
		
		iRiskItems++;
		frmVehicle2.riskItems.value = iRiskItems;
		
		//strHTML = "<span id='txtNumber" + iPrefixItems + "' name='txtNumber" + iPrefixItems + "'>&nbsp;" + iPrefixItems + "</span>";
		// Insert a new Row
	  oRow = tblRiskItems.insertRow();
		
	  // Insert the Cells
	  // Cell 1
	  strHTML = "<td>&nbsp;</td>";
	  oCell = oRow.insertCell();
	  oCell.innerHTML = strHTML; 
	  
	  // Cell 2 - Item Number
	  strHTML = iRiskItems + ".";
	  oCell = oRow.insertCell();
	  oCell.width="5";
	  oCell.align="right";
	  oCell.className="body_text";
	  oCell.innerHTML = strHTML; 
	  
	  // Cell 3 - Type Combo
	  strHTML = "<td width='90'>";
	  strHTML += "<select name='cboRisk' class='listbox'>";
		strHTML += "<option value='1'>Radio</option>";
		strHTML += "<option value='1'>CD Shuttle</option>";
		strHTML += "</select>";
		strHTML += "</td>";
	  
	  oCell = oRow.insertCell();
	  oCell.width="90";
	  oCell.align="right";
	  oCell.className="body_text";
	  oCell.innerHTML = strHTML;
	  
	  // Cell 4 - make
	  strHTML = "<td width='90'><input type='textbox' name='txtMake' value='MAKE' id='txtMake' class='textbox_border'></td>";
	  oCell = oRow.insertCell();
	  oCell.width="90";
	  oCell.align="center";
	  oCell.className="body_text";
	  oCell.innerHTML = strHTML;
	  
	  // Cell 5 - Model
	  strHTML = "<td width='90'><input type='textbox' name='txtModel' value='model' id='txtModel' class='textbox_border'></td>";
	  oCell = oRow.insertCell();
	  oCell.width="90";
	  oCell.align="center";
	  oCell.className="body_text";
	  oCell.innerHTML = strHTML;
	  
	  // Cell 6 - Value
	  strHTML = "<td width='60'><input type='textbox' name='txtValue' value='value' id='txtValue' class='textbox_border'></td>";
	  oCell = oRow.insertCell();
	  oCell.width="60";
	  oCell.align="center";
	  oCell.className="body_text";
	  oCell.innerHTML = strHTML;
	  
	  // Cell 7 - Trash can
	  strHTML = "<td width='16'><a href='javascript:deleteRisk(1)';><img src='../images/trashcan.gif' width='16' height='16' border='0' alt='Delete this item'></a></td>";
	  oCell = oRow.insertCell();
	  oCell.width="16";
	  oCell.align="center";
	  oCell.className="body_text";
	  oCell.innerHTML = strHTML;
	
	}

	function removeInvalidChars()
	{
		var arrCharsToInclude = new Array(); //Chars to be included in the Return String (chars not within the range 32 - 126)
		var arrCharsToExclude = new Array(); //Chars that are within the range 32 - 126, but should be excluded from the Return String
		var oInputElements, oTextareaElements;
		
		oInputElements = document.body.getElementsByTagName("INPUT");
		oTextareaElements = document.body.getElementsByTagName("TEXTAREA");
		
		arrCharsToExclude = [60,62];
		
		if(oInputElements)
		{	
			for(k = 0; k < parseInt(oInputElements.length); k++)		
			{	
				oInputElement = oInputElements.item(k);
				
				if(oInputElement.type == "text")
				{
					oInputElement.value = removeChars(oInputElement.value, arrCharsToExclude, arrCharsToInclude);
				}							
			}			
		}
		
		arrCharsToInclude = [10,13];		
		if(oTextareaElements)
		{
			for(l = 0; l < parseInt(oTextareaElements.length); l++)
			{
				oTextareaElement = oTextareaElements.item(l);
				oTextareaElement.value = removeChars(oTextareaElement.value, arrCharsToExclude, arrCharsToInclude);
			}				
		}		
	}	

	function removeChars(sStr, arrCharsToExclude ,arrCharsToInclude)
	{
		var iCharCode;
		var bExcludeChar;
		var sTemp = "";		
				
		//Replace (with reqular expression) all double quotes with single quotes.
		sStr = new String(sStr).replace(/"/g, "'");
		
		for(j = 0; j < sStr.length; j++)
		{
			iCharCode = sStr.charCodeAt(j);			
			
			if(iCharCode >= 32 && iCharCode <= 126)
			{	
				bExcludeChar = false;
				
				for(m = 0; m < arrCharsToExclude.length; m++)	
					if(iCharCode == arrCharsToExclude[m])
					{
						bExcludeChar = true;
						break;
					}
				
				if(!bExcludeChar)
				{
					sTemp = sTemp + sStr.charAt(j);
				}
					
			}
			else
				for(m = 0; m < arrCharsToInclude.length; m++)
				{
					if(iCharCode == arrCharsToInclude[m])
					{
						sTemp = sTemp + sStr.charAt(j);
					}
				}
		}													
		return sTemp;
	}

var currentDivName = "";
var currentInsuranceDivName = "divDefault";


function showLayer(objEvent,theLayer){
	if (currentDivName!= ""){
		var oDiv=document.getElementById(currentDivName);
		oDiv.style.visibility="hidden";
	}
	currentDivName = theLayer;
	var oDiv=document.getElementById(theLayer);
	var oParent=oDiv.parentNode;
	var iTop = 200; //parseInt(document.body.clientHeight/2-150);
	var iLeft = parseInt(document.body.clientWidth/2-200);
	//var iTop = objEvent.y;
	//var iLeft = parseInt(objEvent.x-200);
	//var iLeft = parseInt(oParent.offsetWidth/2 - 35);
	//var iTop = parseInt(oParent.offsetHeight/2 - 150);
	//var iTop = screen.height/2 - 150;
 	//var iLeft = screen.width/2 - 200;
	
	oDiv.style.left = iLeft;
	oDiv.style.top = iTop;
	oDiv.style.width = 400;
	oDiv.style.height = 300;
	oDiv.style.zIndex = 0;
	oDiv.style.visibility="visible";
	
}


function showInsuranceLayer(objEvent,theLayer){
	if (currentInsuranceDivName!= ""){
		var oDiv=document.getElementById(currentInsuranceDivName);
		oDiv.style.visibility="hidden";
	}
	currentInsuranceDivName = theLayer;
	var oDiv=document.getElementById(theLayer);
	var oParent=oDiv.parentNode;	
	var iLeft = parseInt(document.body.clientWidth/2-200);	
	oDiv.style.zIndex = 0;
	oDiv.style.visibility="visible";	

	
}

function closeInsuranceLayer(theLayer){
  var oDiv=document.getElementById(theLayer);
  oDiv.style.visibility="hidden";
  

  //var oDefaultDiv=document.getElementById("divDefault");
//oDefaultDiv.style.visibility="visible";

}

function closeLayer(theLayer){
  var oDiv=document.getElementById(theLayer);
  oDiv.style.visibility="hidden";
}