window.onerror=function(err,url,line){
    return true;
}
/*--------------------------------------------------------------------------------------
-- Package Name: qv_common_js
-- Author:       KM, GW
-- Purpose:      Displays common JavaScript functions
-- Created: 	 13-Dec-2006
--------------------------------------------------------------------------------------**
--------------------------------------------------------------------------------------
-- Modification History:

-- 13-12-2006	 Kiran M.    Moved all the sacttered Javascripts from the templates onto the JS file
-- 20-2-2007   Kiran M.    Added new function to hide item and hide item row to hide and show the row or item
-- 20-12-2006  Kiran M     Added isNumeric funtion to check the input value of the amount if other than numbers display alert message
-- 2-02-2007   Kiran M.	Added Functions HideDiv ShowDiv, hidedhow div, Hide_div _value.
-- 17-11-2009  Simon C.		 Added resize_htdb_iframe to resize apex form within iframe
--
--------------------------------------------------------------------------------------
--------------------------------------------
--            GLOBAL PROCEDURES
--------------------------------------------
Javascript for Bubble Tooltips by Alessandro Fulciniti
http://pro.html.it - http://web-graphics.com 


-- THIS FILE WAS PREVIOUSLY BUBLETOOLTIPS.JS  */


function enableTooltips(id){
var links,i,h;
if(!document.getElementById || !document.getElementsByTagName) return;
AddCss();
h=document.createElement("span");
h.id="btc";
h.setAttribute("id","btc");
h.style.position="absolute";
document.getElementsByTagName("body")[0].appendChild(h);
if(id==null) links=document.getElementsByTagName("span");
else links=document.getElementById(id).getElementsByTagName("span");
for(i=0;i<links.length;i++){
    Prepare(links[i]);
    }

}

function Prepare(el){
var tooltip,t,b,s,l;
t=el.getAttribute("title");
if(t==null || t.length==0) return; /* t="link:"; */
//prevent IE from bringing back img alt tags as titles
if (navigator.appVersion.indexOf("MSIE")!=-1 &&
    el.getAttribute("className") != "popup" || el.getAttribute("className") == 'topTablePopup') return;
el.removeAttribute("title");
tooltip=CreateEl("span","tooltip");
s=CreateEl("span","top");
s.appendChild(document.createTextNode(t));
tooltip.appendChild(s);
b=CreateEl("b","bottom");

/*
l=el.getAttribute("href");
if(l.length>28) l=l.substr(0,25)+"...";
b.appendChild(document.createTextNode(l));
*/
tooltip.appendChild(b);
setOpacity(tooltip);

el.tooltip=tooltip;
el.onmouseover=showTooltip;
el.onmouseout=hideTooltip;
el.onmousemove=Locate;
}

function showTooltip(e){
document.getElementById("btc").appendChild(this.tooltip);
Locate(e);
//Locate.call(this);
}

function hideTooltip(e){
var d=document.getElementById("btc");
if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
el.style.filter="alpha(opacity:95)";
el.style.KHTMLOpacity="0.95";
el.style.MozOpacity="0.95";
el.style.opacity="0.95";
}

function CreateEl(t,c){
var x=document.createElement(t);
x.className=c;
x.style.display="block";
return(x);
}

