var wndConWizard = null ;

function goLogin() {
	var oForm = document.forms.frmLogin ;

	if ((oForm.email.value == "") || (oForm.password.value == ""))
		alert("Login error.\n\nYou have not entered an email address and/or password.") ;
	else
		oForm.submit() ;

	return false ;
}

function doTask( sTask, strArgs ) {
	
	switch ( sTask ) {
		// execute an order
		case "order" :		
			var strURL = "/freelunch/protected/shared/fl_execute_task.asp?task=order";
			var wnd = window.open( strURL, "executewnd", "width=430,height=250,resizable,status" );
			break ;
		// chart
		case "chart" :
			//var strURL = "/freelunch/protected/shared/fl_execute_task.asp?task=chart&" + strArgs  ;
			var strURL = "/freelunch/protected/cht/default.aspx?task=chart&" + strArgs ;
			var wnd = window.open( strURL, "executewnd", "width=700,height=580,resizable,scrollbars,status" );
			break ;
		// chart
		case "table" :
			var strURL = "/freelunch/protected/shared/fl_execute_task.asp?task=table&" + strArgs  ;
			var wnd = window.open( strURL, "executewnd", "width=650,height=580,resizable,scrollbars,status");
			break ;
	}		

	//window.location.href = strURL
}

function goTable( sMnemonic ) {
	var sArg = document.frmMain.target.value + "?" + document.frmMain.querystring.value;
//	var sUrl = "/freelunch/protected/fl_check_reg.asp?target=" + adv_escape(sArg) + "&type=table&m=" + adv_escape(sMnemonic);	
//	var wnd = window.open( sUrl, "executewnd", "width=650,height=580,resizable,scrollbars,status");
	location.href="/freelunch/protected/fl_check_reg.asp?sURL=" + adv_escape(sArg) + "&type=table&m=" + adv_escape(sMnemonic);	
}

function goChart( sMnemonic ) {
	var sArg = document.frmMain.target.value + "?" + document.frmMain.querystring.value;
//	var sUrl = "/freelunch/protected/fl_check_reg.asp?target=" + adv_escape(sArg) + "&type=chart&m=" + adv_escape(sMnemonic);
//	var wnd = window.open( sUrl, "executewnd", "width=650,height=580,resizable,scrollbars,status" );
	location.href="/freelunch/protected/fl_check_reg.asp?sURL=" + adv_escape(sArg) + "&type=chart&m=" + adv_escape(sMnemonic);
}

function adv_escape( strUrl ) {
	var sRet = escape(strUrl);
	sRet = sRet.replace(/\+/g,"%2b");
	sRet = sRet.replace(/\-/g, "%2d");
	sRet = sRet.replace(/\*/g, "%2a");
	sRet = sRet.replace(/\//g, "%2f");
	return sRet;
}

function goConceptWizard( sConcept, sFunction, bFree ) {
	var sCMD = "/freelunch/fl_geo_concept.asp?cmd=3&c=" + sConcept + "&f=" + sFunction + "&fl=" + bFree;
	if ( wndConWizard == null ) {
		wndConWizard = window.open(sCMD,"con","status,height=350,width=500");
		if ( !wndConWizard.opener )
			wndConWizard.Opener = window;
	} else if ( wndConWizard.closed ) {
		wndConWizard = window.open(sCMD,"con","status,height=350,width=500");
		if ( !wndConWizard.opener )
			wndConWizard.Opener = window;
	}
}

function doDictionary( m_id, header, folder, concept, blnNewWnd ) {
	var strURL = "/freelunch/fl_dictionary.asp?m=" + m_id + "&h=" + header + "&f=" + folder + "&c=" + concept;
	if (blnNewWnd)
		var wnd = window.open( strURL, "fl_dct" );
	else {
	//	if (opener)	
	//		opener.window.location = strURL;
	//	else
			window.location = strURL;

	}
		
}

function goBasket() {
	var strURL = "/freelunch/protected/fl_basket.asp";
	window.location = strURL ;
}

function goClear() {
	document.forms.frmMain.cmd.value = "2"
	document.forms.frmMain.submit() ;
}

function goHome() {
	var strURL = "/freelunch/default.asp";
	window.location = strURL ;	
}

function goBid() {
	if ( CountBasket() == 0 ) {
		alert("There are no series in your basket.");
	} else {
		var sArg = document.frmMain.target.value + "?" + document.frmMain.querystring.value;
		var sUrl = "/freelunch/protected/fl_check_reg.asp?surl=" + adv_escape(sArg);
		window.location = sUrl ;
		//var wnd = window.open( sUrl, "executewnd", "width=430,height=250,resizable,status" );
	}
}

function DeleteCookie( name ) {
	var path = "/";
	var domain = ".economy.com";
	document.cookie = name + "=" +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}