function close_list(p_list,p_obj,p_event)
{
	//if (p_event != undefined) 
	//{
		//var cur_tag = ($(p_event.target).get(0).tagName);
		
		//if (cur_tag == 'INPUT') 
		//	return false;
	//}

	$("#"+p_list).fadeOut(200);
	win_status[p_list] = undefined;
	win_progress[p_list] = undefined;
}
function close_all(p_event)
{
	
	for(var i_all in win_status)
	{
		if(win_progress[i_all]==null)
				close_list(i_all,null,p_event);
	}
}
var win_status = new Array();
var win_progress = new Array();
function get_list(p_list,p_obj,p_event)
{


	if(win_status[p_list] != undefined && win_status[p_list] == 1 )
	{
		close_list(p_list,p_obj,p_event);
		return;
	}
	win_status[p_list] = 1;	
	win_progress[p_list] = 1;
	var top = $(p_obj).position().top;
	var left = $(p_obj).position().left;
	
	$("#"+p_list).css({"top":top+22,"left":left+10}).fadeIn(200,function(){
		win_progress[p_list] = undefined;
	});
	$("#"+p_list+" div").mouseover(function(){
		$(this).css({"background":"#c0c0c0"})
	}).mouseout(function(){
		$(this).css({"background":""})
	});
	$("#"+p_list+" div").click(function(){
		$(p_obj).children("input").val($(this).html())
		//close_list(p_list,p_obj);
	})
}

function open_chat()
{
    var lang_id = getCookie('lang_id');
    
    if(lang_id == 'cn'){
        window.open('http://server.iad.liveperson.net/hc/19196107/?cmd=file&file=visitorWantsToChat&site=19196107&referrer='+document.location,'chat19196107','width=472,height=320');return;
    }
    else{             
        window.open('http://server.iad.liveperson.net/hc/22042808/?cmd=file&file=visitorWantsToChat&site=22042808&referrer='+document.location,'chat22042808','width=472,height=320');return;
    }    
}
function open_login()
{
    var lang_id = getCookie('lang_id');
    if(lang_id == 'cn')
    {
        window.open('https://live.btrader.com/FWS/Login.aspx?partition=BT&language=zh-CN', "login" + Math.floor(Math.random()*10001), "width=" + screen.availWidth +",height=" + screen.availHeight + ",resizable=yes,scrollbars=yes");
        return;
    }
    if(lang_id == 'tr')
    {
        window.open('https://live.btrader.com/FWS/Login.aspx?partition=BT&language=tr-TR', "login" + Math.floor(Math.random()*10001), "width=" + screen.availWidth +",height=" + screen.availHeight + ",resizable=yes,scrollbars=yes");
        return;
    }
    if(lang_id == 'de')
    {
        window.open('https://live.btrader.com/FWS/Login.aspx?partition=BT&language=de-DE', "login" + Math.floor(Math.random()*10001), "width=" + screen.availWidth +",height=" + screen.availHeight + ",resizable=yes,scrollbars=yes");
        return;
    }
    if(lang_id == 'jp')
    {
        window.open('https://live.btrader.com/FWS/Login.aspx?partition=BT&language=ja-JP', "login" + Math.floor(Math.random()*10001), "width=" + screen.availWidth +",height=" + screen.availHeight + ",resizable=yes,scrollbars=yes");
        return;
    }
    else
    {              
        window.open('https://live.btrader.com/FWS/Login.aspx?partition=BT', "login" + Math.floor(Math.random()*10001), "width=" + screen.availWidth +",height=" + screen.availHeight + ",resizable=yes,scrollbars=yes");
        return;
    }
    
}

function open_account_form(platform)
{
    if (platform==2)
    {
        location.href="/forex-trading-registration";
    }else
    {                   
        location.href="/MetaTrader4/forex-trading-registration";
    }
}

function open_market_review()
{    
    window.open ("http://www.btrader.com/voiceMarketReview.php","mywindow","width=820,height=520");
    return;
}

function open_charts()
{   
    javascript:window.open('/tools/chart.php','','width=670,height=300');
    return;
}

function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function getLocation(lang){
    location.href = '/lang_id/'+lang;
}
