var bAllowSideBar = true;
var bAllowViewPane = true;
var bAllowGrid = true;
var oHighlightItems = new Array();
var FCKeditorId = '';
var FCKeditorId2 = '';
//navigation tree toggle node
function t_ntn(oNode, iNodeId, e)
{
	var tNavNode;
	var tItemNode;
	var lNavLink;
	var bChanged;
	var ParentNode;
	tNavNode = document.getElementById("tNavNode");
	tItemNode = document.getElementById("tItemNode");
	lNavLink = document.getElementById("lNavLink");
	bChanged = (tNavNode.value != iNodeId);
	if(bChanged)
	{
		bChanged = t_dc(oNode, true, e);
		
		if(bChanged)
		{
			tNavNode.value = iNodeId;
			tItemNode.value = "";
			lNavLink.onclick(e);
			h_i(oNode, "Navigation");
		}
	}
	t_tn(oNode, true, e);
}
//navigation force tree toggle node
function t_ftn(oNode, iNodeId, e)
{
	var tNavNode;
	var tItemNode;
	var lNavLink;
	var bChanged;
	tNavNode = document.getElementById("tNavNode");
	tItemNode = document.getElementById("tItemNode");
	lNavLink = document.getElementById("lNavLink");
	h_i(oNode, "Navigation");
	t_tn(oNode, true, e);
	tNavNode.value = iNodeId;
	tItemNode.value = "";
	lNavLink.onclick(e);
}

//navigation force tree toggle node without Highlight Change
function t_ftnnhi(oNode, iNodeId, e)
{
	var tNavNode;
	var tItemNode;
	var lNavLink;
	var bChanged;
	tNavNode = document.getElementById("tNavNode");
	tItemNode = document.getElementById("tItemNode");
	lNavLink = document.getElementById("lNavLink");
	t_tn(oNode, true, e);
	tNavNode.value = iNodeId;
	tItemNode.value = "";
	lNavLink.onclick(e);
}

//tree toggle node... and whether we allow items to collapse
function t_tn(oNode, bAllowCollapse, e){
	var i, j, k, l;
	var oParent;
	oParent = oNode.parentNode;
	for (i = 0; i < oParent.childNodes.length; i++)
	{
		if ((' ' + oParent.childNodes[i].className + ' ').toLowerCase().indexOf(' topnodes ') != -1)
		{
			if ((' ' + oParent.childNodes[i].className + ' ').toLowerCase().indexOf(' hidden ') != -1)
			{
				oParent.childNodes[i].className = oParent.childNodes[i].className.replace('Hidden', '');
				oParent.childNodes[i].className = oParent.childNodes[i].className.replace('  ', ' ');
				oParent.childNodes[i].className += ' Visible';
				t_svn(oParent, e, false);
			}
			else if(bAllowCollapse)
			{
				oParent.childNodes[i].className = oParent.childNodes[i].className.replace('Visible', '');
				oParent.childNodes[i].className = oParent.childNodes[i].className.replace('  ', ' ');
				oParent.childNodes[i].className += ' Hidden';
			}
		}
		else if((' ' + oParent.childNodes[i].className + ' ').toLowerCase().indexOf(' subnodes ') != -1)
		{
			if ((' ' + oParent.childNodes[i].className + ' ').toLowerCase().indexOf(' visible ') != -1)
			{
				if(bAllowCollapse)
				{
					oParent.childNodes[i].className = oParent.childNodes[i].className.replace('Visible', '');
					oParent.childNodes[i].className = oParent.childNodes[i].className.replace('  ', ' ');
					oParent.childNodes[i].className += ' Hidden';
				}
			}
			else
			{
				oParent.childNodes[i].className = oParent.childNodes[i].className.replace('Hidden', '');
				oParent.childNodes[i].className = oParent.childNodes[i].className.replace('  ', ' ');
				oParent.childNodes[i].className += ' Visible';
				t_svn(oParent, e, true);
			}
		}
	}
}

