var DL_bNS4=(document.layers);
var DL_bNS6 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
var DL_bDOM=(document.getElementById);
var DL_bIE=(document.all);
var DL_bIE4=(DL_bIE && !DL_bDOM);
var DL_bMac = (navigator.appVersion.indexOf("Mac") != -1);
var DL_bIEMac=(DL_bIE && DL_bMac);
var DL_bIE4Mac=(DL_bIE4 && DL_bMac);
var DL_bNS =(DL_bNS4 || DL_bNS6);

function windowWidth() { 
	if (window.innerWidth != null){ return window.innerWidth; }    
	if (document.body.clientWidth != null) { return document.body.clientWidth;  }    
	return (0);    
}

function createPopup(url, name) {
	var newwindow=window.open(url,name,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=670,height=600,left=20,top=20');
	if (newwindow.focus) {
		newwindow.focus();
	}
}

function validateSearchQuery(searchobjname) {
	var searchq = document.getElementById(searchobjname);
	if (!searchq) return true;
	var searchtext = searchq.value;
	var searchtext2 = searchtext.replace(/(\w)\+/g,'$1 +');
	searchtext2 = searchtext2.replace(/\+\s+(\w)/g,'+$1');
	searchtext2 = searchtext2.replace(/(\w)\-/g,'$1 -');
	searchtext2 = searchtext2.replace(/\-\s+(\w)/g,'-$1');
	searchq.value = searchtext2;
}

function windowHeight() {
	if (window.innerHeight != null){ return window.innerHeight; }    
	if (document.body.clientHeight != null) { return document.body.clientHeight;  }    
	return (0);    
}

function objGetScreenLeft(oElement) 
{
	var  lA = window.screenY? window.screenY: window.screenTop;
	return objGetRealLeft(oElement) + lA; 
}

function findPosition( oLink ) {
	if( oLink.offsetParent ) {
		for( var posX = 0, posY = 0; oLink.offsetParent; oLink =
				oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
		}
		this.x = posX;
		this.y = posY;
		return this;
	} else {
		this.x = oLink.x;
		this.y = oLink.y;
		return this;
	}
}
function objGetRealLeft(oElement)
{
	var nXPos = oElement.offsetLeft;
	var oParentEl = (DL_bIE4Mac) ? oElement.parentElement : oElement.offsetParent;

	while (oParentEl != null)
	{
		if(DL_bIE4Mac)
		{
			if(oParentEl.tagName=="SPAN")
			{
				oParentEl = oParentEl.parentElement;
			}
			if(oParentEl.tagName=="HTML")
			{
				break;
			}
		}

		nXPos += oParentEl.offsetLeft;
		oParentEl = (DL_bIE4Mac) ? oParentEl.parentElement : oParentEl.offsetParent;
	}
	return nXPos;

}


function objGetScreenTop(oElement) 
{
	var  tA = window.screenY? window.screenY: window.screenTop;
	return objGetRealTop(oElement) + tA; 
}
function objGetRealTop(oElement)
{
	var nYPos = oElement.offsetTop;
	var oParentEl = (DL_bIE4Mac) ? oElement.parentElement : oElement.offsetParent;
	while (oParentEl != null)
	{
		if(DL_bIE4Mac)
		{
			if(oParentEl.tagName=="SPAN")
			{
				oParentEl = oParentEl.parentElement;
			}
			if(oParentEl.tagName=="HTML")
			{
				break;
			}
		}
		nYPos += oParentEl.offsetTop;
		oParentEl = (DL_bIE4Mac) ? oParentEl.parentElement : oParentEl.offsetParent;
	}
	return nYPos;
}

function confirmSubmit()
{
var agree=confirm("Are you sure?");
if (agree)
	return true ;
else
	return false ;
}












function pageback() 
{
	window.history.back();
	return false;
}

function doit() 
{
   return confirm("Are you sure?")
}
      
// Survey functionality 

function setCookie(name, value) 
{ 
  if (value != null && value != "")
    document.cookie=name + "=" + escape(value) + "; expires=" + value.toGMTString();
}

function CreateSurveyWindow() 
{
	var today = new Date();
	var expiry = new Date(today.getTime() + 90 * 24 * 60 * 60 * 1000); // plus 90 days

   msgWindow=window.open("http://survey.euro.confirmit.com/wi/p3640860/i.asp","popup","toolbar=no,width=550,height=440,left=20,top=20,directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
   setCookie ("ibcsurvey", expiry);
   return false;
}


function bannerWindow(location) 
{
         
         var difference = screen.availWidth - 630;
         
         

         msgWindow=window.open(location,"popup","toolbar=no,width=630,height=375,left=" + difference +",top=0,directories=yes,status=yes,scrollbars=yes,resizable=yes,menubar=yes,location=yes,toolbar=yes");
         //return false;
}



//=============Loans Specific JavaScript:===============//
function fullLoanIllustrationPopup(url)
{
    fullIllPopup = window.open( url, "fullLoanIllustrationPopup", "toolbar=no,width=550,height=580,left=20,top=20,directories=no,status=no,scrollbars=yes,resize=yes,menubar=no");
    try
    {
        fullIllPopup.focus();
    }
    catch(oException)
    {/*Do nothing*/}
}

function CreateLoanPFWindow(url) 
{
    statWindow=window.open(url,"loanpf","toolbar=no,width=780,height=450,left=0,top=0,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes");
    try
    {
        statWindow.focus();
    }
    catch(oException)
    {/*Do nothing*/}
   return false;
}

function CreateHelpWindowByUrl (helpURL)
{
   msgWindow=window.open(helpURL,"popup","toolbar=no,width=630,height=500,left=20,top=20,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no")
   return false;
}

