$(function() {
	
setInterval('updateTime()',1000);
/* ----- Main Menu ----- */
//$("#nav_main > ul > li").hover(function () { $('.current_page ul.nav_sub').hide();	$(this).find('ul.nav_sub').show(); }, function () { $(this).find('ul.nav_sub').hide(); $('.current_page ul.nav_sub').show(); });
//$("#nav_main > ul > li").click(function () { $('#nav_main > ul > li.current_page').removeClass(); $(this).addClass("current_page"); });
/* ----- Main Menu ----- */

$("#nav_main li").hover(function () 
{ 
	$('#nav_sub ul.current').hide();
	$($(this).find('a').attr('href')).show();	
}, function () 
{
	$($(this).find('a').attr('href')).hide();
	$('#nav_sub ul.current').show();
});

$("#nav_sub ul").hover(function () 
{ 
	$('#nav_sub ul.current').hide();	
	$(this).show();
	$('#nav_main li.current_page a').css('background-position','center -100%');
	$('#nav_main li').find("a[href='#"+ $(this).attr('id') +"']").addClass('hover');	
}, function () 
{
	$(this).hide();
	$('#nav_sub ul.current').show();
	$('#nav_main li.current_page a').css('background-position','center bottom');
	$('#nav_main li').find("a[href='#"+ $(this).attr('id') +"']").removeClass('hover');
});

$("#nav_main li").click(function () 
{ 
	$('#nav_main li.current_page').removeClass();
	$(this).addClass("current_page"); 

	$('#nav_sub ul.current').removeClass();
	$($(this).find('a').attr('href')).addClass("current"); 

	return false;
});



$("#sidebar .section .head").toggle(function () 
{
	var id = $(this).closest('.section').attr('id');
	var opt = location.href;
	opt = opt.substring(opt.indexOf("?")+1,opt.length);
	opt = opt + '&src=gadgets&sub=gadgets&sec='+id;
	
	$.ajax
	({
		url: 		'index.php?src=gadgets&sub=gadgets&sec='+id,
		data:		opt,
		cache:		false,
		success: 	function(data) 
		{
			var body = data.substring(data.indexOf("<div class = 'body'"),data.indexOf("<p class = 'foot'"));
			$('#'+id+' .body').replaceWith(body);
			$('#'+id+' .body').show('blind');
			
			if(data.indexOf('<script')!=-1)	eval(data.substring(data.indexOf("<script type = 'text/javascript'>")+33,data.indexOf("</script>")));
		}
	});

	//$(this).closest('.section').find(".body").show('blind');
}, function () 
{
	$(this).closest('.section').find(".body").hide('blind');	
});

$("#user_status").click(function ()
{
	$("#user_status p").hide();
	$("#user_status textarea").show();	
}); 

$("#user_status textarea").blur(function ()
{
	$("#user_status p").html($("#user_status textarea").val());
	$("#user_status textarea").hide();
	$("#user_status p").show();	
}); 

/*$("#user_status textarea").change(function ()
{
	cmdExec('info_upt&LID=100&Comments='+$("#user_status textarea").val(),null,null,null,null);
});*/

$("#load").bind("ajaxSend", function()
{
	$('body').css('cursor','wait'); 
	$(this).show();
}).bind("ajaxComplete", function()
{
	$('body').css('cursor','default');
	$(this).hide();
});

$("#sub_profile #profile").after("<span class = 'clearer'></span>");
$("#sub_profile #upcoming_contests").before("<span class = 'clearer'></span>");

});

/*var t = setInterval('ticker_init()',20);
$('#ltopic').hover(function () {clearInterval(t);}, function () {t=setInterval('ticker_init()',20);});

function ticker_init()
{
	var cpos = $('#ltopic').scrollLeft();	
	$('#ltopic').scrollLeft(cpos + 1);
	if($('#ltopic').scrollLeft() == cpos) $('#ltopic').scrollLeft(0);
}*/