// Generic JavaScript code for Experian E-Series Applications
//
// Copyright 2002, Experian Ltd

// Global variables used by function openHelpWind().
var helpChild, helpContext;

// *********************************************************
// Image Rollover and Pre-loading Functions (Macromedia Inc)
// *********************************************************

function MM_findObj(n, d) { //v3.0
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_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 MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// ***************************************************
// Frameset Functions
// ***************************************************

// Detect secure/non secure frameset
function IsFramesetSecure() {
	var slocation = parent.location.href;
		
	if (slocation.indexOf("https") > -1) {
		return(true);
	} else {
		return(false);
	}
}

function IsFramesetDifferent(sFrameset) {
	var slocation = parent.location.href;
		
	if (slocation.indexOf(sFrameset) > -1) {
		return(false);
	} else {
		return(true);
	}
}

// ***********************************************************
// Browser Detection Routines Accessible by Entire Application
// ***********************************************************

// Determines version of browser being used and stores properties for interrogation

function WhichBrowser() {

	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);

	// Netscape Navigator
	this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns4b= (this.ns && (this.minor > 4.04));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns4up = (this.ns && (this.major >= 4)); 
	this.ns5 = (this.ns && (this.major == 5)); 
	this.ns5up = (this.ns && (this.major >= 5)); 
	this.ns6 = (this.ns && (this.major == 6));   
	this.ns6up = (this.ns && (this.major >= 6)); 

	// IE
    	this.ie=((agent.indexOf("msie") != -1) && (agent.indexOf("opera") == -1));
        this.ie4=(this.ie && (this.major == 4) && (agent.indexOf("msie 4")!=-1) );
    	this.ie4up=(this.ie && (this.major >= 4));
    	this.ie5=(this.ie && (this.major == 4) && (agent.indexOf("msie 5.0")!=-1) );
    	this.ie5_5=(this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") !=-1));
    	this.ie5up=(this.ie && !this.ie3 && !this.ie4);
    	this.ie5_5up=(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    	this.ie6=(this.ie && (this.major == 4) && (agent.indexOf("msie 6.")!=-1) );
    	this.ie6up=(this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
}
	
// Determine browser being used and open appropriate certificate download page in new window.

function InstallCertificate() { 
	var isBrowser = new WhichBrowser();
	var lsBuf="";

	if(isBrowser.ie4up) {
		lsBuf="https://ewc.e-series.uk.experian.com/cdaiebcert.html";
	}
	else if(isBrowser.ns4up) {
		lsBuf="https://ewc.e-series.uk.experian.com/cdansbcert.htm";
	}
	delete isBrowser;

	window.open(lsBuf);
}

// ***************************************************
// Core Functions
// ***************************************************


// Navigate back through Browser history
function Back(num) {
	window.history.go(num);
}

// Gets a handle on an element that has an ID assigned to it.  Different browsers grab elements
// in different ways, but this covers IE4+ and NS4+.
function getElement(elementId) {
	if (document.getElementById) {
		return document.getElementById(elementId);
	} else if(document.all) {
		return document.all(elementId);
	} else {
		return document.layers[elementId];
	
	}
}

// Retrieve URL/Unix Path for Secure/Non-Secure Server

function GetServerPath(type, appId) {

	// If second argument not supplied, use empty string.
	if ( typeof(appId) == "undefined" ) appId = "";
	
	var path = "";
	
	switch (type) {
		case "SecureHTTP":
			path = "https://192.168.16.7:8507/" + appId;
			break;
			
		case "SecureUnix":
			path = "/usr/netscape/server4.1/docs/8507/" + appId;
			break;
			
		case "NonSecureHTTP":
			path = "http://192.168.16.7:8506/" + appId;
			break;
			
		default:
			path = "" + appId;
			break;
	}
	
	return path;
}

// Navigates to a page from either secure or non secure
function navigateTo(sProductPath, sPage, bActivate, sNewFrameset) {
	var loTarget;
	var sFrameset = "index.html";
		
	// If no value passed, deafult to true
	if (bActivate == null) {
		bActivate = true;	
	}
	
	if (sNewFrameset) {
		sFrameset = sNewFrameset;
	}
	if (IsFramesetSecure() || IsFramesetDifferent(sFrameset)) {
		lsPath = GetServerPath("NonSecureHTTP", sProductPath) + sFrameset + "?" + sPage;
		loTarget = parent;
	} else {
		lsPath = sPage;
		loTarget = parent.PageContent;
	}
	
	if (bActivate) {
		loTarget.location.href = lsPath;
	} else {
		return lsPath;
	}
}

function menuTarget() {
	var sTarget = "PageContent";
	if (IsFramesetSecure()) {
		sTarget = "_top";
	}
	return sTarget;
}

function openHelpWind( context ) {
	// Grab product specific directory catering for a frameless homepage
	var productDirectory = "e-help/" + ( top.PageHeader ? top.PageHeader.helpDirectory : helpDirectory ) + "/";
	
	// If no parameter passed, obtain help context from Content Page
	if ( arguments.length == 0 && ( top.PageContent && top.PageContent.helpContext ) ) { context = top.PageContent.helpContext; }
	
	if(!context){context=""}
	var winFeatures = "height=" + (screen.availHeight - 200) + ",width=" + (screen.availWidth - 200) + ",top=0,left=0,menubar=yes,toolbar=no,resizable=yes,scrollbars=auto,status=no";
	if(context.indexOf("?")>0){
			helpChild = window.open(GetServerPath("NonSecureHTTP", productDirectory)+context, "HelpWin", winFeatures);
	} else {
		helpChild = window.open(GetServerPath("NonSecureHTTP", productDirectory) + "?" + context, "HelpWin", winFeatures);
	}
	
	helpChild.focus();
}

function printReport(framename)
{ 
var Is=new WhichBrowser();

	parent.frames[framename].focus(); 
	if(document.all) 
	{ 
		// IE4 doesnt have window.print method, use object 
		if(Is.ie4)
		{
			var OLECMDID_PRINT = 6; 
			var OLECMDEXECOPT_DONTPROMPTUSER = 2; 
			var OLECMDEXECOPT_PROMPTUSER = 1; 
			var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";

			document.body.insertAdjacentHTML("BeforeEnd", WebBrowser); 
			setTimeout("printReportIE4()",200);
		}
		else 
			parent.frames[framename].print();
	} 
	else
	{ 
		// NS4+ 
		parent.frames[framename].focus(); 
		parent.frames[framename].print(); 
	}    
} 
	  
function printReportIE4() 
{ 
	WebBrowser1.ExecWB(6, 2); 
	WebBrowser1.outerHTML = "";
}

// ------------------------------------------------------
//	LINES ADDED IN CASE OF STRIPPING BY R and D SCRIPTS
// ------------------------------------------------------