function changeTab(tabNum)
{
  var blueLeft ="images/ltr_left_corner_blue_tab.gif";
  var blueRight ="images/ltr_right_corner_blue_tab.gif";
  var whiteLeft ="images/ltr_left_corner_white_tab.gif";
  var whiteRight ="images/ltr_right_corner_white_tab.gif";
  
  var tabID;
	for(var i=2; i<5; i++)
	{
	 tabID = "tab_"+i;
		if(tabNum == i)
		{
    		document.getElementById(tabID).style.display = "";
    		document.getElementById("tab"+tabNum).className = "white_tab";
    		document.getElementById("l"+tabNum).src = whiteLeft;//left corner
    		document.getElementById("r"+tabNum).src = whiteRight;//right corner
		}
		else
		{
			document.getElementById(tabID).style.display = "none";
			document.getElementById("tab"+i).className = "blue_tab";
      document.getElementById("l"+i).src = blueLeft;//left corner
    	document.getElementById("r"+i).src = blueRight;//right corner		
		}
	
	}
}

//function that switches quotes bar tabs & content
function switch_quotes_bar_tab(num) {
	$('#quotes_bar_layer'+num).siblings().css({'display':'none'});
	$('#quotes_bar_layer'+num).css({'display':''});
	document.getElementById('quotes_bar_tabs_left').className = 'quotes_bar_' + num;
	document.getElementById('quotes_bar_tabs_right').className = 'quotes_bar_rtl_' + num;
}

function changeTabNew(prefix,tabNum)
{ 
  var tabID;
	for(var i=1; i<=3; i++)
	{
	 tabID = prefix+"_tab_"+i;
		if(tabNum == i)
		{
    		if (i>1)
    		{	var prev;
    		prev=i-1;
    			document.getElementById(prefix+'_seperator_'+prev).style.display = "none";	
    		}
    			
    		document.getElementById(tabID).className = "profile_on_tab";
    		document.getElementById(prefix+'_tab_data_'+i).style.display = "";	
		}
		else
		{	
			document.getElementById(tabID).className = "profile_off_tab";
			document.getElementById(prefix+'_tab_data_'+i).style.display = "none";	
		}
	
	}
}

function changeTabFreeBee(tabNum)
{	
  var tabID;
	for(var i=1; i<=3; i++)
	{
	 tabID = "freebee_tab_"+i;
		if(tabNum == i)
		{
    		if (i>1)
    		{	var prev;
    			prev=i-1;
    			document.getElementById('freebee_seperator_'+prev).style.display = "none";	
    		}
    			
    		document.getElementById(tabID).className = "freebee_on_tab";
    		document.getElementById('freebee_data_'+i).style.display = "";	
		}
		else
		{	
			document.getElementById(tabID).className = "freebee_off_tab";
			document.getElementById('freebee_data_'+i).style.display = "none";	
			document.getElementById('freebee_seperator_'+i).style.display = "";	
		}
	
	}
}


/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}


function analysis_print_Popup(type,myID) {
	if(type!='analysis' && type!='education') {
                window.open('/'+type+'/analysis_print.php?contentID='+myID,"Window2",
                "menubar=no,width=830,height=640,toolbar=no, scrollbars=1");
	}
	else if(type == 'news') {
				window.open('/news/news_print.php?newsID='+myID,"Window2",
                "menubar=no,width=830,height=640,toolbar=no, scrollbars=1");
	}else {
		window.open('/analysis/analysis_print.php?contentID='+myID,"Window2",
        "menubar=no,width=830,height=640,toolbar=no, scrollbars=1");
	}
}
var tgs = new Array( 'div','span','td','tr');

var szs = new Array('small','medium','large');
var startSz = 0;                
function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 1 ) sz = 2;
	if ( sz > 2 ) sz = 0;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.className = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].className = szs[ sz ];
	}
}                   