function AddCss(){
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","/i/Ratecity/bt.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Locate(e){
var posx=0,posy=0;

if(e==null) e=window.event;
if(e.pageX || e.pageY){
    posx=e.pageX; posy=e.pageY;
    }
else if(e.clientX || e.clientY){
    if(document.documentElement.scrollTop){
	
        posx=e.clientX+document.documentElement.scrollLeft;
        posy=e.clientYdocument.documentElement.scrollTop;
        }
    else{
        posx=e.clientX+document.body.scrollLeft;
        posy=e.clientY+document.body.scrollTop;
        }
    }

document.getElementById("btc").style.top=(posy-2)+"px";
document.getElementById("btc").style.left=(posx+1)+"px";
document.getElementById("btc").style.zIndex=10;
}

/*-----------------------------------------------------------------
-- Name:    callMyPopup
-- Purpose: Calls the popup window
-- Pre:	 formItem1 -
--		 formItem2 -
-- Post:   popup window will appear to display the product features
-----------------------------------------------------------------
--  copied the javascripts from the templates	*/

 function callMyPopup (formItem1, formItem2)
 {
  var url;
  url = 'f?p=405:11:::::P11_COCODE,P11_PAGEID:' + formItem1 + ',' + formItem2;
  
w = open(url,"winLov","Scrollbars=0, menubar=0, toolbar=0,status=0,resizable=0,width=450,height=400, left=100, top=200", modal="yes");
  if (w.opener == null)
  w.opener = self;
  setTimeout("w.focus();",1);
  w.focus();
  }

function addWindow(add_window_url) {
  if(!winref || winref.closed) {
    winref = window.open(add_window_url,'popup');
  } else {
    setTimeout("winref.focus();",1);
  }
  return false;
}

/*-----------------------------------------------------------------
-- Name:    resize
-- Purpose: to resize the fram 
-- Pre:	 
-- Post:    resizes the page
-----------------------------------------------------------------
*/

  function resize()
  {
    document.domain = 'ratecity.com.au';
	
    var h = 0;
    window.onload = function(){
        document.domain = 'ratecity.com.au';
        if (document.getElementById('wwvFlowForm'))
            h = document.getElementById('wwvFlowForm').scrollHeight;
        else
            h = 530;
//
//        if (parent.document.getElementById('htdb_iframe'))
//        parent.document.getElementById('htdb_iframe').style.height = (h+20)  + 'px';
        parent.document.getElementById('htdb_iframe').style.height = (h+20)  + 'px';
    }
    window.onload();
/*
    if ( !document.all ) {
      h = document.height;
      if (parent.document.getElementById('htdb_iframe'))
         parent.document.getElementById('htdb_iframe').style.height = (h+80)  + 'px';
    } else if( document.all ) {
      h = document.body.scrollHeight;
      if (parent.document.all.htdb_iframe)
         parent.document.all.htdb_iframe.style.height = h + 80 + 'px';
    }
*/
   }

/*-----------------------------------------------------------------
-- Name:    resize_htdb_iframe
-- Purpose: to resize the form displayed within an apex iframe 
-- Pre:	 
-- Post:    resizes the form
-----------------------------------------------------------------
*/

  function resize_htdb_iframe()
  {
    document.domain = 'ratecity.com.au';
    window.onload = function(){
        document.domain = 'ratecity.com.au';
        var iframe = document.getElementById('htdb_iframe').contentDocument;
        h = iframe.getElementById('wwvFlowForm').scrollHeight;
        
//        if (document.getElementById('wwvFlowForm'))
//            h = document.getElementById('wwvFlowForm').scrollHeight;
//        else
//            h = 530;

//        if (parent.document.getElementById('htdb_iframe'))
//          parent.document.getElementById('htdb_iframe').style.height = (h+20)  + 'px';
            parent.document.getElementById('htdb_iframe').style.height = (h+20)  + 'px';
    }
    window.onload();
    }
//    var h = 0;
//    if (document.getElementById('wwvFlowForm'))
//        h = document.getElementById('wwvFlowForm').scrollHeight;
//    else
//        h = 530;
//    h = document.body.scrollHeight;
//    if (parent.document.getElementById('htdb_iframe'))
//      parent.document.getElementById('htdb_iframe').style.height = (h+20)  + 'px';
//   }

/*-----------------------------------------------------------------
-- Name:    custom alert
-- Purpose: To create the custom alert tilte on the window
-- Pre:	
-- Post:    Ratecity alert on the title for alert window
-----------------------------------------------------------------
*/
//  Javascript to have a title for the popuup alert box
//  from  http://slayeroffice.com/code/custom_alert/
// constants to define the title of the alert and button text.
var ALERT_TITLE = "RateCity Alert Message";
var ALERT_BUTTON_TEXT = "Ok";

// over-ride the alert method only if this a newer browser.
// Older browser will see standard alerts
if(document.getElementById) {
	window.alert = function(txt) {
		createCustomAlert(txt);
	}
}

function createCustomAlert(txt) {
	// shortcut reference to the document object
	d = document;

	// if the modalContainer object already exists in the DOM, bail out.
	if(d.getElementById("modalContainer")) return;

	// create the modalContainer div as a child of the BODY element
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	 // make sure its as tall as it needs to be to overlay all the content on the page
	mObj.style.height = document.documentElement.scrollHeight + "px";

	// create the DIV that will be the alert 
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the //alert
if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop  +  "px"; // alertObj.style.top = (parent.document.getElementById('htdb_iframe').style.height) /2+  "px";
	// center the alert box
alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";

	// create an H1 element as the title bar
	h1 = alertObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(ALERT_TITLE));

	// create a paragraph element to contain the txt argument
	msg = alertObj.appendChild(d.createElement("p"));
	msg.appendChild(d.createTextNode(txt));

	// create an anchor element to use as the confirmation button.
	btn = alertObj.appendChild(d.createElement("a"));
	btn.id = "closeBtn";
	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
	btn.href = "#";
	// set up the onclick event to remove the alert when the anchor is clicked
	btn.onclick = function() { removeCustomAlert();return false; }
}

// removes the custom alert from the DOM
function removeCustomAlert() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}


