/*
	shows a modal dialog with the about dialog page
*/
var S_ROOT_VIRTUAL_DIRECTORY = "/6110CCM";

function showReportModeHelp()
{
	showHelpPopUp("reportmode.htm");
}

function showHelpPopUp(sPage)
{
	var sHeight = "500px";
	var sWidth = "500px";
	var sFeatures;
	
	var vReturnValue;
	
	sFeatures = "resizable:yes;edge:sunken;dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";help:no;status:no";
	
	vReturnValue = window.showModalDialog(sPage, null ,sFeatures);
}

function  showPopUp(sPage,w,h)
{
	var sHeight =h; //"500px";
	var sWidth =w; //"500px";
	var sFeatures;
	
	var vReturnValue;
	
	sFeatures = "resizable:no;edge:sunken;dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";help:no;status:no";
	
	vReturnValue = window.showModalDialog(sPage, null ,sFeatures);
}
function showAbout()
{
	var sHeight = "450px";
	var sWidth = "575px";
	var sFeatures;
	
	var vReturnValue;
	
	sFeatures = "dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";help:no;status:no";
	
	vReturnValue = window.showModalDialog("about6110CCM.htm", null ,sFeatures);
}

function showOnLineHelp(sPath)
{
	window.open(sPath, null ,"");
}

/*
Asks the user if they want to add the calling page to their favorites
*/
function addToFavorites()
{
	window.external.AddFavorite(location.href, document.title);
}

/*
Asks the user if they want to make the calling page
their home page.

Depends upon the following being in the source html page
	<HTML xmlns:IE>
	<IE:homePage ID="oHomePage" />
*/
function makeHomePage()
{
	//Call behaviour from IE namespace
	oHomePage.setHomePage(location.href);
}

/*
	Toggles an objects visibility.
	Returns the state of the objects visibility
*/
function toggleObjectVisible(MyObject)
{
	if ("inline" == MyObject.style.display ||
		"" == MyObject.style.display)
	{
		MyObject.style.display = "none";
		return false;
	}
	else
	{
		MyObject.style.display = "inline";
		return true;
	}
}

/*
	Toggles an objects visibility.
	Returns the state of the objects visibility
	Differs from toggleObjectVisible in that when
	display is "" (null) then the desired value
	is assumed to be inline, not none
*/
function toggleObjectVisibleNoNull(MyObject)
{
	if ("inline" == MyObject.style.display)
	{
		MyObject.style.display = "none";
		return false;
	}
	else
	{
		MyObject.style.display = "inline";
		return true;
	}
}

/*
	Change the parent window title
*/
function fnChangePageTitle(newTitle)
{			
	window.parent.document.title = newTitle;
}

/*
Toggle the checkboxes in a table based on a datagrid.
param:  this -- a checkbox used for select all/deselect all
		table -- a reference to the table
*/
function ChangeCheck(chkbox,table)
{	
	var InputTagsInTable = table.getElementsByTagName("INPUT");
	var i;
	for(i=0; i<InputTagsInTable.length; i++)
	{	/*HACK:  the second condition makes sure that the second last character is not a
			     checkbox list such as on the view employee logins screen */
		if(InputTagsInTable(i).id.indexOf("_chk",0) != -1 && InputTagsInTable(i).id.charAt(InputTagsInTable(i).id.length-2) != "_")
		{						
			InputTagsInTable(i).checked= chkbox.checked;
		}
	}		
}

/*Toggle the enabled state and background off all the
  input controls in a table. Sets disabled property equal to opposite
  of checkbox.checked property
  NOTE: Exceptions are textboxes if the naming convention is to start the name with 'chk'
 */
function ToggleEnabledState(chkbox,tbl)
{	
	var InputsInTable = tbl.getElementsByTagName("INPUT");	
	var SelectsInTable = tbl.getElementsByTagName("SELECT");
	var TextAreaInTable = tbl.getElementsByTagName("TEXTAREA");
	var i;
	
	if(chkbox.checked)
	{	
		for(i=0; i < InputsInTable.length; i++)
		{	
			if(InputsInTable(i).type != 'submit')
			{
				if(InputsInTable(i).id.indexOf('chk')==-1)
				{				
				InputsInTable(i).style.backgroundColor='#ffffff';  //white
				InputsInTable(i).disabled = !chkbox.checked;				
				}				
			}	
				
		}
		for(i=0; i < SelectsInTable.length; i++)
		{	
			SelectsInTable(i).disabled = !chkbox.checked;
			SelectsInTable(i).style.backgroundColor='#ffffff';  //white
		}
		
		for(i=0; i < TextAreaInTable.length; i++)
		{	
			TextAreaInTable(i).disabled = !chkbox.checked;
			TextAreaInTable(i).style.backgroundColor='#ffffff';  //white
		}
	}
	else
	{	//do all the input tags
		for(i=0;i<InputsInTable.length;i++)
		{
			if(InputsInTable(i).type != 'submit')
			{
				if(InputsInTable(i).id.indexOf('chk')==-1)
				{					
					InputsInTable(i).style.backgroundColor='#d4d0c8'; //disabled grey					
					InputsInTable(i).disabled = !chkbox.checked;
				}				
			}
			
		}
		//do all the select tags			
		for(i=0;i<SelectsInTable.length;i++)
		{	
			SelectsInTable(i).disabled = !chkbox.checked;
			SelectsInTable(i).style.backgroundColor='#d4d0c8'; //disabled grey
			SelectsInTable(i).selectedIndex=0;
		}			
		
		for(i=0; i < TextAreaInTable.length; i++)
		{	
			TextAreaInTable(i).disabled = !chkbox.checked;
			TextAreaInTable(i).style.backgroundColor='#d4d0c8';  //white
		}
	}
	SelectsInTable=null;
	InputsInTable=null;
}

