/***********************************************************************************************
	
Author : P Bridge
Last Revised Date : 05/11/2002
Version : 1.15
Purpose :
Called By:
Calls To:
Scripts Used:
	
-----------------------History---------------------------------------------------------------------
06/04/2001	P.Bridge    Added function 'ViewApprovalPath' to view related Approval Path Details
20/07/2001	P.Bridge	TestNumeric function updated to correctly reflect value of entire string
17/07/2002	P.Bridge	Include new shared logic (DisplayReportList) for report parameter pages
28/08/2002	P.Bridge	ShowHistory visible window resized to accomodate longer date displays
29/09/2002	P.Bridge	ShowHistory visible window resized to accomodate longer date-time displays
			P.Bridge	ViewUsers and ViewGroups window size increased by 1 pixel (XP)
05/11/2002	P.Bridge	New SwapImg function
18/01/2007	M Daniels	Merged with incGeneral.js
13/03/2007	M Daniels	Changed ShowSpecificPage(), add CheckDate()
09/07/2009	D Stan		Changed ShowSpecificPage() to include ISH changes
16/08/2010	M Daniels	Added CheckNumber
***************************************************************************************************/

var vbCrLf = "\r\n";
var objUserList, objGroupList, objCalendar, objViewDoc, objViewMetadata, objHistory, objViewAppPath;


var arrPageGroups;



function CheckNumber(strControlID, strDetail)		{

	var strResult = "";

	if (document.getElementById(strControlID) != null)		{
		if (document.getElementById(strControlID).value != "")		{
			if (isNaN(document.getElementById(strControlID).value))	{
				strResult = "You must enter a number - " + strDetail;
			}
			else	{
				if ((document.getElementById(strControlID).value >= 0) && (document.getElementById(strControlID).value <= 99.99))	{
					var intIndex = document.getElementById(strControlID).value.indexOf(".");
					if (intIndex == -1)	{
						strResult = "Please give your result to one decimal place - " + strDetail;
					}
					else	{
						var intCount = document.getElementById(strControlID).value.substring(intIndex + 1).length;
						/*
							Merdol said he wanted results to 2 decimal places but would accept 3.1 as 3.10!!!!!!
						*/
						if ((intCount > 2) || (intCount < 1))	{
							strResult = "Please give your result to one decimal place - " + strDetail;
						}
						else	{
							strResult = "";
						}
					}			
				}
				else	{
					strResult = "You must enter a number between zero and 99.99 - " + strDetail;
				}	
			}
		}
	}
	else	{
		alert(strControlID);
	}
	
	return strResult;
}








function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function SwapImg(strImg,strImgSrc)	{

	document[strImg].src = strImgSrc;

}

function ShowHistory(intID,strTable,intCount) {
	var strScrollBars, intHeight, intHeader, intFooter, intBody
	intHeader=35
	intFooter=25
	if (intCount > 10) {
		intBody=150
		strScrollBars = ",scrollbars=yes"
	}
	else	{
		intBody = intCount * 15
		strScrollBars = ""
	}
	intHeight=intHeader+intBody+intFooter
	var strParams = 'id=' + intID + '&Table=' + strTable + '&Count=' + intCount
    objHistory = window.open('../ViewSystemDetails/ViewHistory.asp?id=' + intID + '&Table=' + strTable + '&Count=' + intCount,intCount + strTable + intID,'resizable=no' + strScrollBars + ',left=200,top=200,width=230,height=' + intHeight);
	if (window.focus) {
	  objHistory.opener = self;
	  objHistory.focus();
	}
}

function ReloadForm(strPage,varValue,strVarName)	{
	if (strPage=='ContentListADM.asp')	{
		varValue = varValue + '&LookupField=' + document.frmSort.txtLookupField.value + '&LookupForm=' + document.frmSort.txtLookupForm.value;
	}
	location.href = strPage + '?' + strVarName + '=' + varValue;
}

function UpdateContextID(intID)	{
	top.buttons.document.ContextID = intID;
}

function CheckData()	{
	if (document.frmDetails.txtRestoreData.value=="True")	{
		RestoreData();
	}
}

function TestNull(str) {
	var charexp = /./
	return charexp.test(str)
}

function TestNumeric(str) {
	
	if (isNaN(str))	{return false;}
	else	{return true;}

}

