﻿var ImgExpand_plus;
var ImgExpand_minus;
var HadScriptsInit = 0;
var oPopup;
var EditBox;
var EditIDBox;
var CloseAfaterComplete = false;
var DocumentModified = false;
var UserEnterCount = 0;
var TempParam;
var MyAccessID;

function CommonJavaScriptsInit()
{
	ImgExpand_plus = new Image();
	ImgExpand_plus.src="images/plus-expand.gif";
	
	ImgExpand_minus = new Image();
	ImgExpand_minus.src="images/minus-expand.gif";
	
	HadScriptsInit = 1;
}

function IsEmpty(item) 
{
    var sTest
    sTest = trim(item)
    if (sTest == null || sTest == "") 
    {
        return true
    }
    return false
}

function OnItemValueChanged10009(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;
	}
	
	var show=true;
	if(result=="False")
	{
		if(inputobj.checked)
			show=true;
		else
			show=false;
	}
	else
	{
		if(inputobj.checked)
			show=false;
		else
			show=true;
	}
	if(show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function OnItemValueChanged10008(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;

	}
	var show=true;
	if(result=="False")
	{
		if(inputobj.checked)
			show=false;
		else
			show=true;
	}
	else
	{
		if(inputobj.checked)
			show=true;
		else
			show=false;
	}
	if(show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function GetItemValueString(inputobj) 
{
	//alert("inputobj.name=" + inputobj.name);
	var valstr="";
    for (var i=0;i<document.forms[0].elements.length;i++)
	{
		if (document.forms[0].elements[i].name == inputobj.name)
		{
			if (document.forms[0].elements[i].checked)
			{
				if (valstr.length>0)
				{
					valstr=valstr+",";
				}
				valstr=valstr+document.forms[0].elements[i].value;
			}
		}
	}
	//alert("valstr=" + valstr);
	return valstr;
}
function GetItemValueString(inputobj) 
{
	var valstr="";
	try 
	{
	    var trlist;
		var children;
	    var ActionItem;
	    var someitemlist = inputobj.parentNode;
	    if (someitemlist.id==inputobj.name)
	    {
			// Get table element
			someitemlist = someitemlist.parentNode.parentNode;
			children = someitemlist.childNodes;
			for (var i = 0; i < children.length; i++) 
			{
				trlist = children[i].childNodes;
				for (var j = 0; j < trlist.length; j++) 
				{
					ActionItem = trlist[j].childNodes[0];
					if (ActionItem.name == inputobj.name)
					{
						if (ActionItem.checked)
						{
							if (valstr.length>0)
							{
								valstr=valstr+",";
							}
							valstr= valstr+ ActionItem.value;
						}
					}
				}
			}
	  		return valstr;
		}


	    children = someitemlist.childNodes;
	    //alert(children[i].name);
	    for (var i = 0; i < children.length; i++) 
	    {
	        ActionItem = children[i];
		    if (ActionItem.name == inputobj.name)
		    {
			    if (ActionItem.checked)
			    {
				    if (valstr.length>0)
				    {
					    valstr=valstr+",";
				    }
				    valstr= valstr+ ActionItem.value;
			    }
		    }
	    }
	    //alert("valstr=" + valstr);
	} catch( myError ) 
	{

		//alert( myError.name + ': ' + myError.message );
	} finally 
	{

	}
	return valstr;
}
function ScanMathItem(inputobj, mathtext) 
{
	try 
	{
	    var trlist;
	    var children;
	    var ActionItem;
	    var someitemlist = inputobj.parentNode;
	    if (someitemlist.id==inputobj.name)
	    {
			// Get table element
			someitemlist = someitemlist.parentNode.parentNode;
			children = someitemlist.childNodes;
			for (var i = 0; i < children.length; i++) 
			{
				trlist = children[i].childNodes;
				for (var j = 0; j < trlist.length; j++) 
				{
					ActionItem = trlist[j].childNodes[0];
					if (ActionItem.name == inputobj.name)
					{
						if (ActionItem.checked)
						{
							if (ActionItem.value == mathtext)
								return true;
						}
					}
				}
			}
			return false;
	    }
	    children = someitemlist.childNodes;
	    for (var i = 0; i < children.length; i++) 
	    {
	        ActionItem = children[i];
		    if (ActionItem.name == inputobj.name)
		    {
			    if (ActionItem.checked)
			    {
				    if (ActionItem.value == mathtext)
				        return true;
			    }
		    }
	    }
	} catch( myError ) 
	{

	} finally 
	{

	}
	return false;
}
function OnItemValueChanged10007(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;

	}
	var inputvalue = GetItemValueString(inputobj);
	var show=true;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(inputvalue==splitString[i])
			show=false;
	}
	if(show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function OnItemValueChanged100(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;

	}
	var inputvalue = GetItemValueString(inputobj);
	var show=true;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(inputvalue!=splitString[i])
			show=false;
	}
	if (show == false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function OnItemValueChanged101(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;

	}
	//alert(inputobj.name);
	var inputvalue = GetItemValueString(inputobj);
    var show=false;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(inputvalue==splitString[i])
		{
			show=true;
			break;
		}
	}
	//alert("inputvalue=" + inputvalue + ", result=" + result + ", show=" + show);
	if (show == false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function OnItemValueChanged130(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
		return;

	var show=true;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(ScanMathItem(inputobj, splitString[i]))
		{
			show=false;
			break;
		}
	}
	//alert("result=" + result + ", show=" + show);
	if (show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function OnItemValueChanged131(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
		return;

	var show=false;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(ScanMathItem(inputobj, splitString[i]))
		{
			show=true;
			break;
		}
	}
	if(show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}


function OnItemValueChanged0(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;

	}
	var show=true;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(inputobj.value==splitString[i])
			show=false;
	}
	if(show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function OnItemValueChanged1(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;

	}
	var show=false;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(inputobj.value==splitString[i])
			show=true;
	}
	if(show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function OnItemValueChanged2(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;

	}
	var show=true;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(inputobj.value>splitString[i])
			show=false;
	}
	if(show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}
function OnItemValueChanged3(inputobj, result, ItemObj) 
{
    DocumentModified = true;
	if (ItemObj == null)
	{
		return;

	}
	var show=true;
	var splitString = result.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
		if(inputobj.value<splitString[i])
			show=false;
	}
	if(show==false)
	{
		ItemObj.style.display="none";
	}
	else
	{
		ItemObj.style.display="";
	}
}

function CleanLookupItem(linkObj)
{
	linkObj.value = "";
}

function FileBrowseDialog(linkObj, path, pattern, w, h, fullexplorer) 
{
    EditBox = linkObj;
    OpenModalDialog("FileBrowser.aspx?path=" + path + "&pattern=" + pattern + "&fullexplorer=" + fullexplorer, w, h, "yes", "no");
}

function OpenPopupMenu(linkObj, AjaxUrl, w, h)
{
	EditBox = linkObj;
	OpenPopup(AjaxUrl, linkObj, w, h);
}

function OpenPopupMenuEx(linkObj, linkIDObj, AjaxUrl, w, h) 
{
    EditBox = linkObj;
    EditIDBox = linkIDObj;
    OpenPopup(AjaxUrl, linkObj, w, h);
}

function OpenLookupDialogEx(linkObj, linkIDObj, Lookupname, w, h) 
{
    EditBox = linkObj;
    EditIDBox = linkIDObj;
    OpenModalDialog("TableLookup.aspx?Lookupname=" + Lookupname, w, h, "yes", "no");
}

function OpenLookupDialog(linkObj, Lookupname, w, h)
{
	EditBox = linkObj;
	OpenModalDialog("TableLookup.aspx?Lookupname=" + Lookupname, w, h, "yes", "no");
}

function OpenLookupWindow(linkObj, Lookupname)
{
	//OpenModalDialog("TableLookup.aspx?Lookupname=" + Lookupname, 250, 400, "yes", "no");
	//return;

	EditBox = linkObj;
	window.TableLookup.location.href="TableLookup.aspx?Lookupname=" + Lookupname;
}

function OpenSelectionpDialog(url, w, h, linkObj)
{
    EditBox = linkObj;

    //alert(EditBox.value);
    
    OpenModalDialog(url, w, h, "yes", "no");
}


function OnSelectedItem(itemid, name)
{
    DocumentModified = true;
	EditBox.value=name;
}

function iFrameSelectThisItem(itemid, name)
{
    DocumentModified = true;
	parent.OnSelectedItem(itemid, name);
}


var DateTimeInputForm = null;
function HideDateTimeCalendar() 
{
	if (DateTimeInputForm == null)
		return;
		
	window.document.body.removeChild(DateTimeInputForm);
	DateTimeInputForm = null;
}
function ShowDateTimeCalendar(inputname) 
{
	if (DateTimeInputForm != null)
	{
		HideDateTimeCalendar();
	}
	try 
	{
		DateTimeInputForm = document.createElement("iframe");
		DateTimeInputForm.id = "Calendariframe";
		DateTimeInputForm.name = "Calendariframe";
		DateTimeInputForm.frameborder = 1;
		DateTimeInputForm.style.top = document.body.scrollTop + event.clientY;
		DateTimeInputForm.style.left = 20 + document.body.scrollLeft + event.clientX;
		DateTimeInputForm.height = 180;
		DateTimeInputForm.width = 268;
		DateTimeInputForm.style.position = "absolute"; //relative,absolute
		DateTimeInputForm.style.display = "block";
		DateTimeInputForm.scrolling = "auto";
		DateTimeInputForm.src = "DateTimeInput.aspx?inputname=" + inputname;
		window.document.body.appendChild(DateTimeInputForm);
	}
	catch(exception) 
	{
	}
	var IFrameDoc;
	IFrameObj = document.frames['Calendariframe'];
	IFrameObj.location.replace("DateTimeInput.aspx?inputname=" + inputname);
	return false;
}


function ReOpenCalendar(selstr)
{
	var year  = parseInt(selstr.substring(1, 5), 10);
	var month = parseInt(selstr.substring(6, 8), 10);
	if (month < 1)
	{
		month = 12;
		year = year - 1;
	}
	if (month > 12)
	{
		month = 1;
		year = year + 1;
	}
	month = month - 1;
	var Contents = GenerateCalendar(year, month);
	var oPopupBody = oPopup.document.body;
	oPopupBody.innerHTML = Contents; 
	for (var i = 0; i < oPopupBody.all.length; i++)
	{
		if (oPopupBody.all[i].tagName == "A")
		    oPopupBody.all[i].onclick = DoCalendarClick;
	}
}
function DoCalendarClick()
{
	var selstr = this.id;
	if (selstr.substring(0,1) == '_')
	{
		parent.ReOpenCalendar(selstr);
	}
	else
	{
	    if (EditBox != null)
	    {
            DocumentModified = true;
		    EditBox.value=selstr;
		    EditBox.select();
		    EditBox.focus();
	    }
	    else
	    {
            parent.DocumentModified = true;
		    parent.EditBox.value=selstr;
		    parent.EditBox.select();
		    parent.EditBox.focus();
		}
	    oPopup.hide();
	}
}
function GenerateCalendar(year, month)
{
	var DayOfMonth = new Date(year, month, 1);
	var Contents = "<table cellspacing='0' cellpadding='2' bordercolor='White' border='0' style='color:Black;background-color:White;border-color:White;border-width:1px;border-style:solid;font-family:Verdana;font-size:9pt;'>";
	Contents = Contents + "<tr><td height=24 valign='bottom' align='center'><a href='' id='_";
	Contents = Contents + year;
	Contents = Contents + "-";
	Contents = Contents + (month);
	Contents = Contents + "'><<</a>";
	Contents = Contents + "</td><td height=26 colspan='5' valign='bottom' align='center' style='background-color:White;border-color:Black;border-width:2px;'>";
	Contents = Contents + DayOfMonth.toString().substring(4,7);
	Contents = Contents + ", ";
	Contents = Contents + year;
	Contents = Contents + "</td><td height=24 valign='bottom' align='center'><a href='' id='_";
	Contents = Contents + year;
	Contents = Contents + "-";
	Contents = Contents + (month + 2);
	Contents = Contents + "'>>></a>";
	Contents = Contents + "</td></tr><tr><td colspan=7><hr></td></tr><tr><td align='Center' style='font-size:8pt;font-weight:bold;'>Sun</td><td align='Center' style='font-size:8pt;font-weight:bold;'>Mon</td><td align='Center' style='font-size:8pt;font-weight:bold;'>Tue</td><td align='Center' style='font-size:8pt;font-weight:bold;'>Wed</td><td align='Center' style='font-size:8pt;font-weight:bold;'>Thu</td><td align='Center' style='font-size:8pt;font-weight:bold;'>Fri</td><td align='Center' style='font-size:8pt;font-weight:bold;'>Sat</td></tr>";
	var SkeepDay = DayOfMonth.getDay();
	var Loop;
	var DateStr;
	Contents = Contents + "<tr height=20>";
	for (Loop = 0; Loop < SkeepDay; Loop++)
	{
		Contents = Contents + "<td align='Center' style='color:#999999;width:14%;'>&nbsp;</td>";
	}
	while (DayOfMonth.getMonth() == month)
	{
		if (DayOfMonth.getDate() > 6)
		Contents = Contents + "<tr height=20>";
		DateStr =year+"-"+(month+1)+"-"+DayOfMonth.getDate();
		Contents = Contents + "<td align='Center'>";
		if (DateStr == EditBox.value)
		{
			Contents = Contents + "<a  style='color:Blue;width:14%;' href='' id='" + DateStr + "'>";
		}
		else if (DayOfMonth.getDay() == 6 || DayOfMonth.getDay() == 0)
		{
			Contents = Contents + "<a  style='color:Red;width:14%;' href='' id='" + DateStr + "'>";
		}
		else
		{
			Contents = Contents + "<a style='color:Black;width:14%;' href='' id='" + DateStr + "'>"
		}
		Contents = Contents + DayOfMonth.getDate();
		Contents = Contents +"</a></td>";
		DayOfMonth.setDate(DayOfMonth.getDate() + 1);
		while (DayOfMonth.getDay() != 0 && DayOfMonth.getMonth() == month)
		{
			DateStr =year+"-"+(month+1)+"-"+DayOfMonth.getDate();
			Contents = Contents + "<td align='Center'>";
			if (DateStr == EditBox.value)
			{
				Contents = Contents + "<a  style='color:Blue;width:14%;' href='' id='" + DateStr + "'>";
			}
			else if (DayOfMonth.getDay() == 6 || DayOfMonth.getDay() == 0)
			{
				Contents = Contents + "<a  style='color:Red;width:14%;' href='' id='" + DateStr + "'>";
			}
			else
			{
				Contents = Contents + "<a style='color:Black;width:14%;' href='' id='" + DateStr + "'>"
			}
			Contents = Contents + DayOfMonth.getDate();
			Contents = Contents +"</a></td>";
		   	DayOfMonth.setDate(DayOfMonth.getDate() + 1);
		}
		Contents = Contents + "</tr>";
	}
	Contents = Contents + "</table>";
	return Contents
}
function OpenCalendar(linkObj)
{
	EditBox = linkObj;
	oPopup = window.createPopup();
	var calendar = new Date();
	var month = calendar.getMonth();
	var year = calendar.getYear();
	var Contents = GenerateCalendar(year, month);
	
	var oPopupBody = oPopup.document.body;
	oPopupBody.style.backgroundColor = "white";
	oPopupBody.style.border = "solid blue 3px";
	oPopupBody.innerHTML = Contents; 
	for (var i = 0; i < oPopupBody.all.length; i++)
	{
		if (oPopupBody.all[i].tagName == "A")
		oPopupBody.all[i].onclick = DoCalendarClick;
	}
	oPopup.show(linkObj.offsetWidth, 0, 210, 196, linkObj);
}
function OpenYearCalendar(linkObj)
{
	EditBox = linkObj;
	oPopup = window.createPopup();
	var selstr = parent.EditBox.value;
	var year  = parseInt(selstr.substring(0, 4), 10);
	if (selstr.length < 4 || year < 1900)
	{
		year = 1990;
	}
	var Contents = GenerateYearCalendar(year);
	
	var oPopupBody = oPopup.document.body;
	oPopupBody.style.backgroundColor = "white";
	oPopupBody.style.border = "solid blue 3px";
	oPopupBody.innerHTML = Contents; 
	for (var i = 0; i < oPopupBody.all.length; i++)
	{
		if (oPopupBody.all[i].tagName == "A")
		oPopupBody.all[i].onclick = DoYearCalendarClick;
	}
	
	oPopup.show(linkObj.offsetWidth, 0, 175, 370, linkObj);
	
}
function GenerateYearCalendar(year)
{
	var Contents = "<table cellspacing='0' cellpadding='2' bordercolor='White' border='0' style='color:Black;background-color:White;border-color:White;border-width:1px;border-style:solid;font-family:Verdana;font-size:9pt;'>";
	Contents = Contents + "<tr><td height=26 valign='bottom' align='center'><a href=''style='text-decoration: none;' id='_";
	Contents = Contents + (year - 10);
	Contents = Contents + "'><10</a><a href='' id='_"+(year-5)+"' style='text-decoration: none;'> 5</a><a href='' style='text-decoration: none;' id='_"+(year-2)+"'> 2</a><a href='' style='text-decoration: none;' id='_"+(year-1)+"'> 1</a>";
	Contents = Contents + "</td><td height=26  valign='bottom' align='center' style='background-color:White;border-color:Black;border-width:2px;'><font color=red>";
	Contents = Contents + year;
	Contents = Contents + "</font></td><td height=26 valign='bottom' align='center'><a href=''style='text-decoration: none;' id='_";
	Contents = Contents + (year + 1);
	Contents = Contents + "'> 1</a><a href='' style='text-decoration: none;' id='_"+(year+2)+"'> 2</a><a href='' style='text-decoration: none;' id='_"+(year+5)+"'> 5</a><a href='' style='text-decoration: none;' id='_"+(year+10)+"'> 10></a>";
	Contents = Contents + "</td></tr>";
	Contents = Contents + "<tr><td colspan='3'><hr></td></tr>";
	var Loop;
	var DateStr;
		DateStr = "";
		Contents = Contents + "<tr><td colspan='3' height='24'>&nbsp;&nbsp;";
		Contents = Contents + "<a  style='color:Red;width:100%;' href='' id='" + DateStr + "'>";
		Contents = Contents + "[未定义]";
		Contents = Contents +"</a></td></tr>";
	for (Loop = 1; Loop <= 12; Loop++)
	{
		DateStr = year+"年"+Loop+"月";
		Contents = Contents + "<tr><td colspan='3' height='24'>&nbsp;&nbsp;";
		Contents = Contents + "<a  style='color:Red;width:100%;' href='' id='" + DateStr + "'>";
		Contents = Contents + DateStr;
		Contents = Contents +"</a></td></tr>";
	}
	Contents = Contents + "</table>";
	return Contents
}
function DoYearCalendarClick()
{
	var selstr = this.id;
	if (selstr.substring(0,1) == '_')
	{
		parent.ReOpenYearCalendar(selstr);
	}
	else
	{
	    if (EditBox != null)
	    {
		    EditBox.value=selstr;
		    EditBox.select();
		    EditBox.focus();
            DocumentModified = true;
	    }
	    else
	    {
		    parent.EditBox.value=selstr;
		    parent.EditBox.select();
		    parent.EditBox.focus();
            parent.DocumentModified = true;
		}
		oPopup.hide();
	}
}
function ReOpenYearCalendar(selstr)
{
	var year  = parseInt(selstr.substring(1, 5), 10);
	var Contents = GenerateYearCalendar(year);
	var oPopupBody = oPopup.document.body;
	oPopupBody.innerHTML = Contents; 
	for (var i = 0; i < oPopupBody.all.length; i++)
	{
		if (oPopupBody.all[i].tagName == "A")
		oPopupBody.all[i].onclick = DoYearCalendarClick;
	}
}
var xmlhttp
var XMLHttpRequestURL;
var UpdateJobName;

function StartAutoUpdate(url, freq)
{
	UpdateFrequency = freq;
    XMLHttpRequestURL = url;
	setTimeout("SetUpdateRequest()", UpdateFrequency);
}

function SetUpdateRequest()
{
    ShowBlinking();
    CallXMLHttpRequest(XMLHttpRequestURL, UpdateStatus);
}

function LoadAJAXContent(url)
{
    var theXMLHttp;
    theXMLHttp = CreateXMLHttpObject();
    if (theXMLHttp)
    {					
		theXMLHttp.open("GET", url, true);
		theXMLHttp.onreadystatechange = function()
		{
	        if (theXMLHttp.readyState==4)
	        {
		        if (theXMLHttp.status==200)
		        {
			        //alert(theXMLHttp.responseText);
		            UpdateDHTMLContent(theXMLHttp.responseText);
		        }
		        else
		        {
			        theElement = document.getElementById("ErrorMeaasge")
			        if (theElement != null)
			        {
				        theElement.innerHTML = theXMLHttp.statusText;
			        }
		        }
	        }
	        else
	        {
		        theElement = document.getElementById("ErrorMeaasge")
		        if (theElement != null)
		        {
			        theElement.innerHTML = theXMLHttp.statusText;
		        }
	        }
		
		}
		theXMLHttp.send(null);
	}
}

function LoadAJAXContentByXML(url)
{
    var theXMLHttp;
    theXMLHttp = CreateXMLHttpObject();
    if (theXMLHttp)
    {					
		theXMLHttp.open("GET", url, true);
		theXMLHttp.onreadystatechange = function()
		{
	        if (theXMLHttp.readyState==4)
	        {
		        if (theXMLHttp.status==200)
		        {
    	            //alert(theXMLHttp.responseText);
                    UpdateDHTMLContentByXML(theXMLHttp.responseXML);
		        }
		        else
		        {
			        theElement = document.getElementById("ErrorMeaasge")
			        if (theElement != null)
			        {
				        theElement.innerHTML = theXMLHttp.statusText;
			        }
		        }
	        }
	        else
	        {
		        theElement = document.getElementById("ErrorMeaasge")
		        if (theElement != null)
		        {
			        theElement.innerHTML = theXMLHttp.statusText;
		        }
	        }
		
		}
		theXMLHttp.send(null);
	}
}

function CreateXMLHttpObject()
{
	var newXMLHttp;
	try
    {    
		newXMLHttp = new XMLHttpRequest();
	}
	catch (e)
    {
		try
		{
			newXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				newXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX which is needed for this feature!");
				return false;
			}
		}
	}
	return newXMLHttp;
}

