/*Utils.js
* by Mark Lonsway
* Copyright (c) 2001 Calypso Systems. All Rights Reserved.
*/
function go_back()
{
	window.history.back();
}

function doFireEvent(oID)
{
    document.all(oID).fireEvent("onclick");
}

function test()
{
	alert('hey now!');
}

function set_focus(elementname) {
	if (document.all)
	{
		document.all[elementname].focus();
	}	
}

function set_formfocus() {
	if(document.forms[0][1] != null) 
	{
		document.forms[0][1].focus(); 
	}
}

function is_framed() {
	return (window.length == 0);
}

function is_toplevel() {
	return (window.parent == window);
}
	
function currency( num ) 
{ 
   var prefix = "$"; 
   var suffix = ""; 
   if ( num < 0 ) 
   { 
       prefix = "($"; 
       suffix = ")"; 
       num = - num; 
   } 
       var temp = Math.round( num * 100.0 ); // convert to pennies! 
       if ( temp < 10 ) return prefix + "0.0" + temp + suffix; 
       if ( temp < 100 ) return prefix + "0." + temp + suffix; 
       temp = prefix + temp; // convert to string! 
       return temp.substring(0,temp.length-2) + "." + temp.substring(temp.length-2) + suffix; 
} 
	

function open_ftp(url) {
	var sTop = vCenter(400);
	var sLeft = hCenter(700);
	/*
	alert(navigator.appVersion);
	*/
	
	var IsMac = inStr(navigator.appVersion,"Mac");
	
	if (IsMac == 0)
	{	
		var Win = window.open('www.google.com','FTPVIEW','Height=1,Width=1,left=50000,top=50000,scrollbars=no,toolbar=no,menubar=no,resizable=0'); 
		Win.close(); 
	}
	//Win = window.open('ftp://www.lonz.com/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + url + '/','FTPVIEW','Height=300,Width=400,left=' + sLeft + ',top=' + sTop + ',scrollbars=no,titlebar=no,location=no,toolbar=no,menubar=no,status=no,resizable=0'); 
	Win = window.open('ftp://www.lonz.com/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + url + '/','FTPVIEW','Height=300,Width=400,left=' + sLeft + ',top=' + sTop + ',scrollbars=no,titlebar=no,location=no,toolbar=no,menubar=no,status=no,resizable=0'); 

	return false;
}

function inStr(mainStr, searchStr)
{
	var foundOffset = mainStr.indexOf(searchStr);
	if (foundOffset == -1)
	{
		return 0;
	}
	else
	{
		return foundOffset;
	}
}

function vCenter(lHeight)
{
	if (screen.height)
	{
		return (screen.height-lHeight) /2;
	}
	else
	{
		return 50;
	}
}
function hCenter(lWidth)
{
	if (screen.width)
	{
		return (screen.width-lWidth) /2;
	}
	else
	{
		return 50;
	}

}	

function gettopquote()
{ 
	var topquote = document.forms['frmsearch2'].cbotopquote;
	if (topquote.options[topquote.selectedIndex].value != 1) 
	{
		if (document.forms['frmsearch2'].optquote[0].checked == true)
		{
			window.location = 'quoteresult.asp?quotesymbol=' + topquote.options[topquote.selectedIndex].value;
		} else {
			window.location = 'charting.asp?symbols=' + topquote.options[topquote.selectedIndex].value;
		}
	}
}

function dosymbolsearch()
{
	var quotesearch = document.forms['frmsearch2'].txtsearchquote;
	if (document.forms['frmsearch2'].optquote[0].checked == true)
	{
		window.location = 'quoteresult.asp?quotesymbol=' + quotesearch.value;
	} else {
		window.location = 'charting.asp?symbols=' + quotesearch.value;
	}
}

function sendpasswordreminder()
{
	document.forms['frmreminder'].reminder.value =1
	document.forms['frmreminder'].reminderusername.value = document.forms['frmlogin'].username.value
	document.forms['frmreminder'].submit()
}
