// ========================================================================
// Page Initialise
// ======================================================================== 
var bV = parseInt(navigator.appVersion); 
var IE4 = false; 
var NS4 = false; 
var NS6 = false; 
var OPR = false;
if (document.layers){
   NS4 = true
}else if ((document.all) && (bV >= 4)){ 
	  IE4 = true;
	if(navigator.userAgent.indexOf('Opera') > -1){
		OPR = true;
	}
}else if (document.getElementById){ 
	  NS6 = true;
}
ver4 = (NS4 || IE4 || NS6 ) ? true : false; 
isExpanded = false; 
imgBlockOff = new Image();
imgBlockOn = new Image();
imgBlockOff.src = "" + imgblock_off_full;
imgBlockOn.src = "" + imgblock_on_full;
// ========================================================================
// Display Operations
// ========================================================================
// ************************************
// Flash Error (IE)
// ************************************
function errorflashie(obj) {
	obj.outerHTML = "<img src=\"" + obj.getAttribute("path", 0) + obj.getAttribute("altfile", 0) + "\" border=\"0\" />";
}
// ************************************
// Flash Error (NS)
// ************************************
function errorflashns(elt) {
	with (navigator) if (appName.indexOf('Microsoft') == -1 || (plugins && plugins.length)) {
	var elt = document.getElementsByName(elt)[0];
	var size = (elt.getAttribute('width', 0) != '' ? ' width=' + elt.getAttribute('width', 0):'') + (elt.getAttribute('width', 0) != '' ? ' height=' + elt.getAttribute('height', 0): '')
	if (plugins && plugins['Shockwave Flash']) {
		elt.innerHTML = "<embed src=\"" + elt.getAttribute("path", 0) + elt.getAttribute("flashfile", 0) + "\" loop=\"true\" play=\"true\" quality=\"high\""+size+"></embed>";
	} else {
		elt.innerHTML = "<img src=\"" + elt.getAttribute("path", 0) + elt.getAttribute("altfile", 0) + "\" border=\"0\" />";
	}
	}
}
// ************************************
// Add Bookmark
// ************************************
function addBookmark(){ 
	strThisUrl = self.location;
	if(IE4){
		strName = doReplace(strPageTitle,"'","");
		window.external.AddFavorite(strThisUrl, strName);
	}else if(NS6){
		ret = prompt('To bookmark this page, press ctrl+shift+d,\nthen copy the following into the location field:\n\n', strThisUrl);
	}else{
		alert('To bookmark this page, press ctrl+d');
	}
} 
// ************************************
// Open a URL given string arguments
// ************************************
function openIt(strArgs1, strArgs2){
 var txtURL = openItURL1 + strArgs2 + '?opendocument&SID=' + strSessionID + '&DTC=' + strDateCode; 
 parent.location = txtURL; 
}
// ************************************
// Center Window
// ************************************
function centerWindow(strHeight,strWidth) { 
	strHalfWidth = strWidth / 2; 
	strHalfHeight = strHeight / 2; 
	strHalfScreenWidth = screen.width / 2; 
	strHalfScreenHeight = screen.height / 2; 
	strLeft = strHalfScreenWidth - strHalfWidth; 
	strTop = strHalfScreenHeight - strHalfHeight; 
	return "width=" + strWidth + "px,height=" + strHeight + "px,top=" + strTop + "px,left=" + strLeft + "px";
}
// ************************************
// Close a Window
// ************************************
function closeFunction() { 
	top.close(); 
} 
// ************************************
// Find an element
// ************************************
function getElements(doc, str) {
	var returnTable = new Array();
	if (IE4) {
		if (doc.all[str]) {
			if (doc.all[str][0]) {
				var i = 0;
				while (doc.all[str][i]) { returnTable[i] = doc.all[str][i]; i++;}
			} else {
				returnTable[0] = doc.all[str];
			}
		}
	} else {
		returnTable = doc.getElementsByName(str);
	}
	return returnTable;
}
// ************************************
// Add a row to a table
// ************************************
function addRow(doc, fileName, fileID) {	
 var myTable = getElements(doc,"fileAttachmentsTable");
 var myRow = myTable[0].insertRow(myTable[0].rows.length-2);
 var myCell = myRow.insertCell(0);
 myCell.innerHTML = '<input type="hidden" name="*txtMultipleFileAttachmentID*" value="' + fileID + '" /><input type="checkbox" id="*txtMultipleFileAttachment*" name="*txtMultipleFileAttachment*" />' + fileName;
}
// ************************************
// Remove a row from a table
// ************************************
function removeRow(msg) {
 var attachedFiles = new Array();
 attachedFiles = getElements(document,"*txtMultipleFileAttachment*");
 var i = 0;
 var c = 0;
 var myTable = new Array();
 myTable = getElements(document,"fileAttachmentsTable");
 while (attachedFiles[i]) {
  if (attachedFiles[i].checked) {c++; myTable[0].deleteRow(i); i--; attachedFiles = getElements(document,"*txtMultipleFileAttachment*"); myTable = getElements(document,"fileAttachmentsTable");}
  i++;
 }
 if (c == 0) {alert(msg);}
}
// ========================================================================
// General functions
// ========================================================================
// ************************************
// Replace
// ************************************
function doReplace(strInput, strFrom, strTo) { 
	while(strInput.indexOf(strFrom) > -1){ 
		strStart = strInput.substring(0, strInput.indexOf(strFrom)); 
		strEnd = strInput.substring(strInput.indexOf(strFrom)+strFrom.length); 
		strInput = strStart + strTo + strEnd; 
	} 
	return strInput ; 
} 
// ************************************
// Check for Number
// ************************************
function isNumeric(nb) {
figures = "0123456789";
var retour = true;  
var c; 
for (var x = 0; x < nb.length; x++) 
if (retour) { 
c = nb.charAt(x); 
retour = (figures.indexOf(c) != -1); 
} 
return retour; 
} 
// ************************************
// Check for Decimal
// ************************************
function isDecimal(nb) { 
figures = "0123456789";
var retour = true; 
var virgule = false; 
var c; 
c = nb.charAt(0); 
retour = (figures.indexOf(c) != -1); 
for (var x = 1; x < nb.length; x++) 
if (retour) { 
c = nb.charAt(x); 
if (c == ".") 
if (virgule) 
retour = false; 
else { 
retour = true; 
virgule = true; 
} 
else 
retour = (figures.indexOf(c) != -1); 
} 
return retour; 
} 
// ************************************
// Check for Date
// ************************************
function checkDate(myDate, format) { 
//myDate has to be mm/dd/yyyy if format=0, dd/mm/yyyy if format=1
correct = true; 
if (myDate.indexOf("/") == 1){ 
myDate = "0" + myDate; 
} 
if ((myDate.length == 7) || (myDate.length == 9)){ 
myDate = myDate.substring(0,3) + "0" + myDate.substring(3,myDate.length);
} 
if ( (myDate.length < 11) && (myDate.length > 7) ) { 
if (format) {
   mm = myDate.substring(3,5); 
   jj = myDate.substring(0,2); 
} else {
   jj = myDate.substring(3,5); 
   mm = myDate.substring(0,2); 
}
aa = myDate.substring(6,myDate.length); 
bi = ((parseInt(aa) % 4) == 0); 
if (((mm == "01") || (mm == "03") || (mm == "05") || (mm == "07") || (mm == "08") || (mm == "10") || (mm == "12")) && ((Math.round(jj) >= 1) && (Math.round(jj) <= 31))) {
correct = true; 
} 
else { 
if (((mm == "04") || (mm == "06") || (mm == "09") || (mm == "11")) && ((Math.round(jj) >= 1) && (Math.round(jj) <= 30))) { 
correct = true; 
} else { 
if (bi) { 
correct = (((Math.round(jj) >= 1) && (Math.round(jj) <= 29) ) && (mm == "02")); 
} else { 
correct = (((Math.round(jj) >= 1) && (Math.round(jj) <= 28)) && (mm == "02")); 
} 
} 
} 
} else { 
correct = false; 
} 
return correct; 
}
// ************************************
// Check for Email
// ************************************
function checkEmail(address) {
at = address.indexOf("@");
if (at == -1 || at == 0 || at == address.length-1) return false;
dot = address.lastIndexOf(".");
if (dot < at || dot == address.length-1) return false;
return true;
}
// ************************************
// Prnt version
// ************************************
function printVersion(){  
 url = "/" + strCurrentDBPath + "/vwPagesWebLive/" + thisUNID + "?opendocument&SID=" + strSessionID + "&DTC=" + strDateCode + "&TMP=2"; 
 strWinStr = centerWindow("480", "640"); 
 ret = window.open(url,"ChildWindow", strWinStr + ",scrollbars=1,menubar=1,resizable=1"); 
 ret.focus();
}
// ************************************
// Back to parent
// ************************************
function backFunction() { 
 if(parentUNID != ""){
  var txtURL = "/" + strCurrentDBPath + "/vwPagesWebLive/" + parentUNID + "?opendocument&SID=" + strSessionID + "&DTC=" + strDateCode;
  if(top.name == "ChildWindow"){ 
   top.opener.location = txtURL; 
   top.close(); 
  } else { 
   parent.location = txtURL; 
  }
 }else{
   parent.history.go(-1); 
 }
} 
// ************************************
// Load Home page
// ************************************
function homeFunction() { 
	var txtURL = "/" + strCurrentDBPath + "/vwlivelookupHomePage/HOME?opendocument&SID=" + strSessionID + "&DTC=" + strDateCode;
	if(top.name == "ChildWindow"){ 
		top.opener.location = txtURL; 
		top.close(); 
	} else { 
		parent.location = txtURL; 
	} 
} 
// ************************************
// Submit a form
// ************************************
function submitFunction(intOverride) { 
 tf = self.document.forms[0]; 
 if (IE4) { 
	if(self.document.all('formParam') || self.document.all('*pollCode*')){
 		if(self.document.all('*pollCode*')){ }else {
 			strAction = self.document.all('formParam').getAttribute('formParam', 0) ;
 			strSaveForm = (self.document.all('formParam').getAttribute('formSave', 0) ? self.document.all('formParam').getAttribute('formSave', 0) : "1");			
			strSessionFields = (self.document.all('formParam').getAttribute('sessionFields', 0) ? self.document.all('formParam').getAttribute('sessionFields', 0) : "");
			strGotoDoc = (self.document.all('formParam').getAttribute('formReturn', 0) ? self.document.all('formParam').getAttribute('formReturn', 0) : "");
	 		tf.txtFrmAction.value = strSaveForm + "##" + strAction + "##" + doReplace(strSessionFields,"\n","^^") + "##" + strGotoDoc; 
			if(strAction == "savesess" || strAction == "loadsess" || strAction == "register"){
				strSessionKeys = (self.document.all('formParam').getAttribute('sessionKeys', 0) ? self.document.all('formParam').getAttribute('sessionKeys', 0) : "");
				strSessionError = (self.document.all('formParam').getAttribute('sessionError', 0) ? self.document.all('formParam').getAttribute('sessionError', 0) : "");
				tf.txtFrmAction.value = tf.txtFrmAction.value + "##" + doReplace(strSessionKeys,"\n","^^") + "##" + strSessionError; 
			}
	 		if(strAction == "message"){
	 			tf.txtFrmReturnMessage.value = self.document.all('formParam').getAttribute('formReturn', 0); 
			}else if(strAction == "goto"){
				strRet = tf.txtFrmReturnMessage.value;
				strRetP1 = strRet.substring(0, strRet.indexOf("vwPagesWebLive/")+15);
				strRetP2 = strRet.substring(strRet.indexOf("?"));
				tf.txtFrmReturnMessage.value = strRetP1 + self.document.all('formParam').getAttribute('formReturn', 0) + strRetP2;			
	 		} 
 		} 
 //ret=doValidate();  
 if(intOverride == 1){ 
 self.document.forms[0].submit(); 
} else {
 var validation = 1;  
 var coll = document.all.tags("INPUT");  
 if (coll != null)  
 {  
    for (i = 0; ((i < coll.length) && (validation)); i++) { 
       if ((coll[i].type == "text") || (coll[i].type == "password")) {
       		if ((coll[i].getAttribute('minLength', 0) && coll[i].getAttribute('minLength', 0)!= -1) && (coll[i].value.length < coll[i].getAttribute('minLength', 0))) {
				alert('' + coll[i].getAttribute('validation', 0)); 
				coll[i].focus();
				validation = 0;
		      }
       		if ((coll[i].getAttribute('maxLength', 0) && coll[i].getAttribute('maxLength', 0) != -1) && (coll[i].value.length > coll[i].getAttribute('maxLength', 0))) {
				alert('' + coll[i].getAttribute('validation', 0)); 
				coll[i].focus();
				validation = 0;
		      }
       		if ((coll[i].type == "text") && (validation)) {
       			if (coll[i].getAttribute('contentType', 0) == "Integer") {
	       			if (!isNumeric(coll[i].value)) {
						alert('' + coll[i].getAttribute('validation', 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       			if (coll[i].getAttribute('contentType', 0) == "Decimal") {
	       			if (!isDecimal(coll[i].value)) {
						alert('' + coll[i].getAttribute('validation', 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       			if (coll[i].getAttribute('contentType', 0) == "Email") {
	       			if (!checkEmail(coll[i].value)) {
						alert('' + coll[i].getAttribute('validation', 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       			if (coll[i].getAttribute('contentType', 0) == "Date") {
	       			if (!checkDate(coll[i].value,1)) {
						alert('' + coll[i].getAttribute('validation', 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       			if (coll[i].getAttribute('contentType', 0) == "USDate") {
	       			if (!checkDate(coll[i].value,0)) {
						alert('' + coll[i].getAttribute('validation', 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       		}
       }
      }
 }
 coll = document.all.tags("TEXTAREA");  
 if ((coll != null) && (validation))  
 {  
    for (i = 0; ((i < coll.length) && (validation)); i++) { 
       		if ((coll[i].getAttribute('minLength', 0) && coll[i].getAttribute('minLength', 0) != -1) && (coll[i].innerText.length < coll[i].getAttribute('minLength', 0))) {
				alert('' + coll[i].getAttribute('validation', 0)); 
				coll[i].focus();
				validation = 0;
		      }
       		if ((coll[i].getAttribute('maxLength', 0) && coll[i].getAttribute('maxLength', 0) != -1) && (coll[i].innerText.length > coll[i].getAttribute('maxLength', 0))) {
				alert('' + coll[i].getAttribute('validation', 0)); 
				coll[i].focus();
				validation = 0;
		      }
      }
 }
 if (validation) self.document.forms[0].submit();   
 }  
 } else { 
 alert('This page requires a \'Form Parameters\' field before it can be submitted.'); 
 } 
 } else if(NS6) { 
 if(self.document.getElementById('formParam') || self.document.getElementById('*pollCode*')){
 if(self.document.getElementById('*pollCode*')){}else{ 
 strAction = self.document.getElementById('formParam').getAttribute('formParam', 0); 
 strSaveForm = (self.document.getElementById('formParam').getAttribute('formSave', 0) ? self.document.getElementById('formParam').getAttribute('formSave', 0) : "1");
strSessionFields = (self.document.getElementById('formParam').getAttribute('sessionFields', 0) ? self.document.getElementById('formParam').getAttribute('sessionFields', 0) : "");
strGotoDoc =(self.document.getElementById('formParam').getAttribute('formReturn', 0) ? self.document.getElementById('formParam').getAttribute('formReturn', 0) : "");
	 		tf.txtFrmAction.value = strSaveForm + "##" + strAction + "##" + doReplace(strSessionFields,"\n","^^") + "##" + strGotoDoc; 
	 		 
			if(strAction == "savesess" || strAction == "loadsess" || strAction == "register"){
				strSessionKeys = (self.document.getElementById('formParam').getAttribute('sessionKeys', 0) ? self.document.getElementById('formParam').getAttribute('sessionKeys', 0) : "");
				strSessionError = (self.document.getElementById('formParam').getAttribute('sessionError', 0) ? self.document.getElementById('formParam').getAttribute('sessionError', 0) : "");
				tf.txtFrmAction.value = tf.txtFrmAction.value + "##" + doReplace(strSessionKeys,"\n","^^") + "##" + strSessionError; 
			}
			if(strAction == "message"){
 				tf.txtFrmReturnMessage.value = self.document.getElementById('formParam').getAttribute('formReturn', 0); 
			}else if(strAction == "goto"){
				strRet = tf.txtFrmReturnMessage.value;
				strRetP1 = strRet.substring(0, strRet.indexOf("vwPagesWebLive/")+15);
				strRetP2 = strRet.substring(strRet.indexOf("?"));
				tf.txtFrmReturnMessage.value = strRetP1 + self.document.getElementById('formParam').getAttribute('formReturn', 0) + strRetP2;			
	 		} 
 } 
 //ret=doValidate();  
 if(intOverride == 1){ 
 self.document.forms[0].submit(); 
} else {
 var validation = 1;  
 var coll = document.getElementsByTagName("INPUT");  
 if (coll != null)  
 {  
    for (i = 0; ((i < coll.length) && (validation)); i++) { 
       if ((coll[i].type == "text") || (coll[i].type == "password")) {
       		if ((coll[i].getAttribute("minLength", 0) != "" && coll[i].getAttribute("minLength", 0) != null) && (coll[i].value.length < coll[i].getAttribute("minLength", 0))) {
				alert('' + coll[i].getAttribute("validation", 0)); 
				coll[i].focus();
				validation = 0;
		      }
       		if ((coll[i].getAttribute("maxLength", 0) != "" && coll[i].getAttribute("maxLength", 0) != null) && (coll[i].value.length > coll[i].getAttribute("maxLength", 0))) {
				alert('' + coll[i].getAttribute("validation", 0)); 
				coll[i].focus();
				validation = 0;
		      }
       		if ((coll[i].type == "text") && (validation)) {
       			if (coll[i].getAttribute("contentType", 0) == "Integer") {
	       			if (!isNumeric(coll[i].value)) {
						alert('' + coll[i].getAttribute("validation", 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       			if (coll[i].getAttribute("contentType", 0) == "Decimal") {
	       			if (!isDecimal(coll[i].value)) {
						alert('' + coll[i].getAttribute("validation", 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       			if (coll[i].getAttribute("contentType", 0) == "Email") {
	       			if (!checkEmail(coll[i].value)) {
						alert('' + coll[i].getAttribute("validation", 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       			if (coll[i].getAttribute("contentType", 0) == "Date") {
	       			if (!checkDate(coll[i].value,1)) {
						alert('' + coll[i].getAttribute("validation", 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       			if (coll[i].getAttribute("contentType", 0) == "USDate") {
	       			if (!checkDate(coll[i].value,0)) {
						alert('' + coll[i].getAttribute("validation", 0)); 
						coll[i].focus();
						validation = 0;
       				}
       			}
       		}
       }
      }
 }
 coll = document.getElementsByTagName("TEXTAREA");  
 if ((coll != null) && (validation))  
 {  
    for (i = 0; ((i < coll.length) && (validation)); i++) { 
       		if ((coll[i].getAttribute("minLength", 0) != "" && coll[i].getAttribute("minLength", 0) != null) && (coll[i].value.length < coll[i].getAttribute("minLength", 0))) {
				alert('' + coll[i].getAttribute("validation", 0)); 
				coll[i].focus();
				validation = 0;
		      }
       		if ((coll[i].getAttribute("maxLength", 0) != "" && coll[i].getAttribute("maxLength", 0) != null) && (coll[i].value.length > coll[i].getAttribute("maxLength", 0))) {
				alert('' + coll[i].getAttribute("validation", 0)); 
				coll[i].focus();
				validation = 0;
		      }
      }
 }
 if (validation) self.document.forms[0].submit();   
 }  
 } else { 
 alert('This page requires a \'Form Parameters\' field before it can be submitted.'); 
 } 
 } 
}
// ************************************
// Open a page link
// ************************************
function openLink(strArgs1, strDocType, strUNID, strDocCode, strTemplate, strLaunch, strSize, strQS) {   
 //var disclaimText = "22You are now leaving the website operated by British American Tobacco and transferring to a separate website operated by an independent third party or British American Tobacco Group company. British American Tobacco does not control the content of the website or websites to which you are now linking, is not responsible for its/their content and disclaims all liability directly or indirectly in connection with its/their use. Your use of such sites is at your own risk and such links are provided for convenience only.\n\nOK to proceed, Cancel to cancel.";
 strWindowName = 'ChildWindow'; 
 if(strDocCode == ""){ strDocCode = strUNID; } 
 if(strDocType.toLowerCase() == "site") { 
  openSite(strDocCode); 
 } else { 
  if(strUNID.toLowerCase() == "this"){ strDocCode = thisUNID; } 
  if(strDocCode.toLowerCase() == "function"){
	if(strUNID.substring(0,1) == "*"){ 
		strCustomJS = strUNID.substring(1); 
		strCustomJS = doReplace(strCustomJS, "*SQ*", "'");
		strCustomJS = doReplace(strCustomJS, "*DQ*", '"');
		strCustomJS = unescape(strCustomJS);
		eval('' + strCustomJS);
	}
   if(strUNID.toLowerCase() == "back"){ backFunction(); } 
   if(strUNID.toLowerCase() == "home"){ homeFunction(); } 
   if(strUNID.toLowerCase() == "next"){  } 
   if(strUNID.toLowerCase() == "previous"){  } 
   if(strUNID.toLowerCase() == "submit"){ submitFunction(0); }
   if(strUNID.toLowerCase() == "submitpoll"){ submitFunction(1); }
   if(strUNID.toLowerCase() == "close"){ closeFunction(); }
   if(strUNID.toLowerCase() == "print"){ 
		if(strQS == ""){ 
			print(); 
		}else{ 
			objFrame = eval(strQS); 
			if(objFrame){
				printFrame(objFrame); 
			}else{
				print();
			}
		} 
   }
   if(strUNID.toLowerCase() == "printversion"){ printVersion(); }
   if(strUNID.toLowerCase() == "bookmark"){ addBookmark(); }
  } else { 
   if(strDocType.toLowerCase() == "fileattach"){ 
    strWindowName = 'FileWindow'; 
    strFileExt = strUNID.substring(strUNID.lastIndexOf('.')+1); 
    strFileExt = strFileExt.substring(0, strFileExt.indexOf('?'));
    if(strFileExt.toLowerCase() == "wmv" || strFileExt.toLowerCase() == "avi" || strFileExt.toLowerCase() == "asf") { 
	 var txtURL = "/" + strDBControl + "/frmMediaViewer?readform&SKN=" + strSchemeCode + "&FURL=" + strUNID ; 
	 strSize = "250x270";
	} else { 
	 var txtURL = strUNID ;
	 strSize = "630x500"; 
	} 
   } else if(strDocType.toLowerCase() == "externallink"){ 
    var txtURL = strUNID;
   } else { 
	if(strArgs1 != ""){
		arrArgs1 = new Array;
		arrArgs1 = strArgs1.split("~");
		strSitePath = "";
		for(c = 0; c < arrArgs1.length; c++){
			strSitePath = strSitePath + arrArgs1[c] + "/";
		}
		
    var txtURL = "/" + strSitePath + "vwPagesWebLive/" + strDocCode + "?opendocument&SID=" + strSessionID + "&DTC=" + strDateCode + "&TMP="+ strTemplate + strQS; 
	}else{
    var txtURL = "/" + strCurrentDBPath + "/vwPagesWebLive/" + strDocCode + "?opendocument&SID=" + strSessionID + "&DTC=" + strDateCode + "&TMP="+ strTemplate + strQS; 
	}
   }
   if(strDocType.toLowerCase() == "externallink"){ 
    if((strShowDisclaimer != "N" && strQS!="NoDisclaimer") || (strDisableDisclaimer != "Y" && strQS != "" && strQS != "NoDisclaimer")){ 
	 disclaimURL = "/" + strDBControl + "/frmExternalDisclaimer?readform&SITE=" + strSiteCode + "&SKN=" + strSchemeCode + "&MSG=" + strQS; 
	 var retVal;
	 if(NS6 || OPR) {
      if(confirm(disclaimText)) {
	   retVal = 'proceed';
	  } else {
	   retVal = 'not proceed';
	  }
	 } else { 
	  retVal = window.showModalDialog(disclaimURL, '', 'dialogHeight:280px;dialogWidth:500px;scrollbars:0'); 
     }
    }else{
     retVal = "proceed";
    }
    if(retVal == "proceed"){ 
     if(strLaunch.toLowerCase() == "new"){ 
		strLeft = "";
		strTop = "";
		if(strSize == "x" || strSize == "x|x"){
	  			strWidth = '750'; 
				strHeight = '550';  
		} else {
			if(strSize.indexOf('|') > -1){
				strSizeParam = strSize.substring(0, strSize.indexOf('|'));
				strPosParam = strSize.substring(strSize.indexOf('|')+1);
				strWidth = strSizeParam.substring(0, strSizeParam.indexOf('x')); 
	  			strHeight = strSizeParam.substring(strSizeParam.indexOf('x')+1); 
				strLeft = strPosParam.substring(0, strPosParam.indexOf('x')); 
		  		strTop = strPosParam.substring(strPosParam.indexOf('x')+1); 
			} else {
	  			strWidth = strSize.substring(0, strSize.indexOf('x')); 
				strHeight = strSize.substring(strSize.indexOf('x')+1);  
			}
		}
		strHalfWidth = strWidth / 2; 
		strHalfHeight = strHeight / 2; 
		strHalfScreenWidth = screen.width / 2; 
		strHalfScreenHeight = screen.height / 2; 
		if(strLeft == ""){
			strLeft = strHalfScreenWidth - strHalfWidth;
		}
		if(strTop == ""){
			strTop = strHalfScreenHeight - strHalfHeight;
		}
	  strWinStr = "width=" + strWidth + ",height=" + strHeight + ",top=" + strTop + ",left=" + strLeft + ",scrollbars=1,resizable=1";
		 ret = window.open(txtURL, 'ExternalLink', strWinStr);
	 } else { 
		strWinStr = ""; 
		if(strLaunch != ""){
			eval(strLaunch + '.location = txtURL;');		
		} else {
			top.location = txtURL; 
		}
	 }
    } 
   } else {
    strCheck = strAllowedLinks;
    if(strCheck.indexOf("#"+strDocCode+"#") > 0 || strCheck == "" || strDocCode.length > 7) { 
     if(strLaunch.toLowerCase() == "new"){ 
		strLeft = "";
		strTop = "";
		if(strSize == "x" || strSize == "x|x"){
	  			strWidth = '750'; 
				strHeight = '550';  
		} else {
			if(strSize.indexOf('|') > -1){
				strSizeParam = strSize.substring(0, strSize.indexOf('|'));
				strPosParam = strSize.substring(strSize.indexOf('|')+1);
				strWidth = strSizeParam.substring(0, strSizeParam.indexOf('x')); 
	  			strHeight = strSizeParam.substring(strSizeParam.indexOf('x')+1); 
				strLeft = strPosParam.substring(0, strPosParam.indexOf('x')); 
		  		strTop = strPosParam.substring(strPosParam.indexOf('x')+1); 
			} else {
		  		strWidth = strSize.substring(0, strSize.indexOf('x')); 
				strHeight = strSize.substring(strSize.indexOf('x')+1);  
			}
		}
		strHalfWidth = strWidth / 2; 
		strHalfHeight = strHeight / 2; 
		strHalfScreenWidth = screen.width / 2; 
		strHalfScreenHeight = screen.height / 2; 
		if(strLeft == ""){
			strLeft = strHalfScreenWidth - strHalfWidth;
		}
		if(strTop == ""){
			strTop = strHalfScreenHeight - strHalfHeight;
		}
	  strWinStr = "width=" + strWidth + ",height=" + strHeight + ",top=" + strTop + ",left=" + strLeft + ",scrollbars=1,resizable=1";
	  ret = window.open(txtURL, strWindowName, strWinStr); 
	 } else {
		if(strLaunch != ""){
			eval(strLaunch + '.location = txtURL;');		
		} else {
			top.location = txtURL; 
		}	
	 } 
    } else { 
     alert('Sorry. The page you are linking to has been temporarily removed.'); 
    } 
   } 
  } 
 } 
} 
// ************************************
// Open a Site
// ************************************
function openSite(strCode){
	top.location = "/" + strdbPath + "/sites/" + strCode + ".nsf?open&SID=" + strSessionID + "";
}
// ************************************
// Check that a DIV Tag exists
// ************************************
function doesDivExist(secCat) { 
	var Test = 'False'; 
	if (IE4) { 
		var strCheck = 'document.all.' + secCat; 
		if (eval(strCheck)) {Test = 'True';} else {Test =  'False';}
	} else { 
		var strCheck = 'document.getElementById[' + secCat + ']'; 
		if ('document.getElementById[' + strCheck + ']') {Test = 'True';} else {Test =  'False';}
	} 
//	if (eval(strCheck)) {Test = 'True';} else {Test =  'False';}  27/7/05 COMMENTED OUT BY BB AND REPLACED WITH FOLLOWING LINE IN ORDER TO MAKE LHN AUTO-EXPAND IN MOZILLA
//	if ('document.getElementById[' + strCheck + ']') {Test = 'True';} else {Test =  'False';}  
	return Test;
} 
// ************************************
// Upload a File
// ************************************
function uploadFile(msg1,msg2,msg3,msg4, sessionLink, fileGroup) {
	if(sessionLink != null){
		self.document.forms[0].txtFrmFileGroup.value = "SESSION##" + fileGroup;
	}
	var newWindow=window.open('/' + strFileUploadDBPath + '/frmUpload?OpenForm&SID=' + strSessionID + '&SITE=' + strSiteCode + '&SCHEME=' + strSchemeCode + '&MSG1=' + escape(msg1) + '&MSG2=' + escape(msg2) + '&MSG3=' + escape(msg3) + '&MSG4=' + escape(msg4),'windowID','width=380,height=80,toolbar=no,titlebar=no,scrollbars=no,resizable=no');
	newWindow.focus();
	return false;
}
