//--- GLOBAL VARIABLES ---//
//--- Data containers for PDF info managed by javascript ---//
var arrPDFName = new Array();
var arrPDFDesc = new Array();
var arrPDFLink = new Array();

var currWinObj, hrefClickedIdSav;
var iframeUpdatedBool = false;

//--- FUNCTIONS ---//
function openSelector_ArticleCitator(urlString) {
	citatorWin = window.open(urlString, 'articleCitatorSelectorWin', 'width=700,height=600,status=no,scrollbars=yes');
	citatorWin.focus();
}


function demoPdfWin( fileName ){
	fileNameArray = fileName.split("?");
	queryStringArray = fileNameArray[fileNameArray.length-1].split("&");
	winName = '';
	for(i=0;i<queryStringArray.length;i++){
		//alert(queryStringArray[i]);
		qsNameValueArray = queryStringArray[i].split("=");
		if( i>0 ){
			tempName = qsNameValueArray[qsNameValueArray.length-1];
			tempName2 = tempName;
			/*for(j=0;j<tempName.length;j++){
				alert(tempName[j]);
				if(j=0){
					tempName2 += tempName[j].toUpperCase();
				}else{
					tempName2 += tempName[j];
				}
			}*/
		}else{
			tempName2 = qsNameValueArray[qsNameValueArray.length-1];
		}
		winName += tempName2;

	}
	winName += 'Win';

	//alert( 'pdfWin: '+ winName );

	if( winName == 'contentdemo2BWin' )
		pdfDemoWin = window.open(fileName,winName,"width=900,height=600,menubar=1,resizable=yes,toolbar=0,location=0,scrollbars=1");
	else
		pdfDemoWin = window.open(fileName,winName,"width=700,height=600,menubar=1,resizable=yes,toolbar=0,location=0,scrollbars=1");

	//alert( pdfDemoWin.closed );

	//parent.close();

	if( isObject(pdfDemoWin) )
		pdfDemoWin.focus();

	return pdfDemoWin;
}

function removePDFTab(desc1) {

	if( desc1 == 'ALL' ){
		if( confirm('You want to close ALL open pdf\'s?') ){
			arrPDFName = new Array();
			arrPDFDesc = new Array();
			document.getElementById('divtabPDF').innerHTML = '';
			document.getElementById('divtabPDF').style.display='none';
			document.getElementById('divfrmPDF').style.display='none';

			divController2( 'pdf', 'hide' );

			return false;
		}
	}


	//search next empty position in the array or check if the file is already on the list
	var pos, foundtab, x;
	foundtab = false;
	pos = -1;

	//for (x = 0; x < arrPDFName.length; x++) {
		//alert(pos+'->'+arrPDFDesc[x]+'->'+arrPDFName[x]);
	// }

	for (x = 0; x < arrPDFName.length; x++) {
		//if the file is already on the list
		if ( arrPDFDesc[x] == desc1 ) {
			pos = x;
			//alert('a:'+x);
			foundtab = true;
			break;
		}
	}

	if ( pos > -1 ) {
		arrPDFName.splice(pos,1);
		arrPDFDesc.splice(pos,1);
	}

	//for (x = 0; x < arrPDFName.length; x++) {
		//alert(pos+'->'+arrPDFName[x]);
	// }


	if ( arrPDFName.length > 0 ) {
		//alert('6:'+arrPDFName[0]);
		loadPDFIframe('ifrmPDF', arrPDFName[0]);
		return false;
	}
	else {
		document.getElementById('divtabPDF').style.display='none';
		document.getElementById('divfrmPDF').style.display='none';
		divController2( 'pdf', 'hide' );
		return false;
	}
}

function removePDFTab4( nameExtension, desc1, pdfReaderOptions1, pdfReaderOptions2 ) {

	thisArrPDFName = arrPDFName[ nameExtension ];
	thisArrPDFDesc = arrPDFDesc[ nameExtension ];
	thisArrPDFLink = arrPDFLink[ nameExtension ];

	if( isUndefined(thisArrPDFName) ){
		thisArrPDFName = new Array();
		thisArrPDFDesc = new Array();
		thisArrPDFLink = new Array();
	}

	//tempUrl = url1.split("#");
	//tempUrl1 = tempUrl[0] +pdfReaderOptions2+ tempUrl[1]

	if( desc1 == 'ALL' ){
		if( confirm('You want to close ALL open pdf\'s?') ){
			arrPDFName = new Array();
			arrPDFDesc = new Array();
			document.getElementById('divtabPDF'+ nameExtension).innerHTML = '';
			document.getElementById('divtabPDF'+ nameExtension).style.display='none';
			document.getElementById('divfrmPDF'+ nameExtension).style.display='none';

			divController2( 'pdf', 'hide' );

			return false;
		}
	}


	//search next empty position in the array or check if the file is already on the list
	var pos, foundtab, x;
	foundtab = false;
	pos = -1;

	//for (x = 0; x < arrPDFName.length; x++) {
		//alert(pos+'->'+arrPDFDesc[x]+'->'+arrPDFName[x]);
	// }

	for (x = 0; x < thisArrPDFName.length; x++) {
		//if the file is already on the list
		if ( thisArrPDFDesc[x] == desc1 ) {
			pos = x;
			//alert('a:'+x);
			foundtab = true;
			break;
		}
	}

	if ( pos > -1 ) {
		thisArrPDFName.splice(pos,1);
		thisArrPDFDesc.splice(pos,1);
		thisArrPDFLink.splice(pos,1);
	}

	//for (x = 0; x < arrPDFName.length; x++) {
		//alert(pos+'->'+arrPDFName[x]);
	// }

	arrPDFName[ nameExtension ] = thisArrPDFName;
	arrPDFDesc[ nameExtension ] = thisArrPDFDesc;
	arrPDFLink[ nameExtension ] = thisArrPDFLink;

	if ( thisArrPDFName.length > 0 ) {
		//alert('6:'+arrPDFName[0]);
		loadPDFIframe4( nameExtension, thisArrPDFName[0], pdfReaderOptions1, pdfReaderOptions2);
		return false;
	}
	else {
		divController4( 'pdfFrame'+ nameExtension, 'collapse' );
		return false;
	}
}

function loadPDFIframe( iframeName, url1, winObj ) {

	var x, pos, lastpos, desc1, strtmp, rootpath;
	var tabs, foundtab;

	thisWin = window;
	thisDoc = window.document;

		rootpath = getRootPath();

	//alertArgs( loadPDFIframe.arguments, 'loadPDFIframe' );

	if( !isUndefined(winObj) && isObject( winObj ) ){

		thisWin = winObj;
		thisDoc = winObj.document;

		arrPDFName = thisWin.arrPDFName;
		arrPDFDesc = thisWin.arrPDFDesc;

	}

	//strip filename from the url
	//cannot search for this character because PDF accepts / as a queryString variable
	//lastpos = url1.lastIndexOf('/');
	lastpos = url1.lastIndexOf('.pdf');
	//to account for the extension '.pdf'
	lastpos += 3;
	if ( lastpos <= -1 )
		lastpos = url1.lastIndexOf('\\');

	desc1 = url1;
	if ( lastpos > -1 )
		desc1 = url1.substring(lastpos+1);

	//----- if desc1 is blank ( if there are no pdf querystring args ) then use the name of pdf
	if( desc1 == '' ){
		startpos = url1.lastIndexOf('/');
		desc1 = url1.substring(startpos+1,lastpos+1);
	}

	//search next empty position in the array or check if the file is already on the list
	foundtab = false;
	pos = arrPDFName.length;
	for (x = 0; x < arrPDFName.length; x++) {
		//if the file is already on the list
		//alert( arrPDFDesc[x] +' == '+ desc1 );
		if ( arrPDFDesc[x] == desc1 ) {
			pos = x;
			foundtab = true;
			break;
		}
	}

	if ( foundtab == false ) {
		arrPDFName[pos] = url1;
		arrPDFDesc[pos] = desc1;
	}

	tabs = '';

	for (x = 0; x < arrPDFName.length; x++) {
		if ( arrPDFName[x] == '' )
			break;

		if ( tabs != '' ) {
			//alert('3.1:'+tabs+'->'+arrPDFName[x]);
			tabs += '&nbsp;&nbsp;';
		}

		strtmp = '<div id="' + arrPDFDesc[x] + '" style="white-space:nowrap;display:inline;height:25px;line-height:20px;border:1px solid #ACA899;padding:5px;border-bottom:0px;vertical-align:bottom;';
		if( url1 == arrPDFName[x] ){
			strtmp = strtmp + 'background-color:#FFFFFF;padding-top:4px;"';
		}else{
			strtmp = strtmp + 'background-color:#ECE9D8;" onMouseOut="document.getElementById(\''+ arrPDFDesc[x] +'\').style.backgroundColor =\'#ECE9D8\';document.getElementById(\''+ arrPDFDesc[x] +'\').style.paddingTop=\'5px\';" ';
		}
		strtmp = strtmp + '" onMouseOver="document.getElementById(\''+ arrPDFDesc[x] +'\').style.backgroundColor =\'#FFFFFF\';document.getElementById(\''+ arrPDFDesc[x] +'\').style.paddingTop=\'4px\';"><a href="" onclick="javascript:return loadPDFIframe(ifrmPDF,url);"><img src="' + rootpath + 'images/icon_pdf.gif" border="0" alt="' + arrPDFName[x] + '" /> Pdf-' + (x+1) + '</a>';
		strtmp = strtmp.replace("ifrmPDF", "'ifrmPDF'");
		strtmp = strtmp.replace('url'   ,"'"+ arrPDFName[x] +"'");

		tabs   += strtmp +'&nbsp;&nbsp;&nbsp;';

		strtmp = '<a href="'+ arrPDFName[x] +'" target="_blank"><img src="' + rootpath + 'images/icon_link.gif" border="0" alt="new pdf window" /></a>';
		strtmp = strtmp.replace("url", "'"+ arrPDFDesc[x] +"'");

		tabs   += '&nbsp;' + strtmp;

		strtmp = '<a href="" onclick="javascript:return removePDFTab(url);"><img src="' + rootpath + 'images/icon_close-sm.gif" border="0" alt="close pdf" /></a>';
		strtmp = strtmp.replace("url", "'"+ arrPDFDesc[x] +"'");

		tabs   += strtmp;

		tabs   += '</div>';
	}
	tabs += '<div style="display:inline;height:25px;line-height:22px;border:0px solid #ACA899;padding:5px;border-bottom:0px;">&nbsp;</div>';

	thisDoc.getElementById('divtabPDF').style.display='';
	thisDoc.getElementById('divfrmPDF').style.display='';
	thisDoc.getElementById('divtabPDF').focus();

	thisDoc.getElementById('divtabPDF').innerHTML = tabs;

	//thisDoc.getElementById('pdfFrame').style.height='';

	//alert('8:'+pos);

	if ( thisWin.frames[iframeName] ) {
		thisWin.frames[iframeName].location = url1;
		return false;
	}else return true;

}


	function retCookie(name) {
		var dc = document.cookie;
		var prefix = name + '=';
		var begin = dc.indexOf('; ' + prefix);
		if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
		} else {
		begin += 2;
		}
		var end = document.cookie.indexOf(';', begin);
		if (end == -1) {
		end = dc.length;
		}
		return unescape(dc.substring(begin + prefix.length, end));
}