function TestRange(lngFrom,lngTo,varValue)	{
	if (varValue >= lngFrom && varValue <= lngTo)	{return true;}
	else {return false;}
	
}


function TestDate(str) {
	var charexp = /[0-3][0-9]\/[0-1][0-9]\/[0-1][0-9]/;
	return charexp.test(str);
}

function DisplayMessage(strMsg) {
	alert(strMsg);
}


function ShowHand() {
	alert("hand")
	document.body.style.cursor = "hand";
}

function ShowDefaultCursor() {
	document.body.style.cursor = "default";
	parent.frames[0].document.body.style.cursor="default";
	parent.frames[1].document.body.style.cursor="default";
	parent.frames[2].document.body.style.cursor="default";	
}


function ShowCalendar(strCallingPage,strFieldDesc) {
 
	var intWidth
	var strParam;
	var strDayDesc = "cbo" + strFieldDesc + "Day"
	var strMonthDesc = "cbo" + strFieldDesc + "Month"
	var strYearDesc = "cbo" + strFieldDesc + "Year"
	var strCOParams;
	
	document.frmDetails.txtDay.value=document.frmDetails[strDayDesc].value	
	document.frmDetails.txtMonth.value=document.frmDetails[strMonthDesc].value	
	document.frmDetails.txtYear.value=document.frmDetails[strYearDesc].value	

	strParam = "action=initialise&StoreData=True&id=" + document.frmDetails.txtHiddenID.value + "&CallingForm=" + strCallingPage + "&day=" + document.frmDetails.txtDay.value + "&month=" + document.frmDetails.txtMonth.value + "&year=" + document.frmDetails.txtYear.value + "&et=" + strFieldDesc 
  
	StoreData();

	if (navigator.appName.indexOf("Microsoft") != -1) {
		intWidth=121
	}
	else	{intWidth=126}
	
	intHeight = 125
	
	objCalendar = window.open('../SystemScripts/Calendar.asp?' + strParam,'CalendarL','resizable=no,left=200,top=200,width=' + intWidth + ',height=' + intHeight);
	if (window.focus) {
		objCalendar.opener = self;
		objCalendar.focus();
	}
}


function ViewUsers(strCFID,strField)	{
	
	var strParam
	
	StoreData();
	
	strParam = "CallingForm=" + document.frmDetails.txtPageName.value + "&CFID=" + strCFID + "&CallingField=" + strField
	
	objUserList = window.open('../SystemScripts/UserListSelect.asp?' + strParam,'UserListSelect','resizable=no,scrollbars=yes,left=100,top=100,width=436,height=350');
	if (window.focus) {
		objUserList.opener = self;
		objUserList.focus();
	}
}

function ViewGroups(strCFID)	{
	
	var strParam
	
	StoreData();
	
	strParam = "CallingForm=" + document.frmDetails.txtPageName.value + "&CFID=" + strCFID
	
	objGroupList = window.open('../SystemScripts/GroupListSelect.asp?' + strParam,'GroupListSelect','resizable=no,scrollbars=yes,left=100,top=100,width=436,height=350');
	if (window.focus) {
		objGroupList.opener = self;
		objGroupList.focus();
	}
}


function ViewDoc(lngCID)	{

	var intWidth = 700
	var intHeight = 500
	var intTop = 25
	var intLeft = 50
	
	objViewDoc = window.open('../Administrator/LoadDocADM.asp?ID=' + lngCID,'ViewDoc','scrollbars=yes,resizable=yes,toolbar=yes,location=no,menubar=yes,left=' + intLeft + ',top=' + intTop + ',width=' + intWidth + ',height=' + intHeight);
	if (window.focus) {
		objViewDoc.opener = self;
		objViewDoc.focus();
	}

}

function ViewMetaData(strURL)	{

	var intWidth = 650
	var intHeight = 500
	var intTop = 25
	var intLeft = 50
	
	objViewMetadata = window.open(strURL,'ViewMetaData','scrollbars=yes,resizable=no,left=' + intLeft + ',top=' + intTop + ',width=' + intWidth + ',height=' + intHeight);
	if (window.focus) {
		objViewMetadata.opener = self;
		objViewMetadata.focus();
	}
	
}


