NS = (document.layers);
IE = (document.all);

var cookie_name = "FXalluserID";
var cookie_data = "logged_out";
var story = null;

function doNothing() {
	// This function does nothing
}

function getCookie() {
	if(document.cookie) {
		index = document.cookie.indexOf(cookie_name);
		if (index != -1) {	
			namestart = (document.cookie.indexOf("=", index) + 1);
			nameend = document.cookie.indexOf(";", index);
			if (nameend == -1) { nameend = document.cookie.length; }
			if (document.cookie.substring(namestart, nameend)) { cookie_data = document.cookie.substring(namestart, nameend); }
		}
	}
	if (cookie_data == "FXalluserID" || cookie_data == "" || cookie_data == "logged_out") { cookie_data = "logged_out" }
	else { cookie_data = "logged_in" }
	return cookie_data;
}

function newFrameSet(frameSrc) {
	story = window.open('','newWin','dependent,resizable,top=20,left=20,width=700,height=500');
	story.focus();
	var sd = story.document;
	sd.open();
	sd.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n');
	sd.write('<html><head><title>Market News</title></head>\n');
	sd.write('<frameset rows="45,*" frameborder="no" framespacing="0" border="0">\n');
	sd.write('<frame name="header" src="/research/header.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="no" align="top" border="0" noresize="noresize">\n');
	sd.write('<frame name="main" src="' + frameSrc + '" marginwidth="0" marginheight="0" scrolling="auto" frameborder="no" align="top" border="0">\n');
	sd.write('</frameset></html>\n');
	sd.close();
} 

function redirectFlash(lastpage){
 	//cookie_data = getCookie();
	//if (cookie_data == "logged_in") 
	//{ 
 //		window.open('/private/?file=/flash/demo.html&lastpage=\"/trading/overview.html\"','FlashDemo','dependent,resizable=no,top=20,left=20,width=640,height=400') 
	//}

        window.open('/flash/demo.html','FlashDemo','dependent,resizable=no,top=20,left=20,width=640,height=400')

	//else { 
	//	location.href = "/private/?lastpage="+lastpage; 
	//}
}

function redirectResearch(file,lastpage){
 	cookie_data = getCookie();
	if (cookie_data == "logged_in") 
	{
		window.open('/private/?file=' + file + '&lastpage="' + lastpage + '"','Research','dependent,resizable,top=20,left=20,width=700,height=500'); 
	}
	else { 
		location.href = "/private/?lastpage="+lastpage; 
	}
}

function redirectNews(file,lastpage){
 	cookie_data = getCookie();
	if (cookie_data == "logged_in") 
	{
		var frameSrc= "/private/redirect.cgi?" + file
		newFrameSet(frameSrc);
	}
	else { 
		location.href = "/private/redirect.cgi?lastpage="+lastpage; 
	}
}
