// $Header:   //USBHPVCS2/dnbprojects/FabSrv/EBIR/archives/Scripts/pac/pac.js_v   1.2   23 Feb 2004 14:14:26   grahamg  $

var isNav, isIE, isIE4, isNav6;
var lastDisplayedDivId = "overview";
var showWord = "visible";
var hideWord = "hidden";

var surveyURL = '/product/new_features/betapac.htm?param1=' + requestSubscriber;
var surveyURLPlus = '/product/new_features/betapacplus.htm?param1=' + requestSubscriber;
var paymentDetailDate = '';
var rowCount = 0;
var blueTableBackground = '#ccffff';
var numberFormatter = new NumberFormat();
var judgmentCount = 0;
var suitCount = 0;
var lienCount = 0;
var uccCount = 0;

// For closing the "Please wait while we're processing your order" pop-up window
function closeOrderInProgress() {
	if (orderinprogress) {
		if (!orderinprogress.closed) {
			orderinprogress.close();
		}
	}
}

// ** BEGIN TAB IMAGE ARRAY DEFINITION AND ROLLOVER FUNCTIONS **
var layerarray = new Array("overview","scores","payments","public","histops","bankfin"); // Array that holds the base names of all the layers and images used
var namearray = new Array("OVERVIEW","SCORES","PAYMENTS","PUBLIC FILINGS","HISTORY &amp; OPERATIONS","BANKING &amp; FINANCE");

if (parseInt(navigator.appVersion) >= 4) {
	if (navigator.appName == "Netscape") {
		isNav = true;
		showWord = "show";
		hideWord = "hide";
	} else if (navigator.appName.indexOf("Microsoft") != -1) {
		isIE = true;
        var msie = navigator.appVersion.indexOf("MSIE ");

        var msieVersion = parseInt(navigator.appVersion.substring(msie+5, navigator.appVersion.indexOf(".", msie)));
        if (msieVersion == 4) {
            isIE4 = true;
        }
	}
}	
if (parseInt(navigator.appVersion) >= 5 && navigator.appName == "Netscape")
{
	isNav6 = true;
	isNav = false;
	showWord = "visible";
	hideWord = "hidden";
}	
function openTicker() {
	var tickerSite = "http://dnb.edgarexplorer.com/profile.asp";
	var query = "?ticker=" + escape(stockTicker);
	var tickerUrl = tickerSite + query;
	window.open(tickerUrl,'ticker','width=770,height=600,resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes')
}
function openFilings() {
	var tickerSite = "http://dnb.edgarexplorer.com/searchrouter.asp";
	var query = "?ticker=" + escape(stockTicker);
	var tickerUrl = tickerSite + query;
	window.open(tickerUrl,'ticker','width=770,height=600,resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes')
}

function openHelp(doc)
{
	var helpWin = window.open(doc,'help','width=770,height=500,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes');
	helpWin.focus();
}

function openWebsite(doc, urlType)
{
	var targetURL = helpPath + "bizURL.html?targetURL=" + escape(doc) + "&urlType=" + urlType + "&dunsCase=" + dunsCase;
	bizWin = window.open(targetURL,'biz','width=770,height=500,resizable=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes');
	bizWin.focus();
}

function infobotURL(parameters)
{

	if (sessionid == '123456789') 
	{
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }

   	return ( "/scripts/ProductRetriever.asp?" + parameters + "&SESSIONID=" + sessionid );
}

function callInfobot(parameters, msg)
{
	if (msg == null || confirm(msg))
	{
		location = infobotURL(parameters);
	}
}

function openExport(doc)
{
	var exportWin = window.open(doc,'export','width=770,height=500,resizable=yes,toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes');
	exportWin.focus();
}

function exportOne(sectionName) {
        var requestURL = "/scripts/ProductRetriever.asp?REQUESTTYPE=CsvExport&SESSIONID=" + sessionid +"&dunsCase=" + dunsCase + "&productDirectory=" + productDirectory + "&productFilename=" + productFilename + "&CsvSectionName=" + sectionName;
	openExport(requestURL);
}

function exportChoose() {
	var requestURL=helpPath+"exportForm.html?sessionid=" + sessionid + "&dunsCase=" + dunsCase + "&primName=" + escape(companyName) + "&primAddr=" + escape(companyAddress + ", " + companyCity + ", " + companyState + "  " + companyZip) + "&productDirectory=" + productDirectory + "&productFilename=" + productFilename;
	if (showPaymentSummaryExport) {
		requestURL += "&showPmtSum=1";
	}
	if (showPaymentDetails) {
		requestURL += "&showPmtDet=1";
	}
	if (showUpdateExport) {
		requestURL += "&showUpdate=1";
	}
	if (showStatementUpdate) {
		requestURL += "&showFinUpd=1";
	}
	if (showFinance) {
		requestURL += "&showFinance=1";
	}
	if (showJudgments) {
		requestURL += "&showJudg=1";
	}
	if (showBankruptcy) {
		requestURL += "&showBankruptcy=1";
	}
	if (showSuits) {
		requestURL += "&showSuit=1";
	}
	if (showLiens) {
		requestURL += "&showLien=1";
	}
	if (showUCCs) {
		requestURL += "&showUCC=1";
	}
	openExport(requestURL);
}