function ViewApprovalPath()	{

	if (document.frmDetails.cboAppPath.value > 0)	{	
		objViewAppPath = window.open('../Change/ApprovalPathActionListCHG.asp?ID=' + document.frmDetails.cboAppPath.value + '&ViewOnly=True','ViewAppPath','scrollbars=yes,resizable=no,left=100,top=100,width=540,height=300');
		if (window.focus) {
			objViewAppPath.opener = self;
			objViewAppPath.focus();
		}
	}
	else	{alert("No Approval Path has been selected.");}
		
}


function DisplayReportList()	{

	location.href = "../SystemScripts/ReportList.asp";

}


var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage(frame, arg) {
  if (frame == window) {
    printThis();
  } else {
    link = arg; // a global variable 
    printFrame(frame);
  }
  return false;
}

function printThis() {
  if (pr) { // NS4, IE5
    window.print();
  } else if (da && !mac) { // IE4 (Windows)
    vbPrintPage();
  } else { // other browsers
    alert("Sorry, your browser doesn't support this feature.");
  }
}

function printFrame(frame) {
  if (pr && da) { // IE5
    frame.focus();
    window.print();
    link.focus();
  } else if (pr) { // NS4
    frame.print();
  } else if (da && !mac) { // IE4 (Windows)
    frame.focus();
    setTimeout("vbPrintPage(); link.focus();", 100);
  } else { // other browsers
    alert("Sorry, your browser doesn't support this feature.");
  }
}

function printNetscape() {
	alert("Print");
	top.Home.window.print()
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}












function getlogin(strMsg) {
	document.frmLogin.txtLabNumber.focus();
	DisplayMsg(strMsg);
}


function PasswordHint()	{

	var strLogin = document.frmLogin.txtLogonName.value;
	var strPwdHint = document.frmLogin.txtPwdHnt.value;
	
	if (strLogin.length==0)	{
		alert("You need to enter your login ID before a password hint can be provided.")
	}
	else if (strPwdHint.length>0) {
		alert("Your password hint is: \r\n\r\n" + strPwdHint);
	}
	else	{
		document.frmLogin.txtPwdHelp.value = "True"
		document.frmLogin.submit();
	}

}

function RedirectPage(strURL)	{

	if (self.parent.frames.length != 0)	{self.parent.location.href=strURL;}
	else	{location.href = strURL;}

}

function DisplayMsg(strMsg)	{
	
	if (strMsg.length>0)	{alert(strMsg);}
	
}

function SendEmail()	{

	document.frmSort.action = "DataUpdate.asp";
	document.frmSort.submit();

}

function SelectAll(intSelection)	{
	if (intSelection==1) {
		document.frmSort.txtChecked.value = "All";
		document.frmSort.submit();
	}
	else if	(intSelection==0)	{
		document.frmSort.txtChecked.value = "None";
		document.frmSort.submit();
	}
}

function Reload(intSelection) {
	if (intSelection==1) {
		document.frmSort.txtSelectList.value = "Members";
		document.frmSort.submit();
	}
	else if	(intSelection==2)	{
		document.frmSort.txtSelectList.value = "EmailList";
		document.frmSort.submit();
	}
}

function RowInFocus(cellName, strPriority) {

	if (document.getElementById)	{
		document.getElementById(cellName).className = 'RowInFocus';
	}
	else	{
		alert("No scripting!");
	}
}

function RowNotInFocus(cellName, strPriority) {

	if (document.getElementById)	{
		document.getElementById(cellName).className = 'RowNotInFocus';
	}
	else	{
		alert("No scripting!");
	}	
}

function GlossaryRowInFocus(cellName,num) {
	if (document.images) {
		eval(cellName+".className='GlossaryRowInFocus'");
		eval(cellName+".style.cursor='hand'");	
	}
}

function GlossaryRowNotInFocus(cellName,num) {
	if (document.images) {
		eval(cellName+".className='GlossaryRowNotInFocus'");
	}
}

function ShowDiscussionGroup(ID)	{
  location.href = 'DiscussionGroupEdit.asp?id=' + ID;
}


function ShowMember(ID) {
  location.href = 'MemberEdit.asp?id=' + ID;
}


function ShowNews(ID) {
  location.href = 'NewsEdit.asp?id=' + ID;
}


function ShowLinkType(ID) {
  location.href = 'LinkTypeEdit.asp?id=' + ID;
}

function ShowTopic(ID) {
  location.href = 'TopicEdit.asp?id=' + ID;
}

