

/*	-------------------------------------------------------------
	function getBrowserWidth()
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Description:	As odd as it may seem, this function returns
					the browser's width in pixels.
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Credits:		Script found on Particle Tree
					http://www.particletree.com
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -	*/
	
		<!--
		function getBrowserWidth(){
			if (window.innerWidth){
				return window.innerWidth;}	
			else if (document.documentElement && document.documentElement.clientWidth != 0){
				return document.documentElement.clientWidth;	}
			else if (document.body){return document.body.clientWidth;}		
				return 0;
		}
		//-->

/*	-------------------------------------------------------------
	function determineStyle()
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Description:	With this here function we can swap styles.
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Credits:		Script found on A List Apart
					http://www.alistapart.com
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -	*/
	
		<!--
		function determineStyle(){
			
			var browserWidth = getBrowserWidth();
				
			var i, a, main;
			
			if (browserWidth <= 980){
				for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
					if(a.getAttribute("rel").indexOf("style") != -1
					&& a.getAttribute("title")) {
						a.disabled = true;
						if(a.getAttribute("title") == "narrow") a.disabled = false;
					}
				}
			}
			
			if (browserWidth > 980){
				for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
					if(a.getAttribute("rel").indexOf("style") != -1
					&& a.getAttribute("title")) {
						a.disabled = true;
						if(a.getAttribute("title") == "wide") a.disabled = false;
					}
				}
			}
		}
		//-->
	

/*	-------------------------------------------------------------
	function setLinkAttributes()
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Description:	setLinkAttributes finds ALL anchor links and
					can set new attributes. The following script
					specifically finds anchor links labeled as
					external, and add a terget="_blank". We do
					in order to validate in XHTML 1.1 Strict.
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Credits:		Script found on Site Point (I think)
					http://www.sitepoint.com
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -	*/
	
		<!--
		function setLinkAttributes(switchLinks) {
			if (switchLinks == "true") {
				if (!document.getElementsByTagName) return;
				var anchors = document.getElementsByTagName("a");
					for (var i=0; i<anchors.length; i++) {
					var anchor = anchors[i];
					
					//if (anchor.getAttribute("href") && ( anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "nofollow" ) ) {
					//	anchor.target = "_blank";
					//}
					
					if (anchor.getAttribute("href") && ( anchor.getAttribute("rel") == "external" ) ) {
						anchor.target = "_blank";
					}
				}
			} else {
				if (!document.getElementsByTagName) return;
				var anchors = document.getElementsByTagName("a");
					for (var i=0; i<anchors.length; i++) {
					var anchor = anchors[i];
					
					if (anchor.getAttribute("href") && ( anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "nofollow" ) ) {
						anchor.target = "_self";
					}
				}
			}
		}
		
		function toggleLinkAttributes() {
			var ExpireLongTerm = new Date();
			var ExpireLongTermValue = new Date(ExpireLongTerm.getTime()+(1000 * 60 * 60 * 360000));
			
			if ( getCookie("externalLinks") == "true" ) {
				setLinkAttributes("false");
				setCookie("externalLinks","false",ExpireLongTermValue);
			} else if (getCookie("externalLinks") == "false") {
				setLinkAttributes("true");
				setCookie("externalLinks","true",ExpireLongTermValue);
			} else if ( !getCookie("externalLinks") ) {
				setLinkAttributes("true");
				setCookie("externalLinks","true",ExpireLongTermValue);
			}
		}
		//-->
	
	
