var cookieEnabled=(navigator.cookieEnabled)? true : false
var Sitename = 'CorpfinLtd:'
var EntryType = 0;
var AllowPayPerView = 0;
   
var PurchForms = ['CWCQ','STAT','PURCH_DTLS'];
  
var Product_suite = [
	//name , Short Title, url , homepage, main logo, textlogo 
	['CorpfinWorldwide','Corporate Finance DEAL Information','corpfinworldwide','cwindex.jsp','images/logo.jpg','images/cfi.jpg'], //CorpfinWorldwide
	['CompanyQuery','Company Financial, Director, CCJ, Mortgage, Ownership, M&A History  .....','companyquery','cqindex.jsp','images/logo.jpg','images/cfi2.jpg'],         //CompanyQuery
	['CompanyBrief','Summary Financial, Director, Ownership, Lead information  .....','companybrief','cbindex.jsp','images/logo.jpg','images/cfi2.jpg'],         //CompanyBrief
	['FiledReturns','Registered Filed Returns & Company Documentation','filedreturns','frindex.jsp','images/logo.jpg','images/cfi2.jpg'],         //CompanyQuery
	['CompanyPrep','Mobile access to Company, Director, Financial and Lead Information  .....','companyprep','cpindex.jsp','images/logo.jpg','images/cfi2.jpg'],    //CompanyPREP
	
	//['CompanySTAT','FREE!!&nbsp;&nbsp; Brief Details of 2,500,000 Companies','companybrief','cbindex.jsp','images/logo.jpg','images/cfi2.jpg'],         //CompanySTAT
	//////
	['','','','','',''] //leave as blank
	]; 

var Product_colors = [
	//url under logo, top horiz nav , left header nav
	['#D2AB08','#B7B7B7','#015CAD'], //CorpfinWorldwide
	['#D2AB08','#B7B7B7','#015CAD'], //CompanyQuery
	['#D2AB08','#B7B7B7','#015CAD'], //CompanyBrief
	['#D2AB08','#B7B7B7','#015CAD'], //FiledReturns
	['#D2AB08','#B7B7B7','#015CAD'], //CompanyPREP
	
	//['#D2AB08','#B7B7B7','#015CAD'], //CompanySTAT
	/////
	['','',''] //leave as blank
	]; 

var Product_pages = [
	//product page // benefits page
	['product_CW.jsp','benefits_CW.jsp'], //CorpfinWorldwide
	['product_CQ.jsp','benefits_CQ.jsp'], //CompanyQuery
	['product_CB.jsp','benefits_CQ.jsp'], //CompanyBrief
	['product_FR.jsp',''], //FiledReturns
	['product_CP.jsp',''], //CompanyPREP
	
	//['product_CS.jsp',''], //CompanySTAT
	/////
	['',''] //leave as blank
	]; 


var Product_ExmpOutp = [
	//Example Output Report , Example Output Spreadsheet, Width & Height of IFRAME within 'ExampleOutput.jsp'
	['Info/OutputExmpls/CorpfinReportDeals.jsp','../OutputExmpls/CorpfinDataDeals.xls',''], //CorpfinWorldwide
	['Info/OutputExmpls/CorpfinReportCQuery.jsp','../OutputExmpls/CorpfinDataCQuery.xls',''], //CompanyQuery
	['Info/OutputExmpls/CorpfinReportCQuery.jsp','../OutputExmpls/CorpfinDataCQuery.xls',''], //CompanyBrief
	['Info/OutputExmpls/CorpfinReportFReturns.html','',''], //FiledReturns
	['Info/OutputExmpls/CorpfinReportCPrep.jsp','','width=\"780\" height=\"830\"'], //CompanyPREP
	//['',''],
	
	//['Info/OutputExmpls/CorpfinReportCQuery.html','Info/OutputExmpls/CorpfinDataCQuery.xls','<font size=\"-1\" color=\"red\">CompanyQuery</font>|<font size=\"-1\" color=\"red\">CompanySTAT</font>'], 
	/////
	['',''] //leave as blank
	]; 