/* This is much faster than using (el.innerHTML = str) when there are many
existing descendants, because in some browsers, innerHTML spends much longer
removing existing elements than it does creating new ones. */
function replaceHtml(el, html) {
	var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
	/*@cc_on // Pure innerHTML is slightly faster in IE
		oldEl.innerHTML = html;
		return oldEl;
	@*/
	var newEl = oldEl.cloneNode(false);
	newEl.innerHTML = html;
	oldEl.parentNode.replaceChild(newEl, oldEl);
	/* Since we just removed the old element from the DOM, return a reference
	to the new element, which can be used to restore variable references. */
	return newEl;
}

function replaceHtml2(el, html) {
	var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
	var newEl = document.createElement(oldEl.nodeName);
	// Preserve the element's id and class (other properties are lost)
	newEl.id = oldEl.id;
	newEl.className = oldEl.className;
	// Replace the old with the new
	newEl.innerHTML = html;
	oldEl.parentNode.replaceChild(newEl, oldEl);
	/* Since we just removed the old element from the DOM, return a reference
	to the new element, which can be used to restore variable references. */
	return newEl;
}

function RemoveNumbers(str1) {
	str1 = str1.replace(/0/g,'');
	str1 = str1.replace(/1/g,'');
	str1 = str1.replace(/2/g,'');
	str1 = str1.replace(/3/g,'');
	str1 = str1.replace(/4/g,'');
	str1 = str1.replace(/5/g,'');
	str1 = str1.replace(/6/g,'');
	str1 = str1.replace(/7/g,'');
	str1 = str1.replace(/8/g,'');
	str1 = str1.replace(/9/g,'');
	return str1;
}



function createPdfDiv2_new( divNameExtesion, pdfFileName, pdfDestinationCodes, displayTabDiv, extraControlLine, iframeNumber, hrefClickedId ) {
		var newPdfDiv, tmpI, toolBarOptions, toolBarOptions2, nn, tmpIframe, tmpNumberId, thisNumberId, appPdfPath, isStaging, currIframe, tmp1, tmpStr, origPdfFileName, rootpath;

		//alert('cpd1');

		newPdfDiv = "";
		if ( divNameExtesion.length > 1 ) {
			if ( divNameExtesion.substring(0,1) == "-" ) {
				divNameExtesion = divNameExtesion.substring(1);
			}
		}

		isStaging = (retCookie("isStaging") == "1");
		if ( isStaging == true ) {
			appPdfPath = "/wwwstaging/documents/documents/";
		} else {
			appPdfPath = "/documents/documents/";
		}

		//tempDivNameExtesion = divNameExtesion.replace("-","");
		//tempDivNameExtesion = tempDivNameExtesion.replace(".","");
		//tempDivNameExtesion = tempDivNameExtesion.replace(",","");

		if( pdfDestinationCodes == "" ) {
			pdfDestinationCodes = "Page=1";
		}

		origPdfFileName = pdfFileName;
		pdfFileName     = pdfFileName + " ";
		nn = pdfFileName.toLowerCase().indexOf(".pdf");
		if ( nn > -1 ) {
			pdfFileName = pdfFileName.substring(0, nn+4);
		}

		//---- FTS feeds in QueryString an xml argument ---'
		if( pdfFileName.indexOf("#xml=") > -1 ) {
			toolBarOptions = "&navpanes=1";
			toolBarOptions2 = "&navpanes=1&statusbar=1&view=FitV";
			pdfDestinationCodes = "";
		} else {
			toolBarOptions = "#navpanes=1&";
			toolBarOptions2 = "#navpanes=0&toolbar=0&statusbar=0&view=FitV&";
		}

		//alert('cpd5');

		newPdfDiv = "<div id='outterPdfDiv' style=''><div id='pdfFrame-"+ divNameExtesion +"-Controls' class='popupLinks' style='z-index:6;left:;border:0px solid #989898;width:100%;margin:0px;padding:0px 0px 0px 0px;background-color:;";

		newPdfDiv = newPdfDiv + "display:none;";
		//if (displayTabDiv == true) {
		//	newPdfDiv = newPdfDiv + "display:none;top:0px;";
		//} else {
		//	newPdfDiv = newPdfDiv + "display:none;top:-10px;";
		//}
		newPdfDiv = newPdfDiv + "'>";

		if (extraControlLine > 0) {
			for (nn = 1; nn <= extraControlLine; nn++) {
				newPdfDiv = newPdfDiv + "<br />";
			}
		}

		rootpath = getRootPath();
		//alert(rootpath + "images/icon_close.gif");

		if (displayTabDiv == false) {

				//check whether the toolbar will be displayed or not and when is not displayed the tip needs to be displayed
				if ( toolBarOptions2.indexOf("toolbar=1") == -1 && origPdfFileName.indexOf("toolbar=1") == -1 ) {
					newPdfDiv = newPdfDiv + "<br />";
			}
			newPdfDiv = newPdfDiv + "<div style='width:80%;float:left;text-align:left;margin:0px;'>";
			newPdfDiv = newPdfDiv + "<span style='padding-left:0px;color:#A6A6A6;font: normal 9px Verdana !important;' id='PdfF8ToolBar11'>"

			//check whether the toolbar will be displayed or not and when is not displayed the tip needs to be displayed
			if ( toolBarOptions2.indexOf("toolbar=1") == -1 && origPdfFileName.indexOf("toolbar=1") == -1 ) {
					//alert(toolBarOptions2);
					//alert(origPdfFileName);
			    //newPdfDiv = newPdfDiv + "VIEWING TIP: FOR DISPLAY & SEARCHING – CLICK IN DOCUMENT AND PRESS F8 FOR TOOLBAR";
			    newPdfDiv = newPdfDiv + "VIEWING TIP: TO HIDE TOOLBAR PRESS F8";
			}
			newPdfDiv = newPdfDiv + "</span>";
			newPdfDiv = newPdfDiv + "</div>";

			newPdfDiv = newPdfDiv + "<div style='width:15%;float:right;text-align:right;margin:0px;padding-right:15px;'>";
			newPdfDiv = newPdfDiv +"<a id='pdfFrame-"+ divNameExtesion +"-iconLinkAnchor' href='" + appPdfPath + pdfFileName + toolBarOptions + pdfDestinationCodes + "' target='_blank'><img src='" + rootpath + "images/icon_link.gif' border='0' title='new pdf window' alt='new pdf window' /></a>&nbsp;";
			newPdfDiv = newPdfDiv +"<a href='#pdfFrame-"+ divNameExtesion +"' onclick='divController4( \"pdfFrame-"+ divNameExtesion +"\", \"collapse\" );'><img src='" + rootpath + "images/icon_close.gif' border='0' title='close' alt='close' /></a>";
			newPdfDiv = newPdfDiv + "</div>";
			//newPdfDiv = newPdfDiv + "<br style='line-height:3px;' />"; //<br style='line-height:5px;' />";
			//alert('1');
		} else {
			newPdfDiv = newPdfDiv + "<div style='width:100%;float:right;text-align:right;margin:0px;'>";
			newPdfDiv = newPdfDiv +"<a id='pdfFrame-"+ divNameExtesion +"-iconLinkAnchor' href='" + appPdfPath + pdfFileName + toolBarOptions + pdfDestinationCodes + "' target='_blank'><img src='" + rootpath + "images/icon_link.gif' border='0' title='new pdf window' alt='new pdf window' /></a>&nbsp;";
				newPdfDiv = newPdfDiv +"<a href='#pdfFrame-"+ divNameExtesion +"' onclick='divController4( \"pdfFrame-"+ divNameExtesion +"\", \"collapse\" );'><img src='" + rootpath + "images/icon_close.gif' border='0' title='close' alt='close' /></a>";
				newPdfDiv = newPdfDiv + "</div>";
				//newPdfDiv = newPdfDiv + "<br style='line-height:3px;' />";
				//alert('2');
		}

		newPdfDiv = newPdfDiv + "</div><br style='line-height:11px;' />";

		newPdfDiv = newPdfDiv
							+"<div id='pdfFrame-"+ divNameExtesion +"' align='left' "
							+"	style='"
							+"		width:100%;"
							+"		margin:0px 0px 0px 0px;"
							+"		padding:0px 0px 0px 0px;"
							+"		border:0px solid #989898;"
							+"		height:auto;"
							+"		display:none;'"
							+">"
							+"<br style='line-height:5px;'>"
							+"<div id='divtabPDF-"+ divNameExtesion +"' align='left' style='z-index:5;width:100%;text-align:left;height:430px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;border:0px solid red;";

		if (displayTabDiv == true) {
			newPdfDiv = newPdfDiv +"display:;";
		} else {
			newPdfDiv = newPdfDiv +"display:none;";
		}

		newPdfDiv = newPdfDiv +"'></div>";

		if ( iframeNumber == "" ) {
			iframeNumber = "";
		}

		tmpNumberId = parseInt(iframeNumber); //PDFManframeId.Item(tempDivNameExtesion)
		if (tmpNumberId <= 0) {
			tmpNumberId = 1;
		}
		thisNumberId = tmpNumberId;
		tmpIframe = "";

		var links1;
		try {
			//alert(window.document.getElementById("href_*"));
			//alert(window.document.getElementById("href_*").getElementsByTagName("a"));
			//links1=window.document.getElementById("href_").getElementsByTagName("a");
			links1=window.document.getElementsByTagName("a");
		} catch(err) {
			//alert('error1');
		}
		//alert('number of links: '+links1.length);

		//save the current iframe
		currIframe = " <iframe style='display:none;z-index:-1' name='ifrmPDF-" + divNameExtesion + tmpNumberId + "' id='ifrmPDF-"+ divNameExtesion + tmpNumberId + "' src='javascript:false;' width='100%' height='420px' scrolling='no' frameborder='0'>Sorry, your browser doesn't support iframes.</iframe>";

		//alert('cpd7');

		/*****************************************************************************************************************************************
		The code below is used to speed up the creating of the iframes as only the correct number of frames should be created (or (+)aproximatelly
		******************************************************************************************************************************************/
		tmpStr = RemoveNumbers(hrefClickedId).toLowerCase();
		nn = 0;
		//alert('a0:'+tmpStr+'/'+links1.length);
		for (tmpI = 0; tmpI <= links1.length-1; tmpI++) {
			tmp1 = RemoveNumbers(links1[tmpI].id.toLowerCase());
			if ( tmp1 != '' ) {
				//alert('1.1:'+tmpStr+'/'+links1[tmpI].id+'/'+RemoveNumbers(links1[tmpI].id.toLowerCase())+'/'+tmpStr.indexOf(RemoveNumbers(links1[tmpI].id.toLowerCase())));
				if ( tmpStr.indexOf(tmp1) > -1 ) {
					//alert('1.2:'+tmpStr+'/'+RemoveNumbers(links1[tmpI].id.toLowerCase())+'/'+tmpStr.indexOf(RemoveNumbers(links1[tmpI].id.toLowerCase())));
					nn += 1;
				}
			}
		}
		//alert('2:'+nn+'/'+tmpNumberId);
		if ( nn > 0 && nn > tmpNumberId ) {
			tmpNumberId = nn;
		}
		//alert('cpd7b'+tmpNumberId);

		/********************************************************************************************************************************************
		The fix below is necessary to have acrobat reader use the fast load feature when working with the destination codes, unfortunatelly leaving
		the iframes to be added dynamically as requested wasn't working with the fast load feature.
		*********************************************************************************************************************************************/
//		if ( tmpNumberId < 80 ) {
//			tmpNumberId = 80;
//			//check number of links in the page and tmpNumberId should not be greater than that
////alert('4:'+tmpNumberId+'/'+links1.length);
//			if ( tmpNumberId > links1.length ) {
//				tmpNumberId = links1.length
//			}
//		}

		//alert('number of links: '+tmpNumberId);
		//tmpNumberId = 150;

		//alert('a1: '+tmpNumberId);

		for (tmpI = 1; tmpI <= tmpNumberId; tmpI++) {
			tmpIframe += " <iframe style='display:none;z-index:-1' name='ifrmPDF-" + divNameExtesion + tmpI + "' id='ifrmPDF-"+ divNameExtesion + tmpI + "' src='javascript:false;' width='100%' height='420px' scrolling='no' frameborder='0'>Sorry, your browser doesn't support iframes.</iframe>";
			//alert(tmpI);
		}

		//alert('a2: '+tmpIframe);
		/*****************************************************************************************************************************************/

		newPdfDiv = newPdfDiv
							+"	"
							+"	<div id='divfrmPDF-"+ divNameExtesion +"' align='center' style='display:none;width:99%;height:430px;border:1px solid #989898;'>"
							+"	  " + tmpIframe
							+"	</div>"
							+"</div></div>";

		/***************************************************************************************************************************************/

		//alert('a:'+newPdfDiv);

		//alert('a3: '+newPdfDiv);

		if ( window.document.getElementById('span_'+ divNameExtesion).innerHTML.length < 40 ) {
			//alert('a4a:'+newPdfDiv);

			//alert('a4b: '+'span_'+ divNameExtesion+' / '+window.document.getElementById('span_'+ divNameExtesion));
			/************* The code below can get quite slow depending on the number of html elements (divs, etc...) being inserted **************/
			//replaceHtml('span_'+ divNameExtesion, newPdfDiv);
			/*************************************************************************************************************************************/
			//replaceHtml('span_'+ divNameExtesion, "test");
			try {
				window.document.getElementById('span_'+ divNameExtesion).innerHTML = newPdfDiv;
			} catch(err)
			{
				//alert('error:');
				//some pages where mal-formed html is present may throw errors (reportGenerator.asp), surrounding with a table usually 'hide' the error
				window.document.getElementById('span_'+ divNameExtesion).innerHTML = '<table width="100%"><tr><td width="100%"><div>' + newPdfDiv + '</div></td></tr></table>';
			}
			//alert('a5: '+newPdfDiv);
			//alert('b');
		} else {
			//alert('a6: '+hrefClickedId);
			//This code apparently could be the best one but only using it and not having the commented code above was leading to acrobat not using
			//the fast loading feature, so this code is left only in case there are more than [100] PDF files...
			tmpStr = "ifrmPDF-" + divNameExtesion + thisNumberId;
			tmpStr = tmpStr.toLowerCase();
			//alert('a8:'+tmpStr);
			//check whether this iframe has been already inserted or not
			if ( window.document.getElementById('span_'+ divNameExtesion).innerHTML.toLowerCase().indexOf(tmpStr) == -1 ) {
				//alert('d:'+currIframe);
				window.document.getElementById("divfrmPDF-" + divNameExtesion).innerHTML += currIframe;
				//alert('e:'+window.document.getElementById("divfrmPDF-" + divNameExtesion).innerHTML);
			}
		}

		//alert('a9: '+hrefClickedId);

		return newPdfDiv;
}