/*	-------------------------------------------------------------
	function toTop()
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Description:	This little functions performs a smooth
					scroll from the bottom to the top of the
					page.
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -	*/
		
		<!--
		var g_USER_AGENT = getAgent();
		
		// return NN4, NN5(Netscape 6+, Mozilla 1+?), IE4, IE5(IE5+), Unknown
		function getAgent(){
		  var userAgent = navigator.userAgent;
		  var charIndex;
		  var majorVersion;
		
		  charIndex = userAgent.indexOf("MSIE");
		  if(charIndex){
			majorVersion = userAgent.charAt(charIndex + 4 + 1);
			if(majorVersion > 4){
			  return("IE5");
			}
			else if(majorVersion == 4){
			  return("IE4");
			}
		  }
		
		  charIndex = userAgent.indexOf("Mozilla");
		  majorVersion = userAgent.charAt(charIndex + 7 + 1);
		  if(majorVersion > 4){
			return("NN5");
		  }
		  else if(majorVersion == 4){
			return("NN4");
		  }
		
		  return("Unknown");
		}
		/* USER_AGENT check end -------------------------------------------------- */
		
		function getWindowYOffset(){
		  if(g_USER_AGENT == "IE5" || g_USER_AGENT == "IE4"){
			return document.body.scrollTop;
		  }else if(g_USER_AGENT == "NN5" || g_USER_AGENT == "NN4"){
			return window.pageYOffset;
		  }else{
			return 0;
		  }
		}
		
		var waitTimer;
		function jumpTo(dstY, srcY, scrollRate, waitMillSec) {
		  if(waitTimer){
			clearTimeout(waitTimer);
		  }
		  if( ! dstY || dstY < 0 ){
			dstY = 0;
		  }
		  if( ! srcY ){
			srcY = 0 + getWindowYOffset();
		  }
		  if( ! scrollRate ){
			scrollRate = 5;
		  }
		  if( ! waitMillSec ){
			waitMillSec = 20;
		  }
		
		  srcY += (dstY - getWindowYOffset()) / scrollRate;
		  if(srcY < 0){
			srcY = 0;
		  }
		  posY = Math.floor(srcY);
		  window.scrollTo(0, posY);
		
		  if(posY != dstY){
			waitTimer = setTimeout("jumpTo("+ dstY +", "+ srcY +", "+ scrollRate +", "+ waitMillSec +")", waitMillSec);
		  }
		  else if(posY == dstY){
			clearTimeout(waitTimer);
		  }
		  else if(posY < 1){
			window.scroll(0, 0);
		  }
		}
		
		function toTop(){
		  jumpTo(0, 0, 7, 14);
		}
		//-->


	<!-- 
		function doOnResize () {
//			determineStyle();
			setTall();
//			document.getElementById("alpha").style.height="auto";
//			document.getElementById("beta").style.height="auto";
		}
		
		function doOnLoad () {
//			determineStyle();
			//if ( getCookie("externalLinks") ) {
			//	setLinkAttributes( getCookie("externalLinks") );
			//}
			setTall();
			setLinkAttributes("true");
//						document.getElementById("alpha").style.height="";
//			document.getElementById("beta").style.height="";
		}
			
	//-->
	
	function toggleDisplay(elem){
		el = document.getElementById(elem);
		if (el.style.display == 'block'){
			el.style.display = 'none';
		} else {
			el.style.display = 'block';
		}
	}
	
	
	function setTall() {
		if (document.getElementById) {
			// the divs array contains references to each column's div element.  
			// Replace 'center' 'right' and 'left' with your own.  
			// Or remove the last one entirely if you've got 2 columns.  Or add another if you've got 4!
			var divs = new Array(document.getElementById('alpha'), document.getElementById('beta'));
			
			// Let's determine the maximum height out of all columns specified
			var maxHeight = 0;
			for (var i = 0; i < divs.length; i++) {
				if (divs[i]){
					if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
				}
			}
			
			// Let's set all columns to that maximum height
			for (var i = 0; i < divs.length; i++) {
				if (divs[i]){
					divs[i].style.height = maxHeight + 'px';
	
					// Now, if the browser's in standards-compliant mode, the height property
					// sets the height excluding padding, so we figure the padding out by subtracting the
					// old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
//					if (divs[i].offsetHeight > maxHeight) {
						divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
//					}
				}
			}
		}
	}
	
	
function formatNumber(srcStr,nAfterDot){
    var srcStr,nAfterDot;
    var resultStr,nTen;
    srcStr = ""+srcStr+"";
    strLen = srcStr.length;
    dotPos = srcStr.indexOf(".",0);
    if (dotPos == -1){
        resultStr = srcStr+".";
        for (i=0;i<nAfterDot;i++){
            resultStr = resultStr+"0";
        }
        return resultStr;
    } else{
        if ((strLen - dotPos - 1) >= nAfterDot){
            nAfter = dotPos + nAfterDot + 1;
            nTen =1;
            for(j=0;j<nAfterDot;j++){
            nTen = nTen*10;
        }
        resultStr = Math.round(parseFloat(srcStr)*nTen)/nTen;
        return resultStr;
        } else{
            resultStr = srcStr;
            for (i=0;i<(nAfterDot - strLen + dotPos + 1);i++){
                resultStr = resultStr+"0";
            }
            return resultStr;
        }
    }
}	