function ShowFAQ(ID) {
  location.href = 'FAQEdit.asp?id=' + ID;
}

function ShowEmail(ID)	{
  location.href = 'ComposeEmail.asp?id=' + ID;
}

function ShowAdvert(ID)	{
  location.href = 'AdvertEdit.asp?id=' + ID;
}

function ShowLink(ID)	{
  location.href = 'LinkEdit.asp?id=' + ID;
}

function ShowParameter(ID)	{
  location.href = 'ParameterEdit.asp?id=' + ID;
}


function ShowSpecificPage(ID, strType)	{

	switch (strType)	{
		case "ATP":
			location.href = 'ATP/TrialEdit.asp?id=' + ID;
			break;
		case "BRE":
			location.href = 'BRE/TrialEdit.asp?id=' + ID;
			break;
		case "HER2":
			location.href = 'BreastHER/TrialEdit.asp?id=' + ID;
			break;
		case "ISH":
			location.href = 'ISH/TrialEdit.asp?id=' + ID;
			break;
		default:
			location.href = 'GEN/TrialEdit.asp?id=' + ID + "&type=" + strType;
			break;
	}
	
	
}


function CreatePGArray(strPageGroups)	{

	arrPageGroups = strPageGroups.split(",");

}

function CheckImageSizes()		{

	var index = document.frmDetails.cboContent.selectedIndex;
	var lngContent = document.frmDetails.cboContent.options[index].value;
	var strContentID = "CO" + lngContent
	var lngPageGroup = 1
	var strPageGroup
	
	for(var i = 0; i < (arrPageGroups.length-1); i++)	{
		if (arrPageGroups[i]==strContentID)	{
			i = i+1;
			strPageGroup = arrPageGroups[i]
			lngPageGroup = strPageGroup.slice(2,strPageGroup.length);
			break;
		}
	}

	if (lngPageGroup > 1)	{
		if (document.frmDetails.txtMenuImg.value == "True")	{
			document.imgMenuItem.width=88;
			document.imgMenuItem.height=23;
		}
		if (document.frmDetails.txtMenuImgF.value == "True")	{
		}
			document.imgMenuItemF.width=75;
			document.imgMenuItemF.height=110;
	}
	else	{
		if (document.frmDetails.txtMenuImg.value == "True")	{
			document.imgMenuItem.width=88;
			document.imgMenuItem.height=23;
		}
		if (document.frmDetails.txtMenuImgF.value == "True")	{
		}
			document.imgMenuItemF.width=200;
			document.imgMenuItemF.height=66;
	}

}



function isValidDate(dateStr) {

// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
var strMessage

// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
	strMessage = "Date is not in a valid format. Use DD/MM/YY  DD/MM/YYYY  DD-MM-YY  DD-MM-YYYY.\n";
	return strMessage;
}

// changed matchArray[1] to 3  & 3 to 1 for UK date format 
month = matchArray[3]; // parse date into variables
day = matchArray[1];
year = matchArray[4];

if (month < 1 || month > 12) { // check month range
	strMessage = "Month must be between 1 and 12.\n";
	return strMessage;
}
if (day < 1 || day > 31) {
	strMessage = "Day must be between 1 and 31.\n";
	return strMessage;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
	strMessage = "Month "+month+" doesn't have 31 days!\n";
	return strMessage
}
if (month == 2) { // check for february 29th
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day>29 || (day==29 && !isleap)) {
	strMessage = "February " + year + " doesn't have " + day + " days!\n";
	return strMessage;
   }
}
return "";  // date is valid
}


function OpenWindow(strControl) {
		
	if (strControl=="txtHeadline") {
		var strHTML=document.frmDetails.txtHeadline.value;	
	}
	else if (strControl=="txtAbstract") {
		var strHTML=document.frmDetails.txtAbstract.value;	
	}
	else if (strControl=="txtDetails") {
		var strHTML=document.frmDetails.txtDetails.value;	
	}
	
	var varWindow = window.open("", "ViewHtml", "width=500,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");	
	varWindow.document.write(strHTML);
	varWindow.document.close;
}


function ViewNews()	{

	var varWindow = window.open("../Scripts/News.asp?id=" + document.frmDetails.txtID.value, "ViewHtml", "width=500,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");	

}



