// JavaScript Document
function DateDiff(sDate1, sDate2){  //sDate1和sDate2是2002-12-18格式
        var aDate, oDate1, oDate2, iDays;
        aDate = sDate1.split("-");
        oDate1 = new Date(aDate[1] + '/' + aDate[2] + '/' + aDate[0]);  //转换为12-18-2002格式
        aDate = sDate2.split("-");
        oDate2 = new Date(aDate[1] + '/' + aDate[2] + '/' + aDate[0]);
        iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24);  //把相差的毫秒数转换为天数
        return iDays;
}


$(document).ready(function(){
	
	var browser=navigator.appName;
	var b_version=navigator.appVersion; 
	var version=b_version.split(";"); 
	var trim_Version=version[1].replace(/[ ]/g,""); 
		
	
	$("#news_detail_content > #img_list > div").click(function(){
		
		$(".white_content_lend").css("display","block");
		$(".black_overlay").css("display","block");
		var shadow_height=$("body").height();
		$("#fade1").css("height",shadow_height);
		//var img_number=$("#news_detail_content > div > img").length;	
		var img_order=$("#news_detail_content > #img_list > div").index(this);
		$(".news_pop_img").html($("#news_detail_content > #img_list > div:eq(" + img_order + ")").html());
		$(".news_pop_content").html($("#news_detail_content  > #img_list > span:eq(" + img_order + ")").html());
		
		var screen_width=$("body").width();
		var img_number_width=$(".news_pop_img > img").width();
		var img_number_height=$(".news_pop_img > img").height();
		
		$("#light2").css("left",(screen_width - img_number_width )/2);
		$("#light2").css("width",(img_number_width + 34) + "px");
		if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") {
			$("#light2").css("width",(img_number_width + 44) + "px");
		}
		$("#light2").css("height",(img_number_height + 130) + "px");
		$("#close_layor").css("margin-left",(img_number_width + 15) + "px");
		$(".news_pop_content").css("width",img_number_width);
		//$("#light2").addClass();
		document.documentElement.scrollTop=0;
		
	});//image click end
	
	$("#close_layor").click(function(){
		$(".white_content_lend").css("display","none");
		$(".black_overlay").css("display","none");
	});

//news_sort
	
	document.getElementById("selectCity_top").selectedIndex=0;
	document.getElementById("selectCity_bottom").selectedIndex=0;

	
	//var news_content=$(".news_title").text();
	//alert(news_content);
	
	var sort_flag="0";	
	$("#ppxw,.ppxw").click(function(){
				sort_flag="1";
				document.getElementById("selectCity_top").selectedIndex=0;
				document.getElementById("selectCity_bottom").selectedIndex=0;
				if($(".sub_menu li a").hasClass("current")){
					$(".sub_menu li a").removeClass("current");
				}
				$(".BorderBottomTitle").css("width","55px");
				$(".BorderBottomTitle").html("品牌新闻");
				
				$("#ppxw >a").addClass("current");
				//$("#column_bottom > .news_list").css("display","inline");
				if($("#column_bottom > .news_list").hasClass("sort_news")){
					$("#column_bottom > .news_list").removeClass("sort_news");
				}
				
				var news_length=$("#column_bottom > .news_list").length;
				var sort_tag=new Array(news_length);
				for(i=0;i < news_length;i++){
					sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
					if(sort_tag[i]!=1){
						//$("#column_bottom > .news_list:eq("+i+")").css("display","none");sort_news
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
					}
				}
				$("#column_top").height($("#column_bottom").height()+20+"px");
				/*
					if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
				{ 
					$("#column_top").height($("#column_bottom").height()+60+"px"); 
				} 
				else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
				{ 
					$("#column_bottom").css("margin-top",(-$("#column_top").height()-20)+"px");
					//$("#locationBar").css("margin-left",5+"px");
					if($("#column_bottom").height()<180){
						$("#column_bottom").css("margin-top",(-$("#column_top").height()+174)+"px");
						//$("#locationBar").css("margin-left",5+"px");
					}
				} 
				*/
	});
	$("#cpfb,.cpfb").click(function(){
				sort_flag="2";
				document.getElementById("selectCity_top").selectedIndex=0;
				document.getElementById("selectCity_bottom").selectedIndex=0;
				if($(".sub_menu li a").hasClass("current")){
					$(".sub_menu li a").removeClass("current");
				}
				$(".BorderBottomTitle").css("width","65px");
				$(".BorderBottomTitle").html("产品发布会");
				$("#cpfb >a").addClass("current");
						
				//$("#column_bottom > .news_list").css("display","inline");
				if($("#column_bottom > .news_list").hasClass("sort_news")){
					$("#column_bottom > .news_list").removeClass("sort_news");
				}
				var news_length=$("#column_bottom > .news_list").length;
				var sort_tag=new Array(news_length);
				for(i=0;i < news_length;i++){
					sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
					if(sort_tag[i]!=2){
						//$("#column_bottom > .news_list:eq("+i+")").css("display","none");
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
					}
				}
				$("#column_top").height($("#column_bottom").height()+20+"px");
				/*
				if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
				{ 
					$("#column_top").height($("#column_bottom").height()+60+"px"); 
				} 
				else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
				{ 
					$("#column_bottom").css("margin-top",(-$("#column_top").height()-20)+"px");
					//$("#locationBar").css("margin-left",5+"px");
					if($("#column_bottom").height()<180){
						$("#column_bottom").css("margin-top",(-$("#column_top").height()+174)+"px");
						//$("#locationBar").css("margin-left",5+"px");
					}
				} 
				*/
	});
	$("#djxw,.djxw").click(function(){
				sort_flag="3";
				document.getElementById("selectCity_top").selectedIndex=0;
				document.getElementById("selectCity_bottom").selectedIndex=0;
				if($(".sub_menu li a").hasClass("current")){
					$(".sub_menu li a").removeClass("current");
				}
				$(".BorderBottomTitle").css("width","55px");
				$(".BorderBottomTitle").html("杜鹃新闻");
				$("#djxw >a").addClass("current");
				
				//$("#column_bottom > .news_list").css("display","inline");
				if($("#column_bottom > .news_list").hasClass("sort_news")){
					$("#column_bottom > .news_list").removeClass("sort_news");
				}
				var news_length=$("#column_bottom > .news_list").length;
				var sort_tag=new Array(news_length);
				for(i=0;i < news_length;i++){
					sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
					if(sort_tag[i]!=3){
						//$("#column_bottom > .news_list:eq("+i+")").css("display","none");
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
					}
				}
				$("#column_top").height($("#column_bottom").height()+20+"px");
				/*
				if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
				{ 
					$("#column_top").height($("#column_bottom").height()+60+"px"); 
				} 
				else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
				{ 
					$("#column_bottom").css("margin-top",(-$("#column_top").height()-20)+"px");
					//$("#locationBar").css("margin-left",5+"px");
					if($("#column_bottom").height()<180){
						$("#column_bottom").css("margin-top",(-$("#column_top").height()+174)+"px");
						//$("#locationBar").css("margin-left",5+"px");
					}
				} 
				*/
	});
	$("#gyhd,.gyhd").click(function(){
				sort_flag="4";
				document.getElementById("selectCity_top").selectedIndex=0;
				document.getElementById("selectCity_bottom").selectedIndex=0;
				if($(".sub_menu li a").hasClass("current")){
					$(".sub_menu li a").removeClass("current");
				}
				$(".BorderBottomTitle").css("width","55px");
				$(".BorderBottomTitle").html("公益活动");
				$("#gyhd >a").addClass("current");		
				//$("#column_bottom > .news_list").css("display","inline");
				if($("#column_bottom > .news_list").hasClass("sort_news")){
					$("#column_bottom > .news_list").removeClass("sort_news");
				}
				var news_length=$("#column_bottom > .news_list").length;
				var sort_tag=new Array(news_length);
				for(i=0;i < news_length;i++){
					sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
					if(sort_tag[i]!=4){
						//$("#column_bottom > .news_list:eq("+i+")").css("display","none");
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
					}
				}
				$("#column_top").height($("#column_bottom").height()+20+"px");
				/*
				if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
				{ 
					$("#column_top").height($("#column_bottom").height()+60+"px"); 
				} 
				else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
				{ 
					$("#column_bottom").css("margin-top",(-$("#column_top").height()-20)+"px");
					//$("#locationBar").css("margin-left",5+"px");
					if($("#column_bottom").height()<180){
						$("#column_bottom").css("margin-top",(-$("#column_top").height()+174)+"px");
						//$("#locationBar").css("margin-left",5+"px");
					}
				} 
				*/
	});
//news sort
	$("#selectCity_top").change(function(){
		var selectId=document.getElementById("selectCity_top").selectedIndex;
		document.getElementById("selectCity_bottom").selectedIndex=selectId;
		var now  =  new Date();
		var  yy  =  now.getFullYear();
		var  mm  =  now.getMonth();
		var  dd  =  now.getDay();
		var now_time= yy + "-" + mm + "-" + dd;
		var news_length=$("#column_bottom > .news_list").length;
		
		var news_array=new Array(news_length);
		var sort_tag=new Array(news_length);
		//if(sort_flag=="0"){
		//$("#column_bottom > .news_list").css("display","inline");
		if($("#column_bottom > .news_list").hasClass("sort_news")){
					$("#column_bottom > .news_list").removeClass("sort_news");
				}
		if(sort_flag=="1"){
			for(i=0;i < news_length;i++){
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(news_array[i]!=1){
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}
		if(sort_flag=="2"){
			for(i=0;i < news_length;i++){
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(news_array[i]!=2){
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}
		if(sort_flag=="3"){
			for(i=0;i < news_length;i++){
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(news_array[i]!=3){
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}
		if(sort_flag=="4"){
			for(i=0;i < news_length;i++){
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(news_array[i]!=4){
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}
	    if(selectId==0){
			for(i=0;i < news_length;i++){
				sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > a  > .news_time").html();
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(DateDiff(now_time,sort_tag[i]) < 0 ){
					$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
			
		}
		if(selectId==1){
			for(i=0;i < news_length;i++){
				sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > a > .news_time").html();
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				//alert(news_array[i]!=sort_flag);
				
				if(DateDiff(now_time,sort_tag[i]) > 91 || sort_tag[i]=="" ){
					$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
			
		}
		if(selectId==2){
			for(i=0;i < news_length;i++){
				sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > a >  .news_time").html();
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				//alert(news_array[i]!=sort_flag);
				
				if(DateDiff(now_time,sort_tag[i]) > 181 || sort_tag[i]=="" ){
					$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
			
		}
		
		if(selectId==3){
			for(i=0;i < news_length;i++){
				sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > a  >  .news_time").html();
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				//alert(news_array[i]!=sort_flag);
				
				if(DateDiff(now_time,sort_tag[i]) > 366 || sort_tag[i]=="" ){
					$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}//left menu not select
		$("#column_top").height($("#column_bottom").height()+20+"px");
		/*
		if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
		{ 
			$("#column_top").height($("#column_bottom").height()+60+"px"); 
		} 
		else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
		{ 
			$("#column_bottom").css("margin-top",(-$("#column_top").height()-20)+"px");
			if($("#column_bottom").height()<180){
						$("#column_bottom").css("margin-top",(-$("#column_top").height()+174)+"px");
			}
		} 
		*/
});
////////////////////////////////	
	$("#selectCity_bottom").change(function(){
		var selectId=document.getElementById("selectCity_bottom").selectedIndex;
		document.getElementById("selectCity_top").selectedIndex=selectId;
		var now  =  new Date();
		var  yy  =  now.getFullYear();
		var  mm  =  now.getMonth();
		var  dd  =  now.getDay();
		var now_time= yy + "-" + mm + "-" + dd;
		var news_length=$("#column_bottom > .news_list").length;
		var news_array=new Array(news_length);
		var sort_tag=new Array(news_length);
		if($("#column_bottom > .news_list").hasClass("sort_news")){
					$("#column_bottom > .news_list").removeClass("sort_news");
				}
		if(sort_flag=="1"){
			for(i=0;i < news_length;i++){
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(news_array[i]!=1){
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}
		if(sort_flag=="2"){
			for(i=0;i < news_length;i++){
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(news_array[i]!=2){
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}
		if(sort_flag=="3"){
			for(i=0;i < news_length;i++){
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(news_array[i]!=3){
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}
		if(sort_flag=="4"){
			for(i=0;i < news_length;i++){
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(news_array[i]!=4){
						$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}
	    if(selectId==0){
			for(i=0;i < news_length;i++){
				sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > a  > .news_time").html();
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				if(DateDiff(now_time,sort_tag[i]) < 0 ){
					$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
			
		}
		if(selectId==1){
			for(i=0;i < news_length;i++){
				sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > a > .news_time").html();
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				//alert(news_array[i]!=sort_flag);
				
				if(DateDiff(now_time,sort_tag[i]) > 91 || sort_tag[i]=="" ){
					$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
			
		}
		if(selectId==2){
			for(i=0;i < news_length;i++){
				sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > a >  .news_time").html();
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				//alert(news_array[i]!=sort_flag);
				
				if(DateDiff(now_time,sort_tag[i]) > 181 || sort_tag[i]=="" ){
					$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
			
		}
		
		if(selectId==3){
			for(i=0;i < news_length;i++){
				sort_tag[i]=$("#column_bottom > .news_list:eq("+i+") > a  >  .news_time").html();
				news_array[i]=$("#column_bottom > .news_list:eq("+i+") > .news_list_sort").html();
				//alert(news_array[i]!=sort_flag);
				
				if(DateDiff(now_time,sort_tag[i]) > 366 || sort_tag[i]=="" ){
					$("#column_bottom > .news_list:eq("+i+")").addClass("sort_news");
				}
			}
		}//left menu not select
		$("#column_top").height($("#column_bottom").height()+20+"px");
		/*
		if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
		{ 
			$("#column_top").height($("#column_bottom").height()+60+"px"); 
		} 
		else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
		{ 
			$("#column_bottom").css("margin-top",(-$("#column_top").height()-20)+"px");
			if($("#column_bottom").height()<180){
						$("#column_bottom").css("margin-top",(-$("#column_top").height()+174)+"px");
			}
		} 
		*/
						 
});
		
/////////////////////////////////
	var right_height=$("#column_bottom").height();
	$("#column_top").css("height",right_height);

});