﻿/*
@ Title: common.js
@ Explain: 09财经频道LayoutEffects
@ Update: 2009-11-27
@ Author: DevAnge.GuoCong
*/

$(function() {
	menu_effect();
	rollnews();
	$("#video ul li").hover(function(){$(this).css("background","#f1f7ff")},function(){$(this).css("background","none")})
});
function menu_effect() {
	$("#nav ul li:last-child").css({ "border-right": "0", "padding-right": "0", "margin-right": "0" }); 
	$("#nav li").each(function(n) {
		var menu_y = -71-(37*n);
		$(this).css("background-position", "-484px "+menu_y+"px");
	});
}
function layer_hide(layer) {
	$("#"+layer).animate({opacity:'hide'},400);
}
function layer_show(layer) {
	$("#"+layer).animate({opacity:'show'},400);
}
function rollnews() {
	var rheight = 20;
	var rnum = 5;
	var i = rnum+1;
	$("#rollnews2").html($("#rollnews1").html());
	$("#rollnews3").html($("#rollnews1").html());
	$("#rollnews4").html($("#rollnews1").html());
	for (j=1;j<=4;j++) { $("#rollnews"+j).css("top",(j-3)*(rheight*rnum)); }
	t = setInterval(rollup,3000);
	$("#rollnews").hover(function(){clearInterval(t);},function(){t=setInterval(rollup,3000);});
	$("#rollup").hover(function(){clearInterval(t);},function(){t=setInterval(rollup,3000);});
	$("#rolldown").hover(function(){clearInterval(t);},function(){t=setInterval(rollup,3000);});
	$("#rollup").click(rollup);
	$("#rolldown").click(rolldown);
	function rollup() {
		for (k=1;k<=4;k++) { $("#rollnews"+k).animate({top:"-="+rheight}, 500); }
		i+=1;
		if (i>=rnum*2) {
			setTimeout(function(){
				for (j=1;j<=4;j++) { $("#rollnews"+j).css("top",(j-3)*(rheight*rnum)+rheight); }
				i = rnum;
			},600);
		}
	}
	function rolldown() {
		for (k=1;k<=4;k++) { $("#rollnews"+k).animate({top:"+="+rheight}, 500); }
		i-=1;
		if (i<=1) {
			setTimeout(function(){
				for (j=1;j<=4;j++) { $("#rollnews"+j).css("top",(j-3)*(rheight*rnum)); }
				i = rnum+1;
			},600);
		}
	}
}


/*--投票--*/
var newWindow = null;
function openvotewindow(loadpos) {
	if (!newWindow || newWindow.closed) {
		newWindow = window.open(loadpos,'votewindow','resizable,dependent,width=400,height=600');
	} else {
		newWindow.focus();
	}
}
function view_result(subjectid) {
	var url = 'http://localhost/livcms3.0/jsqx/vote/vote.php?subjectid=' + subjectid;
	window.open(url,'votewindow','resizable,dependent,width=400,height=400');
}