function DeleteListItem(lngID, strEntity)	{

	var strMsg = "Delete Logic called in Error";

	if (strEntity == 'tblNews') {
		strMsg = "Are you sure that you want to delete this News Item?"
	}
	else if (strEntity == 'tblContent') {
		strMsg = "Are you sure that you want to delete this Content?"
	}
	else if (strEntity == 'RootMenu') {
		strMsg = "Are you sure that you want to delete this Menu Item?"
	}
	else if (strEntity == 'MenuItem') {
		strMsg = "Are you sure that you want to delete this Menu Item?"
	}
	else if (strEntity == 'tblGlossary') {
		strMsg = "Are you sure that you want to delete this Glossary Item?"
	}
	else if (strEntity == 'PageGroup') {
		strMsg = "Are you sure that you want to delete this PageGroup?"
	}
	else if (strEntity == 'Upload') {
		strMsg = "Are you sure that you want to delete this PDF/Flash Item?"
	}
	bolChoice=window.confirm(strMsg) 
	if (bolChoice==true) {
		document.frmSort.txtAction.value='Delete';
		document.frmSort.txtID.value=lngID;
		document.frmSort.submit();
	}
}


function DeleteItem(strEntity)	{

	var strMsg = "";
	var bolErrors = false;
	var bolChoice = false;
		
	if (document.frmDetails.txtID.value == 0)	{
		alert("This record cannot be deleted as it has not yet been saved.");
	}
	else	{
	
		if (strEntity == 'News') {
			strMsg = "Are you sure that you want to delete this News Item?"
		}
		else if (strEntity == 'tblContent') {
			strMsg = "Are you sure that you want to delete this Content?"
		}
		else if (strEntity == 'Glossary') {
			strMsg = "Are you sure that you want to delete this Glossary Item?"
		}
		else if (strEntity == 'tblMenuItem') {
			if (document.frmDetails.txtApplicationItem.value > 0)	{
				bolErrors = true;
				alert("You cannot delete this item.  It is part of the application\r\n\r\nSet Display = No if you wish to hide it."); 	
			}
			else	{
				strMsg = "Are you sure that you want to delete this Menu Item?"
			}
		}
		if (bolErrors==false)	{bolChoice=window.confirm(strMsg) }
		if (bolChoice==true && bolErrors==false) {
			document.frmDetails.txtFunction.value='Delete';
			document.frmDetails.txtTable.value=strEntity;
			document.frmDetails.submit();
		}

	}
}


function NewRecord(strType)	{

	if (strType=="News")	{location.href="../admin/NewsEdit.asp?ID=0";}
	else if (strType=="RootMenu")	{location.href="../admin/MenuEdit.asp?ID=0";}
	else if (strType=="Content")	{location.href="../admin/ContentEdit.asp?ID=0&PG=" + document.frmSort.cboPageGroup.value;}	
	else if (strType=="Glossary")	{location.href="../admin/GlossaryEdit.asp?ID=0&gi=" + document.frmSort.txtASCII.value;}	
	else if (strType=="PageGroup")	{location.href="../admin/PageGroupEdit.asp?ID=0";}	
	else if (strType=="Member")	{location.href="../admin/MemberEdit.asp?ID=0";}	

}


function NewSubMenu(lngMenuID)	{

	location.href="../admin/MenuEdit.asp?ID=0&PID=" + lngMenuID
	
}


function DeleteImage(strImage)
{
	bolChoice=window.confirm("Are you sure that you want to delete " + strImage + " ?")
	if (bolChoice==true) {
		document.frmDetails.txtAction.value="Delete";
		document.frmDetails.txtImgName.value=strImage;
		document.frmDetails.submit()
	}
}


function NewDirectory()	{

	location.href="../admin/ImageSelect.asp?Dir=" + document.frmDetails.cboDirectory.value + "&CFID=" + document.frmDetails.txtCFID.value;
}


function Back()	{

	var strParams = "";

	if (document.frmSample.ReferringPage.value == "TrialEdit.asp")	{
		location.href = '../Main.asp';
	}
	else	{
	location.href = 'Main.asp';
	}
}

function Preview()	{

	var index = document.frmDetails.cboPageGroup.selectedIndex;
	var lngPageGroup = document.frmDetails.cboPageGroup.options[index].value;
	
	var objPreview = window.open("../ContentReader.asp?PU=True&CID=" + document.frmDetails.txtID.value + "&PG=" + lngPageGroup, "Preview", "width=620,height=520,top=50,left=75,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");	
	if (window.focus) {
		objPreview.opener = self;
		objPreview.focus();
	}

}