//decide if we should allow click to be called
function t_dc(oNode, bAllowCollapse, e){
	var i, j, k, l;
	var oParent;
	var bAllowClick
	
	bAllowClick = false;
	
	oParent = oNode.parentNode;
	for (i = 0; i < oParent.childNodes.length; i++)
	{	    
		if((' ' + oParent.childNodes[i].className + ' ').toLowerCase().indexOf(' subnodes ') != -1) {
			if ((' ' + oParent.childNodes[i].className + ' ').toLowerCase().indexOf(' visible ') != -1)
			{
				bAllowClick = true;
			}
			else if(oParent.childNodes[i].childNodes.length <= 1 )
			{	
				bAllowClick = true;
			}
		}
	}
	
	return bAllowClick;
}
//highlight item
function h_i(oNode, sGroup)
{
	if (oNode != null)
	{
		if(oHighlightItems[sGroup] != null)
		{
			oHighlightItems[sGroup].className = e_rv(oHighlightItems[sGroup].className, "Highlight");
		}
		oHighlightItems[sGroup] = oNode;
		oHighlightItems[sGroup].className = e_rv(oHighlightItems[sGroup].className, "Highlight") + " Highlight";
	}
}
//tree select node
function t_svn(oNode, e, bIsSub)
{
	var oParentNode;
	var i;
		oParentNode = oNode.parentNode.parentNode;
		while((' ' + oParentNode.className + ' ').toLowerCase().indexOf('tree') == -1 && (' ' + oParentNode.className + ' ').toLowerCase().indexOf('node') == -1 && (' ' + oParentNode.className + ' ').toLowerCase().indexOf('nodegroup') == -1 && (' ' + oParentNode.className + ' ').toLowerCase().indexOf('navigation') == -1)
		{
			oParentNode = oParentNode.parentNode;
		}
		if(oParentNode != null)
		{
			for(i = 0; i < oParentNode.childNodes.length; i++)
			{
				t_hrn(oParentNode.childNodes[i], oNode);
			}
		}
	if(bIsSub)
	{
		t_srn(oNode, e);
	}
}
//tree select recursive node
function t_srn(oNode, e)
{
	var i, j, k;
	var bReturn;
	bReturn = false;
	for(i = 0; i < oNode.childNodes.length; i++)
	{
		if((' ' + oNode.childNodes[i].className + ' ').toLowerCase().indexOf(' topnodes ') != -1 || (' ' + oNode.childNodes[i].className + ' ').toLowerCase().indexOf(' subnodes ') != -1)
		{
			for(j = 0; j < oNode.childNodes[i].childNodes.length; j++)
			{
				if((' ' + oNode.childNodes[i].childNodes[j].className + ' ').toLowerCase().indexOf('node') > -1)
				{
					for(k = 0; k < oNode.childNodes[i].childNodes[j].childNodes.length; k++)
					{
						if((' ' + oNode.childNodes[i].childNodes[j].childNodes[k].className + ' ').toLowerCase().indexOf('title') > -1)
						{
							bReturn = t_srn(oNode.childNodes[i].childNodes[j], e);
							if(!bReturn)
							{
								oNode.childNodes[i].childNodes[j].childNodes[k].onclick(e);
							}
							else
							{
								t_tn(oNode.childNodes[i].childNodes[j].childNodes[k], false, e);
							}
							return true; 
						}
					}
				}
			}
		}
	}
	return bReturn;
}
//tree hide recursive node (goes through DIVS and stops as soon as a tree or node is hit)
function t_hrn(oNode, oIgnoreNode)
{
	var i;
	if((' ' + oNode.className + ' ').toLowerCase().indexOf(' tree ') > -1 || (' ' + oNode.className + ' ').toLowerCase().indexOf(' node ') > -1)
	{
		if(oNode != oIgnoreNode)
		{
			for(i = 0; i < oNode.childNodes.length; i++)
			{
				if((' ' + oNode.childNodes[i].className + ' ').toLowerCase().indexOf(' topnodes ') != -1 || (' ' + oNode.childNodes[i].className + ' ').toLowerCase().indexOf(' subnodes ') != -1)
				{
					if ((' ' + oNode.childNodes[i].className + ' ').toLowerCase().indexOf(' visible ') != -1)
					{
						oNode.childNodes[i].className = oNode.childNodes[i].className.replace('Visible', '');
						oNode.childNodes[i].className = oNode.childNodes[i].className.replace('  ', ' ');
						oNode.childNodes[i].className += ' Hidden';
						t_hrn(oNode.childNodes[i], oIgnoreNode);
					}
				}
			}
		}
	}
	else if(oNode.tagName && oNode.tagName.toLowerCase() == "div")
	{
		for(i = 0; i < oNode.childNodes.length; i++)
		{
			t_hrn(oNode.childNodes[i], oIgnoreNode);
		}
	}
}
//find a first matching sub html node based on current node position (recursive)
function t_gsn(oNode, sTag, sQualifier)
{
	var i;
	var oReturnNode;
	oReturnNode = null;
	for(i = 0; i < oNode.childNodes.length; i++)
	{
		if(oNode.childNodes[i].tagName && oNode.childNodes[i].tagName.toLowerCase() == sTag.toLowerCase())
		{
			if(sQualifier.length == 0 || oNode.id.toLowerCase().indexOf(sQualifier.toLowerCase()) > -1)
			{
				oReturnNode = oNode.childNodes[i];
			}
		}
		if(oReturnNode == null)
		{
			oReturnNode = t_gsn(oNode.childNodes[i], sTag, sQualifier);
		}
		if(oReturnNode != null)
		{
			break;
		}
	}
	return oReturnNode;
}
//tab select node
function t_sn(iIndex, iNodeId, sTabs, sTabPanels, iSubNodeId, e)
{
	var i;
	var oTab;
	var oPanel;
	var tItemNode;
	var tItemNode;
	var lNavLink;
	var bChanged;
	tNavNode = document.getElementById("tSubNavNode");
	tItemNode = document.getElementById("tSubItemNode");
	lNavLink = document.getElementById("lSubNavLink");
	for(i = 0; i < sTabs.length; i++)
	{
		oTab = document.getElementById(sTabs[i]);
		oPanel = document.getElementById(sTabPanels[i]);
		if(oTab != null && oPanel != null)
		{
			oTab.className = (i == iIndex) ? "Tab Active" : "Tab";
			oPanel.className = (i == iIndex) ? "Tab Active" : "Tab";
		}
	}
	bChanged = (tNavNode.value != (iSubNodeId.length > 0 ? iSubNodeId : iNodeId));
	if(bChanged)
	{
		tNavNode.value=(iSubNodeId.length > 0 ? iSubNodeId : iNodeId);
		tItemNode.value = "";
		lNavLink.onclick(e);
	}
}
//grid select item
function g_ssi(oNode, iNodeId, e)
{
	var tItemNode;
	var lItemLink;
	var bChanged;
	tItemNode = document.getElementById("tSubItemNode");
	lItemLink = document.getElementById("lSubItemLink");
	g_hr(oNode);
	bChanged = (tItemNode.value != iNodeId);
	if(bChanged)
	{
		tItemNode.value = iNodeId;
		lItemLink.onclick(e);
	}
}
//grid select item
function g_si(oNode, iNodeId, e)
{
	var tItemNode;
	var lItemLink;
	var bChanged;
	tItemNode = document.getElementById("tItemNode");
	lItemLink = document.getElementById("lItemLink");
	g_hr(oNode);
	bChanged = (tItemNode.value != iNodeId);
	if(bChanged)
	{
		tItemNode.value = iNodeId;
		lItemLink.onclick(e);
	}
}