var __ThisIsFirstLoad = true;
var canUseFrameLocationHRef = true;
//var __IsLoadingFile   = false;

function loadPDFIframe4( nameExtension, url1, pdfReaderOptions1, pdfReaderOptions2, iframeNumber, hrefClickedId, multipleSettings ) {
	var useFrame = document.getElementById("useFrame");
	if (useFrame) {
		if (useFrame.checked) {
			nameExtension = "-common";
		}
	}

//--- ARGUMENTS:
//--- nameExtension String = unique id used to append to all inline elements
//--- url1 String = location of pdf file
//--- pdfReaderOptions1 String = querystring open parameters for PDF reader used inline
//--- pdfReaderOptions2 String = querystring open parameters for PDF reader used for external doc

	/*
	alert(
		arguments[0] +'\n'+
		arguments[1] +'\n'+
		arguments[2] +'\n'+
		arguments[3] +'\n'
	);
	//return false;
	*/

	var rootpath;
		rootpath = getRootPath();

	try {
		var currBrowserCheck;
		currBrowserCheck = navigator.userAgent.toLowerCase();
		if ( currBrowserCheck.indexOf('macintosh') > -1 ) {
			alert('The Integrated PDF browser functions used in TradeLawGuide do not currently work on Mac computers. We are working to correct this.');
			//return true;
		}
		//alert('start1: ' + navigator.userAgent.toLowerCase());
	} catch (Err) {}

	var x, pos, lastpos, desc1, strtmp;
	var tabs, foundtab ,temp, returnValue1;
	var tmpNameExtension, fixedNameExtension, tmpobj;

	//alert('1');
	if ( multipleSettings == null ) {
		multipleSettings = '';
	}
	//alert('2');

	hrefClickedIdSav = hrefClickedId;

	/* This code checks whether that iframe tags have been previously inserted by the asp code or not */
	fixedNameExtension = nameExtension;
	if ( nameExtension.length > 1 ) {
		if ( nameExtension.substring(0,1) == "-" ) {
			fixedNameExtension = nameExtension.substring(1);
		}
	}

	tmpobj = window.document.getElementById('span_'+ fixedNameExtension);
	//alert(tmpobj+'/'+'span_'+ fixedNameExtension);
	if ( tmpobj ) {
		//alert('start1:');
		createPdfDiv2_new( nameExtension, url1, '', false, 0, iframeNumber, hrefClickedId );
	}
	//return false;

	//alert('start2:');

	thisWin = window;
	thisDoc = window.document;

	//alert('3:');

	//canUseFrameLocationHRef = true;

	//////////////////////////////////////////////////////////////////////
	//IE7 for instance doesn't like when we use 'currWinObj.location.href'
	//////////////////////////////////////////////////////////////////////
	try
	{
		temp = currWinObj.location.href;
	}
	catch(err)
	{
		//alert('abc0');
		canUseFrameLocationHRef	= false;
	}
	//////////////////////////////////////////////////////////////////////
	//alert('4:');
	//This code makes sure there's no iframe that is still downloading any PDF, so we cancel any previous download that might be in course.
	for (tmpI = 1; tmpI < 1000; tmpI ++) {
		currWinObj = thisWin.frames['ifrmPDF'+ nameExtension + tmpI];
		//alert('5:');
		if ( currWinObj ) {
			//alert('6.0:'+currWinObj+' => '+'[ifrmPDF'+ nameExtension + tmpI + ']');
			//alert('6.0:'+'ifrmPDF'+ nameExtension + tmpI+' => '+currWinObj.location.href);
			//thisWin.frames['ifrmPDF'+ nameExtension + tmpI].location.href = "blank.html"
			//frames['ifrmPDF'+ nameExtension + tmpI].location.href = "blank.html"
			//currWinObj.src = "blank.html";
			//try {

			if ( ('ifrmPDF'+nameExtension+iframeNumber).toLowerCase() == ('ifrmPDF'+ nameExtension + tmpI).toLowerCase() ) {
				//alert('1:'+'ifrmPDF'+nameExtension+iframeNumber);
				currWinObj.location.href = "blank.pdf";
			}

			if ( ('ifrmPDF'+nameExtension+iframeNumber).toLowerCase() != ('ifrmPDF'+ nameExtension + tmpI).toLowerCase() ) {
				if ( IsBrowser("msie 7") ) {
					
					//commented by Hitech
					
					//currWinObj.location.href = "blank.html"; //IE7
					//alert('abc1');
				} else {
					//currWinObj.location.href = "javascript:void(0);"
				}
				//} catch(err)
				//{
				//}
				//alert('6.1:'+'ifrmPDF'+ nameExtension + tmpI+' => '+currWinObj.location.href);
				//alert('6.1:'+navigator.userAgent.toLowerCase());
				document.getElementById('ifrmPDF'+ nameExtension + tmpI).style.display='none';
			} else {
				//alert('1:'+'ifrmPDF'+nameExtension+iframeNumber);
			}

		} else {
			break;
		}
	}

	//alert('9:');

	//if ( canUseFrameLocationHRef == false ) {
	//	alert('2a:');
	//} else {
	//	alert('2b:');
	//}

	//alert('2:'+currWinObj.location.href);

	//--- data is stored in multi-dimensional associative arrays
	//--- the 'nameExtension' (unique id) is used as the key
	thisArrPDFName = arrPDFName[ nameExtension ];
	thisArrPDFDesc = arrPDFDesc[ nameExtension ];
	thisArrPDFLink = arrPDFLink[ nameExtension ];

	//alert('3:');

	if( isUndefined(thisArrPDFName) ){
		thisArrPDFName = new Array();
		thisArrPDFDesc = new Array();
		thisArrPDFLink = new Array();
	}

	//strip filename from the url
	//cannot search for this character because PDF accepts / as a queryString variable
	//lastpos = url1.lastIndexOf('/');
	lastpos = url1.lastIndexOf('.pdf');
	//to account for the extension '.pdf'
	lastpos += 3;
	if ( lastpos <= -1 )
		lastpos = url1.lastIndexOf('\\');

	desc1 = url1;

	if ( lastpos > -1 )
		desc1 = url1.substring(lastpos+1);

	//desc1 = desc1 + pdfReaderOptions2 + urlDestCodes;
	//----- if desc1 is blank ( if there are no pdf querystring args ) then use the name of pdf
	if( desc1 == '' ){
		startpos = url1.lastIndexOf('/');
		desc1 = url1.substring(startpos+1,lastpos+1);

		//arrPDFLink

		tempDesc = desc1.split("/")
		//alert( desc1 +'==\'\'\n'+ tempDesc);


	}else{

		//arrPDFLink
		tempDesc = desc1.split("&")
		lastIndex = tempDesc.length-1;
		tempDesc = tempDesc[ lastIndex ].split(",")
		lastIndex = tempDesc.length-1;
		link1 = tempDesc[ lastIndex ];

	}

	//search next empty position in the array or check if the file is already on the list
	foundtab = false;
	pos = thisArrPDFName.length;
	for (x = 0; x < thisArrPDFName.length; x++) {
		//if the file is already on the list
		//alert( arrPDFDesc[x] +' == '+ desc1 );
		if ( thisArrPDFDesc[x] == desc1 ) {
			pos = x;
			foundtab = true;
			break;
		}
	}

	if ( foundtab == false ) {
		thisArrPDFName[pos] = url1 ;
		thisArrPDFDesc[pos] = desc1;
		thisArrPDFLink[pos] = link1;
	}


	tabs = '';

	//alert('3a');

	//for (x = 0; x < thisArrPDFName.length; x++) {
		x = pos;
		//if ( thisArrPDFName[x] == '' )
		//	break;

		if ( tabs != '' ) {
			//alert('3.1:'+tabs+'->'+arrPDFName[x]);
			tabs += '&nbsp;&nbsp;';
		}

		strtmp = '<div id="' + thisArrPDFDesc[x] + '" style="white-space:nowrap;display:inline;height:25px;line-height:20px;border:1px solid #ACA899;padding:5px;border-bottom:0px;vertical-align:bottom;';
		if( url1 == thisArrPDFName[x] ){
			strtmp = strtmp + 'background-color:#FFFFFF;padding-top:4px;"';
		}else{
			strtmp = strtmp + 'background-color:#ECE9D8;" onMouseOut="document.getElementById(\''+ thisArrPDFDesc[x] +'\').style.backgroundColor =\'#ECE9D8\';document.getElementById(\''+ thisArrPDFDesc[x] +'\').style.paddingTop=\'5px\';" ';
		}
		strtmp = strtmp + '" onMouseOver="document.getElementById(\''+ thisArrPDFDesc[x] +'\').style.backgroundColor =\'#FFFFFF\';document.getElementById(\''+ thisArrPDFDesc[x] +'\').style.paddingTop=\'4px\';"><a href="#" onclick="javascript:return loadPDFIframe4(\''+ nameExtension +'\',url,\''+ pdfReaderOptions1 +'\',\''+ pdfReaderOptions2 +'\');"><img src="' + rootpath + 'images/icon_pdf.gif" border="0" alt="' + thisArrPDFName[x] + '" /> '+ thisArrPDFLink[x] +'<!--Pdf-' + (x+1) + '--></a>';
		strtmp = strtmp.replace("ifrmPDF", "'ifrmPDF'");
		strtmp = strtmp.replace('url'   ,"'"+ thisArrPDFName[x] +"'");

		tabs   += strtmp +'&nbsp;&nbsp;&nbsp;';

		strtmp = '<a href="url" target="_blank"><img src="' + rootpath + 'images/icon_link.gif" border="0" alt="new pdf window" /></a>';
		tempUrl = thisArrPDFName[x].split("#");
		tempUrl1 = tempUrl[0] + pdfReaderOptions1 +'#'+ tempUrl[1];
		tempUrl1 = tempUrl1.replace("##", "#");
		tempUrl1 = tempUrl1.replace("&#", "&");

		tempUrl1 = tempUrl1.replace("view=FitBH", "view=FitBH&zoom=100");
		//alert(tempUrl1);
		strtmp = strtmp.replace("url", tempUrl1);

		tabs   += '&nbsp;' + strtmp;

		strtmp = '<a href="" onclick="javascript:return removePDFTab4(\''+ nameExtension +'\',url, \''+ pdfReaderOptions1 +'\', \''+ pdfReaderOptions2 +'\');"><img src="' + rootpath + 'images/icon_close-sm.gif" border="0" alt="close pdf" /></a>';
		strtmp = strtmp.replace("url", "'"+ thisArrPDFDesc[x] +"'");

		tabs   += strtmp;

		tabs   += '</div>';
	// }
	tabs += '<div style="display:inline;height:25px;line-height:22px;border:0px solid #ACA899;padding:5px;border-bottom:0px;">&nbsp;</div>';

	//alert('3b:'+iframeNumber);

	//thisDoc.getElementById('divtabPDF').style.display='';
	thisDoc.getElementById('pdfFrame'+ nameExtension +'-Controls' ).style.display='';
	thisDoc.getElementById('pdfFrame'+ nameExtension ).style.display='';
	thisDoc.getElementById('divfrmPDF'+ nameExtension ).style.display='';

	//alert('3.1:'+iframeNumber);
	//thisDoc.getElementById('ifrmPDF'+ nameExtension + iframeNumber).style.display='';

	//alert('4:'+iframeNumber);

	tempUrl2 = tempUrl[0] +pdfReaderOptions2 +'#'+ tempUrl[1];
	tempUrl2 = tempUrl2.replace("##", "#");
	tempUrl2 = tempUrl2.replace("&#", "&");

	//for the icon that opens up the pdf in a new window set the zoom=100% instead of view=FitBH
	tempUrl2 = tempUrl2.replace("view=FitBH", "zoom=100")

	//alert('5:'+iframeNumber);

	thisDoc.getElementById('pdfFrame'+ nameExtension +'-iconLinkAnchor' ).href=tempUrl2;

	tmpNameExtension = nameExtension.replace(/-/g,"");
	tmpNameExtension = tmpNameExtension.replace(".","");
	tmpNameExtension = "#pdfanc_"+tmpNameExtension;
	//alert('1:'+tmpNameExtension);

	//alert('3');
	if ( multipleSettings.indexOf('gotoanchortop=y') > -1 ) {
		try
		{
			thisDoc.getElementById(hrefClickedId).href = tmpNameExtension;
			returnValue1 = true;
			//alert('abc0');
		}
		catch(err)
		{
			//alert('abc1');
			returnValue1 = false;
		}

	} else {
		returnValue1 = false;
	}
	//alert('4');
	//alert('2:'+thisDoc.getElementById(hrefClickedId).href);

	//alert('7:'+tabs);
		//COMMENTED IT OUT July 10th 2007 by Eduardo.Sales (testing IE7 crashing)
	//thisDoc.getElementById('divtabPDF'+ nameExtension).innerHTML = tabs;



	//--- assigning values back to global pdf data container ---//
	arrPDFName[ nameExtension ] = thisArrPDFName;
	arrPDFDesc[ nameExtension ] = thisArrPDFDesc;
	arrPDFLink[ nameExtension ] = thisArrPDFLink;

	//alert('5.1');

	if ( thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber] ) {
		//alert('ifrmPDF'+ nameExtension);
		//thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location = 'pdflink.htm';
		//alert(thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location);
		//alert('existing: '+ thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location.href +'\n'+ 'new: '+ url1);

		//--- changed from 'about:blank' to 'void(0);' to fix https cert issues ---//
		//thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location.href = 'about:blank';
		//thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location.href = void(0);

		//thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location.href = 'blank_pdf.asp';

		//pausecomp(100) //pause to see if fix problem when switching between destination codes/closing/re-opening the same file
		currWinObj = thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber];

		//reloadPdfLocation( currWinObj, url1, '', hrefClickedIdSav );

		if( pdfReaderOptions2 != '' ){
			tempUrl = url1.split("#");
			tempUrl1 = tempUrl[0] +pdfReaderOptions2 +'#'+ tempUrl[1];
			tempUrl1 = tempUrl1.replace("##", "#");
			tempUrl1 = tempUrl1.replace("&#", "&");

			//tempUrl1 = tempUrl[0] +pdfReaderOptions2+ tempUrl[1];
		}else{
			tempUrl1 = url1;
		}

	//alert('6:');

	currWinObj = thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber];

	//////////////////////////////////////////////////////////////////////
	//IE7 for instance doesn't like when we use 'currWinObj.location.href'
	//////////////////////////////////////////////////////////////////////

	//FOR SOME REASON I HAD TO DUPLICATE THIS CODE IN HERE AS THE canUseFrameLocationHRef
	//VARIABLE WAS FAILING THE TEST "if ( canUseFrameLocationHRef == false )" IN IE7
	//WHEN A 2ND LINK WAS CLICKED ON THE PAGE. THAT'S WEIRD !!!!!!!!
	try
	{
		temp = currWinObj.location.href;
		canUseFrameLocationHRef	= true;
	}
	catch(err)
	{
		//alert('abc1');
		canUseFrameLocationHRef	= false;
	}
	//////////////////////////////////////////////////////////////////////

	var pdfManWinQty;
	//increment cookie variable that stores the number of open windows
	//(this can be used for postbacks to know that the scroll position of the bar will change as PDF windows won't be displayed on postbacks - see annotated agreement pop-up)
	try {
		//alert('pdf1:');
		pdfManWinQty = getCookie('pdfmanwinqty');
		if ( pdfManWinQty == '' ) {
			pdfManWinQty = '0';
		}
		pdfManWinQty = parseInt(pdfManWinQty)+1;
		pdfManWinQty = pdfManWinQty + ''; //convert to string
		//alert('pdf3:'+pdfManWinQty);
		setCookie('pdfmanwinqty', pdfManWinQty,1);
		//alert('pdf4:'+pdfManWinQty);
	}
	catch(errpdf1)
	{
	}

	//alert('7a:');

	//if ( canUseFrameLocationHRef == false ) {
	//	alert('7a:');
	//} else {
	//	alert('7b:');
	//}

	//alert('8a:'+tempUrl1);

	///////////////////////////////////////////////////////////////////////////////////////////
	//FOR IE7 (WHEN IS FIRST TIME THE IFRAME IS SET VISIBLE) OR FIREFOX: DO SOMETHING DIFFERENT
	///////////////////////////////////////////////////////////////////////////////////////////
	if ( IsBrowser("msie 7") || IsBrowser("firefox") || canUseFrameLocationHRef == false ) {

		//alert('8b:');

		
		//Commented by Hitech
		//currWinObj.location.href = '/blank.html';

		//alert('8c:');

		tmpNameExtension = nameExtension.replace(/-/g,"");
		tmpNameExtension = tmpNameExtension.replace(".","");

		// The "if" below is to fix a problem when using our widget window when the
		// type=iframe. The widget object's name is preceeded by "_iframe-"
		// and in this case we don't want to set the window location as it screws the window
		// alert('a');
		if ( window.name.toLowerCase().indexOf('_iframe-') == -1 && multipleSettings.indexOf('gotoanchortop=y') > -1 ) {
			document.location.href = "#pdfanc_"+tmpNameExtension;
		}
		//alert('b');

		//alert('8d:'+window.id+'/'+typeof(window)+'/'+window.name+'/'+window.document.name);

		currWinObj = thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber];
		for (tmpI = 1; tmpI < 1000; tmpI ++) {
			if ( document.getElementById('ifrmPDF'+ nameExtension + tmpI) != null ) {
				document.getElementById('ifrmPDF'+ nameExtension + tmpI).style.display='none';
			} else {
				break;
			}
		}

		//alert('d');

		//tempUrl1 = tempUrl1.replace('#','#page=1&');

		//alert('8e:'+tempUrl1);

		document.getElementById('ifrmPDF'+ nameExtension + iframeNumber).style.display='';
		tempUrl1 = fixZoomDestCode(tempUrl1);
		setTimeout( 'reloadPdfLocation( currWinObj, \''+ tempUrl1 +'\', \'\', hrefClickedIdSav )', 200);

		//alert('8f:'+thisDoc.getElementById(hrefClickedId).href);

		return returnValue1;
	}
	///////////////////////////////////////////////////////////////////////////////////////////

	//***************************************************
	currWinObj = thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber];

	//alert('8g:'+currWinObj);

	//alert('1:'+currWinObj.location.href);