function dbiaNewSearch()
{
  if (isInfobot == "true")
	callInfobot('REQUESTTYPE=CONTRACTNEWSEARCH&PROCESSFLOW=CORPT');
  else
    location = searchURL;
}

function dbiaHome()
{
	callInfobot('REQUESTTYPE=CONTRACTMENU');
}

function dbiaReportArchive()
{
  if (isInfobot == "true")
    callInfobot('REQUESTTYPE=unreadarchive&PROCESSFLOW=CORPT');
  else
    location = archiveURL;
}

function dbiaMonitoring(cmid)
{
	var f = document.MonitoringForm;
	if (f)
	{
		f.SESSIONID.value = sessionid;
		f.DUNSNUMBER.value = dunsCase;
		f.COMPANYNAME.value = companyName;
                if (cmid != null && cmid != '') {
                  f.CMID.value = cmid;
                }
		if (companyName.length > 30) {
			f.ABBREVCOMPANYNAME.value = companyName.substring(0,30);
		} else {
			f.ABBREVCOMPANYNAME.value = companyName;
		}
		f.submit();
	}
}

function dbiaEmailReport()
{	
  if (isInfobot == "true")
    callInfobot('REQUESTTYPE=emailreportsconfirm&emailFilePath=' + escape(emailFilePath));
  else
    location = emailURL;
}

function dbiaInvestigation()
{
	var f = document.InvestigationForm;
	if (f)
	{
		var phoneNum = phoneNumber(companyPhone);
		f.SESSIONID.value = sessionid;
		f.COMPANYNAME.value = companyName;
		f.COMPANYADDRESS.value = companyAddress;
		f.COMPANYCITY.value = companyCity;
		f.COMPANYSTATE.value = companyState;
		f.COMPANYPHONE.value = phoneNum;
		f.INVESTDUNSNUMBER.value = dunsCase;
		f.INVESTCOMPANYNAME.value = companyName;
		f.INVESTCOMPANYADDRESS.value = companyAddress;
		f.INVESTCOMPANYCITY.value = companyCity;
		f.INVESTCOMPANYSTATE.value = companyState;
		f.INVESTCOMPANYPHONE.value = phoneNum;
		f.submit();
	}
}

function dbiaCompanyReports()
{
	callInfobot('REQUESTTYPE=contractnewsearch&PROCESSFLOW=CORPT');
}

function dbiaCompanyLookup()
{
	callInfobot('REQUESTTYPE=contractWBColkup&PROCESSFLOW=WBCL');
}

function dbiaPublicRecordsSearch()
{
	callInfobot('REQUESTTYPE=prnewsearch&PROCESSFLOW=PR');
}

function dbiaCountryRisk()
{
	callInfobot('REQUESTTYPE=countryrisk&PROCESSFLOW=CRSR');
}

function dbiaUSMarketingLists()
{
	callInfobot('REQUESTTYPE=usmlhome&PROCESSFLOW=USML');
}

function dbiaGlobalFamilyLinkage(cmid)
{
	callInfobot('REQUESTTYPE=contractWBFamLnkge&PROCESSFLOW=WBFL&FIRDUNS=' + dunsCase + (cmid != null && cmid != '' ? "&CMID=" + cmid : "") + (caseDunsType != null && caseDunsType != '' ? "&CASETYPE=" + caseDunsType : ""));
}

function dbiaGlobalMarketingLists()
{
	callInfobot('REQUESTTYPE=contractWBCrtList&PROCESSFLOW=WBML');
}

var tid;
var popupTarget;
function setSurveyTimer(popupFile) {
	popupTarget = popupFile;
	tid = window.setTimeout("surveyPopup(popupTarget)", 45000);
}

function surveyPopup (popupFile) {
    var apop = window.open(popupFile, "popupwindow", "menubar=no,width=380,height=280");
}

function displaySurvey()
{
	window.clearTimeout(tid);
	openHelp(surveyURL);
}

function displaySurveyPlus()
{
	window.clearTimeout(tid);
	openHelp(surveyURLPlus);
}

var introTid;
var introPopupTarget;
function setIntroTimer(popupFile) {
	if (!repeatCustomer.load() || !repeatCustomer.repeatVisit) {
		introPopupTarget = popupFile;
		introTid = window.setTimeout("introPopup(introPopupTarget)", 500);
		repeatCustomer.repeatVisit = 'true';
		repeatCustomer.store();
	}
}