function CallXMLHttpRequest(url, func) 
{
    try 
    {
        // code for Mozilla, etc.
        if (window.XMLHttpRequest) 
        {
            xmlhttp = new XMLHttpRequest()
            xmlhttp.onreadystatechange = func; //state_Change
            xmlhttp.open("GET", url, true)
            xmlhttp.send(null)
            //alert(url);
        }
        // code for IE
        else if (window.ActiveXObject) 
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
            if (xmlhttp) 
            {
                xmlhttp.onreadystatechange = func; //state_Change
                xmlhttp.open("GET", url, true)
                xmlhttp.send()
            }
        }
        return true;
        
    } catch (myError) 
    {
        alert(url + "," + myError.name + ': ' + myError.message);

        return false; 
    } finally 
    {

    }
}
function UpdateStatus()
{
	var theElement;
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
		{
			//alert(xmlhttp.responseText);
			theElement = document.getElementById("LastUpdate");
			if (theElement != null)
			{
				var Today = new Date();
				theElement.innerHTML=Today;
			}
		
		    if (UpdateDHTMLContent(xmlhttp.responseText))
        		setTimeout("SetUpdateRequest()",  UpdateFrequency);
		}
		else
		{
			theElement = document.getElementById("ErrorMeaasge")
			if (theElement != null)
			{
				theElement.innerHTML=xmlhttp.statusText;
			}
		}
	}
	else
	{
		theElement = document.getElementById("ErrorMeaasge")
		if (theElement != null)
		{
			theElement.innerHTML=xmlhttp.statusText;
		}
	}
}