//grid unselect item
function g_usi()
{
	var tItemNode;
	var lItemLink;
	
	tItemNode = document.getElementById("tItemNode");
	lItemLink = document.getElementById("lItemLink");
	
	tItemNode.value = '0';
	lItemLink.onclick(null);
}
//grid doubleclick item
function g_di(oNode, iNodeId, e)
{
	var tItemNode;
	var lItemLink;
	tItemNode = document.getElementById("tItemDoubleNode");
	lItemLink = document.getElementById("lItemDoubleLink");
	tItemNode.value = iNodeId;
	lItemLink.onclick(e);
}
//grid set scroll offset
function g_o(sGridId, iOffset)
{
	var oGrid;
	oGrid = document.getElementById(sGridId);
	oGrid.offsetParent.scrollTop = iOffset;
}
//grid recursive click item
function g_rci(oRow, iDepth, iNodeId, sLevelField, sItemField, sItemScroll, sClickField, e)
{
	var tLevelField;
	var tItemField;
	var tItemScroll;
	var lClickField;
	var bChanged;
	var i;
	var oTopNode;
	var oWorkNode;

	tLevelField = document.getElementById(sLevelField);
	tItemField = document.getElementById(sItemField);
	tItemScroll = document.getElementById(sItemScroll);
	lClickField = document.getElementById(sClickField);
	oTopNode = oRow.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
	tItemScroll.value = "";
	for(i = 0; i <= iDepth; i++)
	{
		if(i <= oTopNode.childNodes.length)
		{
			oWorkNode = oTopNode.childNodes[i].childNodes[0].childNodes[1].childNodes[0];
			tItemScroll.value += tItemScroll.value.length > 0 ? "," : "";
			tItemScroll.value += oWorkNode.offsetParent.scrollTop;
		}
	}
	bChanged = false;
	if(tLevelField.value != iDepth)
	{
		bChanged = true;
		tLevelField.value = iDepth;
	}
	if(tItemField.value != iNodeId)
	{
		bChanged = true;
		tItemField.value = iNodeId;
	}
	if(bChanged)
	{
		lClickField.onclick(e);
	}
}
//grid highlight row
function g_hr(oNode)
{
	var i;
	var iRowId;
	var oParent;
	oParent = oNode.parentNode;
	iRowId = 0;
	var sStyle;
	var sNewStyle;
	for (var i = 0; i < oParent.childNodes.length; i++)
	{
		if(oParent.childNodes[i].tagName && oParent.childNodes[i].tagName.toLowerCase() == "tr")
		{
			sStyle = oParent.childNodes[i].className;
			sNewStyle = (oParent.childNodes[i] == oNode) ? "c" : (iRowId % 2 == 0) ? "a" : "s";
			if(sStyle.length > 1)
			{
				sStyle = e_rv(sStyle, "c")
				sStyle = e_rv(sStyle, "a")
				sStyle = e_rv(sStyle, "s")
				sStyle += " " + sNewStyle;
			}
			else
			{
				sStyle = sNewStyle;
			}
			oParent.childNodes[i].className = sStyle;
			
			iRowId++;
		}
	}
}
//grid highlight row and click
function g_hrc(oNode, sClickField, e)
{
	g_hr(oNode);
	var oClickField;
	c_lb(sClickField, e);
}
//click link button
function c_lb(sClickField, e)
{
	if(sClickField && sClickField.length > 0)
	{
		oClickField = document.getElementById(sClickField);
		oClickField.onclick(e);
	}
}
//click command
function c_c(oCommand, iCommand, sText, e)
{
	var tCommand;
	var lCommandLink;
	if(sText.toLowerCase().indexOf('delete') != 0 || confirm("Are you sure you want to delete this item?"))
	{
		tCommand = document.getElementById("tCommand");
		lCommandLink = document.getElementById("lCommandLink");
		tCommand.value = iCommand;
		lCommandLink.onclick(e);
	}
}
//click sub command
function c_sc(oCommand, iCommand, sText, e)
{
	var tCommand;
	var lCommandLink;
	if(sText.toLowerCase().indexOf('delete') != 0 || confirm("Are you sure you want to delete this item?"))
	{
		tCommand = document.getElementById("tSubCommand");
		lCommandLink = document.getElementById("lSubCommandLink");
		tCommand.value = iCommand;
		lCommandLink.onclick(e);
	}
}
//click dialog command
function c_dc(oCommand, iCommand, e)
{
	var tCommand;
	var lCommandLink;
	tCommand = document.getElementById("tDialogCommand");
	lCommandLink = document.getElementById("lDialogCommandLink");
	tCommand.value = iCommand;
	lCommandLink.onclick(e);
}