function strpos( haystack, needle, offset){
    // http://kevin.vanzonneveld.net
    // +     original by: Martijn Wieringa
    // *         example 1: substr('abcdef', 0, -1);
    // *         returns 1: 'abcde'	
	var i = haystack.indexOf( needle, offset ); // returns -1
    return i >= 0 ? true : false;
}

function substr( f_string, f_start, f_length ) {
    // http://kevin.vanzonneveld.net
    // +     original by: Martijn Wieringa
    // *         example 1: substr('abcdef', 0, -1);
    // *         returns 1: 'abcde'
 
    if(f_start < 0) {
        f_start += f_string.length;
    }
 
    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }
 
    if(f_length < f_start) {
        f_length = f_start;
    }
 
    return f_string.substring(f_start, f_length);
}

function openAddReviewDiv(div,gotolocation)
{
  	document.getElementById(div).style.display='block';
	location.href=gotolocation;

}

function checkUncheckAll(theElement) 
{
var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++)
	{
	      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
	      {
		  	theForm[z].checked = theElement.checked;
	      }
	}
}

//COOL DETECT BROWSER FUNCTION
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
//COOL DETECT BROWSER FUNCTION END



function changeIndexfeaturedTabNew(prefix_tab,prefix_data,tabNum,last_tab_num)
{	
  var tabID;
	for(var i=1; i<=20; i++)
	{
	 	 tab_div = prefix_tab+i;
	 	 data_div = prefix_data+i;
	 	 last_tab = prefix_tab+last_tab_num;
		 if(document.getElementById(tab_div) && document.getElementById(data_div))
		 {
		 	//checking if tab is last one, so save it in var, to save it's classname.
			if(tabNum == i)
			{	    	
	    		document.getElementById(tab_div).className = "selected";
	    		document.getElementById(data_div).style.display = "";	
			}
			else
			{	
				if(tab_div==last_tab)
				document.getElementById(tab_div).className = "last";
				else
				document.getElementById(tab_div).className = "";
				document.getElementById(data_div).style.display = "none";	
			}
		}
	}
}

function getElementsByStyleClass (className) {
  var all = document.all ? document.all :
    document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
    if (all[e].className == className)
      elements[elements.length] = all[e];
  return elements;
}


function erase_input_onclick (element){
if(element.firstTime){return}
element.firstTime=true
element.value=""
}

function urlencode(str) {
	return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
}

function validateEmail(email)
{
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  if (filter.test(email))
    retVal=1;
  else
    retVal=0;
	return retVal;
}

//function to know which radio button was checked
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

//check if value is numeric
function IsNumeric(strString) {
	var strValidChars = "0123456789.";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0) return false;
	
	//check if strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++) {
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1) {
			blnResult = false;
		}
	}
	return blnResult;
}

function error_open_popup(url,type_dir)
{
	childWin=open(""+url+"&usr_type="+type_dir,"","width=650,height=450,resizable=no,alwaysRaised=no,screenX=0,screenY=0,dependent=no,scrollbars=0");
}

function analysis_toggle_div(direction, no_of_divs, new_link) {
	var current_div = parseInt($('#analysis_active_div_id').val());
	var new_div;
	
	if(direction == 'next') {
		if(current_div == no_of_divs) {
			new_div = 1;
		} else {
			new_div = current_div + 1;
		}
	} else {
		if(current_div == 1) {
			new_div = no_of_divs;
		} else {
			new_div = current_div - 1;
		}
	}
	$('#analysis_div_'+current_div).css('display','none');
	$('#analysis_div_'+new_div).css('display','block');
	$('#analysis_active_div_id').attr('value',new_div);
	
	$('#hp_more_link').attr('href', $('#title_link_'+new_div).attr('href'));
}

function webinar_box_toggle_div(direction,num_of_items) {

	item_number = $('#webinar_box_current_div').val();
	number_to_check = num_of_items - 1;
	
	if(direction=='next') {
		if(item_number < number_to_check) {
			item_number++;
		} else {
			item_number=0;
		}
	} else { // previous
		if(item_number > 0) {
			item_number--;
		} else {
			item_number=number_to_check;
		}
	}
	$('#webinar_box_current_div').val(item_number);
	
	$.get("/common/ajax_func.php",{ action:'get_webinar_box_item', item_number: item_number } ,function(data) {
		if(data!='') {
  			$('#webinar-box-item').html(data);
		}
   });
}

