//GENERIC HEADER INFO
var IE = true; var NS = false; var browser = ""; var bVersion = ""; var OPERA = false;

try { eval(pageTitle.length); 	}catch(exception){ pageTitle="&nbsp;"; }
try{ eval(frameenv); 	}catch(exception){ frameenv=false; }
try{ eval(scriptPath.length); 	}catch(exception){ scriptPath="../../scripts/"; }
try{ eval(imagePath.length); 	}catch(exception){ imagePath="../../images/"; }

if(pageTitle == "&nbsp;" || pageTitle == "" || pageTitle == " "){
	document.write("<title>QBE :: Insurance Group</title>");
	self.status = "QBE :: Insurance Group";
}else{
	document.write("<title>QBE :: "+pageTitle+"</title>");
	self.status = "QBE :: " + pageTitle;
}

var checkTime;
var PageBuilt = false;
var XMLReady = false;
var xMnuAvail = false;

function buildMainMenu(){
	if(IE){
		document.body.onbeforeprint = setForPrint;
		document.body.onafterprint = resetFromPrint;
	}
	performBuildMainMenu();
	handleRightClickLinks();
	setNamedLinks();
	checkNamedLink();
	if(screen.width < 801){ fix800by600(); }
}

function fix800by600(){
	try{
		cLogo = captureObj('contentlogo');
		cLogo.style.display = "none";
/*		cLogoSrc = cLogo.src;
		cLogo.src = cLogoSrc.substring(0,cLogoSrc.indexOf('.gif'))+"small.gif";
		
		if(NS){ cLogo.style.left = "468px"; }
		if(MOZ){ 
			cLogo.style.top = "2px";
			cLogo.style.left = "650px";
		}
*/
	}catch(exception){}
}

function handleRightClickLinks(){
	lnkObjs = document.links;
	for(lo=0;lo<lnkObjs.length;lo++){
		lnkObj = lnkObjs[lo];

		if(IE){
			lnkObj.onmousedown = controlLinkClick;
			lnkObj.onmouseover = resetLinkHREF;
		}
	}
}

function cancelEvent(){
	window.event.keyCode = 0;
	window.event.returnValue = false;
	window.event.cancelBubble = true;
	return false;
}

function resetLinkHREF(){
	aObj = window.event.srcElement;
	if(aObj.parentElement.tagName == "A"){
		aObj = aObj.parentElement;
	}
	if(aObj.getAttribute("setTarget") == "right"){
		aObj.href = aObj.getAttribute("origHREF");
		aObj.setAttribute("setTarget","left");
	}
}

function controlLinkClick(){
	mButton = window.event.button;
	aObj = window.event.srcElement;
	if(aObj.parentElement.tagName == "A"){
		aObj = aObj.parentElement;
	}

	if(mButton != 1){ //Right or Middle Button Clicked
		if(aObj.getAttribute("setTarget") != "right"){
			aObj.setAttribute("setTarget","right");

			try {
				aObjHref = aObj.href.toString();
				aObjParams = aObjHref.split("','");
				aObjLnk = aObjParams[2].substring(0,aObjParams[2].length-2);
				aObj.setAttribute("origHREF",aObj.href);
				aObj.href = aObjLnk;
			}catch(exception){}
		}
	}
}

//NEW ADDITION TO FIX BACK ISSUE WITH NAMED LINKS
function setNamedLinks(){
	lnks=document.links;
	for(lnk=0;lnk<lnks.length;lnk++){
		thisLink = lnks[lnk];
		thisHref = thisLink.href;
		if(thisHref.indexOf("#") != -1){
			if(MAC || OPERA){
				thisLink.style.textDecoration = "none";
				thisLink.style.cursor = "default";
				/*thisLink.style.display = "none";
				if(thisLink.parentNode.tagName == "LI"){
					thisLink.parentNode.style.display = "none";
					
					listTag = thisLink.parentNode.parentNode;
					if(listTag.tagName == "UL" || listTag.tagName == "OL"){
						listTag.style.display = "none";
					}
				}*/
			}else{
				thisLink.attachEvent('onclick',handleNamedLinks);
			}
		}
	}
}

var docLoc;
function handleNamedLinks(){
	docLoc = document.location.href;
	namedLink = window.event.srcElement.href;
	if(document.location.search){
		document.location.href = docLoc.substring(0,docLoc.indexOf("?"))+"?"+namedLink.substring(namedLink.indexOf("#")+1);
	}else{
		document.location.href = docLoc+"?"+namedLink.substring(namedLink.indexOf("#")+1);
	}
}

function checkNamedLink(){
	if(document.location.search){
		try {
			objName = document.location.search.substring(1);
			namedObjs = document.getElementsByName(objName);
			namedObj = namedObjs[0];
			//scrollNamedItem(namedObj);
			namedObj.scrollIntoView();
		}catch(exception){}
	}
}
//************************************************************************//

function scrollNamedItem(namedObj){
	cumScroll = 0;
	
	while(namedObj.parentNode.id != "maincontent" && namedObj.parentNode.tagName != "BODY"){
		cumScroll += namedObj.offsetTop;
		namedObj = namedObj.parentNode;
		//alert(namedObj.parentNode.id + ":" + cumScroll);
	}
	mnContent = captureObj('maincontent');
	mnContent.scrollBy(0,300);
}