function AJAXUpdatePageContent()
{
	var theElement;
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
		{
			//alert(xmlhttp.responseText);
		    UpdateDHTMLContent(xmlhttp.responseText);
		}
		else
		{
			theElement = document.getElementById("ErrorMeaasge")
			if (theElement != null)
			{
				theElement.innerHTML=xmlhttp.statusText;
			}
		}
	}
	else
	{
		theElement = document.getElementById("ErrorMeaasge")
		if (theElement != null)
		{
			theElement.innerHTML=xmlhttp.statusText;
		}
	}
}
function GetXMLItemValue(doc, nodename)
{
	var thenode;
	try
	{
		thenode = doc.getElementsByTagName(nodename)[0].childNodes[0];
		return thenode.nodeValue;
	}
	catch(ex)
	{
		//alert(ex.message);
	}
	return "error";
}

function UpdateDHTMLContentByXML(XMLDoc)
{
	if(XMLDoc)	
	{
		try
		{
		    var AjaxContent = XMLDoc.getElementsByTagName("AJAX");
		    if (AjaxContent == null || AjaxContent.length == 0)
		    {
    		    alert("AJAX return empty XML!");
    		    return;
		    }
            
            var NodesList = AjaxContent[0].childNodes;
			var theNode;
			var theNodeName;
			var theNodeValue;
	        
            for(var i=0; i < NodesList.length; i ++) 
            { 
                theNode = NodesList[i];
                theNodeName = theNode.nodeName;
                theNodeValue = theNode.childNodes[0].nodeValue;
    			//alert(theNodeName + " = " + theNodeValue);
                if (theNodeName=="COMMAND")
                {
                    ExecuteScriptCommand(theNodeValue);
                    continue;
                }   
                UpdateElementValue(theNodeName, theNodeValue);
            } 
	
		}
		catch(ex)
		{
		    alert(ex.message);
		}
	
	}
}
function ExecuteScriptCommand(scripttext)
{
    try
    {
        eval(scripttext);
	}
	catch(ex)
	{
	}
}
function SetElementSize(Name, w, h)
{
    var theElement;
	theElement = document.getElementById(Name);
	if (theElement == null)
	    return;

    if (w > 0)
         theElement.width = w;
         
    if (h > 0)
         theElement.height = h;
}