//////////Quotes Search ////////////////////
var count_li_next = 2;
var count_li_prev = 0;
var count_li_selected = 0;
var count_new_li = 0;
var search_text_assigned = false;
var search_list_find = false;

function ReplaceAll(Source,stringToFind,stringToReplace){

  var temp = Source;
  var index = temp.indexOf(stringToFind);
  while(index != -1){
	  temp = temp.replace(stringToFind,stringToReplace);
	  index = temp.indexOf(stringToFind);
  }
  return temp;
}

function update_auto_complete(element, evt) {
	if((evt.keyCode>=48 && evt.keyCode<=90) || (evt.keyCode>=96 && evt.keyCode<=111) || evt.keyCode==38 || evt.keyCode==40 || evt.keyCode==8 || evt.keyCode==46) {
		count_li_next = 2;
		count_li_prev = 0;
		count_li_selected = 0;
		count_new_li = 0;
		
		if($(element).val().length>=1) {
			if(evt.keyCode == 40 || evt.keyCode == 38) {
				if($('.li_search_list').length>0) {
					search_text_assigned = true;
					$('.li_search_list').each(function() {
						if($(this).is('.highlight') && count_li_selected==0) {
							count_li_selected=1;
							$(this).removeClass('highlight');
							if(evt.keyCode == 40) {
								$('#search_li_'+count_li_next).addClass('highlight');
								count_new_li = count_li_next;
							} else {
								if(count_li_prev > 0) {
									$('#search_li_'+count_li_prev).addClass('highlight');
									count_new_li = count_li_prev;
								} else {
									$('.search_inner_container ul li:last').addClass('highlight');
									count_new_li = $('.li_search_list').length;
								}
							}
						}
						count_li_next++;
						count_li_prev++;
					});
					if(!$('#search_li_'+count_new_li+' .name').length) {
						count_li_selected=0;
						if($('.search_inner_container ul li:first .name').length) {
							var str = ReplaceAll($('.search_inner_container ul li:first .symbol').html(), '<b>', '');
							str = ReplaceAll(str, '</b>', '');
							str = ReplaceAll(str, '<B>', '');
							str = ReplaceAll(str, '</B>', '');
							$('#quotes_search_text').val( str );
						}
					} else {
						var str = ReplaceAll($('#search_li_'+count_new_li+' .symbol').html(), '<b>', '');
							str = ReplaceAll(str, '</b>', '');
							str = ReplaceAll(str, '<B>', '');
							str = ReplaceAll(str, '</B>', '');
						$('#quotes_search_text').val( str );
					}
					if(count_li_selected == 0) {
						$('.search_inner_container ul li:first').addClass('highlight');
						count_li_selected = 1;
						count_new_li = count_li_selected;
					}
					//$('#quotes_search_text').val( $('#search_li_'+count_new_li+' .symbol').html() );
					$('#quotes_search_form').attr('action',$('#search_li_'+count_new_li+' .link').html());
				}
			} else {
				//search_text_assigned = false;				
				if(window.SearchStartTimerIsOn==1) {
					clearTimeout(window.SearchStartTimer);
				}
		  		window.AllowAutoCompleteFlag = 0;
		  		window.SearchStartTimer = setTimeout('AllowAutoComplete()', 170); 
		  		window.SearchStartTimerIsOn = 1;
		  		setTimeout(function() { CheckAutoComplete($(element).val()); }, 170);
			}
		} else {
			//$('#search_list_container').css('display','none');
			$('#search_list_container').html('&nbsp;');
		}
	}
}

function AllowAutoComplete() {
	window.AllowAutoCompleteFlag = 1;
}

