

/* construct email address : prevent spam */
function constructAddy(name, domain, cssClass, sLabel) {
	if(sLabel == '') {
		sLabel = name + '@' + domain
	}
	document.write('<a class=' + cssClass + ' href=\"mailto:' + name + '@' + domain + '\">');
	document.write(sLabel + '</a>');
}

/* construct email address : prevent spam */
function constructAddyImg(name, domain) {
	document.write('<a href=\"mailto:' + name + '@' + domain + '\">');
	document.write('<img align=absbottom src=\"images/icon_email.gif\" width=18 height=18 alt=\"send feedback\" border=0></a>');
}

/* functions for popup */
function popup(thisUrl,thisWidth,thisHeight,thisTop,thisLeft) {
	optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',toolbar=no, location=no, directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes');
	mainWin = window.open(thisUrl, Math.floor(Math.random()*51), optionString);
	mainWin.opener = self;
} 

function display(statusText) {
	window.status = statusText;
}
/* end functions for popup */


function calcFibs(fib, nDecimalPlaces) {
	var fibL, fibH, fib23, fib38, fib50, fib61, fib76, fib100
	fibL = fib.low.value;
	fibH = fib.high.value;
	
	fib23 = fibH - (fibH - fibL) * .236;
	fib._23.value = fib23.toFixed(nDecimalPlaces);
	fib38 = fibH - (fibH - fibL) * .382;
	fib._38.value = fib38.toFixed(nDecimalPlaces);
	fib50 = fibH - (fibH - fibL) * .5;
	fib._50.value = fib50.toFixed(nDecimalPlaces);
	fib61 = fibH - (fibH - fibL) * .618;
	fib._61.value = fib61.toFixed(nDecimalPlaces);
	fib76 = fibH - (fibH - fibL) * .764;
	fib._76.value = fib76.toFixed(nDecimalPlaces); 
	fib100 = fibH - (fibH - fibL) * 1;
	fib._100.value = fib100.toFixed(nDecimalPlaces);
}

function printFibs(fibLow, fibHigh, nDecimalPlaces, sSymbol, bStandAlone) {
	var URL = "fibonacci_calculator.asp?" + sSymbol + "_FibCalc=--&p=1&sTicker=" + sSymbol + "&fibL=" + fibLow.value + "&fibH=" + fibHigh.value + "&sa=" + bStandAlone;
	//alert(URL);
	popup(URL, 300, 300, 0, 0);
}


function printPivots(pHigh, pLow, pClose, nDecimalPlaces, sym, bStandAlone) {
	var URL = "pivot_calculator.asp?" + sym + "-PivotCalc=--&p=1&sTicker=" + sym + "&ph=" + pHigh.value + "&pl=" + pLow.value + "&pc=" + pClose.value + "&sa=" + bStandAlone;
	popup(URL, 300, 320, 0, 0);
}


function calcPivots(pivot, nDecimalPlaces) {
	var pHigh, pLow, pClose
	var s3,s2,s1,p,r1,r2,r3
	
	pHigh = pivot.high.value;
	pLow = pivot.low.value;
	pClose = pivot.xClose.value;
	
	p = (1 * pHigh + 1 * pLow + 1 * pClose) / 3
	//alert(p);
	r1 = 2 * p - pLow
	s1 = 2 * p - pHigh
	r2 = p + (r1 - s1)
	s2 = p - (r1 - s1)
	r3 = 2 * p + (pHigh - 2 * pLow)
	s3 = 2 * p - (2 * pHigh - pLow)
	
	pivot.xPivot.value = p.toFixed(nDecimalPlaces);
	pivot.r1.value = r1.toFixed(nDecimalPlaces);
	pivot.s1.value = s1.toFixed(nDecimalPlaces);
	pivot.r2.value = r2.toFixed(nDecimalPlaces);
	pivot.s2.value = s2.toFixed(nDecimalPlaces);
	pivot.r3.value = r3.toFixed(nDecimalPlaces);
	pivot.s3.value = s3.toFixed(nDecimalPlaces);
}


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 checkUncheckAll(theElement) {
	//documentation for this script at http://www.shawnolson.net/a/693/
	//alert(theElement.value);
	var theForm = theElement.form, z = 0;
	while (theForm[z].type == 'checkbox' && theForm[z].name != 'checkall') {
		theForm[z].checked = theElement.checked;
		z++;
	}
}


function stripCharacter(words,character) {
	//documentation for this script at http://www.shawnolson.net/a/499/
	var spaces = words.length;
	for(var x = 1; x < spaces; ++x){
		words = words.replace(character, "");   
	}
	return words;
}


/* drop down navigation handler */
function jumpto(form, name, x) {
	//alert(name.value);
	//if (form.name.value != "null") {
		document.location.href = x
	//}
}
/* end drop down navigation */

/*  */
function setupper______(myfield) {
	if (myfield.inchange)return;
	myfield.inchange=true;
	myfield.value=myfield.value.toUpperCase();
	myfield.inchange=false;
}


// eliminate right click
// runs by default (outside of a function)
/*
if (document.all) {
	//IE 5.x and ^
		document.oncontextmenu =
		function () {
			return false;
		}
		document.onkeydown =
		function () {
			//alert("onKeyDown: " + window.event.keyCode + "\nsrcElement: " + window.event.srcElement.tagName);
			if ((window.event.keyCode == 78 && window.event.ctrlKey == true) || window.event.keyCode == 93) {
				window.event.keyCode = 0;
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				return false;
			}
		}
} else if (document.layers) {	 		
		//Netscape 4.x
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown =
		function (evt) {
			if (evt.which == 3)
				return false;
		}
} else if (parseInt(navigator.appVersion) >= 5 && navigator.appName == "Netscape") {
 		//Netscape 6.x and ^
 		document.onmouseup = function (evt) {
 			if (evt.button == 3)
 				event.preventDefault();
 		}
}
*/
// end eliminate right click