function setForPrint(){
	mnContent = captureObj('maincontent');
	mnContent.style.overflowY = "visible";
}

function resetFromPrint(){
	mnContent = captureObj('maincontent');
	mnContent.style.overflowY = "auto";
}

var ic = 0;
var imgPreload = new Array();
var noImgs;
bLogo = new Image();			bLogo.src = imagePath + "generic/qbe_logo_blue.gif";
aFwd = new Image();			aFwd.src = imagePath + "icons/arrowfwd.gif";

function preloadImages(){
	if(!menuBuilt){
		performBuildMainMenu();
	}
	try { clearTimeout(imgPreload); }catch(exception){}
	if(document.images){
		noImgs = document.images.length;
		for(io=0; io<noImgs; io++){
			imgObj = document.images[io];
			if(imgObj.readyState != "complete"){
				imgObj.src = imgObj.src;
			}
		}
	}
}

// Fix for when documents reside in the ASP directory

if (document.location.href.toUpperCase().indexOf("/ASP/") !== -1) {
	scriptPath = "../scri" + "pts/";
	imagePath = "../images/";
}

//SCRIPT LOADER
document.write('<script language="javascript" src="'+mainmenufile+'"></script>');
document.write('<script language="javascript" src="'+scriptPath+'qbebrowserdetect.js"></script>');
document.write('<script language="javascript" src="'+scriptPath+'qbegeneric.js"></script>');
document.write('<script language="javascript" src="'+scriptPath+'qbedates.js"></script>');
document.write('<script language="javascript" src="'+scriptPath+'qbelinkhandling.js"></script>');
document.write('<script language="javascript" src="'+scriptPath+'qbe_jscript_webmenu.js"></script>');
document.write('<script language="javascript" src="'+scriptPath+'qbeformbuilder.js"></script>');
document.write('<script language="javascript" src="'+scriptPath+'qbeformhandling.js"></script>');
document.write('<script language="javascript" src="'+scriptPath+'qbepacebreadcrumbs.js"></script>');

//STYLESHEETS
Nav = navigator.appVersion;
if(Nav.indexOf("Safari") != -1 || Nav.indexOf("Mac") != -1) {
	document.write('<link rel="stylesheet" href="'+imagePath+'stylesheets/qbesafari.css" type="text/css">');
	if(Nav.indexOf("Safari") != -1){
		document.write('<link rel="stylesheet" href="'+imagePath+'stylesheets/qbemac.css" type="text/css">');
	}else{
		document.write('<link rel="stylesheet" href="'+imagePath+'stylesheets/qbemacie.css" type="text/css">');
	}
}else{
	document.write('<link rel="stylesheet" href="'+imagePath+'stylesheets/qbeAPOgeneric.css" type="text/css">');
}

if(navigator.userAgent.indexOf("Opera") != -1){
	OPERA = true;
	document.write('<link rel="stylesheet" href="'+imagePath+'stylesheets/qbeopera.css" type="text/css">');
}

document.write('<link rel="stylesheet" href="'+imagePath+'stylesheets/qbe'+screenStyle+'.css" type="text/css">');

try { 
	eval(screenColor.length);
	document.write('<link rel="stylesheet" href="'+imagePath+'stylesheets/qbe'+screenColor+'.css" type="text/css">');
}catch(exception){}

if(screen.width < 801){
	document.write('<link rel="stylesheet" href="'+imagePath+'stylesheets/qbe800generic.css" type="text/css">');
}


document.write('<link rel="Shortcut Icon" href="'+imagePath+'icons/qbeasiapacific.ico" type="text/css">');

var xSubMnu = "";

xSubMnu += '<div id="submenu" onmouseover="showSubMenu();" onMouseOut="showSubMenu();">';
	xSubMnu += '<table width="100%" cellspacing="0" cellpadding="0" border="0">';
		xSubMnu += '<tr>';
			xSubMnu += '<td width="25%">&nbsp;</td>';
			xSubMnu += '<td width="25%" style="text-align: right;">'
				xSubMnu += '<table width="98%" cellspacing="0" cellpadding="1" border="0" bgcolor="#ffffff">'
					xSubMnu += '<tr><td align="center" class="submenuinactivecell"><a href="/australia/" class="submenulink">Australia</a></td>';
					xSubMnu += '<tr><td align="center" class="submenuinactivecell"><a href="http://www.qbe.asia" class="submenulink">Asia</a></td></tr>';
					xSubMnu += '<tr><td align="center" class="submenuinactivecell"><a href="/Version_2/pace/html/PIN/QBE_PIN_Entry.html" class="submenulink">Pacific Islands</a></td></tr>';
					xSubMnu += '<tr><td align="center" class="submenuinactivecell"><a href="/Version_2/pace/html/NZ/QBE_NZ_Entry.html" class="submenulink">New Zealand</a></td></tr>';
				xSubMnu += '</table>';
			xSubMnu += '</td>';
			xSubMnu += '<td width="25%">&nbsp;</td>';
			xSubMnu += '<td width="25%">&nbsp;</td>';
		xSubMnu += '</tr>';
	xSubMnu += '</table>';
xSubMnu += '</div>';

function showSubMenu() {
	if (document.getElementById) {
		if (window.event.type.toLowerCase() == "mouseover") {
			document.getElementById("submenu").style.display = "block";
		} else {
			document.getElementById("submenu").style.display = "none";
		}
	}
}
