var time1;
var newsLoadding;
$( function() {
	// news ,event ,video
	var bgValue = $(".news_event_video .top").find("input").eq(0).val();//获取背景图片地址
	var isEn = $(".news_event_video .top").find("input").eq(1).val();//判断是否是英文（0 CHN 1 EN）
	$(".news_event_video .top").eq(0).css("background", bgValue);
	var bgTemp = "";
	if(bgValue != null && bgValue != ""){
		bgTemp = bgValue.substring(0, bgValue.lastIndexOf("/"));
	}
	newsLoadding = $(".subwindow .article_content").eq(0).html();
	
	var content = $(".news_event_video .content").eq(0);
	var contentFooter =  $(".news_event_video").eq(0).find(".footer").eq(0);
	var more = $(".news_event_video .top .more").eq(0);
	//setMoreOver();

	
	$(".news_event_video .top .title .new").click(//new 单击事件
			function() {
				if(isEn == "1"){
					$(".news_event_video .top").find("input").val(
						bgTemp + "/news_event_videoEn_bg.gif) no-repeat");
					$(this).parent().parent().css("background",
						bgTemp + "/news_event_videoEn_bg.gif) no-repeat");
				}else{
					$(".news_event_video .top").find("input").val(
							bgTemp + "/news_event_video_bg.gif) no-repeat");
					$(this).parent().parent().css("background",
							bgTemp + "/news_event_video_bg.gif) no-repeat");
				}
				content.css("border", "1px #498C6E solid");
				content.css("border-bottom", "none");
				contentFooter.css("background", bgTemp
						+ "/news_footer_bg.gif) repeat-x");
				if(isEn == "1"){
					//more.html("<div><a href='/newsDetail_1_1.htm'><b><img class='nav_img' border='0' src='template/semicon/images/moreEn.gif'/></b></a></div>");
				}else{
					//more.html("<div><a href='/newsDetail_1_1.htm'><b><img class='nav_img' border='0' src='template/semicon/images/more.gif'/></b></a></div>");
				}
				//setMoreOver();
				$(".news_event_video .content .articles").eq(0).html(newsLoadding);
				$.ajax({type:"post",
		            	  url:"eventlist_1.htm",
		            	  cache:false,
		            	  dataType:"html",
		            	  success:function(data){$(".news_event_video .content .articles").eq(0).html(data);}
		        }); 
			});
	$(".news_event_video .top .title .title_theme").click(//new 单击事件
			function() {
				if(isEn == "1"){
					$(".news_event_video .top").find("input").val(
						bgTemp + "/theme_news_event_videoEn_bg.gif) no-repeat");
					$(this).parent().parent().css("background",
						bgTemp + "/theme_news_event_videoEn_bg.gif) no-repeat");
				}else{
					$(".news_event_video .top").find("input").val(
							bgTemp + "/theme_news_event_video_bg.gif) no-repeat");
					$(this).parent().parent().css("background",
							bgTemp + "/theme_news_event_video_bg.gif) no-repeat");
				}
				content.css("border", "1px #395DA5 solid");
				content.css("border-bottom", "none");
				contentFooter.css("background", bgTemp
						+ "/theme_footer_bg.gif) repeat-x");
				if(isEn == "1"){
					//more.html("<div><a href='/newsDetail_4_1.htm'><b><img class='nav_img' border='0' src='template/semicon/images/thememoreEn.gif'/></b></a></div>");
				}else{
					//more.html("<div><a href='/newsDetail_4_1.htm'><b><img class='nav_img' border='0' src='template/semicon/images/thememore.gif'/></b></a></div>");
				}
				$(".news_event_video .content .articles").eq(0).html(newsLoadding);
				//setMoreOver();
				$.ajax({type:"post",
	            	  url:"eventlist_4.htm",
	            	  cache:false,
	            	  dataType:"html",
	            	  success:function(data){$(".news_event_video .content .articles").eq(0).html(data);}
	        }); 
				
			});
	$(".news_event_video .top .title .event").click(//event 单击时间
			function() {
				if(isEn == "1"){
					$(".news_event_video .top").find("input").val(
						bgTemp + "/event_news_videoEn.gif) no-repeat");
					$(this).parent().parent().css("background",
						bgTemp + "/event_news_videoEn.gif) no-repeat");
				}else{
					$(".news_event_video .top").find("input").val(
							bgTemp + "/event_news_video.gif) no-repeat");
					$(this).parent().parent().css("background",
							bgTemp + "/event_news_video.gif) no-repeat");
				}
				content.css("border", "1px #A24C59 solid");
				content.css("border-bottom", "none");
				contentFooter.css("background", bgTemp
						+ "/events_footer_bg.gif) repeat-x");
				if(isEn=="1"){
					//more.html("<div><a href='/newsDetail_2_1.htm'><b> <img class='nav_img' border='0' src='template/semicon/images/more_eventEn.gif'/></b></a></div>");
				}else{
					//more.html("<div><a href='/newsDetail_2_1.htm'><b> <img class='nav_img' border='0' src='template/semicon/images/more_event.gif'/></b></a></div>");
				}
				$(".news_event_video .content .articles").eq(0).html(newsLoadding);
				$.ajax({type:"post",
	            	  url:"eventlist_2.htm",
	            	  cache:false,
	            	  dataType:"html",
	            	  success:function(data){
						$(".news_event_video .content .articles").eq(0).html(data);
						if(data){
							init();
							}
						}
				}); 
			});
	$(".news_event_video .top .title .video").click(//video 单击时间
			function() {
				if(isEn == "1"){
					$(".news_event_video .top").find("input").val(
						bgTemp + "/video_news_evnetEn_bg.gif) no-repeat");
					$(this).parent().parent().css("background",
						bgTemp + "/video_news_evnetEn_bg.gif) no-repeat");
				}else{
					$(".news_event_video .top").find("input").val(
							bgTemp + "/video_news_evnet_bg.gif) no-repeat");
					$(this).parent().parent().css("background",
							bgTemp + "/video_news_evnet_bg.gif) no-repeat");
				}
				content.css("border", "1px #6B6B6B solid");
				content.css("border-bottom", "none");
				contentFooter.css("background", bgTemp
						+ "/videos_footer_bg.gif) repeat-x");
				//more.html("");
				$(".news_event_video .content .articles").eq(0).html(newsLoadding);
				$.ajax({type:"post",
	            	  url:"eventlist_3.htm",
	            	  cache:false,
	            	  dataType:"html",
	            	  success:function(data){$(".news_event_video .content .articles").eq(0).html(data);}
	        }); 
			});

	
});
$(window).scroll(function(){
	var win = $(".subwindow").eq(0);
	var h = $(window).scrollTop()+(($(window).height() - parseInt(win.css("height")))/2);
	var w = $(window).scrollLeft()+(($(window).width() - parseInt(win.css("width")))/2);
	win.css("top", h);
	win.css("left", w);
	win.css("z-index", 9999);
});
//
function setMoreOver(){
	$(".news_event_video .more .nav_img").mouseover(function(){
		 //alert(123);
		 var srcTemp = $(this).attr("src");
		 srcTemp = srcTemp.substring(0,srcTemp.lastIndexOf("."));
		 $(this).attr("src",srcTemp+"_over.gif");
	});

	$(".news_event_video .more .nav_img").mouseout(function(){
		 var srcTemp = $(this).attr("src");
		 srcTemp = srcTemp.substring(0,srcTemp.lastIndexOf("_"));
		 $(this).attr("src",srcTemp+".gif");
	});
}