//	if ( currWinObj.location.href != 'blank.html' && currWinObj.location.href != 'about:blank') {
//		alert('8h:'+currWinObj.location.href);
//		setTimeout( 'DisplayFrame( "ifrmPDF'+ nameExtension + iframeNumber + '", "ifrmPDF'+ nameExtension+'")', 200);
//		return returnValue1;
//	}
	//***************************************************

	//alert('10:'+currWinObj);

		/**************************************************************************************
		Some of the code below checking variables __ThisIsFirstLoad, __IsLoadingFile and
		and calling setTimeout() function is to avoid acrobat/browser problems when loading
		the PDFs, multiple problems were found like re-loading the same PDF attempting to
		go to another destination code, another problem was links not working, another problem
		was reader wouldn't load PDF in some situations where we click on different pdf links
		almost at the same time, attempts to increase the time of the setTimeOut() function
		seems to make some good difference as it was really low before (150)
		***************************************************************************************/

		//alert('8');

			tmpNameExtension = nameExtension.replace(/-/g,"");
			tmpNameExtension = tmpNameExtension.replace(".","");
			//alert("1: "+tmpNameExtension);
			//set the focus to the anchor moving the browse to the correct position avoiding problems when
			//the PDF icon is located on the bottom of the visible window

			//The "if" below is to fix a problem when using our widget window when the type=iframe. The widget object's name is preceeded by "_iframe-"
			//and in this case we don't want to set the window location as it screws the window
			//if ( window.name.toLowerCase().indexOf('_iframe-') == -1 && multipleSettings.indexOf('gotoanchortop=y') > -1 ) {
			//	parent.document.location.href = "#pdfanc_"+tmpNameExtension;
			//}
			//currWinObj.location.href = 'blank.html';
			//alert(tempUrl1);

			//alert('11:'+'ifrmPDF'+ nameExtension + iframeNumber + '/' + tempUrl1);

			//alert('11:' + document.getElementById('abascasdfas'));

			for (tmpI = 1; tmpI < 1000; tmpI ++) {
				if ( document.getElementById('ifrmPDF'+ nameExtension + tmpI) != null ) {
					document.getElementById('ifrmPDF'+ nameExtension + tmpI).style.display='none';
				} else {
					break;
				}
			}

			//currWinObj.style.display='';
			//alert('1: '+ currWinObj.location.href);
			//if ( currWinObj.location.href == 'blank.html' || currWinObj.location.href == 'about:blank') {
				//alert('2:'+currWinObj.location.href);

				tempUrl1 = fixZoomDestCode(tempUrl1);

				//currWinObj.location.href = 'blank.html';
				//alert('8h:'+'ifrmPDF'+ fixedNameExtension + iframeNumber);
				//document.getElementById('ifrmPDF'+ fixedNameExtension + iframeNumber).style.display='';
				//alert('8i:'+'ifrmPDF'+ nameExtension + iframeNumber);
                //Commneted by Hitech
				//currWinObj.location.href = 'blank.html';
				//document.getElementById('ifrmPDF'+ nameExtension + iframeNumber).style.display='';
				//alert('8j:'+hrefClickedId);
				setTimeout( 'reloadPdfLocation( currWinObj, \''+ tempUrl1 +'\', \'\', hrefClickedIdSav )', 300);
				//alert('8o:'+hrefClickedId);
			//} else {
			//	document.getElementById('ifrmPDF'+ nameExtension + iframeNumber).style.display='';
			//}

			//alert('8p:');


			//load the pdf
			//reloadPdfLocation(currWinObj, tempUrl1, '', hrefClickedIdSav);

		//--- adobe reader needs a delay to refresh cache of current reader ---//