function introPopup (popupFile) {
    var apop = window.open(popupFile, "popupwindow", "menubar=no,width=600,height=400");
}

function displayInto()
{
	window.clearTimeout(tid);
	openHelp(introURL);
}

//Code Change ECOMP - Start
function setFavoritePACPlus() 
{

   if (sessionid == '123456789') {
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }

  var url = "/scripts/ProductRetriever.asp?SESSIONID="+sessionid+"&FAVPROD=USA+Patriot+Act+Compliance+Solution+Plus+Report&REQUESTTYPE=SETFAVORITEFROMPACS&FAVNEXTREQUESTTYPE=FAVPRODCONFIRMPACS&CMID=IOD100604";
  
  var w=300;
  var h = 185;
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=1,resizable,menubar=1,status=1';
  win = window.open(url,"Favorite", winprops);
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function setFavoritePAC() 
{

   if (sessionid == '123456789') {
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }

  var url = "/scripts/ProductRetriever.asp?SESSIONID="+sessionid+"&FAVPROD=USA+Patriot+Act+Compliance+Solution+Report&REQUESTTYPE=SETFAVORITEFROMPACS&FAVNEXTREQUESTTYPE=FAVPRODCONFIRMPACS&CMID=IOD100604";
  
  var w=300;
  var h = 185;
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=1,resizable,menubar=1,status=1';
  win = window.open(url,"Favorite", winprops);
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


function interactiveFormat()
{
	var targetURL = interactiveURL;
      if (sessionid != '123456789')
      {
		  if (targetURL.indexOf("?") == -1)
		  {
		    targetURL += '?SESSIONID=' + sessionid;
		  }
	  	  else
	  	  {
	    	targetURL += '&SESSIONID=' + sessionid;
		  }
       }
	window.open(targetURL,'if','width=770,height=500,resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes');
}
//Code Change - End
function printerFriendly(showPrompt)
{
	var targetURL = printFriendlyURL;
	if (showPrompt) {
	  if (targetURL.indexOf("?") == -1) {
		targetURL += '?printPrompt';
          }
          else {
		targetURL += '&printPrompt';
          }
	}
    if (sessionid == '123456789') {
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }
	
        if (sessionid != '123456789') {
	  if (targetURL.indexOf("?") == -1) {
	    targetURL += '?SESSIONID=' + sessionid;
	  }
	  else {
	    targetURL += '&SESSIONID=' + sessionid;
	  }
        }
	window.open(targetURL,'pf','width=770,height=500,resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes');
}

function doPrint() {
	if (!isIE4) {
		window.print();
	} else {
		alert("To print from this browser, you must select \"File/Print\" from the Main Menu.");
	}
}

function handlePurchase(params) {
//  if (toolbarPF == false) {
//    callInfobot(params);
//  }
//  else {
//    if (sessionid == '123456789') {
//      if (theQuery == null)
//        theQuery = new PageQuery(document.location.search);
//      sessionid = theQuery.getValue("SESSIONID");
//    }

    //var birurl = infobotURL(params);
    //window.open(birurl,'main','resizable=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=//yes,scrollbars=yes').focus();

	if (sessionid == '123456789') 
	{
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }
	
    orderinprogress = window.open("/scripts/ProductRetriever.asp?" + params + "&SESSIONID=" + sessionid,'cl','width=500,height=250,resizable=yes,toolbar=no,location=no,directories=no,status=yes,menubar=  yes,scrollbars=no');
	if (toolbarPF == true)
		if(window.opener != null)
			window.opener.orderinprogress = orderinprogress;

//  }



}

function handleBIRFamilyLinkage(params) {

  // First, reset REASONFORINQUIRY and either DUNSNUMBER or INTLDUNSNUMBER if they are not passed
	if (sessionid == '123456789') 
	{
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }

  params = params + "&REASONFORINQUIRY="
  if (params.indexOf("&dunsNumber=") == -1)
  {
	params = params + "&dunsNumber=";
  }
  
  if (params.indexOf("&intlDunsNumber=") == -1)
  {
	params = params + "&intlDunsNumber=";
  }

  if (params.indexOf("&dunsNumberComp=") == -1)
  {
	params = params + "&dunsNumberComp=";
  }
  
  if (toolbarPF == true) {
    if (sessionid == '123456789') {
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }
    if(window.opener != null)    
	window.opener.focus();
  }

   orderinprogress = window.open("/scripts/ProductRetriever.asp?" + params + "&SESSIONID=" + sessionid,'cl','width=500,height=250,resizable=yes,toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=no');

  	if (toolbarPF == true) 
  		if(window.opener != null)
  			window.opener.orderinprogress = orderinprogress;
} 

function buyPACPlus(cmid,country,duns,companyName)
{
  if(reportWarning('Patriot Act Compliance Solution Plus')) {
    if (isInfobot == "true")
       //commented as fix for trading up always when ordering from CFL.
      //handlePurchase('REQUESTTYPE=orderPACSFromFamilyLinkage&REASONFORINQUIRY=&productselected=USA+Patriot+Act+Compliance+Solution+Plus+Report&productsselected=USA+Patriot+Act+Compliance+Solution+Plus+Report'+(companyName != null ? '&COMPANYNAME=' + companyName : '')+'&hqtradeup=off&DUNSNUMBER=' + duns + (country != null ? '&COUNTRY=' + country : '')+ (cmid != null ? '&CMID=' + cmid : ''));
      handlePurchase('REQUESTTYPE=orderPACSFromFamilyLinkage&REASONFORINQUIRY=&productselected=USA+Patriot+Act+Compliance+Solution+Plus+Report&productsselected=USA+Patriot+Act+Compliance+Solution+Plus+Report'+(companyName != null ? '&COMPANYNAME=' + escape(companyName) : '')+'&hqtradeup=on&DUNSNUMBER=' + duns + (country != null ? '&COUNTRY=' + country : '')+ (cmid != null ? '&CMID=' + cmid : ''));
  }
}

function buyBranchBIR(duns,companyName,cmid)
{
  if(reportWarningBIR('Branch')) {
    if (isInfobot == "true")
      handlePurchase('REQUESTTYPE=orderBIRFromFamilyLinkage&productselected=Business+Information+Report&productsselected=Business+Information+Report&COMPANYNAME='+escape(companyName)+'&hqtradeup=off&INTLDUNSNUMBER=&candidateselection='+duns +'&dunsnumber=' + duns + (cmid != null ? '&CMID=' + cmid : ''));
    else
      location = branchLinkURL;
  }
}
function buyIntlBranchBIR(duns,companyName,country,cmid)
{
	if (sessionid == '123456789') 
	{
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }

  if(reportWarningIntlBIR('Branch')) {
    if (isInfobot == "true")
      handleBIRFamilyLinkage('REQUESTTYPE=orderBIRFromFamilyLinkage&productselected=Business+Information+Report&productsselected=Business+Information+Report&hqtradeup=off&&DUNSNUMBER=&intldunsnumber=' + duns +country+ (cmid != null ? '&CMID=' + cmid : '') + '&intl=1'  + (companyName != null ? '&intlcompanyname=' + escape(companyName) : ''));
    else
      location = intlBranchLinkURL;
  }
}

function buyAffiliateBIR(duns,companyName,cmid)
{
  if(reportWarningECOMP('Affiliate')) {
    if (isInfobot == "true"){
      handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&COMPANYNAMECOMP='+companyName+'&hqtradeup=off&DUNSNUMBER=&INTLDUNSNUMBER=&DUNSNUMBERCOMP=' + duns + (cmid != null ? '&CMID=' + cmid : ''));
    } else {
      location = affiliateLinkURL;
    }
  }
}

function buyIntlAffiliateBIR(duns,companyName,cmid)
{
  if(reportWarningIntlBIR('Affiliate')) {
    if (isInfobot == "true"){
      handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Business+Information+Report&productsselected=Business+Information+Report&hqtradeup=off&DUNSNUMBERCOMP=&DUNSNUMBER=&INTLDUNSNUMBER=' + duns + (cmid != null ? '&CMID=' + cmid : '') + '&intl=1'  + (companyName != null ? '&intlcompanyname=' + escape(companyName) : ''));
    } else {
      location = intlAffiliateLinkURL;
    }
  }
}

function buySubsidiaryBIR(duns,companyName,cmid)
{
  if(reportWarningECOMP('Subsidiary')) {
    if (isInfobot == "true") {
      handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&COMPANYNAMECOMP='+companyName+'&hqtradeup=off&DUNSNUMBER=&INTLDUNSNUMBER=&DUNSNUMBERCOMP=' + duns + (cmid != null ? '&CMID=' + cmid : ''));
    }
    else {
      location = subsidiaryLinkURL;
    }
  }
}

function buyIntlSubsidiaryBIR(duns,companyName,cmid)
{
  if(reportWarningIntlBIR('Subsidiary')) {
    if (isInfobot == "true"){
      handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Business+Information+Report&productsselected=Business+Information+Report&hqtradeup=off&DUNSNUMBERCOMP=&DUNSNUMBER=&INTLDUNSNUMBER=' + duns + (cmid != null ? '&CMID=' + cmid : '') + '&intl=1'  + (companyName != null ? '&intlcompanyname=' + escape(companyName) : ''));
    } else {
      location = intlSubsidiaryLinkURL;
    }
  }
}

function buyHQBIR(cmid)
{
  if(reportWarningECOMP('Headquarters')) {
    if (isInfobot == "true")
      handlePurchase('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&COMPANYNAME_=&hqtradeup=off&DUNSNUMBER=&INTLDUNSNUMBER=&dunsnumbercomp=' + hqDunsCase + (cmid != null ? '&CMID=' + cmid : ''));
    else
      location = hqLinkURL;
  }
}

function buyIntlHQBIR(cmid,countryCode,companyName)
{
  if(reportWarningIntlBIR('Headquarters')) {
	if (isInfobot == "true") {
		if (countryCode == null && companyName == null) {
    		    	handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Business+Information+Report&productsselected=Business+Information+Report&COMPANYNAME_=&hqtradeup=off&DUNSNUMBERCOMP=&DUNSNUMBER=&intldunsnumber=' + hqDunsCase + (cmid != null ? '&CMID=' + cmid : '') + '&intl=1');
		} else {
			handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Business+Information+Report&productsselected=Business+Information+Report&hqtradeup=off&DUNSNUMBERCOMP=&DUNSNUMBER=&intldunsnumber=' + hqDunsCase + countryCode + (cmid != null ? '&CMID=' + cmid : '') + '&intl=1'  + (companyName != null ? '&intlcompanyname=' + escape(companyName) : ''));
		}
	} else {
		location = intlHQLinkURL;
	}
   }
}

function buyParentBIR(cmid)
{
  if(reportWarningECOMP('Parent')) {
    if (isInfobot == "true")
      handlePurchase('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&COMPANYNAME_=&hqtradeup=off&INTLDUNSNUMBER=&DUNSNUMBER=&dunsnumbercomp=' + parentDunsCase + (cmid != null ? '&CMID=' + cmid : ''));
    else
      location = parentLinkURL;
  }
}

function buyIntlParentBIR(cmid,countryCode,companyName)
{
  if(reportWarningIntlBIR('Parent')) {
    if (isInfobot == "true") {
		if (countryCode == null && companyName == null) {
			handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Business+Information+Report&productsselected=Business+Information+Report&COMPANYNAME_=&hqtradeup=off&DUNSNUMBERCOMP=&DUNSNUMBER=&intldunsnumber=' + parentDunsCase + (cmid != null ? '&CMID=' + cmid : '') + '&intl=1');
		} else {
			handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Business+Information+Report&productsselected=Business+Information+Report&hqtradeup=off&DUNSNUMBERCOMP=&DUNSNUMBER=&intldunsnumber=' + parentDunsCase + countryCode + (cmid != null ? '&CMID=' + cmid : '') + '&intl=1'  + (companyName != null ? '&intlcompanyname=' + escape(companyName) : ''));
		}		
	} else {
		location = intlParentLinkURL;
	}
  }
}

function buyParDomUltBIR(cmid)
{
  if(reportWarningECOMP('Domestic Ultimate')) {
    if (isInfobot == "true")
      handlePurchase('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&COMPANYNAME_=&hqtradeup=off&INTLDUNSNUMBER=&DUNSNUMBER=&dunsnumbercomp=' + parentDomUltDunsCase + (cmid != null ? '&CMID=' + cmid : ''));
    else
      location = ultDomParentLinkURL;
  }
}

function buyGlobalBIR(cmid)
{
  if(reportWarningECOMP('Global Ultimate')) {
    if (isInfobot == "true")
      handlePurchase('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&COMPANYNAME_=&hqtradeup=off&INTLDUNSNUMBER=&DUNSNUMBER=&dunsnumbercomp=' + globalUltDunsCase + (cmid != null ? '&CMID=' + cmid : ''));
    else
      location = ultGlblLinkURL;
  }
}

function buyIntlGlobalBIR(cmid,countryCode,companyName)
{
  if(reportWarningIntlECOMP('Global Ultimate')) {
    if (isInfobot == "true") {
		if (countryCode == null && companyName == null) {
			handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&COMPANYNAME_=&hqtradeup=off&DUNSNUMBERCOMP=&DUNSNUMBER=&intldunsnumber=' + globalUltDunsCase + (cmid != null ? '&CMID=' + cmid : '') + '&intl=1');
		} else {
			handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&hqtradeup=off&intldunsnumber=' + globalUltDunsCase + countryCode + (cmid != null ? '&CMID=' + cmid : '') + '&intl=1'  + (companyName != null ? '&DUNSNUMBERCOMP=&DUNSNUMBER=&intlcompanyname=' + escape(companyName) : ''));
		}
	} else {
		location = intlUltGlblLinkURL;
	}
  }
}

function buyComprehensiveReport(cmid)
{
  if(reportWarning('Comprehensive')) {
    if (isInfobot == "true")
      callInfobot('REQUESTTYPE=checkPastPurchaseAndOrder&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&dunsnumber=' + dunsCase + (cmid != null && cmid != '' ? "&CMID=" + cmid : ""));
    else
      location = compUpsellURL;
  }
}

function saveReportAsText()
{
  window.open(textOnlyURL,'pf','width=770,height=500,resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes');
}

function buyPaymentAnalysisReport(cmid)
{
  if(reportWarning('Payment Analysis')) {
    if (isInfobot == "true")
      callInfobot('REQUESTTYPE=checkPastPurchaseAndOrder&productselected=Payment+Analysis+Report&productsselected=Payment+Analysis+Report&dunsnumber=' + dunsCase + (cmid != null && cmid != '' ? "&CMID=" + cmid : ""));
    else
      location = parUpsellURL;
  }
}

function buyHigherRiskScoreReport(cmid)
{
  if(reportWarning('Higher Risk Score')) {
    if (isInfobot == "true")
      callInfobot('REQUESTTYPE=checkPastPurchaseAndOrder&productselected=Higher+Risk+Score+Report&productsselected=Higher+Risk+Score+Report&dunsnumber=' + dunsCase + (cmid != null && cmid != '' ? "&CMID=" + cmid : ""));
    else
      location = highriskUpsellURL;
  }
}

function buyIndustryNormsReport(cmid)
{
  if(reportWarning('Industry Norms')) {
    if (isInfobot == "true")
      callInfobot('REQUESTTYPE=checkPastPurchaseAndOrder&productselected=Industry+Norms&productsselected=Industry+Norms&dunsnumber=' + dunsCase + '&GRP4ADDRESSEE=' + escape(requestAttention) + (cmid != null && cmid != '' ? "&CMID=" + cmid : ""));
    else
      location = industryNormsUpsellURL;
  }
}

function reportWarning(repname)
{
  return(confirm("Confirmation - Order the " + repname + " Report?"));
}

function reportWarningPTP(repname)
{
  return(confirm("Confirmation - " + repname + "?"));
}

function reportWarningBIR(repname)
{
  //return(confirm("Confirmation - Buy the Business Information Report on the " + repname + "?"));
  return(confirm("Confirmation - Order the Business Information Report?"));
}

function reportWarningIntlBIR(repname)
{
  //return(confirm("Confirmation - Buy the International Business Information Report on the " + repname + "?"));
  return(confirm("Confirmation - Order the International Business Information Report?"));
}

function reportWarningECOMP(repname)
{
  return(confirm("Confirmation - Order the Comprehensive Report on the " + repname + "?"));
}

function reportWarningIntlECOMP(repname)
{
  return(confirm("Confirmation - Order the International Business Information Report on the " + repname + "?"));
}

function phoneNumber(phoneString) {
	var phoneNum = '';
	for (var i = 0; i < phoneString.length; i++) {
		var phoneChar = phoneString.charAt(i);
		if (phoneChar >= '0' && phoneChar <= '9') {
			phoneNum += phoneChar;
		}
	}
	return phoneNum;
}

function formatCompanyName(cname) {

   var maxThreshold = 31;
   var smallCompanyStyleThreshold = 28;

   var length = cname.length;
   var score = 0;
   var characters = 0;
   for (var i = 0; i < cname.length && score < maxThreshold; i++) {
     if ((cname.charAt(i) >= 'a' && cname.charAt(i) <= 'z') && (cname.charAt(i) != 'w')) {
       score += .75;
     }
     else if (cname.charAt(i) == 'W') {
       score += 1.2;
     }
     else if (cname.charAt(i) == 'w') {
       score += .8;
     }
     else {
       score += 1;
     }
     characters++;
   }

   if (score < smallCompanyStyleThreshold) {
     document.write('<span class="companyTitle">' + cname + '</span>');
   }
   else if (score < maxThreshold) {
     document.write('<span class="smallCompanyTitle">' + cname + '</span>');
   }
   else {
     document.write('<span class="smallCompanyTitle">' + cname.substr(0, characters-4) + '...' + '</span>');
   }

}

var theQuery = null;

function Cookie(document, name, days, path, domain, secure) {
	this.$document=document;
	this.$name=name;
	if (days) {
		this.$expiration = new Date((new Date()).getTime() + days*24*60*60*1000);
	} else {
		this.$expiration = null;
	}
	if (path) {
		this.$path = path;
	} else {
		this.$path = null;
	}
	if (domain) {
		this.$domain= domain;
	} else {
		this.$domain= null;
	}
	if (secure) {
		this.$secure= secure;
	} else {
		this.$secure= null;
	}
}
function _Cookie_store() {
	var cookieVal = "";
	for (var prop in this) {
		if ((prop.charAt[0] == '$') || ((typeof this[prop]) == 'function')) {
			continue;
		}
		if (cookieVal != "") {
			cookieVal += '&';
		}
		cookieVal += prop + ':' + escape(this[prop]);
	}
	var cookie = this.$name + '=' + cookieVal;
	if (this.$expiration) {
		cookie += '; expires=' + this.$expiration.toGMTString();
	}
	if (this.$path) {
		cookie += '; path=' + this.$path;
	}
	if (this.$domain) {
		cookie += '; domain=' + this.$domain;
	}
	if (this.$secure) {
		cookie += '; secure=' + this.$secure;
	}
	this.$document.cookie = cookie;
}

function _Cookie_load() {
	var allCookies = this.$document.cookie;
	if (allCookies == null || allCookies == "") {
		return false;
	}
	var start = allCookies.indexOf(this.$name + '=');
	if (start == -1) {
		return false;
	}
	start += this.$name.length + 1;
	var end = allCookies.indexOf(';', start);
	if (end == -1) end = allCookies.length;
	var cookieVal = allCookies.substring(start, end);
	var a = cookieVal.split('&');
	for (var i = 0; i < a.length; i++) {
		a[i] = a[i].split(':');
	}
	for (var i = 0; i < a.length; i++) {
		if (a[i][0] == "$expiration") {
			this[a[i][0]] = new Date(unescape(a[i][1]));
		} else {
			this[a[i][0]] = unescape(a[i][1]);
		}
	}
	return true;
}

function _Cookie_remove() {
	var cookie;
	cookie = this.$name + '=';
	if (this.$path) cookie += '; path=' + this.$path;
	if (this.$domain) cookie += '; domain=' + this.$domain;
	cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
	this.$document.cookie = cookie;
}

new Cookie();
Cookie.prototype.store = _Cookie_store;
Cookie.prototype.load = _Cookie_load;
Cookie.prototype.remove = _Cookie_remove;

var repeatCustomer = new Cookie(document, "beenHereDoneThat", 90);

function buyCreditLimit(branch,cmid) {

  var retval = false;
  if (branch != null && branch == "1") {
    retval = confirm("Confirmation: Credit limits are not available for branch locations.\r\n\r\nWould you like to get the Credit Limit Recommendation on the headquarters instead?");
  }
  else {
    retval = true;
  }

  if (retval) {
    handleCreditLimit(branch,cmid);
  }
}

function learnMoreCreditLimit(branch,cmid) {
  var requestURL=helpPath+"creditline_learn.htm?SESSIONID=" + sessionid + "&DUNSNUMBER=" + dunsCase + "&COMPANYNAME=" + escape(companyName) + "&COMPANYADDRESS=" + escape(companyAddress) + "&COMPANYCITY=" + escape(companyCity) + "&COMPANYSTATE=" + escape(companyState) + "&COMPANYZIP=" + escape(companyZip) + (branch != null ? "&branch=" + branch : "") + "&FABPRODTYPE=COMPCL" + (cmid != null && cmid != '' ? "&CMID=" + cmid : "");
  
  window.open(requestURL,'cl','width=400,height=510,resizable=yes,toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=no').focus();
}

function handleCreditLimit(branch,cmid) {
  if (sessionid == '123456789') {
    if (theQuery == null)
      theQuery = new PageQuery(document.location.search);
    sessionid = theQuery.getValue("SESSIONID");
  }

  var requestURL = null;
  if (branch != null && branch == "1") {
    requestURL = infobotURL("DUNSNUMBER=" + hqDunsCase + "&FABPRODTYPE=COMPCL&REQUESTTYPE=GETCRLIMIT&PRODUCTTYPE=CREDITLIMIT" + (cmid != null && cmid != '' ? "&CMID=" + cmid : ""));
  }
  else {
    requestURL= infobotURL("DUNSNUMBER=" + dunsCase + "&COMPANYNAME=" + escape(companyName) + "&COMPANYADDRESS=" + escape(companyAddress) + "&COMPANYCITY=" + escape(companyCity) + "&COMPANYSTATE=" + escape(companyState) + "&COMPANYZIP=" + escape(companyZip) + (branch != null ? "&branch=" + branch : "") + "&FABPRODTYPE=COMPCL&REQUESTTYPE=GETCRLIMIT&PRODUCTTYPE=CREDITLIMIT" + (cmid != null && cmid != '' ? "&CMID=" + cmid : ""));
  }
  
  window.open(requestURL,'cl','width=410,height=510,resizable=yes,toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=no').focus();
}

//Code Change - Start

function buyMultBIR(dunsList,intlDunsList,dunsListBr,companyName,companyNameBr,intlCompanyName,cmid,dunsCnt)
{
  var repname;
  if (dunsCnt == "1") {
  	repname = "Order the selected report";
  } else {
  	if(dunsCnt == "2") {
  		repname = "Order both selected reports";
  	} else {
  		repname = "Order all " + dunsCnt + " selected reports";
  	}
  }
  if(reportWarningPTP(repname)) {
    if (isInfobot == "true") {
      handleBIRFamilyLinkage('REQUESTTYPE=orderECOMPFromFamilyLinkage&productselected=Comprehensive+Report&productsselected=Comprehensive+Report&hqtradeup=off' + (dunsList != null ? '&dunsNumberComp=' + dunsList : '') + (intlDunsList != null ? '&intlDunsNumber=' + intlDunsList : '') + (dunsListBr != null ? '&dunsNumber=' + dunsListBr : '') + (cmid != null ? '&CMID=' + cmid : '') + (companyName != null ? '&companyNameComp=' + escape(companyName) : '')+ (companyNameBr != null ? '&companyName=' + escape(companyNameBr) : '')+ (intlCompanyName != null ? '&intlCompanyName=' + escape(intlCompanyName) : ''));
    } else {
      location = multLinkURL;
    }
  }
}

//This function modified to include ordering Ecomp and Comprehensive Report
//dunslist: US non-branch: eComp
//dunsListBr: US branch: eBIR
//intlDunsList: International ANYTHING: BIR
//intlDunsListBr: no longer used

function validateCheckBoxes(f) {
	var corpFamDuns = f;
	var anyChecked = false;
	var anyCheckedIntl = false;
	var anyCheckedBr = false;

	var dunsList = "";
	var intlDunsList = "";
	var dunsListBr = "";
	
	var companyName = "";
	var intlCompanyName = "";	
	var companyNameBr = "";

	var cmid = "IOD100487";
	dunsCnt = 0;
	
	var duns ="";
	var ch = "";

	for (var i = 0; i < corpFamDuns.corpDuns.length-1; i++) 
	{
		duns = corpFamDuns.corpDuns[i].value;

		ch = duns.charAt(duns.length-1);		

		//for US-Non Branch duns numbers.  will 9 bytes (Call ECOMP)
		if (duns.length == 9 && ch != 'Y') 
		{
			if (corpFamDuns.corpDuns[i].checked) {
				if (anyChecked == true) {
					dunsList += ',';
					companyName += '|';					
				}
				dunsList += duns;
				companyName += corpFamDuns.companyName[i].value;
				anyChecked = true;
				dunsCnt++;
			}
		} 
		else if (duns.length == 11 || duns.length == 12) 
		{
			//for international duns numbers.  will contain the 2 byte country code at the end.  total is 11 or 12 bytes! (Call Intl Business Information Report)
			if (corpFamDuns.corpDuns[i].checked) 
			{
				if (anyCheckedIntl == true) 
				{
					intlDunsList += ',';
					intlCompanyName += '|';
				}
				if (duns.length == 12) 
					intlDunsList += duns.substring(0,duns.length-1);
				else
					intlDunsList += duns;
				intlCompanyName += corpFamDuns.companyName[i].value;
				anyCheckedIntl = true;
				dunsCnt++;
			}
		}
		else if (duns.length == 10 && ch == 'Y') 
		{
			//for US Branch duns numbers.  will 9 bytes + Code, total 10 digits (Call EBIR)
			if (corpFamDuns.corpDuns[i].checked) 
			{
				if (anyCheckedBr == true) 
				{
					dunsListBr += ',';
					companyNameBr += '|';
				}
				dunsListBr += duns.substring(0,duns.length-1);
				companyNameBr += corpFamDuns.companyName[i].value;
				anyCheckedBr = true;
				dunsCnt++;
			}
		}
		
	}
	if (anyChecked == false && anyCheckedIntl == false && anyCheckedBr == false) {
		alert("You must select at least one DUNS");
		return false;
	}
	buyMultBIR(dunsList,intlDunsList,dunsListBr,companyName,companyNameBr,intlCompanyName,cmid,dunsCnt);
//always return false so that either redisplay the BIR if they did not want to buy or let the handlePurchase do its thing
	return false;
}
//Code Change - End

function convertStateToNbr(caseState)
{
	var caseStateNbr = '99';
	var lnkHTML;
	var statearray = new Array("AL","AK","AZ","AR","CA","CO","CT","DE","DC","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","PR","RI","SC","SD","TN","TX","UT","VT","VI","VA","WA","WV","WI","WY");
	for (var i = 0; i < 53; i++) {
		if (statearray[i] == caseState) {
			caseStateNbr = i + 1;
			break;
		}
	}

	if (caseStateNbr != '99') 
	{
		lnkHTML = "<input type=\"hidden\" name=\"hCuststate\" value=\"" + caseStateNbr + "\"/>";
		document.writeln(lnkHTML);
	}
}

function hrefLink(reqType, flow)
 {
   var parmVals;
	if (sessionid == '123456789') 
	{
      if (theQuery == null)
        theQuery = new PageQuery(document.location.search);
      sessionid = theQuery.getValue("SESSIONID");
    }
   
   parmVals="/scripts/ProductRetriever.asp?REQUESTTYPE=" + reqType + "&sessionID=" + sessionid + "&PROCESSFLOW=" + flow 
   top.location.assign(parmVals) 
 }