function CheckAutoComplete(search_text) {
	if(window.AllowAutoCompleteFlag==1) {
		ExecuteAutoComplete(search_text);
	}
}

function ExecuteAutoComplete(search_text) {
	
	$.get("/common/search/search_ajax.php",{ action:'get_auto_complete', search_text: search_text } ,function(data) {
		if(data!='') {
  			$('#search_list_container').html(data);
  			//$('#search_list_container').css('display','block');
  			search_text_assigned = false;
  			search_list_find = true;
		} else {
			//$('#search_list_container').css('display','none');
			$('.li_search_list').html('');
			$('#search_list_container').html('&nbsp;');
			search_list_find = false;
		}
   });
}

function add_search_events() { 
	
	$('.ul_search_list li').each(function() {
		// Add onClick, blur, onmouseover, onmouseout  to each li
		$(this).click(function() {
			//$('#quotes_search_text').val( $(this).find('.symbol').html() );			
			var str = ReplaceAll($(this).find('.symbol').html(), '<b>', '');
			str = ReplaceAll(str, '</b>', '');
			str = ReplaceAll(str, '<B>', '');
			str = ReplaceAll(str, '</B>', '');
			$('#quotes_search_text').val( str );
			$('#quotes_search_form').submit();
		}).blur(function() {
			$(this).removeClass('highlight');
		}).mouseover(function() {
			//$('#quotes_search_text').val( $(this).find('.symbol').html() );			
			var str = ReplaceAll($(this).find('.symbol').html(), '<b>', '');
			str = ReplaceAll(str, '</b>', '');
			str = ReplaceAll(str, '<B>', '');
			str = ReplaceAll(str, '</B>', '');
			$('#quotes_search_text').val( str );
			$('#quotes_search_form').attr('action',$('#'+$(this).attr('id')+' .link').html());
			$(this).addClass('highlight');
			search_text_assigned = true;
		}).mouseout(function() {
			$(this).removeClass('highlight');
		});
		
	});

	$('#quotes_search_form').submit(function() {
		if(search_text_assigned!=true && ($('.ul_search_list').length>0) ) {
			$('#quotes_search_form').attr('action',$('.ul_search_list li:first .link').html());
		}
	});
	
}