function UpdateElementValue(Name, value)
{
    var theElement;
	
	theElement = document.getElementById(Name);
	if (theElement == null)
	    return;

	theElement.innerHTML=value;
}

function FillFormEmptyElementValue(Name, value)
{
    try
    {
        if (document.forms[0] == null)
 	        return;
   
        var theElement;
        
        theElement = document.forms[0].elements[Name];

	    if (theElement == null)
	        return;
	    
	    if (theElement.value != "")
	        return;


	    theElement.value=value;
	    
	} catch( myError ) 
	{
		//alert( myError.name + ': ' + myError.message );
	} 
}

function UpdateFormElementValue(Name, value)
{
    try
    {
        if (document.forms[0] == null)
 	        return;
   
        var theElement;
        
        theElement = document.forms[0].elements[Name];

	    if (theElement == null)
	        return;

	    theElement.value=value;
	    
	} catch( myError ) 
	{
		//alert( myError.name + ': ' + myError.message );
	} 
}

function HideElement(Name)
{
    var theElement;
	
	theElement = document.getElementById(Name);
	if (theElement == null)
	    return;

	theElement.style.display="none";
}

function ShowElement(Name)
{
    var theElement;
	
	theElement = document.getElementById(Name);
	if (theElement == null)
	    return;

	theElement.style.display="";
}

function UpdateDHTMLContent(htmltext)
{
	try 
	{
		var ContinueUpadte;
		var CommandName;
		var CommandValue;
	    var responseText = htmltext;

		if (responseText.substring(0,1) == "@")
		{
		    ContinueUpadte = false;
		    var pos = responseText.indexOf("@", 2);
		    CommandName = responseText.substring(1, pos);
			CommandValue = responseText.substring(pos + 1);
			if (CommandName.charAt(0) == '@')
			{
			    ContinueUpadte = true;
			    CommandName = CommandName.substring(1);
			}
			
		    //alert(CommandName);
		    //alert(CommandValue);
			theElement = document.getElementById(CommandName);
			if (theElement != null)
			{
				theElement.innerHTML=CommandValue;
			}
		    return ContinueUpadte;
		}
		
		var splitString = responseText.split(",");
		for(var i = 0; i < splitString.length; i++)
		{
		    var LineText = splitString[i];
		    var pos = LineText.indexOf("=")
			//var ItemValueSet = splitString[i].split("=");
			//alert(ItemValueSet);
			//if(ItemValueSet.length==2)
			if (pos > 0)
			{
				//CommandName = ItemValueSet[0];
				//CommandValue = ItemValueSet[1];
				CommandName = LineText.substring(0, pos);
				CommandValue = LineText.substring(pos+1);
//				alert(LineText);
//				alert(CommandName);
//				alert(CommandValue);
				
				if (CommandName == "RefreshPage")
				{
					if (CommandValue == "*")
					{
						//alert(window.location.href);
						window.location.href=window.location.href;
						return false;
					}
				    //alert(CommandValue);
					window.location.href=CommandValue;
		            return false;
				}
				else if (CommandName == "STOP")
				{
					return false;
				}
				else if (CommandName.indexOf("PROGRESBAR") >= 0)
				{
					var percent = parseInt(CommandValue, 10);
					UpdateProgressBar(CommandName, percent);
				}
				else
				{
					theElement = document.getElementById(CommandName);
					if (theElement != null)
					{
						theElement.innerHTML=CommandValue;
					}
				}
			}
		}
	    return true;
	} catch( myError ) 
	{
		alert( myError.name + ': ' + myError.message );
	} finally 
	{

	}
	return false;
}











var CurrentPopup = null;