/*-------------------------------------------------------------------------------------
-- Name:    getChk
-- Purpose: to send alert message if more than 4 compare boxes
--	     are selected.
-- Pre:     to check if more than 3 compare boxes are ticked
	
-- Post:    this function gives alert message if more than 4 or less than 1 products are selected to compare
            this function is called from the product details page on clicking the compare button  

-------------------------------------------------------------------------------------
*/
function getChk()
  {
  var c = 0
  var x=document.getElementsByName("f01");
    for (i=0; i<x.length; i++)
    {
      if (x[i].checked==true)
	  { 
	  	c = c+1; 
	  }
     }
     if (c>3)
	 {
           alert ("You have ticked " +c+ " checkboxes, You can compare only 3 records");
	  //return false;
         }
     else if (c<1)
        {
        alert ("Please tick at least 1 product to compare");
        }
     else if (c<=3 && c>=1 )
     {
        doSubmit("COMPARE");  
     }
	 //return true;
 }

/*-------------------------------------------------------------------------------------
-- Name:    isNumeric
-- Purpose: to check if tha mount value is numeric
--	    
-- Pre:     to check if the value entered in the amount field is numeric
	
-- Post:    this function gives alert message if the amount value is not numeric.
-------------------------------------------------------------------------------------
*/

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
                doSubmit('GO');
		// return true;
	}else{
		alert(helperMsg);
		elem.focus();
                // return false;
		
	}
}



/*-------------------------------------------------------------------------------------
-- Name:    isValidate
-- Purpose: to check if the it can submit
--	    
-- Pre:     isValid tels this function if it can submit
-- Post:    submits the form
-------------------------------------------------------------------------------------
*/

function isValidate(isValid){
	if(!isValid)
        return ;        
    doSubmit('GO');        
}

/*-------------------------------------------------------------------------------------
-- Name:    isNumeric
-- Purpose: to check if tha mount value is numeric
--	    
-- Pre:     to check if the value entered in the amount field is numeric
	
-- Post:    this function gives alert message if the amount value is not numeric.
-------------------------------------------------------------------------------------
*/

function isNumeric2(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression))
        return true;
    alert(helperMsg);
    return false;
}


/*-------------------------------------------------------------------------------------
-- Name:    f_Hide_On_Value_Item_Row
-- Purpose: this function is used to hide and show  a row based on value entered in 
--          other parameter.
--	    
-- Pre:     this function is used to hide and show  a row based on value of parameter
-- Post:    Hide the row pThat when value of pThis=pValue
-------------------------------------------------------------------------------------
*/
function f_Hide_On_Value_Item_Row(pThis,pThat,pValue){
	var l_Value;
	if(html_GetElement(pThat)){
		if(html_GetElement(pThis).nodeName=='SELECT'){
			l_Value = html_SelectValue(pThis);
		}else{
			l_Value = html_GetElement(pThis).value;
//                     pThis.value = l_Value;
		}
		if(l_Value==pValue){
			html_HideItemRow(pThat);
		}else{
			html_ShowItemRow(pThat)
		}

	}
}


/*-------------------------------------------------------------------------------------
-- Name:    f_Hide_On_Value_Item
-- Purpose: this function is used to hide and show item not row based on value entered in 
--          other parameter.
--	    
-- Pre:     this function is used to hide and show item not row based on value of parameter
-- Post:    Hide the item pThat when value of pThis=pValue this doesn't hide the label if any.
-------------------------------------------------------------------------------------
*/

function f_Hide_On_Value_Item(pThis,pThat,pThat2,pValue)
{
	var l_Value;
	if(html_GetElement(pThat))
	{
		if(html_GetElement(pThis).nodeName=='SELECT')
		{
			l_Value = html_SelectValue(pThis);
		}else
		{
			l_Value = html_GetElement(pThis).value;
		}

		if(l_Value == pValue)
		{
			
                    html_HideElement(pThat);
			html_ShowElement(pThat2);
		}else
		{
			html_ShowElement(pThat);
			html_HideElement(pThat2);
		}

	}
}

// this is not working have to fix this.............................

function chktype(pThis)
{ var t_value 
  t_value =  html_GetElement(pThis).value;
//  alert (t_value);
  if (t_value =='EQUITY')
    { 'P2_FXDVRBL'.value = NULL;

     }else
   { 'P2_CREDITLINE'.value = NULL;
}
}


function chkpurpose(pThis,pThat) 
{ var t_value 
  t_value =  html_GetElement(pThis).value;
//  alert (t_value);
 if (t_value !='EQUITY')
  { 
//alert(html_GetElement(pThat).value);
   document.getElementById(pThat).value ='OV:BV';
 }
}

  

 
 
 

/*
//Hide status bar msg II script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script  http://www.javascriptkit.com/script/script2/hidestatus2.shtml
//Credit must stay intact for use*/

function hidestatus(){
window.status='';
return true;
}

if (document.layers)
            document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
            document.onmouseover=hidestatus;
            document.onmouseout=hidestatus;
            