//		if ( __ThisIsFirstLoad == true ) {
//			tmpNameExtension = nameExtension.replace(/-/g,"");
//			tmpNameExtension = tmpNameExtension.replace(".","");
//			//alert("1: "+tmpNameExtension);
//			//set the focus to the anchor moving the browse to the correct position avoiding problems when
//			//the PDF icon is located on the bottom of the visible window
//			parent.document.location.href = "#pdfanc_"+tmpNameExtension;
//			//load the pdf
//			reloadPdfLocation(currWinObj, tempUrl1, '', hrefClickedIdSav);
//
//		} else {
//
//			tmpNameExtension = nameExtension.replace(/-/g,"");
//			tmpNameExtension = tmpNameExtension.replace(".","");
//			//alert("2: "+tmpNameExtension);
//			//set the focus to the anchor moving the browse to the correct position avoiding problems when
//			//the PDF icon is located on the bottom of the visible window
//			parent.document.location.href = "#pdfanc_"+tmpNameExtension;
//			if ( __IsLoadingFile == true ) {
//				//clearTimeout(500);
//				//clearTimeout(3000);
//				while (__IsLoadingFile == true) {
//					var ix;
//					ix = 0;
//					//alert('1');
//				}
//				setTimeout( 'reloadPdfLocation( currWinObj, \''+ tempUrl1 +'\' , \'\', hrefClickedIdSav)', 250);
//			} else {
//				setTimeout( 'reloadPdfLocation( currWinObj, \''+ tempUrl1 +'\' , \'\', hrefClickedIdSav)', 250);
//			}
//		}

		__ThisIsFirstLoad = false;
		//setTimeout( 'reloadPdfLocation( currWinObj, \''+ tempUrl1 +'\' , \'\', hrefClickedIdSav)', 150);

		//thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location.href = url1;
		//pausecomp(200) //pause to see if fix problem when switching between destination codes/closing/re-opening the same file
		//alert(thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location.href);
		//thisWin.frames['ifrmPDF'+ nameExtension + iframeNumber].location.reload(  );

//alert('13:');

		return returnValue1;
	} else return returnValue1;

}

//this function solves a problem with the fast load which is sometimes caused by the diference of the zooming from the destination codes and the
//one that is set by 'view=FitBH', the destination codes seem to be set at a 93% zoom which needs to be matched up, but when loading a PDF file
//to its first page there's no need to match anything as we are not jumping to any destination code so 'view=FibBH' is ok.

//THIS FUNCTION IS CAUSING THE FREEZE ISSUE
function fixZoomDestCode(tempUrl1) {
	var t1, tmpI;

	tmpI= tempUrl1.lastIndexOf('&');
	if ( tmpI > -1 ) {
		t1	= tempUrl1.substring(tmpI);
		//alert('1:'+t1);
		if ( t1.indexOf("=") == -1 ) {
			//alert(tempUrl1);
			//if ( IsBrowser("msie 7") ) {
			tempUrl1 	= tempUrl1.replace('view=FitBH&','');
			//}
			//alert(tempUrl1);
			//tempUrl1 	= tempUrl1.replace('view=FitBH','zoom=93');
		} else {
			tempUrl1 	= tempUrl1.replace('&Page=1','');
		}
		//alert('2:'+tempUrl1);
	}
	return tempUrl1;
}

function IsBrowser(browserNameVersion) {
	browserNameVersion = browserNameVersion.toLowerCase();
	if ( navigator.userAgent.toLowerCase().indexOf(browserNameVersion) > -1 ) {
		return true;
	}
	return false;
}

function DisplayFrame(frameName, partName) {
	var currWinObj;

	currWinObj = window.frames[frameName];

	//alert('1aa:'+partName);
	//alert('1bb:'+currWinObj.location.href);
	if ( currWinObj.location.href != 'blank.html' && currWinObj.location.href != 'about:blank') {
		for (tmpI = 1; tmpI < 1000; tmpI ++) {
			if ( document.getElementById(partName + tmpI) != null ) {
				//alert('8a:');
				document.getElementById(partName + tmpI).style.display='none';
			}
		}
		//alert('9a:');
		document.getElementById(frameName).style.display='';
		//alert('9aa:'+frameName);
		return false;
	}
	document.getElementById(frameName).style.display='';
	//alert('9bb:'+frameName);
	return false;
}

