/* 
 * Opens a window to edit data for a selected row.
 */
function openEdit(sURL, iHeight, iWidth)
{
	var iTop = (screen.height - iHeight)/2;
	var iLeft = (screen.width - iWidth)/2;
	
	window.open(sURL, "_blank", "toolbar=0,scrollbars=1,resizable=0,status=1,height=" + iHeight + ",width=" + iWidth + ",top=" + iTop + ",left=" + iLeft);
}

/* 
 * Opens a full screen window
 */
function openFullscreen(sURL, iHeight, iWidth, iFullscreen)
{
	var iTop = (screen.height - iHeight)/2;
	var iLeft = (screen.width - iWidth)/2;
	
	window.open(sURL, "_blank", "toolbar=0,scrollbars=1,resizable=0,status=1,fullscreen=" + iFullscreen + ",height=" + iHeight + ",width=" + iWidth + ",top=" + iTop + ",left=" + iLeft);
}

/* 
 * Opens a modal dialog to edit data for a selected row.
 */
function openModalDialog(sURL, iWantReturnVal, iHeight, iWidth, sControlId)
{
	var sStyleString = "toolbar:0;resizable:0;status:0;dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;centered:1";
	var sRetVal = window.showModalDialog(sURL, "", sStyleString);
	
	if((sRetVal == null) ||
		(sRetVal == "cancel"))
	{
		sRetVal = "";
	}

	if(sRetVal != "")
	{
		if(iWantReturnVal == "1")
		{
			var iControlId = document.getElementById(sControlId);
			iControlId.value = sRetVal;
			Form1.submit();
		}
	}
}

/* 
 * Opens a modal dialog to edit data for a selected row.
 */
function openModalDialogForWebControl(sURL, sTextToPass, iWantReturnVal, iWebControlId, iWebControlType)
{
	var sRetVal = window.showModalDialog(sURL, sTextToPass, "toolbar:0;resizable:0;status:0;dialogHeight:600px;dialogWidth:900px;centered:1");
	
	if((sRetVal == null) ||
		(sRetVal == "cancel"))
	{
		sRetVal = "";
	}
	
	if(sRetVal != "")
	{
		if(iWantReturnVal == "1")
		{
			if((iWebControlType == "1") ||
				(iWebControlType == "2")) // Means text or image
			{
				iWebControlType += "&*^*&" + iWebControlId + "&*^*&" + sRetVal;
				Form1.hdnWindowReturnValueId.value = iWebControlType;
				Form1.submit();
			}
		}
	}
	else
	{
		Form1.hdnWindowReturnValueId.value = "";
		Form1.submit();
	}
}


function setWebControlValue()
{
	alert("in");
	//Form1.hdnWindowReturnValueId.value = "test value";
	//Form1.submit();
}

/* 
 * Opens a modal dialog to edit data for a selected row.
 */
function openModalDialogWithSubmit(sURL, iHeight, iWidth)
{
	var sStyleString = "toolbar:0;resizable:0;scroll:no;status:0;dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;centered:1";
	var sRetVal = window.showModalDialog(sURL, "", sStyleString);
	
	Form1.submit();
}

/* 
 * Opens a modal dialog to edit data for a selected row.
 */
function openModalDialogWithSubmitScroll(sURL, iHeight, iWidth)
{
	var sStyleString = "toolbar:0;resizable:0;scroll:yes;status:0;dialogHeight:" + iHeight + "px;dialogWidth:" + iWidth + "px;centered:1";
	var sRetVal = window.showModalDialog(sURL, "", sStyleString);
	
	Form1.submit();
}


/* 
 * Opens a modal dialog to edit data for a selected row.
 */
function setClearSelection(sWebControlId, sStringToSet)
{
	if(confirm("Are you sure you want to clear the selection?"))
	{
		sWebControlId += "&*^*&" + sStringToSet;
		
		Form1.hdnClearSelectionId.value = sWebControlId;
		Form1.submit();
	}
}

