$(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('\u60a8\u4f7f\u7528\u7684\u6d4f\u89c8\u5668\u6682\u4e0d\u652f\u6301\u8be5\u529f\u80fd\uff0c\u8bf7\u624b\u52a8\u8bbe\u7f6e');
		} 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', '\u4e2d\u94dd\u7f51');
		} else if (window.sidebar){ 
			window.sidebar.addPanel('\u4e2d\u94dd\u7f51', 'http://www.cnal.com', ""); 
		} else { 
		   alert('\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u901a\u8fc7\u5feb\u6377\u952e' + ctrl + '+ D \u52a0\u5165\u5230\u6536\u85cf\u5939~'); 
		}
	});
	$('#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");
	}
}