function reloadPdfLocation( winObj, pdfLocationHref, pdfOpenParameters, hrefClickedId ) {
	var lastpos

	//__IsLoadingFile = true;

	for(args=0;args<arguments.length;args++){
		//alert(arguments[args]);
	}

	//alert(pdfLocationHref);
	var thisPdfLocationHref = '';

	if( !isUndefined( pdfLocationHref ) ){
		thisPdfLocationHref = pdfLocationHref;
	}

	if( !isUndefined( pdfOpenParameters ) ) {
		if ( pdfOpenParameters != '' ) {
			thisPdfLocationHref = thisPdfLocationHref +'#'+ pdfOpenParameters;
		}
	}

	if( thisPdfLocationHref != '' ){
		lastpos = thisPdfLocationHref.lastIndexOf('#');
		if ( lastpos <= -1 )
			thisPdfLocationHref += '#';

		//thisPdfLocationHref += 'asdfasdfasdf';
		//thisPdfLocationHref += '&view=FITBH,left';
		//thisPdfLocationHref += '&zoom=80,240,0';
		//thisPdfLocationHref += '&viewrect=20,20,420,520';

		//thisPdfLocationHref = "/documents/documents/DS267 (AB).pdf#toolbar=0&navpanes=0&statusbar=0&WT/DS267/AB/R,pa370&view=FitBH";

		//thisPdfLocationHref = thisPdfLocationHref.replace('view=FitBH','view=FitBH');

		//thisPdfLocationHref += '&scrollbar=1';
		//thisPdfLocationHref += '&zoom=80';
		thisPdfLocationHref = thisPdfLocationHref.replace('view=FitBH','view=FitBH&scrollbar=1&zoom=80&');

		//alert('a:' + thisPdfLocationHref);

		winObj.location.href = thisPdfLocationHref;

		//the line below (check) is necessary as the line below when called by a link within the PDF may fail if we remove it
		if ( document.getElementById(winObj.name) ) {
			document.getElementById(winObj.name).style.display='';
		}

		//initfocus();
		//winObj.focus();
		//document.getElementById(hrefClickedId).focus();
		//setTimeout('setfocus1("'+hrefClickedId+'",1,-1)', 100);

		//alert('1:'+hrefClickedId);
		//alert('2:'+hrefClickedId);

		//alert('1:' + winObj.name + '/' + winObj.offsetTop + '/' + winObj.offsetLeft);
		//document.getElementById(winObj.name).scrollBy(260, 300);
		//setTimeout('test11aa(\''+winObj.name+'\')',500);

		//setTimeout('scroll_iframe(\''+winObj.name+'\',300,\'h\')',300);

		//setTimeout('winObj.scrollBy(1200, 0)',2500);
		//alert('2:' + winObj.name + '/' + winObj.offsetTop + '/' + winObj.offsetLeft);

	}

	//alert('0:');
	//alert('1:'+winObj.document.all.length);
	//alert('2:'+winObj.document.all.length);

	//alert(thisPdfLocationHref);
	//alert(winObj.location.href);

	//winObj.location.reload( );

	//__IsLoadingFile = false;

	return true;
}

function setfocus1(hrefClickedId,seq,toppos) {
	var tmp;
	if ( toppos != -1 && GetScrollPosition("top") != toppos ) {
		return false;
	}
	document.getElementById(hrefClickedId).focus();
	seq = seq + 1;
	if ( seq < 200 ) {
		tmp = 'setfocus1("'+hrefClickedId+'",'+seq+','+GetScrollPosition("top")+')';
		//alert(tmp);
		setTimeout(tmp, 250);
		//alert(seq);
	}
	return false;
}

function initfocus()
{
	var controller = document.commandDispatcher;
	//controller.rewindFocus();
	//alert('a:'+controller);
	//ownerDocument.commandDispatcher.advanceFocus()
	//controller.advanceFocus();
	//addEventListener("focus",setFocusedElement,true);
}

//function setFocusedElement()
//{
//  var focused = document.commandDispatcher.focusedElement;
//  //document.getElementById("focused").value = focused.tagName;
//  alert('abc:'+focused.tagName);
//}

var timer_id;
function scroll_iframe(frm,inc,dir) {
	//alert('1');
	if (timer_id) clearTimeout(timer_id);
	//if (inc>500) return;
	if (window.frames[frm]) {
		if (dir == "v") {
			window.frames[frm].scrollBy(0, inc);
		}
		else {
			window.frames[frm].scrollBy(inc, 0);
			alert('2:'+frm+'/'+window.frames[frm].src);
		}
		//alert('2:'+frm+'/'+window.frames[frm].src);
		//timer_id = setTimeout("scroll_iframe('" + frm + "'," + parseInt(parseInt(inc)+parseInt(50)) + ",'" + dir + "')", 20);
	}
}

function stopScroll() { if (timer_id) clearTimeout(timer_id); }

function test11aa(a) {
	alert(a);
	//window.frames[a].scrollTo(-20, -10);
	window.frames[a].scrollBy(-50, 0);
	//window.frames[a].scrollBy(0, 10);
	//document.getElementById(a).scrollBy(160, 0);
	alert(a);
}


function loadPdfFile2( pdfFile, destCode, targetwin ){
	if ( isEmpty(destCode) ) {
		destCode = 'Page=1' //when there's not destination code issue command to go to the 1st page in the file
	}

	if ( targetwin == '' )  {
		targetwin = 'pdfWin'
	}

	pdfURL = pdfFile + '#' + destCode

	//the pdflink.htm page is just an empy page to fix problems while loading pdf files multiple times in the same open window
	pdfWinObj = window.open('pdflink.htm', targetwin)
	//refreshTarget(targetwin)

	//pausecomp(200) //pause to see if fix problem when switching between destination codes/closing/re-opening the same file
	pdfWinObj = window.open(pdfURL, targetwin)
	//pausecomp(100) //pause to see if fix problem when switching between destination codes/closing/re-opening the same file
	//pdfWinObj.location.reload()
	pdfWinObj.focus()

	lastPdfFile = pdfFile
	lastDestCode= destCode

	return false;

//	return
}

function divController( divID, action ){
//---- Arguments:
//---- divID String = name of div
//---- action String = expand or collapse

	if( action == 'expand' ){
		divWidth = '';
		divHeight = '';
		divDisplay = '';
	}else if( action == 'collapse' ){
		divWidth = '';
		divHeight = '20px';
		divDisplay = 'none';
	}else if( action == 'expandWidth' ){
		divWidth = 95;
		divHeight = '';
		divDisplay = 'none';
	}else if( action == 'collapseWidth' ){
		divWidth = 50;
		divHeight = '';
		divDisplay = 'none';
	}else{
		return;
	}

	switch( divID ){

		case 'topFrame':
			//document.getElementById('topFrame').style.width= (divWidth/2)+'%';
			//document.getElementById('topFrame').style['width']= divWidth+'%';
			document.getElementById('topFrame').style.height=divHeight;
			//document.getElementById('topFrameControls').style.width=divWidth;
			break;
		case 'pdfFrame':
			document.getElementById('divtabPDF').style.display=divDisplay;
			document.getElementById('divfrmPDF').style.display=divDisplay;
			//document.getElementById('pdfFrame').style.width=divWidth;
			document.getElementById('pdfFrame').style.height=divHeight;
			//document.getElementById('pdfFrame').style.textAlign='right';
			break;
		default:

			break;
	}

}

function divController4( divID, action ){
//---- Arguments:
//---- divID String = name of div
//---- action String = expand or collapse

	//alert(arguments[0] +'\n'+ arguments[1]);
	//return false;

	//alert('1:'+divID);

	divIDParts = divID.split("-")
	ifrmIDParts = divID.split("-")

	if( action == 'expand' ){
		divWidth = '';
		divHeight = '';
		divDisplay = '';
	}else if( action == 'collapse' ){

		//alert('2');
		divWidth = '';
		divHeight = '20px';
		divDisplay = 'none';

		ifrmIDParts = ifrmIDParts.splice(1,2);
		ifrmIDParts.unshift("ifrmPDF");
		ifrmID = ifrmIDParts.join('-');

		if ( thisWin.frames[ ifrmID ] ) {
			thisWin.frames[ifrmID].location.href = void(0);
			thisWin.frames[ifrmID].location.href = 'blank_pdf.asp';
		}

		//alert('2.9');

	}else if( action == 'expandWidth' ){
		divWidth = 95;
		divHeight = '';
		divDisplay = 'none';
	}else if( action == 'collapseWidth' ){
		divWidth = 50;
		divHeight = '';
		divDisplay = 'none';
	}else if( action == 'display' ){
		divDisplay = '';
	}else{
		return;
	}

	switch( divIDParts[0] ){

		case 'topFrame':
			//document.getElementById('topFrame').style.width= (divWidth/2)+'%';
			//document.getElementById('topFrame').style['width']= divWidth+'%';
			document.getElementById('topFrame').style.height=divHeight;
			//document.getElementById('topFrameControls').style.width=divWidth;
			break;
		case 'divtabPDF':
			document.getElementById('divtabPDF-'+ divIDParts[1] +'-'+ divIDParts[2]).style.display=divDisplay;
			break;
		case 'pdfFrame':
			/*alert(
				'ifrmPDF-'+ divIDParts[1] +'-'+ divIDParts[2] +'\n'+
				'divfrmPDF-'+ divIDParts[1] +'-'+ divIDParts[2] +'\n'+
				'pdfFrame-'+ divIDParts[1] +'-'+ divIDParts[2] +'\n'
			);*/
			//alert( document.getElementById('pdfFrame-'+ divIDParts[1] +'-'+ divIDParts[2]) );
			//alert( document.getElementById('pdfFrame-'+ divIDParts[1] +'-'+ divIDParts[2] +'-Controls') );
			//alert('pdfFrame-'+ divIDParts[1] +'-'+ divIDParts[2] +'-Controller');
			//document.getElementById('divtabPDF').style.display=divDisplay;
			//document.getElementById('ifrmPDF-'+ divIDParts[1] +'-'+ divIDParts[2]).style.display=divDisplay;
			//document.getElementById('divfrmPDF-'+ divIDParts[1] +'-'+ divIDParts[2]).style.display=divDisplay;

			//alert('3.1:'+'pdfFrame-'+ divIDParts[1] +'-'+ divIDParts[2]);


			document.getElementById(divID).style.display=divDisplay;

			//alert('3.2:'+'pdfFrame-'+ divIDParts[1] +'-'+ divIDParts[2] +'-Controls');

			document.getElementById(divID+'-Controls').style.display=divDisplay;
			//document.getElementById('pdfFrame-'+ divIDParts[1] +'-'+ divIDParts[2]).style.display=divDisplay;

			//document.getElementById('pdfFrame-'+ divIDParts[1] +'-'+ divIDParts[2] +'-Controls').style.display=divDisplay;

			//alert('3.9');
			//document.getElementById('pdfFrame').style.width=divWidth;
			//document.getElementById('pdfFrame').style.textAlign='right';
			break;
		default:

			break;
	}

//alert('99');

	return false;
}