function OpenPopupFromXMLHttpRequest()
{
	try 
	{
		if (CurrentPopup == null)
			return;
			
		if (CurrentPopup.m_XmlHttp == null)
			return;
		
		if (CurrentPopup.m_XmlHttp.readyState==4)
		{
			if (CurrentPopup.m_XmlHttp.status==200)
			{
				CurrentPopup.m_Popup = window.createPopup();
				var oPopupBody = CurrentPopup.m_Popup.document.body;
				oPopupBody.style.backgroundColor = "white";
				oPopupBody.style.border = "solid blue 3px";

				oPopupBody.innerHTML = CurrentPopup.m_XmlHttp.responseText;

				for (var i = 0; i < oPopupBody.all.length; i++) 
				{
				    if (oPopupBody.all[i].tagName == "A")
				        oPopupBody.all[i].onclick = doPopopMenuLink;
				}
				
				if (CurrentPopup.m_OpenerObj == null)
					CurrentPopup.m_Popup.show(0, 0, CurrentPopup.m_Height, CurrentPopup.m_Width, CurrentPopup.m_OpenerObj);
				else
					CurrentPopup.m_Popup.show(CurrentPopup.m_OpenerObj.offsetWidth, 0, CurrentPopup.m_Height, CurrentPopup.m_Width, CurrentPopup.m_OpenerObj);
					
			}
		}
	} catch( myError ) 
	{
		alert( myError.name + ': ' + myError.message );
	} finally 
	{

	}

}

function doPopopMenuLink() 
{
    parent.location = this.href;
    return false;
}

function IsElementVisible(name) 
{		
	var theElement;
	theElement = document.getElementById(name);
	if (theElement == null)
		return;
    
    //alert(theElement.style.visibility);
    //alert(theElement.style.display);
    
    if (theElement.style.visibility=="hidden") 
        return false;
    else
        return true;
}

function ShowBlinking() 
{		
    if(document.getElementById && document.all)
    {
        obj = document.getElementsByTagName("blink");
        for (var i=0; i<obj.length; i++)
        {
        	if (obj[i].style.visibility=="hidden") 
        	{
        		obj[i].style.visibility="visible";
    		}
    		else 
    		{
        		obj[i].style.visibility="hidden";
    		}
		}
   	}
} 

function PopupObject(url, linkObj, height, width) 
{
	/* Properties */
	this.m_Url = url;
	this.m_OpenerObj = linkObj;
	this.m_Height = height;
	this.m_Width = width;
	this.m_Popup = null;
	this.m_XmlHttp = null;

	/* Methods */
	this.m_EventHandle = OpenPopupFromXMLHttpRequest;
	
	
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	{
		this.m_XmlHttp=new XMLHttpRequest()
		this.m_XmlHttp.onreadystatechange=this.m_EventHandle;
		this.m_XmlHttp.open("GET", this.m_Url, true)
		this.m_XmlHttp.send(null)
	}
	// code for IE
	else if (window.ActiveXObject)
	{
		this.m_XmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
		if (this.m_XmlHttp)
		{
			this.m_XmlHttp.onreadystatechange=this.m_EventHandle
			this.m_XmlHttp.open("GET", this.m_Url, true)
			this.m_XmlHttp.send()
		}
	}
}


function PopopMenuSelectItem(itemid, name) 
{
    window.EditBox.value = name;
    if (window.EditIDBox != null)
        window.EditIDBox.value = itemid;

    window.DocumentModified = true;
    
    if (CurrentPopup != null)
        CurrentPopup.m_Popup.hide();
}



function SelectThisItem(itemid, name)
{
	try
	{
		if (window.dialogArguments == null)
		{
			iFrameSelectThisItem(itemid, name)
			return;
		}
		//alert(window.dialogArguments.OnLocalItemSelected);
		
		if (window.dialogArguments.OnLocalItemSelected != null)
			window.dialogArguments.OnLocalItemSelected(itemid, name);
		else
		{
			window.dialogArguments.EditBox.value = name;
			if (window.dialogArguments.EditIDBox != null)
				window.dialogArguments.EditIDBox.value = itemid;
		}
        window.dialogArguments.DocumentModified = true;
		
	} catch( myError ) 
	{
		alert( myError.name + ': ' + myError.message );
	}  
	window.close();
}

function OpenPopup(url, linkObj, height, width)
{
	CurrentPopup = new PopupObject(url, linkObj, height, width);
}

function OpenModalDialog(url, w, h, scroll, resizable)
{
	var Left = window.screenLeft + event.clientX;
	var Top = window.screenTop + event.clientY;
	var sFeatures = "dialogLeft:" + Left + "; dialogTop:" + Top + "; dialogHeight:" + h + "px;dialogWidth:" + w + "px; scroll:" + scroll + "+; resizable:" + resizable + "; center:no; edge:sunken; status:no; unadorned:yes; toolbar:no;titlebar:no;location:no;directories:no;menubar:no;copyhistory:no;"
	//alert(sFeatures);
	
	window.showModalDialog(url, window, sFeatures)
}
//resizable=yes,scrollbars=yes,toolbar=no,titlebar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no'

function ShowMemberSelecttion(linkObj, inputname, height, width)
{
	OpenModalDialog("MemberSelecttion.aspx?selected=" + linkObj.value + "&inputname=" + inputname, height, width, "yes", "no");
}

function UpdateParentWindow(url, itemname)
{
	EditBox = itemname;
	CallXMLHttpRequest(url, UpdateParentItemContent)
}
function UpdateParentItemContent()
{
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
		{
			try 
			{
				EditBox.innerHTML = xmlhttp.responseText;

			} catch( myError ) 
			{

			} finally 
			{
				if (CloseAfaterComplete)
				{
					window.close();
				}
			}
		}
	}
}

function UpdateProgressBar(barname, percent)
{
	var theElement;
	theElement = document.getElementById(barname);
	if (theElement == null)
		return;

	if (percent < 0)
		percent = 0;
		
	if (percent > 100)
		percent = 100;

	theElement = document.getElementById(barname + "_LEFT");
	if (theElement != null)
	{
		if (percent == 0)
		{
			theElement.style.display="none";
			theElement.innerHTML= "&nbsp;";
		}
		else
		{
			theElement.style.display="";
			theElement.width = percent + "%";
			
			theElement.innerHTML= "&nbsp;" + percent + "&nbsp%&nbsp";
		}
	}
	var left = 100 - percent;
	theElement = document.getElementById(barname + "_RIGHT");
	if (theElement != null)
	{
		if (left == 0)
		{
			theElement.style.display="none";
		}
		else
		{
			theElement.style.display="";
			theElement.width = left + "%";
			
		}
		if (percent == 0)
			theElement.innerHTML= "&nbsp;" + percent + "&nbsp%&nbsp";
		else
			theElement.innerHTML= "&nbsp;";
	}
}
function GroupCollapsing(groupname)
{
	//if (HadScriptsInit == 0)
	//{	
	//	CommonJavaScriptsInit();
	//}
		
		
	var GroupElement, ImageElement;
	GroupElement = document.getElementById(groupname);
	ImageElement = document.getElementById("expand_" + groupname);
	if (ImageElement.src.indexOf("plus") >= 0)
	{
		ImageElement.src = "images/minus-expand.gif";
		GroupElement.style.display = "";
	}
	else
	{
		ImageElement.src = "images/plus-expand.gif";
		GroupElement.style.display = "none";
	}
}
function CatchUserAction()
{
    DocumentModified = true;
    UserEnterCount ++;
    
    //var evt = (evt) ? evt : ((window.event) ? event : null);
    //var oSource = evt.target;
    //alert( "oSource:" + oSource + " oSource.name: " + oSource.name + " has changed to " + oSource.value );
   
    //alert(UserEnterCount);
    //window.status = "change count:" + UserEnterCount;   
}

