var pageConfirm = false;

window.status="X2CMS";

function jumpTo(pageURL)
{
	if(pageConfirm && confirm("Are you sure you want to leave this page without saving?") == false) 
		return false;
	if(pageURL != "")
		window.location = pageURL;
}

function setSelected(tmpFormField,tmpOptSel)
{
	var s = tmpFormField;
	for (var i=0;i<s.options.length;i++)
	{
		if (s.options[i].text == tmpOptSel)
		{
			s.options[i].selected=true;
			break;
		}
	}
}

function popWin(pURL, pName, pWidth, pHeight, pScrollbars)
{
	var winPop;
	winPop = window.open(pURL,pName,"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars="+pScrollbars+",resizable=yes,width="+pWidth+",height="+pHeight);
	return winPop;	
}

function popWin2(pURL, pName, pWidth, pHeight, pScrollbars)
{
	var winPop;
	winPop = window.open(pURL,pName,"toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars="+pScrollbars+",resizable=yes,width="+pWidth+",height="+pHeight);
	return winPop;	
}

function PageJump(varFormField)
{
	var PageLocation;
	PageLocation = varFormField.options[varFormField.selectedIndex].value;
	if(PageLocation != "")
	{
		window.location = PageLocation;

	}
}

function PageJump2(varFormField, varFormField2)
{
	var PageLocation, PageLocation2;
	PageLocation = varFormField.options[varFormField.selectedIndex].value;
	PageLocation2 = varFormField2.options[varFormField2.selectedIndex].value;
	if(PageLocation != "")
	{
		window.location = PageLocation + PageLocation2;
		return true;
	}
}

function ConfirmDelete(DocNm,sURL)
{
	if (confirm("Delete: " + DocNm + "?") == true) 
		window.location = sURL;
}

function Confirm2(DocNm,sURL)
{
	if (confirm(DocNm) == true) 
		window.location = sURL;
}

function hideLyr(TheLayer)
{
	if(!document.getElementById(TheLayer))
		return false;
	document.getElementById(TheLayer).style.visibility = "hidden";
}

// toggle visible layer

function showLyr(TheLayer)
{
	if(!document.getElementById(TheLayer))
		return false;
	document.getElementById(TheLayer).style.visibility = "visible";
}

// toggle hidden layer

function tglHiddenLyr(TheLayer)
{
	if(!document.getElementById(TheLayer))
		return false;
	if(document.getElementById(TheLayer).style.visibility == "hidden")
		showLyr(TheLayer);
	else
		hideLyr(TheLayer);
}

function DispNoneLyr(TheLayer)
{
	if(!document.getElementById(TheLayer))
		return false;
	document.getElementById(TheLayer).style.display = "none";
}

function DispBlockLyr(TheLayer)
{
	if(!document.getElementById(TheLayer))
		return false;
	document.getElementById(TheLayer).style.display = "block";
}

function tglDisplayLyr(TheLayer)
{
	if(!document.getElementById(TheLayer))
		return false;
	if(document.getElementById(TheLayer).style.display == "none")
		DispBlockLyr(TheLayer);
	else
		DispNoneLyr(TheLayer);
}

function trim(strText)
{ 
	while (strText.substring(0,1) == ' ') 
		strText = strText.substring(1, strText.length);
	while (strText.substring(strText.length-1,strText.length) == ' ')
		strText = strText.substring(0, strText.length-1);
	return strText;
}

function changeBtn(ButtonName,Button)
{
	var ButtonFolder = "../images/";
	document.getElementById(ButtonName).src = ButtonFolder + Button;
}

function toggleBtn(ButtonName,ButtonOn,ButtonOff)
{
	if(document.getElementById(ButtonName).src.indexOf(ButtonOff) != -1)
		changeBtn(ButtonName,ButtonOn);
	else
		if(document.getElementById(ButtonName).src.indexOf(ButtonOn) != -1)
			changeBtn(ButtonName,ButtonOff);		
}

function IsPosInt(sInput)
{
	if(sInput=="") return true;
	var sTmp = sInput.toString();
	for(var i=0;i<sTmp.length;i++)
	{
		var sChar = sTmp.charAt(i);
		if(sChar<"0"||sChar>"9")
			return false;
	}
	return true;
}

function IsPosIntNotZero(sInput)
{
	if(sInput=="") return true;
	var sTmp = sInput.toString();
	for(var i=0;i<sTmp.length;i++)
	{
		var sChar = sTmp.charAt(i);
		if(sChar<"0"||sChar>"9")
			return false;
	}
	if(sInput*1==0)
		return false;
	else
		return true;
}

function  printProps(obj) {
  var output = "" ;
  for (var prop in obj) {
    alert(prop + " = " + obj[prop]);
  }
}

var selTmpBackground = '';

function selOver(oMenu)
{
	selTmpBackground = oMenu.style.backgroundColor;
	oMenu.style.backgroundColor="#EBEBEB";
}

function selOut(oMenu)
{
	oMenu.style.backgroundColor = selTmpBackground;
}

function checkWO()
{
	//if(window.opener 
}

function checkFrame()
{
	if (parent.frames.length) 
		top.location.href= document.location;	
}

function regExpFriendly(myStr)
{
	var specialCharArr = new Array('\\','^','*','$','+','?','.');
	
	for(var i=0; i < specialCharArr.length; i++)
		myStr = myStr.replace(specialCharArr[i],'\\'+specialCharArr[i]);
	
	return myStr;
}









