/**Start of the index page price feed**/
var default_box=1;
$(document).ready(function(){
	$('.arrow_left').mouseover(function(){
		if(default_box!=1){								
			$('#rate_left').attr('src','images/pricefeed_back_over.gif');
		}else{
			$('#rate_left').attr('src','images/pricefeed_back_disable.gif');
		}		
    }).mouseout(function(){
		if(default_box!=1){								
			$('#rate_left').attr('src','images/pricefeed_back.gif');
		}else{
			$('#rate_left').attr('src','images/pricefeed_back_disable.gif');
		}   	
    });

	$('.arrow_right').mouseover(function(){
		if(default_box!=5){
			$('#rate_right').attr('src','images/pricefeed_next_over.gif');
		}else{
			$('#rate_right').attr('src','images/pricefeed_next_disable.gif');
		}		
    }).mouseout(function(){
		if(default_box!=5){
			$('#rate_right').attr('src','images/pricefeed_next.gif');
		}else{
			$('#rate_right').attr('src','images/pricefeed_next_disable.gif');
		}
    });
	$('.right_button').mouseover(function(){
		var tt=$(this).find("img").attr('src');
		tt=tt.replace('button1','button2');
		var t=$(this).find("img").attr('src',tt);
    }).mouseout(function(){
		var tt=$(this).find("img").attr('src');
		tt=tt.replace('button2','button1');
		var t=$(this).find("img").attr('src',tt);
    });
	//Commentary javascript
	//CLOSING POPUP 
	//Click the x event!
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
	
	/****Ticker hover ****/
	$('#ticker').hover(
      function () {
        cps=0;
      }, 
      function () {
        cps=tSpeed;
      }
    );
});
var ratebox_content = new Array(6);

ratebox_content[5]='Other CFDs ';
ratebox_content[1]='Forex CFD 1';
ratebox_content[2]='Forex CFD 2';
ratebox_content[3]='Forex CFD 3';
ratebox_content[4]='Forex CFD 4';

function switch_ratebox(status){
	switch(status)
	{
		case "up":
			$('.CFD'+default_box.toString()).hide();
			if(default_box==1){
				$('#rate_left').attr('src','images/pricefeed_back.gif');
			}if(default_box==4)
			{
				$('#rate_right').attr('src','images/pricefeed_next_disable.gif');
			}
			default_box++;
			$('.CFD'+default_box.toString()).show();
			$('.ratebox_content').text(ratebox_content[default_box]);
			break;
		case "down":
			$('.CFD'+default_box.toString()).hide();
			if(default_box==5){
				$('#rate_right').attr('src','images/pricefeed_next.gif');
			}else if(default_box==2)
			{
				$('#rate_left').attr('src','images/pricefeed_back_disable.gif');
			}
			default_box--;
			$('.CFD'+default_box.toString()).show();
			$('.ratebox_content').text(ratebox_content[default_box]);
			break;
		case "initial":
			$('.CFD1').show();
			default_box=1;
			$('.ratebox_content').text(ratebox_content[default_box]);
			break;
		default:
			break;
	}
	if(default_box==1)
	{
		$('#rate_left').attr('disabled','disabled');
	}else if(default_box==5)
	{
		$('#rate_right').attr('disabled','disabled');
	}else
	{
		$('#rate_left').attr('disabled','');
		$('#rate_right').attr('disabled','');
	}
	
}	
/**End of the index page price feed**/
/**Start Center content Javascript**/
var current_tab='tab-1';
var current_tab_id='0';

function switch_tab(tab_name,tabid)
{
	$('#'+current_tab).hide();
	$('#tab li:eq('+current_tab_id+') a').removeClass('tab_selected');
	$('#'+tab_name).show();
	$('#tab li:eq('+tabid+') a').addClass('tab_selected');
	current_tab = tab_name;
	current_tab_id=tabid;
}
function ini_tab()
{
	$('#tab-1').show();	
	
}

/**End Center content Javascript**/

/* START TICKER CODE - RISK WARNING TICKER */

var tWidth='100%';                   // width (in pixels)
var tHeight='14px';                  // height (in pixels)
var tcolour='#e0dfdf';               // background colour:
var moStop=false;                    // pause on mouseover (true or false)
var fontfamily = 'tahoma';           // font for content
var tSpeed=1;                        // scroll speed (1 = slow, 5 = fast)

// enter your ticker content here (use \/ and \' in place of / and ' respectively)
var content='百汇国际不接受美国的客户。百汇国际的服务的发行和使用可能会与一些国家和地区的法律和规章有矛盾，百汇国际并没有故意向任何这些国家或地区的任何人提供其服务或让他们使用其服务。客户有责任了解并遵从自己所在地方的法律和规章的条款，倘阁下使用即表示阁下同意本网站的使用「条件及条款」。';

// Simple Marquee / Ticker Script
// copyright 3rd January 2006, Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the below code in this script (including this
// comment) is used without any alteration
var cps=tSpeed; 
var aw, mq; 
var fsz = parseInt(tHeight) - 3; 

function startticker(){
	
	if (document.getElementById) {
		var tick = '<div style="position:relative;width:'+tWidth+';height:'+tHeight+';overflow:hidden;background-color:'+tcolour+'"'; 
		
		if (moStop) tick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; 
		
		tick +='><div id="mq" style="position:absolute;left:0px;top:0px;font-family:'+fontfamily+';font-size:'+fsz+'px;white-space:nowrap;"><\/div><\/div>'; 
		document.getElementById('ticker').innerHTML = tick; 
		mq = document.getElementById("mq"); 
		mq.style.left=(parseInt(tWidth)+600)+"px"; 
		mq.innerHTML='<span id="tx">'+content+'<\/span>'; 
		aw = document.getElementById("tx").offsetWidth; lefttime=setInterval("scrollticker()",50);
	}
} 

function scrollticker(){
	mq.style.left = (parseInt(mq.style.left)>(-100 - aw)) ?parseInt(mq.style.left)-cps+"px" : parseInt(tWidth)+600+"px";
} 
  
/* END TICKER CODE - RISK WARNING TICKER */


/***********Start of Conten Page JavaScripts********************/



/***********End of Conten Page JavaScripts********************/

/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/
//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");

}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		$('#popupContact').text('');
		
}

//centering popup
function centerPopup(){
	//request data for centering
	/*THE Following line get the current window scroll top position*/
	var sTOP=window.pageYOffset|| document.documentElement && document.documentElement.scrollTop||  document.body.scrollTop;
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact").height();
	var popupWidth = $("#popupContact").width();
	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": sTOP+(windowHeight/2-popupHeight/2),
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

function popup_verify()
{
	//centering with css
	centerPopup();
	$('#popupContact').load("commentary_content.php");
	//load popup
	loadPopup();
	return false;
}
/*********************************************************************/