//photo uploaded
function p_up(iPhotoId, sPhotoFieldId, sPhotoClickId)
{
	document.getElementById(sPhotoFieldId).value = iPhotoId;
	document.getElementById(sPhotoClickId).click();
}
//file uploaded
function f_up(sFilePath, sDocumentFieldId)
{
	document.getElementById(sDocumentFieldId).value = sFilePath;
}
//file uploaded
function f_upm(sFilePath, sDocumentFieldId, sMessageFieldId, sMessage)
{
	f_up(sFilePath, sDocumentFieldId);
	document.getElementById(sMessageFieldId).value = sMessage;
}
//load rich text for FCK
function FCKUpdateLinkedField()
{
    try
    {
        if(typeof(FCKeditorAPI) == "object")
        {
			FCKeditorAPI.GetInstance(FCKeditorId).LinkedField = document.getElementById(FCKeditorId + '1');
            FCKeditorAPI.GetInstance(FCKeditorId).UpdateLinkedField();
        }
    }
    catch(err)
    {
    }
    
    try
    {
        if(typeof(FCKeditorAPI) == "object")
        {
			FCKeditorAPI.GetInstance(FCKeditorId2).LinkedField = document.getElementById(FCKeditorId2 + '1');
            FCKeditorAPI.GetInstance(FCKeditorId2).UpdateLinkedField();
        }
    }
    catch(err)
    {
    }
}