var Product_PurchaseInfo = [
	//yes/NO
	[0,'http://www.corpfinworldwide.com/web/product_prCW.jsp'], //CorpfinWorldwide
	[0,'http://www.companyquery.com/web/product_prCQ.jsp'], //CompanyQuery
	[0,'http://www.companybrief.com/web/product_prCB.jsp'], //CompanyBrief
	[0,'http://www.filedreturns.com/web/product_prFR.jsp'], //FiledReturns	
	[0,'http://www.companyprep.com/web/product_prCP.jsp'], //CompanyPREP
	
	//[1,Product_suite[3][3]], //CompanySTAT //send back to homepage
	/////
	[0,''] //leave as blank
	]; 



var Product_CQ_STATS = [
        //name , amt,
        ['UK Companies:','2.73 mil'], 
        ['UK Accounts:','6.41 mil'],
        ['UK Directors:','4.92 mil'],
        ['UK Ex-Directors:','7.67 mil'],
        ['........',' '],
        //////
        ['',''] //leave as blank
        ];



var iFrmCd = '<iframe width=&quot;570&quot; height=&quot;400&quot; frameborder=&quot;0&quot; src=&quot;http://www.companyquery.com/web/cbfree.jsp&quot;></iframe>';


//if not IE4+ nor NS6+
if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
document.cookie="testcookie"
cookieEnabled=(document.cookie=="testcookie")? true : false
document.cookie="" //erase dummy value
}

//Set cookie routine 
function set_OLDcookie(cookieName,cookieValue,nDays) {
if (cookieEnabled) {
	 var today = new Date();
	 var expire = new Date();
	 if (nDays==null || nDays==0) nDays=1;
	 expire.setTime(today.getTime() + 3600000*24*nDays);
	 document.cookie = cookieName+"="+escape(cookieValue)
	                 + ";expires="+expire.toGMTString();
	}	                 
}