function initPageFormItem()
{
    window.document.onkeydown = CatchUserAction;
    //window.document.onmouseup = ScanPageFormItemChanged;
    //window.document.onchange = CatchUserAction;
    return;
    
    
    if( document.all )
    {
        oElements = document.forms[0].elements;
        for( i=0; i<oElements.length ; i++ )
        {
            oElements[i].onchange=CatchUserAction;
        }
    } else 
    {
        window.document.onchange = CatchUserAction;
    }
}

function ScanPageFormItemChanged()
{
    if (DocumentModified)
        return;

    DocumentModified = IsPageFormItemChanged();
}

function JavasctiptTest()
{
    DirtyCheck();
}
function DirtyCheck()
{
    if (DocumentModified)
    {
        alert(DocumentModified);
        return;
    }
    DocumentModified = IsPageFormItemChanged();
    alert(DocumentModified);
}

function IsPageFormItemChanged()
{
    try
    {
        var strID, nIdx, nNumOpts, nOptIdx;
        var oElem, oOptions, oOpt, nDefSelIdx, nSelIdx;
        var oForm = document.forms[0];
        var nElemCnt = oForm.elements.length;
        
        for(nIdx = 0; nIdx < nElemCnt; nIdx++)
        {
            oElem = oForm.elements[nIdx];
            
            if(oElem.type == "text" || oElem.tagName == "TEXTAREA")
            {
                //if(oElem.value != oElem.defaultValue)
                //    return true;
            }
            else if(oElem.type == "checkbox" || oElem.type == "radio")
            {
                if(oElem.checked != oElem.defaultChecked)
                {
                    //window.status = "checkbob/radio:" + oElem.name + " changed!";   
                    return true;   
                }
            }
            else if(oElem.tagName == "SELECT")
            {
                oOptions = oElem.options;
                nNumOpts = oOptions.length;
                nDefSelIdx = 0;
                nSelIdx = 0;

                for(nOptIdx = 0; nOptIdx < nNumOpts; nOptIdx++)
                {
                    oOpt = oOptions[nOptIdx];

                    if(oOpt.defaultSelected)
                        nDefSelIdx = nOptIdx;

                    if(oOpt.selected)
                        nSelIdx = nOptIdx;
                }

                if(nDefSelIdx != nSelIdx)
                {
                    //window.status = "SELECT:" + oElem.name + " changed!";   
                    return true;   
                }
            }
        }
	} catch( myError ) 
	{

	}
    return false;
}


function FormatDateTime(datetime, FormatType)
/*
	 FomatType takes the following values
		1 - General Date = Friday, October 30, 1998
		2 - Typical Date = 10/30/98
		3 - Standard Time = 6:31 PM
		4 - Military Time = 18:31
*/
{
	var strDate = new String(datetime);

	if (strDate.toUpperCase() == "NOW") {
		var myDate = new Date();
		strDate = String(myDate);
	} else {
		var myDate = new Date(datetime);
		strDate = String(myDate);
	}
	var MonthNumber;

	// Get the date variable parts
	var Day = new String(strDate.substring(0,3));
	if (Day == "Sun") Day = "Sunday";
	if (Day == "Mon") Day = "Monday";
	if (Day == "Tue") Day = "Tuesday";
	if (Day == "Wed") Day = "Wednesday";
	if (Day == "Thu") Day = "Thursday";
	if (Day == "Fri") Day = "Friday";
	if (Day == "Sat") Day = "Saturday";	
	
	var Month = new String(strDate.substring(4,7)), MonthNumber = 0;
	if (Month == "Jan") { Month = "January"; MonthNumber = 1; }
	if (Month == "Feb") { Month = "February"; MonthNumber = 2; }
	if (Month == "Mar") { Month = "March"; MonthNumber = 3; }
	if (Month == "Apr") { Month = "April"; MonthNumber = 4; }
	if (Month == "May") { Month = "May"; MonthNumber = 5; }
	if (Month == "Jun") { Month = "June"; MonthNumber = 6; }
	if (Month == "Jul") { Month = "July"; MonthNumber = 7; }
	if (Month == "Aug") { Month = "August"; MonthNumber = 8; }
	if (Month == "Sep") { Month = "September"; MonthNumber = 9; }
	if (Month == "Oct") { Month = "October"; MonthNumber = 10; }
	if (Month == "Nov") { Month = "November"; MonthNumber = 11; }
	if (Month == "Dec") { Month = "December"; MonthNumber = 12; }
	
	var curPos = 11;
	var MonthDay = new String(strDate.substring(8,10));
	if (MonthDay.charAt(1) == " ") 
	{
		MonthDay = "0" + MonthDay.charAt(0);
		curPos--;
	}	
	
	var MilitaryTime = new String(strDate.substring(curPos,curPos + 5));
	
	var Year = new String(strDate.substring(strDate.length - 4, strDate.length));	
	
	if (FormatType == 1)
	{
		strDate = Day + ", " + Month + " " + MonthDay + ", " + Year;
	}
	else if (FormatType == 2)
	{
		if (MonthNumber < 10)
			MonthNumber = "0" + MonthNumber;
		
		strDate = Year + "-" + MonthNumber + "-" + MonthDay;
		//strDate = MonthNumber + "/" + MonthDay + "/" + Year.substring(2,4);
	}
	else if (FormatType == 3) {
		var AMPM = MilitaryTime.substring(0,2) >= 12 && MilitaryTime.substring(0,2) != "24" ? " PM" : " AM";
		if (MilitaryTime.substring(0,2) > 12)
			strDate = (MilitaryTime.substring(0,2) - 12) + ":" + MilitaryTime.substring(3,MilitaryTime.length) + AMPM;
		else {
			if (MilitaryTime.substring(0,2) < 10)
				strDate = MilitaryTime.substring(1,MilitaryTime.length) + AMPM;
			else
				strDate = MilitaryTime + AMPM;
		}
	}	
	else if (FormatType == 4)
		strDate = MilitaryTime;


	return strDate;
}






function TabletItemSelection(itemlist, current)
{   
    var theElement;
	var splitString = itemlist.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
 	    theElement = parent.document.getElementById(splitString[i]);
	    if (theElement != null)
	    {
	        if (splitString[i] == current)
	            theElement.style.display="";
	        else
	            theElement.style.display="none";
	        
        }
	}
}
function ShowTabletMenu(Name)
{
    ShowElement("smenu_" + Name + "_A");
    ShowElement("smenu_" + Name + "_B");
    ShowElement("smenu_" + Name + "_C");
}
function HideTabletMenu(Name)
{
    HideElement("smenu_" + Name + "_A");
    HideElement("smenu_" + Name + "_B");
    HideElement("smenu_" + Name + "_C");
}