//form select
function f_s(sValue, sValueField, sClickField, e)
{
	var oValueField;
	var oClickField;
	oValueField = document.getElementById(sValueField);
	oValueField.value = sValue;
	if(sClickField && sClickField.length > 0)
	{
		oClickField = document.getElementById(sClickField);
		oClickField.onclick(e);
	}
}

//element remove class
function e_rc(sId, sClass)
{
	var oElement;
	var sStyle;
	oElement = document.getElementById(sId);
	sStyle = oElement.className;
	sStyle = e_rv(sStyle, sClass);
	if(sStyle != oElement.className)
	{
		oElement.className = sStyle;
	}
}
//element add class
function e_ac(sId, sClass)
{
	var oElement;
	var sStyle;
	e_rc(sId, sClass);
	var bAdd;
	
	bAdd = true;

	if(sClass == 'WithSideBar')
	{
		if(!bAllowSideBar)
		{
			//bAdd = false;
		}
	}
	else if(sClass == 'WithViewPane')
	{
		if(!bAllowViewPane)
		{
			bAdd = false;
		}
	}
	else if(sClass == 'WithoutData')
	{
		if(bAllowGrid)
		{
			bAdd = false;
		}
	}
	
	if(bAdd)
	{
		oElement = document.getElementById(sId);
		sStyle = oElement.className;
		if(sStyle.indexOf(sClass) == -1)
		{
			sStyle += (' ' + sClass);
			oElement.className = sStyle;
		}
	}
}
//element remove class from style string
function e_rv(sStyle, sClass)
{
	sStyle = (' ' + sStyle + ' ').replace(' ' + sClass + ' ', ' ');
	sStyle = sStyle.replace('  ', ' ');
	if(sStyle.indexOf(" ") == 0)
	{
		sStyle = sStyle.substring(1, sStyle.length - 1); 
	}
	if(sStyle.lastIndexOf(" ") == (sStyle.length - 1))
	{
		sStyle = sStyle.substring(0, sStyle.length - 1); 
	}
	return sStyle;
}

//repeater radio button set unique radio button(provided by microsoft)
function r_surb(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}

//login enter site
function l_es(sDestination){
	var sNoCache;
	var sFileName;
	var sTitle;
	var xWid;
	var yHei;
	var oWin;
	sNoCache = new Date().getTime();
	sFileName = sDestination + ".aspx?nc=" + sNoCache;
	sTitle = "LeMint";
	xWid = 800;
	yHei = 600;
	try
	{
		if (window.screen)
		{
			xWid = screen.availWidth - 5;
			yHei = screen.availHeight - 5;
		}
		window.resizeTo(xWid, yHei);
		window.moveTo(0,0);
	}
	catch(exception) {}
	
	window.location.replace(sFileName);
}