//Get cookie routine 
function get_OLDcookie(cookieName) {

if (!cookieEnabled)
	return "";
	
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

//To delete a cookie with a given name, set a cookie that 
//has the same name and an expiration date in the past. 


// These will be seen by Any Browser Window - Not Window Independent
function set_ExpiryCookie(name,value,days) {
	if (!cookieEnabled)
		return;
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = Sitename + name + "="+value+expires+"; path=/";
}

// These will be seen by Any Browser Window - Not Window Independent
function get_ExpiryCookie(name) {
	if (!cookieEnabled)
		return "";
	var nameEQ = Sitename + name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return "";
}



//Get cookie routine - These will be Browser Window Independent
function get_cookie(Name) {

if (!cookieEnabled)
	return "";

var search = Sitename + Name + "="
var returnvalue = "";
if (document.cookie.length > 0)
	{
    	offset = document.cookie.indexOf(search)
    	// if cookie exists
    	if (offset != -1)
    		{ 
      		offset += search.length
      		// set index of beginning of value
      		end = document.cookie.indexOf(";", offset);
      		// set index of end of cookie value
      		if (end == -1)
      			end = document.cookie.length;
      		returnvalue=unescape(document.cookie.substring(offset, end))
       		}
	
	}

return returnvalue;
}

//Set cookie routine  - These will be Browser Window Independent
function set_cookie(Name,Value) {
//This is only called at the <head> of every product index page: index.jsp,cqindex.jsp .. etc
//AND within EACH <head> of the Individual PRODUCT AND PRICING Pages eg: product_CW.jsp, product_prCW.jsp, product_CQ.jsp, product_prCQ.jsp ... etc
	if (cookieEnabled) {
		document.cookie = Sitename + Name + "=" + Value;
	}
}

//Sets the logout page relative to the entry page. Only used in the event of a session timeout.
function set_Logout(href) {
	set_cookie('logoutHref', href);
}


//Set EntryType and Write Style Items
function set_EntTypProdStyle(path)
{
EntryType=get_cookie('EntryPoint'); //Get and SET EntryType

if(EntryType == null || EntryType.length == 0) {
	EntryType = 0;
}

if(path)
	{
	if(path.substring(path.length-1,path.length) != "/" && path.substring(path.length-1,path.length) != "\\")  
		path += '/';
	document.write('<link REL=\"stylesheet\" type=\"text/css\" HREF=\"' + path + 'css/website.css\">');
	}
else
	{document.write('<link REL=\"stylesheet\" type=\"text/css\" HREF=\"css/website.css\">');}	

document.write('<style>');
document.write('TD.urlbckgrnd    {BACKGROUND-COLOR: ' + Product_colors[EntryType][0] + '}');
document.write('TD.topnavbckgrnd {BACKGROUND-COLOR: ' + Product_colors[EntryType][1] + '}');
document.write('TD.hdbckgrnd     {BACKGROUND-COLOR: ' + Product_colors[EntryType][2] + '}');
document.write('</style>');

}


function writeYear(){	
	var today = new Date();
	var year = today.getFullYear();
	document.write(year);	
}


function getHTMLObject(objId,prnt) {
	var obj = null;
	if(prnt && prnt==1) {
		if(document.getElementById)	obj = parent.document.getElementById(objId);
		else if (document.all) 		obj = parent.document.all[objId];
		else if (document.layers)	obj = parent.document.layers[objId];
	} else {
		if(document.getElementById)	obj = document.getElementById(objId);
		else if (document.all) 		obj = document.all[objId];
		else if (document.layers)	obj = document.layers[objId];
	}
	return obj;
}


function validateForm(FORM,NAME,type,skipErr)
{
var i=0;
var mess="";
var obj = FORM;

if(!obj)
	{
	if(document.getElementById){
	        obj = document.getElementById(NAME);
	        }
	else if (document.all){
		obj = document.all[NAME];
		}
	else if (document.layers){
		obj = document.layers[NAME];
		}
	}
	
if(!obj)
	return(false);

if(type==0) //PRODUCT SELECTION //CorpfinWorldwide + CompanyQuery  || //CompanySTAT
	{
	mess = "";
	var count=0;
	for(i=0;i<obj.elements.length;i++)
		{
		if(obj.elements[i].type == "radio" && obj.elements[i].value > 0 && obj.elements[i].checked==true) 
			{
			count++;
			set_cookie(NAME+obj.elements[i].name, obj.elements[i].value)
			}
	    	else if(obj.elements[i].type == "radio" && obj.elements[i].value ==0 && obj.elements[i].checked==true)
	    		{//clear selection cookie
	    		set_cookie(NAME+obj.elements[i].name,'');
	    		}	
	    	}
	if(count==0 && !skipErr)
		{
		alert("Please select a product before continuing !!");	
		return(false);
		}
	}	
else if(type==1) //Purchase STEPS
	{
	mess = "";
	var prod=0;
	for(i=0;i<obj.elements.length;i++)
		{
		if(obj.elements[i].type == "hidden") //Product Selection
			{
			//alert(obj.elements[i].name + ' : ' + obj.elements[i].value);	
			prod += obj.elements[i].value;
			continue;	
			}
		
		if(!(obj.elements[i].type == "text" || obj.elements[i].type == "radio" || obj.elements[i].type == "password"))
			continue;

		if(obj.elements[i].type == "radio")
			{
			if(obj.elements[i].checked==true)
				set_cookie(NAME+obj.elements[i].name, obj.elements[i].value);
			}	
		else if(obj.elements[i].type == "text")
			{
			set_cookie(NAME+obj.elements[i].name, obj.elements[i].value);
			if(obj.elements[i].name == "Company" && (obj.elements[i].value== null || obj.elements[i].value.length == 0) )
				continue;
			
			if(obj.elements[i].value.length == 0 )
				mess += obj.elements[i].name  + ' : \t Empty\n';
			else if(obj.elements[i].name == "Email" && 
				   ( obj.elements[i].value.indexOf('@') <= 1 
				   || obj.elements[i].value.indexOf('.')==-1
				   || obj.elements[i].value.indexOf('www')==0
				   || obj.elements[i].value.indexOf(':')> -1
				   || obj.elements[i].value.indexOf('/')> -1
				   || obj.elements[i].value.indexOf('\\')> -1) )
				mess += obj.elements[i].name  + ' : \t\t Invalid Email\n';
			
				
			}
		else if(obj.elements[i].type == "password")
			{
			set_cookie(NAME+obj.elements[i].name, obj.elements[i].value);
			//set_cookie(NAME+obj.elements[i].name,'');
			
			if(obj.elements[i].value.length >= 6 )
				continue;
			
			mess += obj.elements[i].name  + ' : \t Length Error\n';
			}
	    	}
	
	if(prod==0)
		mess = 'Product : \t\t There is no product selected\n' + mess;
		
	if(mess.length > 0 && !skipErr)
		{
		alert("Please check the following fields: !!\n\n" + mess);	
		return(false);
		}
	}	
 
return(true);
}

function setClearFormMrk()
{
for(var i=0;i<PurchForms.length;i++)
	set_cookie('PurchInit_' + PurchForms[i],1);
}

function updateFromLast(FORM,NAME,init)
{
if (!cookieEnabled)
	return;

if(!init)
	{
	var rs = get_cookie('PurchInit_'+ NAME);
	if(rs && rs==1)
		{
		//alert('Initialising');	
		updateFromLast(FORM,NAME,1)
		set_cookie('PurchInit_'+NAME,'');
		}		
	}

var obj = FORM;
var i=0;

if(!obj)
	{
	if(document.getElementById){
	        obj = document.getElementById(NAME);
	        }
	else if (document.all){
		obj = document.all[NAME];
		}
	else if (document.layers){
		obj = document.layers[NAME];
		}
	}
	
if(!obj)
	return(false);


for(i=0;i<obj.elements.length;i++)
	{
	if(!(obj.elements[i].type == "text" || obj.elements[i].type == "radio" || obj.elements[i].type == "password"))
		continue;

	if(init)
		{
		set_cookie(NAME + obj.elements[i].name, '');
		continue;
		}
	
	var val=get_cookie(NAME + obj.elements[i].name );
	if(val==null || val.length==0)
		continue;
	
	if(obj.elements[i].type == "radio")
		{
		if(obj.elements[i].value == val)
			obj.elements[i].checked = true;
		}		
	else
		obj.elements[i].value = val;
	}		
}	




//DISABLES RIGHT HAND MOUSE CLICK and KeyEntries
////
var m_bV  = parseInt(navigator.appVersion);
var m_bNS = navigator.appName=="Netscape";
var m_bIE = navigator.appName=="Microsoft Internet Explorer";

function nrhmc(e) {
   
   var today = new Date();
   var year = today.getFullYear();
   if (m_bNS && e.which > 1){
     alert('Copyright:   Corpfin - a part of Experian')
      return false
   } else if (m_bIE && (event.button >1)) {
     alert('Copyright:   Corpfin - a part of Experian')
     return false;
   }
}


function chkKeyEvnt(e)
{
	if (!e) e = window.event;
	
	var Key = e['keyCode'];
	if(Key == 93){
		var today = new Date();
   		var year = today.getFullYear();
 		alert('Copyright:   Corpfin - a part of Experian')
		return false;			
		}	
	
	//var keyInfo = String.fromCharCode(e.keyCode) + '\n';
	//keyInfo += 'Event: ' + e.type + '\n\n';
	//keyInfo += 'You pressed: ' + String.fromCharCode(e['keyCode']) + ' [Decimal: ' + e['keyCode'] + ']\n';
	//keyInfo += 'ALT: ' + e['altKey'] + '\n';
	//keyInfo += 'CTRL: ' + e['ctrlKey'] + '\n';
	//keyInfo += 'SHIFT: ' + e['shiftKey'] + '\n';
	//keyInfo += 'REPEAT: ' + e['repeat'] + '\n';
	//keyInfo += 'WHICH: ' + e['which'];
	//alert(keyInfo);
}



function disableKeys()
{	
//DISABLES RIGHT HAND MOUSE CLICK

document.onmousedown = nrhmc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (m_bNS && m_bV<5) 
	window.onmousedown = nrhmc;

//DISABLES KEYs for RIGHT HAND MOUSE CLICK
window.onload = function() {
	document.onkeydown = chkKeyEvnt;	document.onkeyup = chkKeyEvnt; 
	//var x = document.forms[0].elements[0];	x.onkeydown = chkKeyEvnt;	x.onkeyup = chkKeyEvnt;
	}
}

  
function writeLclSource() {
var lcn; var temp; var src="";
try       {lcn = top.location.href;}
catch(er) {lcn = location.href;}

if(lcn && lcn.length > 0)
	{
	temp = lcn.split("/");
	if(temp[2])
		{
		temp[2]=temp[2].toLowerCase();
		if(temp[2].indexOf("www.")==0)
			src = temp[2];
		}
	}
if(src.length == 0)src = "<strong>Corpfin - a part of Experian</strong>, www.corpfinworldwide.com";
document.write("Source:&nbsp;&nbsp;" + src);
}


function rightTrim(sString) {
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}


function leftTrim(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	return sString;
}


function setObjArrVisible(visible, cntrls) {
	for(var i=0; i<cntrls.length; i++) {
		var obj=null;
		if(document.getElementById)
			{ obj = document.getElementById(cntrls[i]); }
		else if (document.all)
			{ obj = document.all[cntrls[i]]; }
		else if (document.layers)
			{ obj = document.layers[cntrls[i]]; }	
	 	
	 	if(!obj || obj==null) {
	 		continue;
	 	}

	   	if (visible==1) {
			obj.style.display = "block";
		} else {
			obj.style.display = "none";
		}
	}

}

//$(document).ready(function() 
//{
//   //$("table.detailReport tr:even").addClass("evenrow");
//   //$("table.detailReport tr:odd").addClass("oddrow");
// }); 


function setCssValue(theClass,element,value) {
	var cssRules;
	var added = false;
	for (var S = 0; S < document.styleSheets.length; S++){
		if (document.styleSheets[S]['rules']) {
			cssRules = 'rules';
		} else if (document.styleSheets[S]['cssRules']) {
			cssRules = 'cssRules';
		} else {
			//no rules found... browser unknown
		}

		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
			if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
				if(document.styleSheets[S][cssRules][R].style[element]){
					document.styleSheets[S][cssRules][R].style[element] = value;
					added=true;
					break;
				}
			}
		}
		if(!added){
			if(document.styleSheets[S].insertRule){
					document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
			} else if (document.styleSheets[S].addRule) {
				document.styleSheets[S].addRule(theClass,element+': '+value+';');
			}
		}
	}
}