function getObj(pThis) 
{
   var w3c=(document.getElementById)?true:false;
   if (w3c) 
      {
        if(document.getElementById(pThis))
          {
			return document.getElementById(pThis);
	   } 
       else 
          {
			return null;
	   }
	} 
   else 
     {
	   return document.all[pThis]; 
     }
}


//Hide_Div_Value(this,'fxd','EQUITY'); 
//Hide_Div_Value(this,'fxd','CF0100');
function Hide_Div_Value(pThis,pThat,pValue)
{ var t_value ;
  t_value =  html_GetElement(pThis).value;
  if(t_value == pValue)
    {      
	DispDiv(pThat);
    }
  else
    {
	HideDiv(pThat);
    }
}



function Hide_Div(pThis,pThis2,pThat,pValue, pValue2)
{ 
//alert(pThis+document.getElementById(pThis2));
var t_value;
  var l_value;
objDiv=getObj(pThis2);
  t_value =  html_GetElement(pThis).value;
  l_value =  document.getElementById('p_v05');
    if(t_value != pValue  && l_value ==pValue2)
		{      
			DispDiv(pThat);
    	        }else
		{
			HideDiv(pThat);
		}

}

/*-------------------------------------------------------------------------------------
-- Name:    DispDiv
-- Purpose: this function is used to Display the Div when ID value is passed
--          
--	    
-- Pre:     this function Displays the div where Id = pThat
-- Post:    Displays the Div as requested
-------------------------------------------------------------------------------------
*/

  
function DispDiv(pThis) 
{
	objDiv=getObj(pThis);
	if (objDiv!=null) 
      {
	objDiv.style.display = '';
	objDiv.visibility='show';	   	  
	} else
       {
	  objDiv.style.visibility='visible';
	}
}

/*-------------------------------------------------------------------------------------
-- Name:    HideDiv
-- Purpose: this function is used to Hide the Div when ID value is passed
--          
--	    
-- Pre:     this function Hides the div where Id = pThat
-- Post:    Hide the Div as requested
-------------------------------------------------------------------------------------
*/

function HideDiv(pThis) 
{
   objDiv=getObj(pThis);
   if (objDiv!=null) 
    {
     objDiv.style.display = 'none';
     objDiv.visibility='hidden';
   }
}

/*-------------------------------------------------------------------------------------
-- Name:    hideshowdiv
-- Purpose: this function is used to Hide one div and show another div
-           when the value of pThis is pValue
--          
--	    
-- Pre:     this function Hides the dic HideThat and shows Div ShowThat 
-- Post:    Toggles to hide and show the div based on pThis value
-------------------------------------------------------------------------------------
*/

function hideshowdiv(pThis,HideThat,ShowThat,pValue)
 { 
  var t_value ;
  t_value =  html_GetElement(pThis).value;
        if(t_value == pValue)
		{      
			HideDiv(HideThat)
			DispDiv(ShowThat);
    	        }else
		{
			HideDiv(ShowThat)
			DispDiv(HideThat);
		}
}

function changeType(pThis)
{
//var radgroup = document.getElementById("rGroup");
//alert(radgroup.selectedItem);
 objDiv=getObj(pThis);
//  alert(objDiv.selectedItem);
}


function valLoanPurpose(pThis,pHide,pShow,pValue)  
//f_Hide_On_Value_Item(this,'P2_FXDVRBL','P2_CREDITLINE','EQUITY');
//Hide_Div_Value(this,'fxd','xx'); 
//hideshowdiv(this,'resi','equity','EQUITY');"
{
  var t_value ;
  t_value =  html_GetElement(pThis).value;
   if(t_value == pValue)
   { 
       f_Hide_On_Value_Item(pThis,pHide,pShow,pValue);
       HideDiv('resi');
       DispDiv('equity');
    }
    else
    {
       f_Hide_On_Value_Item(pThis,pHide,pShow,pValue);
       HideDiv('equity');
       DispDiv('resi');
    }


       HideDiv('fxd');
}

function valFxdVrbl(pThis,pValue)  //onclick="javascript:Hide_Div_Value(this,'fxd','CF');hideshowdiv(this, 'step3','step4','CF'); hideshowdiv(this, 'step5','step6','CF')"
{

  var t_value ;
  t_value =  html_GetElement(pThis).value;
  if(t_value == pValue)
    {  
       DispDiv('fxd');
       HideDiv('step3');
       DispDiv('step4');
       HideDiv('step5');
       DispDiv('step6');
  }
  else
  {
	HideDiv('fxd');
       HideDiv('step4');
       DispDiv('step3');
       HideDiv('step6');
       DispDiv('step5');
  }
}

function showField(pThis, pValue, pClass){
	objDiv = document.getElementById(pClass);
	if (pThis.value != pValue){
		objDiv.style.display = 'none';
        return true;
	} else {
        objDiv.style.display = '';
		return false;
	}

}