/*Toggle the enabled state and background off all the
  input controls in a table. Sets disabled property to the
  same as checkbox.checked property.
  NOTE: Exceptions are textboxes if the naming convention is to start the name with 'chk'
 */
function ToggleDisabledState(chkbox,tbl)
{	
	var InputsInTable = tbl.getElementsByTagName("INPUT");	
	var SelectsInTable = tbl.getElementsByTagName("SELECT");
	var i;
	
	if(chkbox.checked)
	{	
		for(i=0; i < InputsInTable.length; i++)
		{	
			if(InputsInTable(i).id.indexOf('chk')==-1)
			{
			InputsInTable(i).disabled = chkbox.checked;
			InputsInTable(i).style.backgroundColor='#d4d0c8'; //disabled grey
			//InputsInTable(i).value='';
			}						
		}
		for(i=0; i < SelectsInTable.length; i++)
		{	
			SelectsInTable(i).disabled = chkbox.checked;
			SelectsInTable(i).style.backgroundColor='#d4d0c8';  //disabled grey
		}
	}
	else
	{	//do all the input tags
		for(i=0;i<InputsInTable.length;i++)
		{
			if(InputsInTable(i).id.indexOf('chk')==-1)
			{
				InputsInTable(i).disabled = chkbox.checked;
				InputsInTable(i).style.backgroundColor='#ffffff'; //white				
			}
		}
		//do all the select tags			
		for(i=0;i<SelectsInTable.length;i++)
		{	
			SelectsInTable(i).disabled = chkbox.checked;
			SelectsInTable(i).style.backgroundColor='#ffffff'; //white
			SelectsInTable(i).selectedIndex=0;
		}			
	}
	SelectsInTable=null;
	InputsInTable=null;
}

// Gets window coordinates
function windowCoords(iWidth)
{
	this.Height = screen.availHeight / 1.5;
	this.Top = (screen.availHeight - this.Height) / 2;
	this.Left = (screen.availWidth - iWidth) / 2;
	this.Width = iWidth;
}


function fnToggleObjectDisabled(chk,obj)
{	
	try{
		if(chk.checked)
		{	
			obj.runtimeStyle.backgroundColor ='#ffffff';
		} else {				
			obj.runtimeStyle.backgroundColor = '#d4d0c8';
			obj.text='';
		}
		obj.disabled = !chk.checked;
    } catch(e) { 
		//do nothing
	}
}

function fnShowPortSettings(txt,options)
	{	
		
		var sHeight ="250px";
		var sWidth = "225px";
		var sFeatures;
		var sPage = "/EnterpriseManager/PortConfiguration.htm";
		var sReturnValue;
		sFeatures = "resizable:no;edge:sunken;dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";help:no;status:no";
		sReturnValue =window.showModalDialog(sPage, options ,sFeatures);		
		txt.value = sReturnValue;
	}

function fnManageSchedule(txt,ID)
{
	var sHeight = "260px";
	var sWidth = "650px";
	var sFeatures;
	
	var vReturnValue;
	
	sFeatures = "resizable:yes;edge:sunken;dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";help:no;status:no";
	
	vReturnValue = window.showModalDialog("ManageSchedule.htm?ID=" + ID, null ,sFeatures);
	if(vReturnValue != null)
	{
	txt.value=vReturnValue;
	__doPostBack(txt.ID,'')
	}
	}
	
	function fnManageAcknowledgement(txt,ID)
{
	var sHeight = "430px";
	var sWidth = "510px";
	var sFeatures;
	
	var vReturnValue;
	
	sFeatures = "resizable:yes;edge:sunken;dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";help:no;status:no";
	
	vReturnValue = window.showModalDialog("/configuration/ManageAcknowledgementPopUp.htm?ID=" + ID, null ,sFeatures);
	if(vReturnValue != null)
	{
	txt.value=vReturnValue;
	__doPostBack(txt.ID,'')
	}
	}
	
function fnManageAlarms(txt,ID)
{
	var sHeight = "320px";
	var sWidth = "410px";
	var sFeatures;
	
	var vReturnValue;
	
	sFeatures = "resizable:yes;edge:sunken;dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";help:no;status:no";
	
	vReturnValue = window.showModalDialog("ManageAlarms.htm?ID=" + ID, null ,sFeatures);
	if(vReturnValue != null)
	{
	txt.value=vReturnValue;
	__doPostBack(txt.ID,'')
	}
	}
	
	function fnManageCalendar(txt)
{
	var sHeight = "225px";
	var sWidth = "160px";
	var sFeatures;	
	var vReturnValue;
		
	sFeatures = "resizable:no;edge:sunken;dialogHeight:" + sHeight + ";dialogWidth:" + sWidth + ";help:no;status:no";
	
	vReturnValue = window.showModalDialog('ManageCalendarPopUp.htm?date='.concat(txt.value), null ,sFeatures);
	
	if(vReturnValue != null)
	{
	txt.value=vReturnValue;	
	}
	}
	
function OpenInNewWindow(sPath)
{	var swidth = (screen.width * 0.8)  + "px";
	var sheight = (screen.height * 0.8) + "px";
	window.showModalDialog(sPath, "some","help:no;dialogHeight:" + sheight +";dialogWidth:" + swidth);
}

function PrintScreen()
{
	window.print();
}

function ShowCustomReport()
{
	window.showModalDialog("../../webforms/configuration/customreports_en.html","some","help:no;dialogHeight:250px;dialogWidth:400px;");
}