//set text and click buttno
function g_stcb(sInput, sClick, sValue, e)
{
	var tInput;
	var lClick;
	tInput = document.getElementById(sInput);
	if(tInput != null)
	{
		tInput.value = sValue;
	}
	lClick = document.getElementById(sClick);
	if(lClick != null)
	{
		lClick.onclick(e);
	}
}

//End Impersonation
function e_i(e)
{
	var lClick;
	
	lClick = document.getElementById("bEndImpersonation");
	
	if(lClick != null)
	{
		lClick.onclick(e);
	}
}

//logout
function l_o()
{
	var sNoCache;
	var sLogoutUrl
	sNoCache = new Date().getTime();
	sLogoutUrl = "LogoutScreen.aspx?nc=" + sNoCache;
	window.location.replace(sLogoutUrl);
}

//Show or Hide Views
function ShowHide(sId)
{
	if(sId == 'Side')
	{
		if(bAllowSideBar)
		{
			bAllowSideBar = !bAllowSideBar;
			e_rc('Body', 'WithSideBar');
		}
		else
		{
			bAllowSideBar = !bAllowSideBar;
			e_ac('Body', 'WithSideBar');
		}
	}
	else if(sId == 'View')
	{
		if(bAllowViewPane)
		{
			bAllowViewPane = !bAllowViewPane;
			e_rc('Body', 'WithViewPane');
		}
		else
		{
			bAllowViewPane = !bAllowViewPane;
			e_ac('Body', 'WithViewPane');
		}
	}
	else if(sId == 'Grid')
	{
		if(bAllowGrid)
		{
			bAllowGrid = !bAllowGrid;
			e_ac('Body', 'WithoutData');
		}
		else
		{
			bAllowGrid = !bAllowGrid;
			e_rc('Body', 'WithoutData');
		}
	}
	else if(sId == 'ExpandView')
	{
		bAllowViewPane = !bAllowViewPane;
		e_ac('Body', 'WithViewPane');
	}
	else if(sId == 'CollapseView')
	{
		e_rc('Body', 'WithViewPane');
	}
	else if(sId == 'CollapseGrid')
	{
		if(bAllowGrid)
		{
			d = GetDiv('c_showgrid')
			if(d)
			{
				d.style.visibility = "hidden";
			}
			bAllowGrid = !bAllowGrid;
			e_ac('Body', 'WithoutData');
		}
		else
		{
			bAllowGrid = !bAllowGrid;
			e_rc('Body', 'WithoutData');
		}
	}
	else if(sId == 'ExpandGrid')
	{
		if(bAllowGrid)
		{
			if(bAllowViewPane)
			{
				bAllowViewPane = !bAllowViewPane;
				e_rc('Body', 'WithViewPane');
			}
			else
			{
				bAllowViewPane = !bAllowViewPane;
				e_ac('Body', 'WithViewPane');
			}
		}
		else
		{
			d = GetDiv('c_showgrid')
			if(d)
			{
				d.style.visibility = "visible";
			}
			bAllowGrid = !bAllowGrid;
			e_ac('Body', 'WithoutData');			
		}
	}
}

//About Us Dialog
function AboutUs()
{
	alert('Lemint\r\nVersion: 4.0.0');
}

//Ticket Status Highlight Row
function ts_hr(oNode)
{
	if(oNode.tagName.toLowerCase() == "tr")
	{
		oNode.className += " c";
	}
}

//Ticket Status UnHighlight Row
function ts_uhr(oNode)
{
	if(oNode.tagName.toLowerCase() == "tr")
	{
		if(oNode.className.toLowerCase().indexOf("selected") == -1)
		{
			oNode.className = "";
		}
		else
		{
			oNode.className = "Selected";
		}
	}
}

