$(document).ready(function() {
	$('.language').bind('click', function(){
		$('#mnu').slideToggle(300);
	}).bind('mouseleave', function(){
		$('#mnu').slideUp(300);
	});	
	
	$('#cots').bind('click', function(){
		$('._cots').removeClass('dn');
		$('.bottom a').removeClass('active');
		$(this).addClass('active');
		$('.under .mid:not(._cots)').addClass('dn');
	});
	$('#analytics').bind('click', function(){
		$('._analytics').removeClass('dn');
		$('.bottom a').removeClass('active');
		$(this).addClass('active');
		$('.under .mid:not(._analytics)').addClass('dn');
	});
	$('#fnews').bind('click', function(){
		$('._fnews').removeClass('dn');
		$('.bottom a').removeClass('active');
		$(this).addClass('active');
		$('.under .mid:not(._fnews)').addClass('dn');
	});
	$('#cnews').bind('click', function(){
		$('._cnews').removeClass('dn');
		$('.bottom a').removeClass('active');
		$(this).addClass('active');
		$('.under .mid:not(._cnews)').addClass('dn');
	});
	
	$('._toggle').hover(function() {
		$(this).find('.text').animate({
			height: 'toggle'
		}, 300)
	}, function(){	
		$(this).find('.text').animate({
			height: 'toggle'
		}, 200)
	});
	
	$('.miniico .favor').bind('click', function(){
		bookmark(this);
	});
	
	if(!navigator.cookieEnabled)
	{
		alert('Your cookie disabled. Please, switch on cookie for correct operations of a site');	
	}
	
	loadQuotes();
	
});

function loadQuotes()
{
	$.ajax({
		type: 'POST',
		url: 'http://forexhunt.org/en/ajaxquotes',
		success: function(data){
			$('._cots').html('');
			$('._cots').html(data);
			setTimeout('loadQuotes()' , 30000);
		},
		error: function (){
			$('._cots').html('<center><img src="/images/loader_round.gif" style="margin: 70px auto"></center>');
			setTimeout('loadQuotes()' , 1000);
		}			
	});	
}

function redirecting_main()
{
	window.location = 'http://forexhunt.org';
}

function get_browser_info()
{
	var t,v = undefined;
	
	if (window.opera)
	{
		t = 'Opera';
	}
	else if (document.all)
	{
		t = 'IE';
		var nv = navigator.appVersion;
		var s = nv.indexOf('MSIE') + 5;
		v = nv.substring(s,s+1);
	}
	else if (navigator.appName)
	{
		t = 'Netscape';
	}
	return {type:t,version:v};
}

function bookmark(a)
{
	var url = window.document.location;
	var title = window.document.title;
	var b = get_browser_info();
	if (b.type == 'IE' && 7 > b.version && b.version >= 4)
	{
		window.external.AddFavorite(url,title);
	}
	else if (b.type == 'Opera')
	{
		a.href = url;
		a.rel = "sidebar";
		a.title = url+','+title;
	
		return true;
	}
	else if (b.type == "Netscape")
	{
		window.sidebar.addPanel(title,url,"");
	}
	else
	{ 
		alert("Could not define your browser. Press CTRL-D for add to favorites");
	}
	
	return false;
}