function SelectedTabletMenu(Name)
{
    var theElement;
	try 
	{
	
	    theElement = document.getElementById("smenu_" + Name + "_A");
        theElement.bgColor = "#E9B179";
        theElement.firstChild.src = "images/YellowTabLeft.gif";
        
 	    theElement = document.getElementById("smenu_" + Name + "_B");
        theElement.bgColor = "#E9B179";
       
 	    theElement = document.getElementById("smenu_" + Name + "_C");
        theElement.bgColor = "#E9B179";
        theElement.firstChild.src = "images/YellowTabRight.gif";
	} catch( myError ) 
	{

	}
}
function DeselectedTabletMenu(Name)
{
    var theElement;
	try 
	{
	
	    theElement = document.getElementById("smenu_" + Name + "_A");
        theElement.bgColor = "#B5BCC4";
        theElement.firstChild.src = "images/GreyTabLeft.gif";
        
 	    theElement = document.getElementById("smenu_" + Name + "_B");
        theElement.bgColor = "#B5BCC4";
       
 	    theElement = document.getElementById("smenu_" + Name + "_C");
        theElement.bgColor = "#B5BCC4";
        theElement.firstChild.src = "images/GreyTabRight.gif";
	} catch( myError ) 
	{

	}
}
/*
property description  
nodeName name of the node  
nodeValue value of node (only applicable to text nodes)  
nodeType type of node - see below  
parentNode parent, if one exists  
childNodes list (array) of child nodes  
firstChild first child  
lastChild last child  
previousSibling previous sibling  
nextSibling next sibling  
attributes list of attributes of an element  
ownerDocument document containing the element  

and the node types 

number description  
1 an HTML element  
2 an element attribute  
3 text  
8 an HTML comment  
9 a document  
10 a document type definition  
*/

function SetCurrentTabletMenu(itemlist, current)
{   
    var tabname;
	var splitString = itemlist.split(",");
	for(var i = 0; i < splitString.length; i++)
	{
	    tabname = splitString[i];
	    if (tabname == current)
	        SelectedTabletMenu(tabname);
	    else
	        DeselectedTabletMenu(tabname);
	}
}

function SetCurrentTabletItem(menuname, current)
{   
    var theElement;
    theElement = document.getElementById("smenu_" + menuname);
    if (theElement == null)
        return;
        
    SetCurrentTabletElement(theElement.childNodes, current);      
}

function SetCurrentTabletElement(nodeslist, current)
{   
    var theElement;
    var splitString;
	try 
	{
	    if (nodeslist == null || nodeslist.length == 0)
	        return;
	    for (var i=0; i < nodeslist.length; i++)
	    {
	        
            theElement = nodeslist[i];   
           	splitString = theElement.id.split("_");
           //	alert(theElement.id);
           	if (splitString.length == 3 && splitString[0] == "smenu")
           	{
           	    if (splitString[1] == current)
           	    {
           	        if (splitString[2] == "A")
           	        {
                        theElement.bgColor = "#E9B179";
                        theElement.firstChild.src = "images/YellowTabLeft.gif";
           	        }
           	        else if (splitString[2] == "B")
           	        {
                        theElement.bgColor = "#E9B179";
           	        }
           	        else if (splitString[2] == "C")
           	        {
                        theElement.bgColor = "#E9B179";
                        theElement.firstChild.src = "images/YellowTabRight.gif";
           	        }
           	    }
           	    else
           	    {
            	    if (splitString[2] == "A")
           	        {
                        theElement.bgColor = "#B5BCC4";
                        theElement.firstChild.src = "images/GreyTabLeft.gif";
           	        }
           	        else if (splitString[2] == "B")
           	        {
                        theElement.bgColor = "#B5BCC4";
           	        }
           	        else if (splitString[2] == "C")
           	        {
                        theElement.bgColor = "#B5BCC4";
                        theElement.firstChild.src = "images/GreyTabRight.gif";
           	        }
          	    }
           	}
            SetCurrentTabletElement(theElement.childNodes, current);
	    }
	} catch( myError ) 
	{

	}

}



function GetCaretPosition(oField) 
{
     var iCaretPos = 0;

     // IE Support
     if (document.selection) 
     { 

       // Set focus on the element
       oField.focus ();
  
       // To get cursor position, get empty selection range
       var oSel = document.selection.createRange ();
  
       // Move selection start to 0 position
       oSel.moveStart ('character', -oField.value.length);
  
       // The caret position is selection length
       iCaretPos = oSel.text.length;
     }

     // Firefox support
     else if (oField.selectionStart || oField.selectionStart == '0')
       iCaretPos = oField.selectionStart;

     // Return results
     return (iCaretPos);
}


   /*
   **  Sets the caret (cursor) position of the specified text field.
   **  Valid positions are 0-oField.length.
   */
function doSetCaretPosition(oField, iCaretPos) 
{

     // IE Support
     if (document.selection) 
     { 

       // Set focus on the element
       oField.focus ();
  
       // Create empty selection range
       var oSel = document.selection.createRange ();
  
       // Move selection start and end to 0 position
       oSel.moveStart ('character', -oField.value.length);
  
       // Move selection start and end to desired position
       oSel.moveStart ('character', iCaretPos);
       oSel.moveEnd ('character', 0);
       oSel.select ();
     }

     // Firefox support
     else if (oField.selectionStart || oField.selectionStart == '0') 
     {
       oField.selectionStart = iCaretPos;
       oField.selectionEnd = iCaretPos;
       oField.focus ();
     }
}

function GoNumberControl(inputobj, evt, max, point)
{
    var charcode = (navigator.appName=="Netsacpe")?evt.which:evt.keyCode;
    var chr = String.fromCharCode(charcode);
    var pos = GetCaretPosition(inputobj);
    
    //alert(charcode);
    if ((charcode < 48 || charcode > 57) && charcode != 45 && charcode != 46)
        return false;
    
    var str = inputobj.value;

    if (str.length >= max)
        return false;
    
    if (charcode == 46)
    {
        str = str.replace(".", "");
        str += ".";
        for (var i = 0; i < point; i++)
            str += "0";
        
        while (str.length > 0 && (str.charAt(0) == '0' || str.length > max))
        {
            str = str.substring(1);
        }
        inputobj.value = str;
        return false;
    }
        
    if (pos == str.length)
    {
        str += chr;
    }
    else
    {
        str = str.substring(0, pos) + chr + str.substring(pos);
    }
    
    var str = "00000000000" + str.replace(".", "");
    var s = str.length - point;
    str = str.substring(0, s) + "." + str.substring(s);
    
    while (str.length > 0 && str.charAt(0) == '0')
    {
        str = str.substring(1);
    }
    inputobj.value = str;
    return false;
}

function OpenAnotationWindow(AnotationText)
{
	Width=400;
	Height=120;
	if (AnotationText.substring(0,1)=='<')
	{
		p1=AnotationText.indexOf(",");
		Width=AnotationText.substring(1,p1);
		p2=AnotationText.indexOf(">");
		Height=AnotationText.substring(p1+1, p2);
		AnotationText=AnotationText.substring(p2+1);
	}
	oPopup = window.createPopup();
	var oPopupBody = oPopup.document.body;
	oPopupBody.style.backgroundColor = "NavajoWhite";
	oPopupBody.style.bgColor = "NavajoWhite";
	oPopupBody.style.border = "solid thin black";
	oPopupBody.innerHTML = "<div style='font:normal 10pt; padding:5px'>" + AnotationText + '</div>';
	oPopup.show(window.event.clientX, window.event.clientY + 10, Width, Height, document.body);
}

function OpenAnotationWindowEx(AnotationText, Width, Height)
{
	oPopup = window.createPopup();
	var oPopupBody = oPopup.document.body;
	oPopupBody.style.backgroundColor = "NavajoWhite";
	oPopupBody.style.bgColor = "NavajoWhite";
	oPopupBody.style.border = "solid thin black";
	oPopupBody.innerHTML = "<div style='font:normal 10pt; padding:5px'>" + AnotationText + '</div>';
	oPopup.show(window.event.clientX, window.event.clientY + 10, Width, Height, document.body);
}


function AJAXLoader(command, param)
{
    LoadAJAXContent(command + param);
}


function ChangeImageContent(ImgName, ImgURL) 
{
    var elt;

    elt = document.getElementById(ImgName)
    if (elt != null) 
    {
        elt.src = ImgURL;
    }
    //alert(ImageKey);
    //document.images.picview.src = ImageKey;

}