//Ticket Status Highlight Row Click
function ts_hrc(oNode)
{
	var i;
	var iRowId;
	var oParent;
	var oTRNode;
	iRowId = 0;
	var sStyle;
	var sNewStyle;
	
	oParent = oNode.parentNode;
	
	while(oParent.tagName.toLowerCase() != "tbody")
	{
		oParent = oParent.parentNode;
		
		if(oParent.tagName.toLowerCase() == "tr")
		{
			oTRNode = oParent;
		}
	}
	
	for (var i = 0; i < oParent.childNodes.length; i++)
	{
		if(oParent.childNodes[i].tagName && oParent.childNodes[i].tagName.toLowerCase() == "tr")
		{
			sNewStyle = (oParent.childNodes[i] == oTRNode) ? "Selected" : "";
			
			oParent.childNodes[i].className = sNewStyle;
		}
	}
}

//back short circuit
function b_s(e)
{ 
	var bReturn;
	var oElement;
	bReturn = true;
	oElement = e.srcElement || e.target;
	if((oElement.tagName.toLowerCase() != "input" && oElement.tagName.toLowerCase() != "textarea") && e.keyCode == 8) 
	{
		bReturn = false;
	}
	
	return bReturn;
}

function filter(e)
{
	var iFilter;
	
	if(e.keyCode == 13)
	{
		iFilter = document.getElementById("iFilter");
	
		if(iFilter != null)
		{
			iFilter.onclick(e);
		}
	}
}

function SetScrollById(sId, iValue)
{
	var oElement;
	oElement = document.getElementById(sId);
	if(oElement != null)
	{
		SetScroll(oElement, iValue);
	}
}

function SetScroll(oElement, iValue)
{
	if(oElement != null)
	{
		if(oElement.parentNode != null)
		{
			if(oElement.parentNode.parentNode != null)
			{
				if(oElement.parentNode.parentNode.parentNode != null)
				{
					oElement.parentNode.parentNode.parentNode.scrollTop = 0;
				}
			}
		}
	}
}

//print screen
function p_s(sDestination){
	var sNoCache;
	var sFileName;
	var sTitle;
	var xWid;
	var yHei;
	var oWin;
	sNoCache = new Date().getTime();
	sFileName = sDestination; 

	window.open(sFileName);
}

//Print Ticket
function p_t(e)
{
	var lClick;
	
	lClick = document.getElementById("bPrint");
	
	if(lClick != null)
	{
		lClick.onclick(e);
	}
}

//Print All Tickets
function p_at(e)
{
	var lClick;
	
	lClick = document.getElementById("bPrintAll");
	
	if(lClick != null)
	{
		lClick.onclick(e);
	}
}

//hide loading div
function h_ld(sDiv)
{
    d = GetDiv(sDiv);
    if (d)
    {
        if (document.layers) d.visibility = "hide";
        else d.style.visibility = "hidden";
    }
}

//show loading div
function s_ld(sDiv)
{
    d = GetDiv(sDiv);
    if (d)
    {
        if (document.layers) d.visibility = "show";
        else d.style.visibility = "visible";
    }
}
//get loading div
function GetDiv(sDiv)
{
    var div;
    if (document.getElementById)
        div = document.getElementById(sDiv);
    else if (document.all)
        div = eval("window." + sDiv);
    else if (document.layers)
        div = document.layers[sDiv];
    else
        div = null;

    return div;
}

function swap_i(sDiv, sUrl)
{
	d = GetDiv(sDiv);
	if (d)
	{
		//alert(d.id);
		bgimage = 'url('+ sUrl +')';
		document.getElementById(d.id).style.backgroundImage = bgimage;
	}
}

function swap_d(sDiv1, sDiv2)
{
	d1 = GetDiv(sDiv1);
	d2 = GetDiv(sDiv2);
	if (d1 && d2)
	{
		if (document.layers)
		{
			alert('here');
		}
		else
		{
			alert(d2.id);
			d1.style.visibility = "visible";
			d2.style.visibility = "hidden";
			//document.getElementById(d1.id).style.visibility = 'visible';
			//document.getElementById(d2.id).style.visibility = 'none';
		}
	}
}

function s_vd(sLinkButtonId, sValueField, sVideo, e)
{
	var lItemLink;
	var tItemNumber;

	lItemLink = document.getElementById(sLinkButtonId);
	tItemNumber = document.getElementById(sValueField);
//	alert(lItemLink);
	tItemNumber.value = sVideo;
	lItemLink.onclick(e);
}
