function left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}
function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}
function wndWidth(){
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth ) ) {
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function ypos(){
    return (document.all)?document.body.scrollTop:window.pageYOffset;
}

function wndHeight(){
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientHeight ) ) {
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}
function fraction(decimal){
    if(!decimal){
        decimal=this;
    }
    whole = String(decimal).split('.')[0];
    decimal = parseFloat("."+String(decimal).split('.')[1]);
    num = "1";
    for(z=0; z<String(decimal).length-2; z++){
        num += "0";
    }
    decimal = parseInt(decimal*num);
    num = parseInt(num);
    for(z=2; z<decimal+1; z++){
        if(decimal%z==0 && num%z==0){
            decimal = decimal/z;
            num = num/z;
            z=2;
        }
    }
    return ((whole==0)?"" : whole+" ")+decimal+"/"+num;
}
    var xMouse=0;
    var yMouse=0;
    document.onmousemove=getMouse;
    function getMouse(e){
        e=e||window.event;
        if (e.pageX||e.pageY){
            xMouse=e.pageX;yMouse=e.pageY;
        }else{
            de=document.documentElement;b=document.body;
            xMouse=e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
            yMouse=e.clientY+(de.scrollTop||b.scrollTop) - (de.clientTop||0);
        }
    }
    function weekday(thedate){
        d = new Date(Date.parse(thedate));
        return d.getDay()+1;
    }
    function month(thedate){
        d = new Date(Date.parse(thedate));
        return d.getMonth()+1;
    }
    function year(thedate){
        d = new Date(Date.parse(thedate));
        return d.getYear()-100+2000;
    }
    function dt(thedate){
        d = new Date(Date.parse(thedate));
        return d.getDate();
    }
    function hour(thedate){
        d = new Date(Date.parse(thedate));
        n = d.getHours();
        if (n>12){n=n-12};
        if (n==0){n=12};
        if(thedate=='?'){return -1}else{return n;};
    }
    function min(thedate){
        d = new Date(Date.parse(thedate));
        if(thedate=='?'){return -1}else{return d.getMinutes();};
    }
    function ampm(thedate){
        d = new Date(Date.parse(thedate));
        n = d.getHours();
        if(thedate=='?'){return -1}else{if (n>11){return 1}else{return 0};};
    }
    function daysinmonth(month,year){
        var d = new Date(year,month,0);
        return d.getDate();
    }