function validate_quotes_search_form(quotes_form) {
	if((($('#quotes_search_text').val().length>=1) && ($('.ul_search_list').length>0)) || search_list_find == true) {
		return true;
	} else {
		return false;
	}
}
////////// End Quotes Search ////////////////
/*################################################################
########################  DROPDOWNS  #############################
################################################################*/
	var disappeardelay=0  //menu disappear speed onMouseout (in miliseconds)
	var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
	var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)
	
	/////No further editting needed
	
	var ie5=document.all
	var ns6=document.getElementById&&!document.all
	
	function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null){
	totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
	parentEl=parentEl.offsetParent;
	}
	return totaloffset;
	}
	
	function showhide(obj, e, visible, hidden){
	if (ie5||ns6)
	dropmenuobj.style.left=dropmenuobj.style.top=-500
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	obj.visibility=visible
	else if (e.type=="click")
	obj.visibility=hidden
	}
	
	function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}
	
	function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
	var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
	dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
	if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
	edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	}
	else{
	var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
	var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
	dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
	if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
	edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
	if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
	edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
	}
	}
	return edgeoffset
	}
	
	function dropdownmenu(obj, e, dropmenuID){
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	if (typeof dropmenuobj!="undefined") //hide previous menu
	dropmenuobj.style.visibility="hidden"
	clearhidemenu()
	if (ie5||ns6){
	//obj.onmouseout=delayhidemenu
	dropmenuobj=document.getElementById(dropmenuID)
	if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
	dropmenuobj.onmouseover=clearhidemenu
	dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
	showhide(dropmenuobj.style, e, "visible", "hidden")
	dropmenuobj.x=getposOffset(obj, "left")
	dropmenuobj.y=getposOffset(obj, "top")
	dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
	dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
	return clickreturnvalue()
	}
	
	function clickreturnvalue(){
	if ((ie5||ns6) && !enableanchorlink) return false
	else return true
	}
	
	function contains_ns6(a, b) {
	while (b.parentNode)
	if ((b = b.parentNode) == a)
	return true;
	return false;
	}
	
	function dynamichide(e){
	if (ie5&&!dropmenuobj.contains(e.toElement))
	delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
	delayhidemenu()
	}
	
	function delayhidemenu(){
	delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
	}
	
	function clearhidemenu(){
	if (typeof delayhide!="undefined")
	clearTimeout(delayhide)
	}
/*################################################################
########################  DROPDOWNS  #############################
################################################################*/
	
/*################################################################
########################  New Header  #############################
################################################################*/

	var oldDropDownId = null;
	var dropDownId = null;
	function showQuotesBar()
	{
		//var arrDivId = document.getElementsByName('mainMenuDropDown');
		var x = 33;
		/*while (arrDivId[x])
		{
			if (x != dropDownId)
				hideQuotesBar(arrDivId[x].id);
			x++;
		}*/
		while (document.getElementById('mainMenuDropDown_' + x + '_container'))
		{
			if (x != dropDownId)
				hideQuotesBar(x);
			x++;
		}
		if (time_out_off)
		{
			clearTimeout(t);
			time_out_off = false;
		}
		
		document.getElementById('mainMenuDropDown_' + dropDownId + '_container').style.visibility = 'visible';
		document.getElementById('mainMenuDropDown_' + dropDownId + '_container').style.display = 'block';
		document.getElementById('mainMenuDropDown_' + dropDownId + '_divid').style.visibility = 'visible';
		sub_menu = true;
		time_out_on = false;
		time_out_off = false;
	}

	function hideQuotesBar(dropDown)
	{
		//return;
		if (dropDown)
		{
			document.getElementById('mainMenuDropDown_' + dropDown + '_container').style.visibility = 'hidden';
			document.getElementById('mainMenuDropDown_' + dropDown + '_container').style.display = 'none';
			document.getElementById('mainMenuDropDown_' + dropDown + '_divid').style.visibility = 'hidden';
		}
		else
		{
			document.getElementById('mainMenuDropDown_' + dropDownId + '_container').style.visibility = 'hidden';
			document.getElementById('mainMenuDropDown_' + dropDownId + '_container').style.display = 'none';
			document.getElementById('mainMenuDropDown_' + dropDownId + '_divid').style.visibility = 'hidden';

			sub_menu = false;
			time_out_on = false;
			time_out_off = false;
		}
	}

	function showMyAccount()
	{
		if (time_out_off)
		{
			clearTimeout(t);
			time_out_off = false;
		}
		document.getElementById('my_account').className = 'selected my_account';
		document.getElementById('my_account_list_div').style.display = 'block';
		sub_menu = true;
		time_out_on = false;
		time_out_off = false;
	}

	function hideMyAccount()
	{
		//return;
		document.getElementById('my_account').className = 'no_selected my_account';
		document.getElementById('my_account_list_div').style.display = 'none';
		sub_menu = false;
		time_out_on = false;
		time_out_off = false;
	}
	
	function markLine(id, dirr)
	{
		document.getElementById(id).style.background = '#DAE5F0';
		if (dirr == 'rtl')
			document.getElementById('a_' + id).style.background = 'url("/images/arrows-rtl.png") right -131px no-repeat #DAE5F0';
		else
			document.getElementById('a_' + id).style.background = 'url("/images/arrows.png") 0px -131px no-repeat #DAE5F0';
	}
	
	function unMarkLine(id, dirr)
	{
		document.getElementById(id).style.background = '#fff';
		if (dirr == 'rtl')
			document.getElementById('a_' + id).style.background = 'url("/images/arrows-rtl.png") right -131px no-repeat #fff';
		else
			document.getElementById('a_' + id).style.background = 'url("/images/arrows.png") 0px -131px no-repeat #fff';
	}

	var time_out_on = false;
	var time_out_off = false;
	var sub_menu = false;
	var t;
	function showSubMenu(what)
	{ 
		if (!time_out_on)
		{
			if (what == 'my_account')
				t=setTimeout("showMyAccount()", 110);
			else
			{
				oldDropDownId = dropDownId; 
				dropDownId = what;
				t=setTimeout("showQuotesBar()", 110);
			}
			time_out_on = true;
			time_out_off = false;
		}
	}

	function hideSubMenu(what)
	{
		if (sub_menu)
		{
			if (what == 'my_account')
				t=setTimeout("hideMyAccount()", 110);
			else
				t=setTimeout("hideQuotesBar()", 110);
		}
		else
			clearTimeout(t);
		time_out_on = false;
		time_out_off = true;
	}
	
	/*################################################################
	########################  Big PopUp  #############################
	################################################################*/

	// Open the lightbox
	function openLightBox(div_id, div_width, div_height, fadin, other)
	{
		var box = document.getElementById(div_id);

		// Enable the dark layer on the al page
		$('#mainLightBoxFilter').css('height',$(document).height());
		$('#mainLightBoxFilter').css('display','block');

		var leftpos = ($(document).width() - div_width) / 2;
		var toppos = ($(window).height() - div_height) / 2;
		$(box).css('left',leftpos);
		$(box).css('top',toppos);
		if(fadin){
			gradient(div_id, 0);
			fadein(div_id);
		}else{ 	
			$('#' + div_id).css('display','block');
		}
	}

	// Close the lightbox
	function closeLightBox(div_id, fadout, other)
	{
		$('#mainLightBoxFilter').css('display','none');
		$('#' + div_id).css('display','none');
	}

	function test(event)
	{
        if(event.keyCode == 27)
        	alert("Esc pressed");
	}
	/*################################################################
	########################  Big PopUp  #############################
	################################################################*/
	
function sendDataToSWF(movieName, dataObj) {
 	//check that movieName is not empty and that dataObj is object
     	if(movieName!='' && typeof dataObj=='object') {
     		
	     	var movieObj; //prepare Variable for SWF object
	     	
	     	//assign SWF element to object variable "movieObj"
				if (navigator.appName.indexOf("Microsoft") != -1) {
					movieObj = window[movieName];
				} else {
					movieObj = document[movieName];
				}
				
			//Exit if SWF element was not found
				if(!movieObj) return false;
				
			//Call function inside SWF and pass dataObj
 				movieObj.sendDataToActionScript(dataObj);
				
     	} else {
     		return false;
     	}
}
//Quotes Refresh //////////////////////////
function quote_rates_refresh(pair_ID,defaultDomain,show_bid_ask) 
{
	$.ajax({
		url: "http://"+defaultDomain+"/common/ajax_quotes.php",
		type: "POST",
		data: "action=refresh_pair_data&pair="+pair_ID,
		dataType: ($.browser.msie) ? "text" : "text",
		success: function(data){
			window.trycount = 0;
			
			var JSONobject = JSON.parse(data);

			if(JSONobject.authorized && JSONobject.authorized=='true') {
				
			//get last value of "Last"
			if(document.getElementById('last_last')) var last_value = document.getElementById('last_last').innerHTML;
			else var last_value = 0;
			
			//get last value of "Change" in percent
			//CHANGE_VALUE - percent
			if(document.getElementById('last_change')) {
				var change_value = document.getElementById('last_change').innerHTML;
				change_value = change_value.substr(-1);
			} else var change_value = '0.00';
			
			//get last value of "Change"
			//CHANGE_VALUE - normal
			if(document.getElementById('last_change_normal')) {
				var change_value_normal = document.getElementById('last_change_normal').innerHTML;
				change_value_normal = change_value_normal.substr(-1);
			} else var change_value_normal = '0.00';
			
			if(show_bid_ask==true) {
				var bid = JSONobject.bid;
				var ask = JSONobject.ask;
			}
			var open 				= JSONobject.open;
			var last 				= JSONobject.last;
			var low  				= JSONobject.low;
			var high 				= JSONobject.high;
			var change 				= JSONobject.change;
			var change_percent 		= JSONobject.change_percent;
			var last_close_value 	= JSONobject.last_close_value;
			var last_step_direction = JSONobject.last_step_direction;
			var datetime 			= JSONobject.datetime;
			var timestamp			= JSONobject.timestamp;

			//change color of "Last" accordingly to value of "last_value"		
//			if(last<last_value) {
//				var color = 'red';
//				var arrow = 'actual_arrow_down';
//			} else if(last>last_value) {
//				var color = 'green';
//				var arrow = 'actual_arrow_up';
//			} else {
//				if(document.getElementById('last_last')) var color = document.getElementById('last_last').style.color;
//				else var color = 'green';
//				var arrow = document.getElementById('actual_arrow_image').className;
//			}
			if(last_step_direction=='Down') {
				var color = 'red';
				var arrow = 'actual_arrow_down';
			} else if(last_step_direction=='Up') {
				var color = 'green';
				var arrow = 'actual_arrow_up';
			} else {
				if(document.getElementById('last_last')) var color = document.getElementById('last_last').style.color;
				else var color = 'green';
				var arrow = document.getElementById('actual_arrow_image').className;
			}

			//UPDATE CHART
			//Build Object that will be PUSHED to SWF			
				var dataObj= {
		     				 last: last,
			     			 change: change,
			     			 change_percent: change_percent,
			     			 high: high,
			     			 low: low,
			     			 last_step_direction: last_step_direction,
			     			 datetime: timestamp
			     		   };
			     		  
			//Push data to SWF
			     sendDataToSWF('LiveChart', dataObj);
			//UPDATE CHART
			
			var change_prefix = '';
			//change color of "CHange" accordingly to value of "change_value"
			if(change_percent==change_value) {
				var change_color = '#000';
			} else {
				//alert(change);
				if(change_percent<0) {
					var change_color = 'red';
					//change_prefix = '-';
				} else if(change_percent>0) {
					var change_color = 'green';
					change_prefix = '+';
				}
			}
			
			if($('#currency_last').html()=='') 
			{
				if(last_step_direction == 'Up') 
				{
					color = 'green';
					arrow = 'actual_arrow_up';
				} else if(last_step_direction == 'Down') 
				{
					color = 'red';
					arrow = 'actual_arrow_down';
				}
			}
			
			if ( last == '' || change == '' || change_percent == '' || high == '' || low == '' || last_close_value == '' || open == '' || ((bid == '' || ask == '') && (show_bid_ask==true)) || datetime == '' )
			{
				// do nothing
			}
			else
			{
				$('#currency_last').html('<span id="last_last" class="arial_24" style="font-weight: bold;">'+last+'</span>');
				$('#last_change_normal').html('<span style="color:'+change_color+';" id="last_change_normal">'+change_prefix+change+'</span>');
				$('#last_change').html('<span style="color:'+change_color+';" id="last_change">('+change_prefix+change_percent+'%)</span>');
				
				$('#currency_high').html(high);
				$('#currency_low').html(low);
				$('#currency_prev').html(last_close_value);
				$('#currency_open').html(open);
				if(show_bid_ask==true) {
					$('#currency_bid').html(bid);
					$('#currency_ask').html(ask);
				}
				$('#currency_time').html(datetime);
				document.getElementById('actual_arrow_image').className = arrow;
				
			}
		}
		},
		error:
			function(XMLHttpRequest, textStatus, errorThrown)
			{
				if ( window.trycount < 2 ) {
					window.trycount++;
					quote_rates_refresh(pair_ID,defaultDomain,show_bid_ask);
				} else if ( trycount == 2) {
					
				}
			}
		
	});
	
}
// End Quotes Refresh //////////////////////////