function divController2( divType, action, winObj ){
//---- Arguments:
//---- divType String = name of divType [ top or pdf ]
//---- action String = expand, expandWidth, collapse or collapseWidth



	thisWin = window;
	thisDoc = window.document;

	if( !isUndefined(winObj) && isObject( winObj ) ){

		thisWin = winObj;
		thisDoc = winObj.document;

	}




	//alert( divType +', '+ action +', '+ thisWin.name );

	if( action == 'expand' ){
		divWidth = '';
		divHeight = '';
		divDisplay = '';
	}else if( action == 'collapse' ){
		divWidth = '';
		divHeight = '20px';
		divDisplay = 'none';

	}else if( action == 'display' ){

		if( divType == 'pdf' ){

			if( isNull( thisDoc.getElementById( 'pdfHorizDiv') ) || isUndefined( thisDoc.getElementById( 'pdfHorizDiv') ) )
				return;

			thisElIdStyleObj = thisDoc.getElementById( 'pdfHorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '49%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );



			thisElIdStyleObj = thisDoc.getElementById( 'topHorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '49%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );



		}

	}else if( action == 'hide' ){

		if( divType == 'pdf' ){

			if( isNull( thisDoc.getElementById( 'pdfHorizDiv') ) || isUndefined( thisDoc.getElementById( 'pdfHorizDiv') ) )
				return;

			thisElIdStyleObj = thisDoc.getElementById( 'pdfHorizDiv').style;
			controlAdjustor( thisElIdStyleObj, 'display', 'none' );


			thisElIdStyleObj = thisDoc.getElementById( 'topHorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '100%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );


		}



	}else if( action == 'expandWidth' ){

		//differentDiv that need to be controlled
		// divType +'HorizDiv'
		// divType +'FrameControls'
		//'mainLegend'
		// divType +'Frame'

		//divWidth = '95%';
		//divHeight = '';
		//divDisplay = 'none';

		thisElIdStyleObj = thisDoc.getElementById( 'mainLegend').innerHTML = 'Agreement Annotator';

			thisElIdStyleObj = thisDoc.getElementById( 'topHorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '49%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );


			thisElIdStyleObj = thisDoc.getElementById( 'pdfHorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '49%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

		/*
		if( divType == 'top' ){

			thisElIdStyleObj = thisDoc.getElementById( divType +'HorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '48%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( 'mainLegend').style;
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = document.getElementById( 'divfrmAnnot' ).style;
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( divType +'FrameControls').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '95%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( 'pdfHorizDiv').style;
			if( thisElIdStyleObj.width.length>0 )
				controlAdjustor( thisElIdStyleObj, 'width', '' );

		}else if( divType == 'pdf' ){

			thisElIdStyleObj = thisDoc.getElementById( divType +'HorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '48%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( divType +'Legend').style;
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( 'divtabPDF' ).style;
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( 'divfrmPDF' ).style;
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( divType +'FrameControls').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '94%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( 'topHorizDiv').style;
			if( thisElIdStyleObj.width.length>0 )
				controlAdjustor( thisElIdStyleObj, 'width', '' );




		}else{
			return;
		}

		*/
	}else if( action == 'collapseWidth' ){
		divWidth = 50;
		divHeight = '';
		divDisplay = 'none';



		if( divType == 'top' ){


			//thisElIdStyleObj = thisDoc.getElementById( 'mainLegend').style;
			//controlAdjustor( thisElIdStyleObj, 'display', 'none' );

			thisElIdStyleObj = thisDoc.getElementById( 'mainLegend').innerHTML = 'Annotator';


			thisElIdStyleObj = thisDoc.getElementById( divType +'HorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '19%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( 'mainLegend').style;
			//controlAdjustor( thisElIdStyleObj, 'display', 'none' );

			thisElIdStyleObj = thisDoc.getElementById( 'divfrmAnnot' ).style;
			//controlAdjustor( thisElIdStyleObj, 'display', 'none' );

			thisElIdStyleObj = thisDoc.getElementById( divType +'FrameControls').style;
			controlAdjustor( thisElIdStyleObj, 'zIndex', '10' );


			thisElIdStyleObj = thisDoc.getElementById( 'pdfHorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '78%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			//thisElIdStyleObj = thisDoc.getElementById( 'pdfLegend').style;
			//controlAdjustor( thisElIdStyleObj, 'display', '' );

		}else if( divType == 'pdf' ){


			//thisElIdStyleObj = thisDoc.getElementById( divType +'Legend').style;
			//controlAdjustor( thisElIdStyleObj, 'display', 'none' );

			thisElIdStyleObj = thisDoc.getElementById( divType +'HorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '19%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			thisElIdStyleObj = thisDoc.getElementById( 'mainLegend').style;
			//controlAdjustor( thisElIdStyleObj, 'display', 'none' );

			thisElIdStyleObj = thisDoc.getElementById( 'divfrmAnnot' ).style;
			//controlAdjustor( thisElIdStyleObj, 'display', 'none' );

			thisElIdStyleObj = thisDoc.getElementById( divType +'FrameControls').style;
			controlAdjustor( thisElIdStyleObj, 'zIndex', '10' );


			thisElIdStyleObj = thisDoc.getElementById( 'topHorizDiv').style;
			//controlAdjustor( thisElIdStyleObj, 'height', '' );
			controlAdjustor( thisElIdStyleObj, 'width', '78%' );
			controlAdjustor( thisElIdStyleObj, 'display', '' );

			//thisElIdStyleObj = thisDoc.getElementById( 'mainLegend').style;
			//controlAdjustor( thisElIdStyleObj, 'display', '' );



			thisElIdStyleObj = thisDoc.getElementById( 'mainLegend').innerHTML = 'Agreement Annotator';

		}else{
			return;
		}

	}else{
		return;
	}

/*
	switch( divID ){

		case 'topFrame':
			//document.getElementById('topFrame').style.width= (divWidth/2)+'%';
			//document.getElementById('topFrame').style['width']= divWidth+'%';
			document.getElementById('topFrame').style.height=divHeight;
			//document.getElementById('topFrameControls').style.width=divWidth;
			break;
		case 'pdfFrame':
			document.getElementById('divtabPDF').style.display=divDisplay;
			document.getElementById('divfrmPDF').style.display=divDisplay;
			//document.getElementById('pdfFrame').style.width=divWidth;
			document.getElementById('pdfFrame').style.height=divHeight;
			//document.getElementById('pdfFrame').style.textAlign='right';
			break;
		default:

			break;
	}
*/
}


function controlAdjustor( elIdStyleObj, styleProp, propValue ){
	elIdStyleObj[ styleProp ]=propValue;
}

function refWinObj( winName, winLocation ){
	//----- references the window object given the 'name' of the window ------//
	//----- if it does not exist, opens a new window ------//
	//----- Argument(1): STRING winName - name of window -----//
	//----- Argument(2): STRING winLocation - URL of popup if window does not exist -----//

		//winObj = window[ winName ];
		//alertArgs( refWinObj.arguments, 'refWinObj' );

		//if( isUndefined(winObj) ){
			//demoPdfWin( 'demopdf.asp?toc=pdfViewer&demoID=demo3' );

			//----- IE wont allow opening a blank window (pop-up blocker) ------//
			winObj = window.open('',winName,'');

			//locationArray = String(winObj.location).split("/");
			//locationStr = locationArray[locationArray.length-1];
			//alert(	String(winObj.location) );

			//at this point there should be a pop-up - if not it has been blocked
			if( ! isObject(winObj) ){
				alert('This site requires pop-ups. Please allow all popups and try again.');
				//return false;
			}

			//--- change from 'about:blank' to 'blank.html' to resolve https cert issues ---//
			//if( String(winObj.location)=='about:blank' ){
			//if( String(winObj.location)=='about:blank' ){
				//alert('blank');
				//alert( winObj.arrPDFName );

				//----- IE pop-up blocker takes affect when attempting to close window ------//
				//if( isObject(winObj) )
				//	winObj.close();

				//----- IE's pop-up blocker ignores pop-up when changing the location right away to it's own domain ------//
				//alert('aa:');
				//winObj = demoPdfWin( winLocation );
			//}else{
				//alert(winObj);
				if( isObject(winObj) )
					winObj.focus();
			//}


			//alert(winObj.location);

		//}else if( winObj.closed ){
			//alert('CLOSED');
		//	winObj = demoPdfWin( 'demopdf.asp?toc=content&demoID=demo1' );
		//}

		//alert(winObj.location);

		//alert( winObj.name );

		//------ need to set timeout allow the browser time to change iframe content ------//

		return winObj;

}

function refWinObj_updateIframe( winObj, winObjIfrmName, pdfUrlStr ){
	//----- updates the iFrame of the given window object reference ------//
	//----- Arguments: OBJECT winObj - object reference of window with iFrame -----//

	//alertArgs( refWinObj_updateIframe.arguments, 'refWinObj_updateIframe' );
	//------- global variable is set back to default ------//
	iframeNOTUpdatedBool = false;
	if( isObject(winObj) ){

		//----- update iframeUpdatedBool variable based on the success of loadPDFframe ----//
		iframeUpdatedBool = !loadPDFIframe( winObjIfrmName, pdfUrlStr, winObj );

	}

	return iframeUpdatedBool;
}

function openPdfManager( pdfURL, winObjName, winObjLocation, winObjIframeName ){

	//alert('1');
	//alert( pdfURL +', '+ winObjName +', '+ winObjLocation +', '+ winObjIframeName );

	if( isUndefined( winObjIframeName ) )
		winObjIframeName = 'ifrmPDF';

	//alertArgs( openPdfManager.arguments, 'openPdfManager' )

	//alert('2'+winObjLocation);
	tempWinObj = refWinObj( winObjName, winObjLocation );

	//alert('3'+pdfURL);
	divController2( 'pdf', 'display', tempWinObj );

	//refWinObj_updateIframe( tempWinObj, winObjIframeName, pdfURL );
	setTimeout('refWinObj_updateIframe( tempWinObj, \''+ winObjIframeName +'\', \''+ pdfURL +'\' )',500);

	setTimeout('pdfManagerError( \''+ pdfURL +'\' )',500);

	//alert('4');

	//------ always returns false - pdfManagerError function will determine if the iframe was updated successfully ----//
	return false;

}

function pdfManagerError( pdfURL ){
	//----- if there was a problem updating the iframe - load the pdf in current window -----//
	if( iframeUpdatedBool == false ) document.location.href = pdfURL;
}

function alertArgs( argsArray, functionName ){

	tempArgStr = '';
	for( k=0;k<argsArray.length;k++ ){
		if( isUndefined(argsArray[k]) )
			tempArgStr += '['+ k +']='+ String(typeof argsArray[k]).toUpperString +',\n';
		else
			tempArgStr += '['+ k +']='+ argsArray[k] +',\n';
	}
	tempArgStr = 'function <<'+ functionName +'>> arguments:\n'+ tempArgStr
	alert(tempArgStr);

}


function isObject(a){
	return (typeof a == 'object' && !!a) || isFunction(a);
}

function isUndefined(a){
	return typeof a == 'undefined';
}

function isNull(a){
	return a === null;
}

function isFunction(a){
		return typeof a == 'function';
}








/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["ifrmAnnot", "ifrmPDF"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {

	var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById)
			resizeIframe(iframeids[i])
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no"){
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			tempobj.style.display="block"
		}
	}
}

function resizeIframe(frameid){

	var currentfr=document.getElementById(frameid)
	if (currentfr && !window.opera){
		currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight){ //ns6 syntax
			//alert(frameid +' (ns6): '+ currentfr.contentDocument.body.offsetHeight+FFextraHeight);
			//alert(frameid +' (ns6): '+ document.body.offsetHeight);
			//currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
			currentfr.height =  currentfr.contentDocument.body.offsetHeight+FFextraHeight;
		}else if (currentfr.Document && currentfr.Document.body.scrollHeight){ //ie5+ syntax
			//alert(frameid +' (ie5): '+ document.body.scrollHeight);
			//currentfr.height = currentfr.Document.body.scrollHeight;
			//currentfr.height =  currentfr.height - 100;
		}

		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent){
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
	}
}

function readjustIframe(loadevt) {
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot)
		resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
	if (document.getElementById)
		document.getElementById(iframeid).src=url
}
/*
if (window.addEventListener)
	window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
	window.attachEvent("onload", resizeCaller)
else
	window.onload=resizeCaller


*/
if (window.addEventListener)
	window.addEventListener("load", resizeIframes, false)