// JavaScript Document
function changePic(flag) {
	var array = $("#pic_array").val().toString().split(",");
	var tempIndex = $("#temp_index").val();
	
	var pic = $(".middle .banner_index .big_pic").find(".pic").find("img")
			.eq(0);
	if (flag) {
		tempIndex++;
		$("#previous_bg").show();
		if (tempIndex == array.length - 1) {
			$("#nest_bg").hide();
		}
	} else {
		tempIndex--;
		$("#nest_bg").show();
		if (tempIndex == 0) {
			$("#previous_bg").hide();
		}
	}
	$("#temp_index").val(tempIndex);
	var picSrc = pic.attr("src");
	pic.hide();
	pic.attr("src", picSrc.substring(0, picSrc.lastIndexOf("/")) + "/"
			+ array[tempIndex]);
	pic.show("fast");

}
/**
 * 关闭弹出框
 * 
 * @return
 */
function colosWin() {
	$(".subwindow").eq(0).hide();
	$(".win_shadow").eq(0).hide();
}


/**
 * 显示文章
 * 
 * @param url
 * @return
 */
function showArticleConent(url) {
	if(url.indexOf("http:")>=0){
		window.open(url);
		return;
	}
	var shadow = $(".win_shadow").eq(0);
	shadow.css("height", $(document).height() + "px");
	shadow.css("width", $(window).width() + "px");
	shadow.css("top", 0);
	shadow.css("left", 0);
	shadow.css("z-index", 8888);
	shadow.show();
	var win = $(".subwindow").eq(0);
	var h = $(window).scrollTop()+(($(window).height() - parseInt(win.css("height")))/2);
	var w = $(window).scrollLeft()+(($(window).width() - parseInt(win.css("width")))/2);
	win.css("top", h);
	win.css("left", w);
	win.css("z-index", 9999);
	$(".subwindow .article_content").eq(0).html(newsLoadding);
	win.show(500);
	//time1 = setInterval(function(){autoGo(win,692);},10);
	$.ajax({type:"post",
    	  url:url+'_0',
    	  cache:false,
    	  dataType:"html",
    	  success:function(data){$(".subwindow .article_content").eq(0).html(data);}
	}); 
}

/**
 * 
 * @return
 */
function autoGo(obj,wid){
	var w =  obj.css("width");
	w=w.substring(0,w.indexOf("p"));
	if(w>=wid){
		clearInterval(time1);
	}else{
		w = parseInt(w)+12;
		obj.css("width",w+"px");
		var h = ($(window).height() - parseInt(obj.css("height"))) / 2;
		var w = ($(window).width() - parseInt(obj.css("width"))) / 2;
		obj.css("top", h);
		obj.css("left", w);
	}
}
