// Displays the Order Details window as a popup
function DisplayOrderDetailsPopup(strURL)
{
	DisplayPopup(strURL, "_blank", true, false, false, false, 5, 5, 780, 510);
}

// Displays the Help window as a popup
function DisplayHelpPopup(strURL)
{
	DisplayPopup(strURL, "_blank", true, false, false, false, 20, 5, 750, 500);
}

// Displays the product information window as a popup
function DisplayProductInfoPopup(strURL)
{
	DisplayPopup(strURL, "_blank", true, false, false, false, 20, 20, 750, 480);
}

// Displays a popup window
function DisplayPopup(strURL, strName, blnScrollBars, blnMenuBars, blnToolBars, blnResizable, intLeft, intTop, intWidth, intHeight)
{
	var strWindowProperties;
	var strScrollBars = "scrollbars=";
	var strMenuBars = "menubar=";
	var strToolBars = "toolbar=";
	var strResizable = "resizable=";
	var strLeft = "left=" + intLeft + ",";
	var strTop = "top=" + intTop + ",";
	var strWidth = "width=" + intWidth + ",";
	var strHeight = "height=" + intHeight + ",";
	
	if(blnScrollBars)
		strScrollBars = strScrollBars + "yes" + ",";
	else
		strScrollBars = strScrollBars + "no" + ",";

	if(blnMenuBars)
		strMenuBars = strMenuBars + "yes" + ",";
	else
		strMenuBars = strMenuBars + "no" + ",";

	if(blnToolBars)
		strToolBars = strToolBars + "yes" + ",";
	else
		strToolBars = strToolBars + "no" + ",";

	if(blnResizable)
		strResizable = strResizable + "yes";
	else
		strResizable = strResizable + "no";
		
	strWindowProperties = strLeft + strTop + strWidth + strHeight + "location=no," + strScrollBars + strMenuBars + strToolBars + strResizable;
	
	window.open(strURL, strName, strWindowProperties);
}

// displays the admin menu
function ShowHideSubMenu(strDivName)
{		
	var objDiv
	objDiv = document.getElementById(strDivName)
	if (objDiv !=null)
	{
		try {
	    if(objDiv.style.display == "none")
		    objDiv.style.display = "";
	    else
		    objDiv.style.display = "none";
			}catch(e){alert(e.message);}
	}

}

// sets the focus on an element.
function setFocus(strControlId) {
    try {
        document.getElementById(strControlId).focus();
    }
    catch(e){}
}

// toggles the rollover effect for buttons.
function toggleButton(obj) {
    if (obj.className == 'button') {
        obj.className = 'button_hover';
    }
    else {
        obj.className = 'button';
    }
}

// toggles the rollover effect for buttons.
function toggleButton_Click(obj) {
	obj.className = 'button_click';
}

// hides or shows a list of elements on a page.
function toggleVisibility(appElmts,bShow) {
    for(var i=0;i<appElmts.length;i++) {
        try{document.getElementById(appElmts[i]).style.visibility=(bShow)?'visible':'hidden';}
        catch(e){alert(e.message);}
    }
}

// enables or disables an of element.
function toggleElement(sElmt) {
    var oElmt;
    try {
        oElmt=window.document.getElementById(sElmt);
        oElmt.disabled=!oElmt.disabled;
    }catch(e){alert(e.message);}
}

// toggleCheckBox(x,false) to set or toggleCheckBox(x) to toggle...
function toggleCheckBox(cbElmt, bChkd) {
    var oElmt=document.getElementById(cbElmt);
    if (bChkd==null) {
        // toggle
        try {
            oElmt.checked = !oElmt.checked;
        }
        catch(e){alert(e.message);}
    }
    else {
        // set
        try {oElmt.checked=bChkd;}
        catch(e){alert(e.message);}
    }
}

// displays text in status bar.
function stat(txt) {
    window.status=txt;
}

// prints the active screen.
function printScreen() {
	var ieVer = parseInt(navigator.userAgent.charAt(parseInt(navigator.userAgent.indexOf('MSIE')) + 5));
	// only print if it is ie 5 +
	if ((ieVer>5)) {
	    window.focus();
		window.print();
	}
	else {
	    alert('Your browser does not support window printing.  Please select print from the browser menu.');
	}
}

// populates a Text Element with a value.
function popGrdTxt(pElmtId,elmt,val) {
    var str=pElmtId.substr(0,pElmtId.lastIndexOf('_')+1)
    try {document.getElementById(str+elmt).value=val;}
    catch(e){alert(e.message);}
}