function ContentScrooling(Action)
{

}


function ChangeContentPlayer(strFormat, ImgURL) 
{
    TempParam = ImgURL;
    //LoadAJAXContent("XMLHTTPRequest.aspx?job=contentplayer&Format=" + Format);
    
    CallXMLHttpRequest("XMLHTTPRequest.aspx?job=contentplayer&Format="+strFormat, UpdateContentPlayer);

    //alert(Format);

}

function UpdateContentPlayer() 
{

    var PlayCode;
    var DebugElement;
    var theElement;
    if (xmlhttp.readyState == 4) 
    {
        if (xmlhttp.status == 200) 
        {

            //alert(xmlhttp.statusText);

            theElement = document.getElementById("ViewWindows")
            if (theElement != null) 
            {
            
                var str = xmlhttp.responseText;
                //str = str.replace("$$", TempParam);
                //alert(str);
                //alert(TempParam);
                PlayCode = str.replace("$$", TempParam);
                PlayCode = PlayCode.replace("$$", TempParam);
                PlayCode = PlayCode.replace("$$", TempParam);

                theElement.innerHTML = PlayCode;

                DebugElement = document.getElementById("playcode");
                if (DebugElement != null) 
                {
                    DebugElement.value = PlayCode;
                }
            }
        }
    }
}

function CheckRemoteServiceAccessAble(strService, AccessID)
{
    try 
    {
        MyAccessID = AccessID;
        if (!CallXMLHttpRequest(strService + "XMLHTTPRequest.aspx?job=GetContentInfo&AccessID=" + AccessID, UpdateRemoteServiceAccessAble)) 
        {
            CallXMLHttpRequest("XMLHTTPRequest.aspx?job=setaccessable&access=no&AccessID=" + MyAccessID, UpdateStatus);
        }

    } catch (myError) 
    {

    }
}

function UpdateRemoteServiceAccessAble()
{
    var theElement;
	try 
	{

        if (xmlhttp.readyState == 4) 
        {
            if (xmlhttp.status == 200) 
            {
                alert(xmlhttp.responseText);

                if (xmlhttp.responseText == "OK")
                {
                    CallXMLHttpRequest("XMLHTTPRequest.aspx?job=setaccessable&access=yes&AccessID=" + MyAccessID, UpdateStatus);
                    return;
                }
            }
            
            CallXMLHttpRequest("XMLHTTPRequest.aspx?job=setaccessable&access=no&AccessID=" + MyAccessID, UpdateStatus);
        }
        
    } catch (myError) 
    {

        alert( myError.name + ': ' + myError.message );
    } finally 
    {

    }

}

function CheckIfComplete2() 
{
    if (document.images.imgavailable.complete) 
    {
        //window.alert("URL is available");
        CallXMLHttpRequest("XMLHTTPRequest.aspx?job=setaccessable&access=yes&AccessID=" + MyAccessID, UpdateStatus);
    }
    else 
    {
        //window.alert("URL is not available");
        CallXMLHttpRequest("XMLHTTPRequest.aspx?job=setaccessable&access=no&AccessID=" + MyAccessID, UpdateStatus);
    }
}


function CheckIfComplete1()
{
    if (document.images.imgavailable.complete) 
    {
        //window.alert("URL is available");
        CallXMLHttpRequest("XMLHTTPRequest.aspx?job=setaccessable&access=yes&AccessID=" + MyAccessID, UpdateStatus);
    }
    else 
    {
        //window.alert("URL is not available");
        window.setTimeout("CheckIfComplete2()", 1000);
    }
}

function CheckIfRemoteFileExists(fileToCheck, AccessID) 
{
    try 
    {
        MyAccessID = AccessID;
        //var tmp = new Image();
        if (fileToCheck.length > 0) 
        {
            document.images.imgavailable.src = fileToCheck;
        }

        window.setTimeout("CheckIfComplete1()", 500);

    } catch (myError) 
    {

    }

}





function getCookie(name) {
    var start = document.cookie.indexOf(name + "=");
    var len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0, name.length))) {
        return null;
    }
    if (start == -1)
        return null;

    var end = document.cookie.indexOf(';', len);
    if (end == -1)
        end = document.cookie.length;

    return unescape(document.cookie.substring(len, end));
}

function setCookie(name, value, expires, path, domain, secure) {
    var today = new Date();
    today.setTime(today.getTime());
    if (expires) {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date(today.getTime() + (expires));
    document.cookie = name + '=' + escape(value) +
		((expires) ? ';expires=' + expires_date.toGMTString() : '') + //expires.toGMTString()
		((path) ? ';path=' + path : '') +
		((domain) ? ';domain=' + domain : '') +
		((secure) ? ';secure' : '');
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) document.cookie = name + '=' +
			((path) ? ';path=' + path : '') +
			((domain) ? ';domain=' + domain : '') +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}




function addEvent(elm, evType, fn, useCapture) {
    if (elm.addEventListener) {
        elm.addEventListener(evType, fn, useCapture);
        return true;
    }
    else if (elm.attachEvent) {
        var r = elm.attachEvent('on' + evType, fn);
        return r;
    }
    else {
        elm['on' + evType] = fn;
    }
}


function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}



function getElementsByClass(searchClass, node, tag) 
{
    var classElements = new Array();
    if (node == null)
        node = document;

    if (tag == null)
        tag = '*';

    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp('(^|\\\\s)' + searchClass + '(\\\\s|$)');
    for (i = 0, j = 0; i < elsLen; i++) {
        if (pattern.test(els[i].className)) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}


function toggle(obj) {
    var el = document.getElementById(obj);
    if (el.style.display != 'none') {
        el.style.display = 'none';
    }
    else {
        el.style.display = '';
    }
}


function $() 
{
    var elements = new Array();

    for (var i = 0; i < arguments.length; i++) 
    {
        var element = arguments[i];
        if (typeof element == 'string')
            element = document.getElementById(element);

        if (arguments.length == 1)
            return element;

        elements.push(element);
    }

    return elements;
}

/*
function $(element) 
{
  if (arguments.length > 1) 
  {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($(arguments[i]));
    return elements;
  }
  
  if (Object.isString(element))
    element = document.getElementById(element);
  return Element.extend(element);
  
}


*/

function TrMenuOnmouseOver(item)
{
    item.style.backgroundColor='#33508D';
    //item.style.paddingLeft='10px'; 
    item.style.color='#ffffff';   
}

function TrMenuOnMouseOut(item)
{
    item.style.backgroundColor='#FFFFFF';
    item.style.color='#000000';  
}



function OnStartFileUpload(UploadType) 
{
    filename = document.forms[0].File.value;
	if (filename == 0)
	{
		alert("Please enter a file to upload");
		return;
	}
	pos = filename.lastIndexOf(".");
	if (pos < 1)
	{
		alert("Invalid ISO file !");
		return;
	}
	extname = filename.substring(pos + 1);
	extname = extname.toLowerCase();

	if (UploadType == 280) 
	{
	    if (extname != "pdf")
	    {
	        alert("Invalid PDF file !");
	        return;
	    }

	}
	else if (UploadType == 511) 
	{
	    if (extname != "csv") 
	    {
	        alert("Invalid CSV file !");
	        return;
	    }

	}
	else 
	{
	    if (extname != "png" && extname != "gif" && extname != "jpg" && extname != "mpg" && extname != "swf" && extname != "mp3") 
	    {
	        alert("Invalid image file !");
	        return;
	    }
	}
	
	document.forms[0].submit();
}