function getCssValue(theClass,element) {
	var cssRules;
	var added = false;
	for (var S = 0; S < document.styleSheets.length; S++){
		if (document.styleSheets[S]['rules']) {
			cssRules = 'rules';
		} else if (document.styleSheets[S]['cssRules']) {
			cssRules = 'cssRules';
		} else {
			//no rules found... browser unknown
			continue;
		}
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
			if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
				return document.styleSheets[S][cssRules][R].style[element];
			}
		}
	}
	return null;
}




function checkfilename(fileName,fileStb,suffix,addsuffix) {

	if(!fileName) return "";
	if(!fileStb) fileStb = "";
	if(!suffix) suffix = "";
	if(!addsuffix) addsuffix = 0;
	
	var validChar="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
	var pos=-1;
	
	if(suffix.length > 0) 
		{
		if((pos = fileName.indexOf("."))>-1)
			fileName = fileName.substring(0,pos-1);
		if(suffix.substring(0,1) != '.')
			suffix = "." + suffix;
		} 
	else if(addsuffix== -1 && (pos = fileName.indexOf("."))>-1)
		fileName = fileName.substring(0,pos-1);
	else 
		validChar += "."; //Add Additional Char

	fileName = rightTrim(fileName);
	fileName = leftTrim(fileName);
	
	if(fileName.length == 0)
		return fileName;
	
	if(fileStb.length > 0)
		fileName += fileStb;
	
	var bf = fileName.toUpperCase();
	var temp="";
	var i=0;
	

	for(i=0;i<bf.length;i++) {
		if(validChar.indexOf(bf.substring(i,i+1)) >= 0) 
			temp += fileName.substring(i,i+1);
	}

	fileName = temp;
	if(fileName.length == 0)
		return fileName;
	if(addsuffix==1 && suffix.length > 0)
		fileName += suffix

return fileName;
}


;