/* 
 * closes a window leaving a return value for the opener window
 */
function closeWindow(sRetVal)
{
	window.returnValue = sRetVal;
	window.close();
}

/* 
 * Contents of the folder are shown.
 */
function showFolderContents(iCheckBoxId)
{
	var arrCheckBoxes = document.getElementsByTagName("input");

	for (i=0; i< arrCheckBoxes.length; i++)
	{
		if (arrCheckBoxes[i].id == iCheckBoxId)
		{
			Form1.hdnFolderId.value = iCheckBoxId;
			Form1.submit();
			break;
		}
	}
}

/* 
 * Confirms before deleting any item.
 */
function confirmDeleteItem(iConfirmationMessage, iItemToDelete)
{
	if(confirm(iConfirmationMessage))
	{
		Form1.hdnItemToDeleteId.value = iItemToDelete;
		Form1.submit();
	}
}

/* 
 * Confirms before deleting any item.
 */
function confirmDeleteFolder(iConfirmationMessage, iItemToDelete)
{
	if(confirm(iConfirmationMessage))
	{
		Form1.hdnFolderToDeleteId.value = iItemToDelete;
		Form1.submit();
	}
}

/* 
 * Confirms before selecting any item.
 */
function confirmSelection(iConfirmationMessage, iItemSelected)
{
	if(confirm(iConfirmationMessage))
	{
		window.returnValue = iItemSelected;
		window.close();
	}
}

/* 
 * Confirms before creating a new version for the existing item.
 */
function confirmCreateVersionItem(iConfirmationMessage, iItemToDelete)
{
	if(confirm(iConfirmationMessage))
	{
		Form1.hdnCreateVersionId.value = iItemToDelete;
		Form1.submit();
	}
}

/* 
 * Shows the confirmation message and then sets the control with the value passed
 */
function showConfirmationMessage(sConfirmationMessage, sValueToSet, sControlId)
{
	if(confirm(sConfirmationMessage))
	{
		var iControlId = document.getElementById(sControlId);
		iControlId.value = sValueToSet;
		Form1.submit();
	}
}

/* 
 * Opens a window that can be resize.
 */
function openWindowResize(sURL, iHeight, iWidth)
{
	var iTop = (screen.height - iHeight)/2;
	var iLeft = (screen.width - iWidth)/2;
	
	window.open(sURL, "_blank", "toolbar=0,scrollbars=1,resizable=1,status=1,height=" + iHeight + ",width=" + iWidth + ",top=" + iTop + ",left=" + iLeft);
}

///<summery>
///Opens a modal dialog to edit information, force off scrolling.
///<summery>
function openModalDialogForReport(sURL, sTextToPass, iWantReturnVal, iWebControlId, iWebControlType)
{
	var sRetVal = window.showModalDialog(sURL, sTextToPass, "toolbar:0;resizable:0;status:0;scroll=no;dialogHeight:600px;dialogWidth:900px;centered:1");
	//var sRetVal = window.open(sURL);
	if((sRetVal == null) ||
		(sRetVal == "cancel"))
	{
		sRetVal = "";
	}
	
	if(sRetVal != "")
	{
		if(iWantReturnVal == "1")
		{
			if((iWebControlType == "1") ||
				(iWebControlType == "2") || (iWebControlType == "3") ) // Means text, image or Report
			{
				//iWebControlType += "&*^*&" + iWebControlId + "&*^*&" + sRetVal;
				Form1.TextBox1.value = sRetVal;
				//Form1.hdnReportId.value = sRetVal;
				alert(Form1.TextBox1.value);
				Form1.submit();
			}
		}
	}
	else
	{
		Form1.hdnReportId.value = "";
		Form1.submit();
	}
}

/* 
 * Set id of personalised items to be removed from personalisation object
 */
