
function PromotionPopup() {
	OpenWindow('/promotion_pages/current_promotions.html', 'promotion', '586', '244', 'no');
	return true;
}

function PerSessionPopup(url, name, width, height, props) {
	OpenWindow(url, name, width, height, props);
	return true;
}

function OpenDetailsWindow (sUrl) {	
	OpenWindow(sUrl, 'Details', 635, 490, 'yes');
}

function OpenPerformanceAnalyzerWindow (sUrl, bSubmit) {
	OpenWindow (sUrl, 'MadOnionWindow', 594, 505, 'yes');
	if (bSubmit) {
		var SystemSelectionObj = GetObjRef(document.PageControlForm, ":SystemSelection");				
		SystemSelectionObj.value = GetSystemSelection();		 
		document.forms[0].submit ();
	}	
}

function OpenWindow(sUrl, sWinName, dWidth, dHeight, bShowScroll)
{   	   
   var winl = (screen.width - dWidth) / 2;
   var wint = (screen.height - dHeight) / 2;
   var winprops = 'height=' + dHeight + ',width=' + dWidth + ',top=' + wint + ',left=' + winl + ',scrollbars=' + bShowScroll + ',resizable=1';
   var win = window.open(sUrl, sWinName, winprops);   
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function Round(nValue, nDecimal)
{
	nSign = (nValue >= 0)?1:-1;
    nValue = Math.abs(nValue); 
	nTempValue = nValue*100;
	nTempValue = Math.round(nTempValue);
	nRemainder = nTempValue % 100;	
	nTempValue -= nRemainder;
	nRemainder /= 100;
	nTempValue /= 100;
	
	if (nTempValue % 2 != 0 && nRemainder >= 0.5)
		nTempValue = nTempValue + nRemainder;	 
		
	return nSign * nTempValue;	
}

function RoundPrice(nValue, nDecimal)
{	
	nSign = (nValue >= 0)?1:-1;
	nExp = Math.pow(10, nDecimal);
	nTempValue = Math.round (nValue * nExp) / nExp;
	
	sDig = "000000000";
	sTempValue = nTempValue.toString();	
	nPos = sTempValue.indexOf(".");
	if (nPos == -1) {
		sTempValue += ".";
		nPos = sTempValue.length - 1;
	}		
	nDec = sTempValue.length - nPos - 1;	
	sTempValue += sDig.substr(0, nDecimal - nDec);
	if (nSign < 0)
		sTempValue = "-" + sTempValue;
					
	return sTempValue;	
}

function GetObjRef(form, objname) 
{
	var objref = null;
	for (i=0; i < form.elements.length; i++) {
		if (form.elements[i].name.indexOf(objname) != -1) {
			objref = form.elements[i];
			break;
		}		
	}
	return objref;
}

function GetDocumentObject (sId) {       
    var statement = '';	
    
    if (document.all) 
	  statement = "var obj = document.all['" + sId + "']";	     
    else if (document.getElementById)           
	  statement = "var obj = document.getElementById('" + sId + "')"; 
    
	try {
	    eval(statement); 
	    return obj;
	} catch(e) {
	} 
	
    return null;	
}

// Netscape fix resize bug Ns4
function WM_netscapeCssFix() {
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth ||
        document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
     document.location = document.location;
    }
}

function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
       document.WM = new Object;
       }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
       document.WM.WM_netscapeCssFix = new Object;
       document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
       document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
       }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn();

// catch all errors...
function stopError() {return true;}
window.onerror=stopError;