function ShowProgress()
{
  strAppVersion = navigator.appVersion;
  if (document.frmDetails.txtFile.value != "")
  {
    if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
    {
      winstyle = "dialogWidth=375px; dialogHeight:130px; center:yes";
      window.showModelessDialog('<% = barref %>&b=IE',null,winstyle);
    }
    else
    {
      window.open('<% = barref %>&b=NN','','width=370,height=115', true);
    }
  }
  return true;
}

function UploadOK()
{
	top.opener.location.href = "ImageSelect.asp?CFID=" + document.frmDetails.txtCFID.value + "&Dir=" + document.frmDetails.txtDirectory.value;
	window.close();
}

function UploadObjectOK(strType)
{
	top.opener.location.href = "UploadList.asp?UT=" + strType;
	window.close();
}

function ViewImage(strPath)	{

	var objViewImg = window.open("ViewImage.asp?path=" + strPath, "ViewImg", "width=450,height=200,top=50,left=75,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");	
	if (window.focus) {
		objViewImg.opener = self;
		objViewImg.focus();
	}

}


function RefreshImage(lngID)	{

	if (lngID==1)	{document.imgMenuItem.src=document.frmDetails.txtMenuImgFile.value;}
	else if (lngID==2)	{document.imgMenuItemF.src=document.frmDetails.txtMenuImgFFile.value;}	
}


function BrowseImages(lngCFID)	{

	var objBrowseImages = window.open("../Admin/ImageSelect.asp?CFID=" + lngCFID, "ImageSelect", "top=50,left=50,width=600,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
	if (window.focus) {
		objBrowseImages.opener = self;
		objBrowseImages.focus();
	}
	
}

function setFormValue(vFormName, vControlName, vValue)
// Purpose:		Sets a control's value. Can handle text boxes, drop-downs,
//				multi-selects, grouped checkboxes and radio buttons etc.
// Parameters:	vFormName		name of form
//				vControlName	name of control
//				vValue			value to set it to
// Returns:		None
{	
	var vControl;
	//alert(vControlName + ' '+ vValue);	
	// get reference to control
	try {
		vControl = document.forms(vFormName).elements(vControlName);
	} catch (e) {
		// control must not exist - exit
		return;
	}
	try
	{
		// if its a multi-select
		if (vControl.type == 'select-multiple')
		{
			// split comma separated string into array
			vOptionArray = convertCommaStringToArray(vValue);
			
			// loop through all selected options
			for (var vCounter = 0; vCounter < vOptionArray.length; vCounter++)
			{
				// set the option to selected				
				setMultiSelectOption(vControl, vOptionArray[vCounter]);
			}
		}
		// if its a drop-down
		else if (vControl.type == 'select-one')
		{
			// set the value
			vControl.value = vValue;
		}
		// if it's a check box
		else if (vControl.type == 'checkbox')
		{
			if (vValue == 'on')
				vControl.checked = true;
			else
				vControl.checked = false;
		}
		// check for textbox
		else if (vControl.type == 'textbox')
		{
			// set the value
			vControl.value = vValue;
		}
		// check to see if it's a multi-select checkbox or a group of radio buttons
		else if ((vControl[0].type == 'checkbox') || (vControl[0].type == 'radio'))
		{
			// split comma separated string into array
			vOptionArray = convertCommaStringToArray(vValue);
			
			// loop through all selected options
			for (var vCounter = 0; vCounter < vOptionArray.length; vCounter++)
			{
				// set the option to selected
				setMultiCheckboxOption(vControl, vOptionArray[vCounter]);
			}
		}
	
	} catch (e) {
		// assume a text box - set the value
		try {
			vControl.value = vValue;
		} catch (e) {
			// do nothing, control cannot exist
		}
	}
}


function CheckDate(strControl)	{

	if (document.getElementById(strControl) != null)	{
		if (document.getElementById(strControl).value.length != 0)	{
			var strMessage = isValidDate(document.getElementById(strControl).value);
			if (strMessage.length != 0)	{
				return strMessage;			
			}
			else	{
				return "";
			}
		}
		else	{
			return "";
		}
	}
	else	{
		return "";
	}	
}