function setRemovePersonaliseId(sConfirmationMessage, sValueToSet, sControlId)
{
	//if(confirm(sConfirmationMessage))
	//{
		var iControlId = document.getElementById(sControlId);
		iControlId.value = sValueToSet;
		//alert(iControlId.value);
		Form1.submit();
	//}
}

/* 
 * method called to submit form in order to refresh web page
 */
function submitForm()
{
	Form1.submit();	
}

/*
 *set values on/off to textbox according to status of checkbox to enable postback 
 *use in cms_report
 */
function setCheckBox(selectedCheckBox)
{
	//get the textbox assciated with checkbox
	var vTBControlName = selectedCheckBox.name.replace("CBparams", "params");				
	var vTBControl = document.getElementById(vTBControlName);
	
	if (vTBControl != null)
	{
		if(selectedCheckBox.checked == true)
			vTBControl.value = "on";					
		else	
			vTBControl.value = "off";
	}
}

/* 
 * Shows the confirmation message and then sets the control with the value passed
 */
function viewConfirmationMessage(sConfirmationMessage, sValueToSet, sControlId)
{
	if(confirm(sConfirmationMessage))
	{
		var iControlId = document.getElementById(sControlId);
		iControlId.value = sValueToSet;
		Form1.submit();
	}
}

/* 
 * Shows the confirmation message and then sets the control with the value passed
 */
function showCustomInformationMessage(sMessage)
{
	alert(sMessage);
}


//dreamweaver-generated popup script used on E-VIS site

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_openBrWindow(theURL,winName,w,h) { //v2.0
  topPos = (screen.height) ? (screen.height-h)/2 : 0;
  leftPos = (screen.width) ? (screen.width-w)/2 : 0;
  features = 'height='+h+',width='+w+',top='+topPos+',left='+leftPos+',scrollbars=yes'
  window.open(theURL,winName,features);
}

function MM_openBrWindowWithoutScrollbars(theURL,winName,w,h) { //v2.0
  topPos = (screen.height) ? (screen.height-h)/2 : 0;
  leftPos = (screen.width) ? (screen.width-w)/2 : 0;
  features = 'height='+h+',width='+w+',top='+topPos+',left='+leftPos+',scrollbars=no'
  window.open(theURL,winName,features);
}

//client list scrpt for E-VIS site

var picArea = new Image();

//toggleRules("txt0", "", "pic0");

///<summary>
///change the text and default logo and image editing link on mouse click
///<summary>
function toggleRules(sTblId, sAId, aLogoId, sImageEditLink) {
		var myTbl = document.getElementById(sTblId);
		
		if (myTbl != null)
		{
		
			var sCurrentDisp = myTbl.style.display;
	                
			var arrTbls = document.getElementsByTagName("table");
			picArea = document.getElementById(aLogoId);
			
			for (i=0; i<=arrTbls.length-1; i++) {
				if (arrTbls[i].id.indexOf("txt") >= 0) {
					if (arrTbls[i].id !=  sTblId) 		
					arrTbls[i].style.display = "none";
				}
			}
		
			if (sCurrentDisp == "none") {
				myTbl.style.display = "";
			}
			
			if ( sImageEditLink != null )
			{
			document.getElementById('anchorEditImage').style.display = "";
			document.getElementById('anchorEditImage').href = "javascript:" + sImageEditLink;		   		
			}
			else
			{
			document.getElementById('anchorEditImage').style.display = "none";
			document.getElementById('anchorEditImage').href = "#";
			}
		}
}
	
///<summary>
///handle onmouseout of the client link
///<summary>
function toggleLogoOut() {
		var logoChange = document.getElementById("logoChange");
		logoChange.src = picArea.src;
}
	
toggleLogo("pic0");

///<summary>
///handle onmouseover of the client link
///<summary>	
function toggleLogo(sLogoId) {
		var myLogo = document.getElementById(sLogoId);
		
		if (myLogo != null)
		{
		
		   var logoChange = document.getElementById("logoChange");
		
		   logoChange.src = myLogo.src;
		}
}