else if (window.attachEvent)
	window.attachEvent("onload", resizeIframes)
else
	window.onload=resizeIframes

if (window.addEventListener)
	window.addEventListener("resize", resizeIframes, false)
else if (window.attachEvent)
	window.attachEvent("onresize", resizeIframes)
else
	window.onresize=resizeIframes




function windowSize( xORy ) {

	winH = 0;
	winW = 0;
	if (parseInt(navigator.appVersion)>3) {
	if (navigator.appName=="Netscape") {
		winH = window.innerWidth;
		winW = window.innerHeight;
	}
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		//winW = document.body.offsetWidth;
		// winH = document.body.offsetHeight;

		winW = '87%';
		winH = '87%';

	}
	}


	if( 'x' )
	return winW;

	if( 'y' )
		return winH;

	//window.alert( 'Width = ' + myWidth );
	//window.alert( 'Height = ' + myHeight );
}





var topHeight = '0px';
var pdfHeight = '0px';

function resizeIframes(){

	//alert( windowSize( 'y' ) );

	currWinHeight = windowSize( 'y' );
	currWinHeightStr = new String(currWinHeight)
	//alert( currWinHeight +'  '+  currWinHeightStr.indexOf("%") );

	if( currWinHeightStr.indexOf("%") < 0 ){
		topHeight = windowSize( 'y' )-100 +'px';
		pdfHeight = windowSize( 'y' )-96 +'px';

	}else{

		topHeight = '87%';
		pdfHeight = '87.80%';

		if( String(window.name) != 'contentdemo2BWin' ){
				return;
		}else{
			if( isObject(refWinObj('contentdemo2BWin')) )
				refWinObj('contentdemo2BWin').document.getElementById("ifrmPdf").style.height = '98%';
		}

	}


	//alert(newHeight);
	//document.getElementById('topHorizDiv').style.height = newHeight;
	//document.getElementById('pdfHorizDiv').style.height = newHeight;

	//alert(window.name);

	//alert( String(window.name) +' != '+ 'contentdemo2BWin' );
	if( String(window.name) != 'contentdemo2BWin' ){
		return;
	}

	//alert( refWinObj('contentdemo2BWin').document.getElementById("topHorizDiv").style.height );

	//alert('why');

	//alert(topHeight);

	if( isObject(refWinObj('contentdemo2BWin')) ){

		refWinObj('contentdemo2BWin').document.getElementById("topHorizDiv").style.height = topHeight;
		refWinObj('contentdemo2BWin').document.getElementById("pdfHorizDiv").style.height = pdfHeight;
	}

	//setTimeout('refWinObj(\'contentdemo2BWin\').document.getElementById("topHorizDiv").style.height = topHeight;',1000);
	//setTimeout('refWinObj(\'contentdemo2BWin\').document.getElementById("pdfHorizDiv").style.height = pdfHeight;',1000);
	//setTimeout('alert(\'done\');',2000);


	//document.getElementById('ifrmAnnot').style.height = windowSize( 'y' )-489;
	//document.getElementById('ifrmAnnot').height = windowSize( 'y' )-489;

	//document.getElementById('ifrmPDF').style.height = windowSize( 'y' )-518;
	//document.getElementById('ifrmPDF').height = windowSize( 'y' )-518;
	//alert('done');
}


function printIframes(){


	window.print();

	iframLocationArray = new Array();
	iframCounter = 0;

	for( ifrmIndx=0;ifrmIndx<window.frames.length;ifrmIndx++ ){
		//currIframeLoc = window.frames[ifrmIndx].location;
		currIframeLoc = new String( window.frames[ifrmIndx].location )
		//alert( currIframeLoc.indexOf("undefined") );
		//alert( window.frames[ifrmIndx].location );

		if( isUndefined( currIframeLoc ) != true && currIframeLoc != 'about:blank' && currIframeLoc.indexOf("undefined") < 0 && currIframeLoc != 'blank.html'  && currIframeLoc.indexOf("blank_pdf.asp") < 0 ){
			iframLocationArray[iframCounter] = ifrmIndx;
			iframCounter++;
		}

	}


	if( iframLocationArray.length > 0 ){
		if(confirm("Would you like to print the open PDFs as well?")){
			for(pdfLocIndx=0;pdfLocIndx<iframLocationArray.length;pdfLocIndx++){
				window.frames[pdfLocIndx].print();
			}
		}
	}


}


// -->


/* XML FUNCTIONS */
function loadXMLframe( divName ){
	var divId, ifrmObj;
	//alert('1');
	divId = 'divfrmXML-'+divName;

	//here temp
	//alert('1a:' + window.frames['ifrmXML-'+ divName].location.href );
	//window.frames['ifrmXML-'+ divName].location.href = window.frames['ifrmXML-'+ divName].location.href.replace('#abc','#Art1');
	//alert('2a:' + window.frames['ifrmXML-'+ divName].location.href );
	//here temp
	var URL1 = window.frames['ifrmXML-'+ divName].location.href;

	ifrmObj = window.frames['ifrmXML-'+ divName];
	ifrmObj.location.href = 'blank.html';

	//alert('1:');
	var urlfinal = "reloadXMLLocation('" + divName + "'," + "'" + URL1 + "','')";
	//alert('1a:'+urlfinal);
	setTimeout(urlfinal,250);

	window.document.getElementById(divId).style.display='';
	window.document.getElementById(divId).focus();

	//window.frames['ifrmXML-'+ divName].location.reload(); //Pre1

	//window.document.getElementById(divId).reload();
	//alert('2');
	//thisDoc.getElementById('xmlFrame-'+divName).style.display='';
	//thisDoc.getElementById('divtabXML-'+divName).style.display='';
	//thisDoc.getElementById('divtabXML-'+divName).focus();
	return false;
}

function reloadXMLLocation(divId, url1, smartcookie) {
	var currWinObj, retcookie;

	//alert('2a:'+'divfrmXML-'+divId + ' / ' +window.document.getElementById('divfrmXML-'+divId));

	window.document.getElementById('divfrmXML-'+divId).style.display='';

	//alert('2b:'+'divfrmXML-'+divId);

	currWinObj = window.frames['ifrmXML-'+divId];
	//alert('0');
	//setTimeout('SaveScrollPosition("temp")',5);

	retcookie = retCookie("SmartNavTree");
	if ( retcookie == null ) {
		retcookie = '';
	}
	//alert('3:'+url1);
	retcookie = retcookie.toLowerCase();
	if ( retcookie == "n" ) {
		//when smart navigation is the normal mode we have to avoid the browser positioning on the iframe as like being an anchor as this is not the
		//desired behaviour
		//alert('4'+retCookie("SmartNavTree"));

		SaveScrollPositionSimple('temp1');
		currWinObj.location.href = url1;

	}
	else {
		currWinObj.location.href = url1;
	}
	//alert('4:'+url1);
	//setTimeout('RestoreScrollPosition("temp",-1)',1400);
	//alert('3');

	//alert('99:'+currWinObj.location.href);
	return false;
}

function checkxmlunload() {
	var vtop,vleft,retcook;
	//alert('1:');
	retcook = retCookie("SmartNavTree");
	if ( retcook == null ) {
		retcook = '';
	}
	if ( retcook.toLowerCase() == "n" ) {
		vtop = getCookie('temp1_top');
		vleft= getCookie('temp1_left');
		parent.scrollTo(vleft, vtop); // determined during run-time
		//alert('6:'+vleft+'/'+vtop);
		//alert('7:'+vleft+'/'+vtop);
		//setTimeout('RestoreScrollPositionSimple("temp1")',1000);
	}
	return true;
}


//function checkFrame(idFrame) {
//	var iframe = document.frames[idFrame];
//	if(iframe == null) {
//  	//alert('Frame not found');
//  	return false;
//  }
//  else {
//    if(iframe.document == null)
//        //alert('Frame exists, but page has not yet loaded');
//        return false;
//    else
//        //alert('Frame exists, and page is loaded!');
//        return true;
//  }
//  return false;
//}

function hidediv( divId ) {
	//alert('1a:' +divId);
	window.document.getElementById(divId).style.display='none';
	//alert('2');
	return false;
}

