﻿// JavaScript Document
$(function (){		
	$(".nav li:last").css("background","none");
	$(".btomcss li:last").css("background","none");	
	$(".lmlist .top_navi").eq(7).css("background","none");
	$(".lmlist .top_navi:last").hide();
	$(".m1_l .news li:lt(3)").addClass("paddingleft");	
	$(".catelist li span").unwrap();
	$(".catelist ul").hide();
	$(".catelist > li").click(
			function(){
				$(this).next("ul").slideDown();
				$(this).siblings().next("ul").slideUp();
				$(this).addClass("thisclass").siblings().removeClass("thisclass");
			});
	//图片延迟加载
	$("div.content").children("img:visible").lazyload({ 
		placeholder : "/Templets/style/loading.gif",   
		effect : "fadeIn" 
	}); 
	var fontcontentsize=$(".c_info font")
	fontcontentsize.eq(0).click(function(){
		$(".c_content *").css("font-size","12px")
		});
	fontcontentsize.eq(1).click(function(){
		$(".c_content *").css("font-size","14px")
		});
	fontcontentsize.eq(2).click(function(){
		$(".c_content *").css("font-size","16px")
		});	
	$("#videoa a:last").click(function(){
		$("#online_wmv").fadeIn();
		})
	setheight();
	$(window).scroll(function(){setheight()});
	$(".cycssli").mouseover(function(){
		$(this).next(".liDiv").fadeIn();
		$(this).siblings().next(".liDiv").hide();
		});
	$(".liDiv:first").show();
	$(".content img").each(function(){
		var imgwidth=$(this).width();
		if(imgwidth>600){$(this).width(600);}
		})
	var year = new Date().getFullYear() ;
	var month = (new Date().getMonth()+1) ;
	var date = new Date().getDate() ;
	var thistime=year+'-'+month+'-'+date	
	$(".newslist .news").each(function(){	
		var newstime=$(this).children(".datetime").html();
		var setime=daysBetween(newstime,thistime);	
		if(setime<5){$(this).children(".datetime").html("<img src='/files/thisnews.gif'>").show()}
		else{$(this).children(".datetime").html("")}	
	})
	$(".listli").each(function(){
		$(this).children("li").each(function(){
			var newstime=$(this).children(".datetime").html();
			var setime=daysBetween(newstime,thistime);	
			if(setime<5){$(this).children(".datetime").html("<img src='/files/thisnews.gif'>").show()}
			else{$(this).children(".datetime").html("")}
			})
		});
	$(".listgscss .gfcss").each(function(i){
		$(this).click(function(){
			$(".listgscss .thiscss img").eq(i).fadeIn();
			$(".listgscss .thiscss img").eq(i).siblings().hide();
			})
		})
	$(".listgscss .thiscss img").eq(0).show();	
});

function daysBetween(DateOne,DateTwo) 
{  	
    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-')); 
    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1); 
    var OneYear = DateOne.substring(0,DateOne.indexOf ('-')); 

    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-')); 
    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1); 
    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-')); 

    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);   
    return Math.abs(cha); 
	
}

function setheight(){
	var leftheight=$(".left").height();
	var rightheight=$(".right").height();
	if(rightheight>leftheight){$(".left").height(rightheight);}	
	}
	
	
function addCookie(){　 // 加入收藏夹   
    if (document.all){   
        window.external.addFavorite('http://5.demo1.cn', '北京中彩印制有限公司');   
    }else if (window.sidebar){   
       window.sidebar.addPanel('北京中彩印制有限公司', 'http://5.demo1.cn', "");   
    }   
}   
  
function setHomepage(){　 // 设置首页   
    if (document.all){   
       document.body.style.behavior = 'url(#default#homepage)';   
        document.body.setHomePage('http://5.demo1.cn');   
   }else if (window.sidebar){   
        if (window.netscape){   
            try {   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
            }catch (e) {   
               alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");   
           }   
        }   
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);   
        prefs.setCharPref('browser.startup.homepage', 'http://5.demo1.cn');   
    }   
}
		


