﻿function hoverMenu(mItem,vMode) {
	var mElem = document.getElementById('menu_item_'+mItem);
	//var mElemLink = document.getElementById('menu_item_text_'+mItem);
	if (vMode=='on') { 
		mElem.style.background='url('+WebSiteUrl+'/images/design/top_menu_on.png) bottom repeat-x';
		//mElemLink.style.color='#ffffff';
	} else { 
		mElem.style.background='none';
		//mElemLink.style.color='#000000';
	}
}

function showFlash (url, width, height, wmode) {
    document.write(
	    '<object name=myFlashMovie classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'> '+
	    '<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+url+'" /><param name="quality" value="high" /><param name="wmode" value="'+wmode+'" /><param name="menu" value="false" /><PARAM NAME="Stacking" VALUE="below" />  '+
	    '<embed src="'+url+'" quality="high" width="'+width+'" height="'+height+'" wmode="'+wmode+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> '+
	    '</object>'
    );
}

function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)

	/**********************************************************************
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
	 **********************************************************************/

{ 
	bolLeadingZero=true;
        if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	// fix display
		tmpNumStr_arr=tmpNumStr.split(".");
		if (tmpNumStr_arr[1]==undefined) { tmpNumStr = tmpNumStr.substring(0,tmpNumStr.length) + '.00'; }
		try { if (tmpNumStr_arr[1].length==1) { tmpNumStr = tmpNumStr.substring(0,tmpNumStr.length) + '0'; } } catch(e) { }

	return tmpNumStr;		// Return our formatted string!

}

function convertToEntities(sourceField) {
  var tstr = sourceField.value;
  var bstr = '';
  for(k=0; k<tstr.length; k++) {
      bstr += '&#' + tstr.charCodeAt(k) + ';';
  }
  sourceField.value=bstr;
}

function window_open(url,width,height,isScroll) {
	x = (800 - width)/2, y = (600 - height)/2;
	if (screen) { y = (screen.availHeight - height)/2; x = (screen.availWidth - width)/2; }
	var newWindow;
	newWindow = window.open(url,'','height='+height+',width='+width+',top='+y+',left='+x+',toolbar=no,minimize=no,status=no,memubar=no,location=no,scrollbars='+isScroll)
}

var isHeightFixed=0;
function fixEngineHeight(vMode) {
	switch(vMode) {
		case 'up': 
			var pcH_delta = 70;
			if (isHeightFixed==1) { pcH_delta=0 } 
			isHeightFixed=1;
			break;
		case 'down':
			var pcH_delta = -70;
			isHeightFixed=0;
			break;
	}
	var pcH = document.getElementById('engine_content').offsetHeight;
	try { pcH = pcH.replace('px',''); } catch(e) {}
	pcH = parseInt(pcH+pcH_delta);
	document.getElementById('engine_content').style.height = pcH+'px';
}
