$(function () {
	$.post("/service/index.php", {'m' : 'Login', 'a' : 'common', 'isnew' : '1', 'from' : encodeURIComponent(window.location.href)}, function(data){
		$('#head .head-right span').html(data);
		$('#commonLogout').click(function () {
			$.post("/service/index.php", {'m' : 'Logout', 'a' : 'common'}, function(data){
				$('#runCommonScript').html(data);
			});
			return false;
		});
	});
	
	$('#commonLogout').click(function () {
		$.post("/service/index.php", {'m' : 'Logout', 'a' : 'common'}, function(data){
			$('#runCommonScript').html(data);
		});
		return false;
	});
	$('#t1').click(function () {
		if(window.netscape) {
			alert('您使用的浏览器暂不支持该功能，请手动设置');
		} else {
			this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.cnal.com');
		}
	});
	
	$.each(['t3', 't6', 't7'], function () {
		$('#' + this).mouseover(function () {
			$(this).find('a.popuplink').removeClass('popuplink_bg').addClass('popuplink_bgon');
			$(this).find('dl.popupmenu').css('display', 'block');
		}).mouseout(function () {
			$(this).find('a.popuplink').removeClass('popuplink_bgon').addClass('popuplink_bg');
			$(this).find('dl.popupmenu').css('display', 'none');
		});
	});
	
	$('#t2').click(function () {
		var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL'; 
		if (document.all){ 
			window.external.addFavorite('http://www.cnal.com','中铝网');
		} else if (window.sidebar){ 
			window.sidebar.addPanel('中铝网', 'http://www.cnal.com', ""); 
		} else { 
		   alert('您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~'); 
		}
	});
	$('#t8').mouseover(function () {
		$(this).attr('class', 'subli2');
		$('#menu1').show();
		
	}).mouseout(function () {
		$(this).attr('class', 'subli');
		$('#menu1').hide();
	});
	
	// weather
	if($('#search div.weather ul').length > 0){
		$.post("/service/?m=weather", function(data){
			$('#search div.weather ul').html(data);
		});
	}
	
	var channel = $('body > input[type=hidden][name=channel]').val();
	if(channel){
		$('form.searchform > input[name=c]').val(channel);
		$('form.searchform ul.searchnav li a').parents('li').attr('class', '');
		$('form.searchform ul.searchnav li a.' + channel).parents('li').attr('class', 's1');
	}
	
	$('form.searchform input[type=submit]').click(function () {
		
	});
});

var fltad1Close = function () {
	$("#hotmarket").css('display', 'none');
};
var setTab = function (name,cursel,n){
	for(i=1; i<=n; i++){
		$('#' + name + i).attr('class', i == cursel ? "hover" : "");
		$("#con_" + name + "_" + i).css('display', i == cursel ? "block" : "none");
	}
}