//<script language=javascript>
//perform binary check
function doCheckBit(strBin,intBit){
	var x = doStrReverse(strBin);
	var y = intBit;
	var z = '';

	if (((x.length) < y) || (y < 0)){
		z = 0;
	}
	else{
		z = x.charAt(y);
	}
	return (z);
}

//pop up window
function doPop(filename,w,h,s,r){
	var options = "width=" + w + ",height=" + h + ",status=no,scrollbars=" + s + ",resizable=" + r + ",directories=no,location=no,menubar=no,toolbar=no,screenX=50,screenY=50,top=50,left=50";
	window.open(filename,"popWin",options);
}

//pop up window
function doPop2(filename,winname,w,h,s,r){
	var options = "width=" + w + ",height=" + h + ",status=no,scrollbars=" + s + ",resizable=" + r + ",directories=no,location=no,menubar=no,toolbar=no,screenX=65,screenY=65,top=65,left=65";
	window.open(filename,winname,options);
}

//pop up External Ad
function doPopExtAd(intAdID, intLocationID, strReferrer){
	var filename = '/exit.asp?AdID=' + intAdID + '&LocationID=' + intLocationID + '&Referrer=' + strReferrer;
	window.open(filename,'popExternalAd');
}

//pop up window
function doPopSecure(filename,w,h,s,r){
	var options = "width=" + w + ",height=" + h + ",status=yes,scrollbars=" + s + ",resizable=" + r + ",directories=no,location=no,menubar=no,toolbar=no,screenX=50,screenY=50,top=50,left=50";
	window.open(filename,"popWin",options);
}

//round any remainders to X number of decimal places
function doRound(num,X) {
	return Math.round(num*Math.pow(10,X))/Math.pow(10,X);
}

//round numeric to next integer
function doShowInt(x) {
	return Math.ceil(x);
}

//format values to #.00 or #.#0, accordingly
function doShowMoney(num){
	var num = doRound(jsCleanNum(num),2);
	var amount = num.toString();
	var newdollars = '';
	if (amount.indexOf('.') != -1) { var dollars = amount.substring(0,amount.indexOf('.')); }
	else { var dollars = amount; }
	//places , for thousands & millions
	if (dollars.length > 3)
	{
		last = dollars.substring(dollars.length-3,dollars.length)
		rest = dollars.substring(0,dollars.length-3);
		if (rest.length > 3)
		{
			middle = rest.substring(rest.length-3,rest.length)
			if (rest.length > 3)
			{
				rest = rest.substring(0,rest.length-3)
				output = rest+','+middle+','+last;
			}
			else { output = middle+','+last; }			
		}
		else
		{
			output = rest+','+last;
		}
		newdollars = output;
	}
	else { newdollars = dollars; }
	if (amount.indexOf('.') != -1){ var cents = amount.substring(amount.indexOf('.'),amount.length); }
	else { var cents='.00' }
	if (cents.length < 3)
	{
		if (cents.length == 2){cents=cents+'0';}
		else {cents=cents+'00';}
	}
	return newdollars+cents+'';
}

//format values to #.00, #.#0, or #.##0 accordingly
function doShowMoney3(x){
	var x = jsCleanNum(x);
	x = doRound(x,3);
	var str1 = x.toString();
	var str1length = str1.length;
	var str1index = str1.indexOf('.') + 1;
	if (str1index == 0){
		return(str1 + '.00');
	}
	else{
		if (str1index == str1length - 1){
			return(str1 + '00');
		}
		else{
			if (str1index == str1length - 2){
				return(str1 + '0');
			}
			else{
				if (str1index == str1length - 3){
					return(str1);
				}
			}
		}
	}
}

function doStrReverse(string){
	var newstring = "";
	for (i=0; i<string.length; i++){
		newstring = string.charAt(i) + newstring;
	}
	return (newstring);
}
function jsCheckVisible(obj)
{
	element = document.getElementById(obj).style;
	if (element.display == 'none') return false;
	else return true;
}
function jsCleanNum(num) 
{
	var newstring = "";
	string = num+'';
	for (i=0; i<string.length; i++)	
	{
		if (!isNaN(string.charAt(i)) || string.charAt(i)=='.') newstring += string.charAt(i);
	}
	var result = parseFloat(newstring);
	if (!isNaN(result)) return result;
	else return 0;
}
function jsHideElement(obj)
{
	element = document.getElementById(obj).style;
	element.display = 'none';
}
function jsPopUp(url,w,h,scroll) 
{
	if (scroll != 'yes') { scroll = 'no'; }
	var features = 'toolbar=no,location=no,directories=no,menubar=no,scrollbars='+scroll+',resizable=no';
	if (url.substring(0,5) == 'https') { features += ',status=yes'; }
	else { features += ',status=no'; }
	if (h != '') { features += ',height='+h; }	
	if (w != '') { features += ',width='+w; }	
	window.open(url,"newWindow",'"'+features+'"');
}
function jsShowElement(obj)
{
	element = document.getElementById(obj).style;
	if (document.getElementById(obj).tagName == 'TR')
	{
		if (navigator.appName != "Microsoft Internet Explorer")element.display = 'table-row';
		else element.display = '';
	}
	else element.display = '';
}
function jsToggleElement(obj)
{
	element = document.getElementById(obj).style;
	element.display == 'none' ? element.display = '' : element.display='none';
}
//</script>