﻿// JScript 文件

function secondDown(start,end,loader)
{    
    $("#" + loader).text(start);
    start=start-1;    
    if(start>=end) setTimeout("secondDown(" + start + ","+ end +",\"" + loader + "\")",1000);
}

function show(showid)
{
    showqid = "#" + showid ;    
    coverqid = "#cover" + showid ;
    
    if($(coverqid).length<=0) $(showqid).after("<div id=\"cover" + showid + "\" />");
    
    $(coverqid).show();
    $(coverqid).css({"position":"absolute","left":"0", "top":"0","z-index":"100"});
    $(coverqid).css({"background-color":"#000","filter":"alpha(Opacity=40)","-moz-opacity":"0.4","opacity":"0.4"});    
    $(coverqid).height($(document).height() > $(window).height() ? $(document).height() : $(window).height());
    $(coverqid).width($(document).width() > $(window).width() ? $(document).width() : $(window).width());   
        
    $(showqid).show();             
    $(showqid).css({"position":"absolute","z-index":"200"});    
    $(showqid).css({"background-color":"#FFF"});        
    $(showqid).css("top",($(window).height()-$(showqid).height())/2);
    $(showqid).css("left",($(window).width()-$(showqid).width())/2);       
}

function hide(showid)
{       
    showqid = "#" + showid ;    
    coverqid = "#cover" + showid ;
    
    $(showqid).hide(); 
    $(coverqid).hide();
}

function tip(content,second,href)
{
    if($("#tip").length<=0) $("body").append("<div id=\"tip\">" + content + "</div>");
    
    show("tip");    
    
    if(typeof(second)!="number") setTimeout("hide(\"tip\")",3000);    
    else setTimeout("hide(\"tip\")",second);  
    
    if(typeof(href)!="undefined") setTimeout("window.location.href='" + href + "'" , second);    
}

function InitCarousel(adID,adTimer,Space)
{
	adID = adID == undefined ? "#ad" : "#"+adID;
	var adLen = $(adID+" .image > li").length; //判断AD有多少个
	var adIndex=0; //初始化AD
	var adSpeed=300; //轮播速度
	var adSpace=Space; //间隔时间
	//计时器
	$(adID+" .title > li").eq(adIndex).show().siblings().hide();
	$(adID+" .serial > li").eq(adIndex).addClass("selected").siblings().removeClass(); 

	//开始轮播
	$(adID).mouseleave(
		function(){		
			adTimer = setInterval(
				function(){ 												
					Carousel(adID,adIndex,adSpeed);
					adIndex++;
					if(adIndex>=adLen){ adIndex=0; } //重新从头开始轮播			  
				  } , adSpace);
        }
		).mouseleave();
	
   //结束轮播
	$(adID).mouseenter(function(){clearInterval(adTimer);}); 	
	
	//悬浮序号
	$(adID+" .serial > li").mouseover(
	  function(){
		  adIndex=$(adID+" .serial > li").index(this); //选中的序号
		  Carousel(adID,adIndex,adSpeed); //显示当前序号的AD
	  });
	
}
   
function Carousel(adID,index,speed)
{    
	//var adHeight=$("#ad").height();
	//$(".image").stop(true,false).animate({marginTop:-adHeight*index},speed); //up 
	//var adWidth=$("#ad").width();
	//$(".image").stop(true,false).animate({marginTop:-adWidth*index},speed); //left
	//$(adID+" .image > li").stop(true,true).eq(index).slideDown(speed).siblings().slideUp(speed); //飞入飞出效果
	$(adID+" .image li").stop(true,true).eq(index).fadeIn(speed*2).siblings().fadeOut(speed); //淡入淡出效果	
    $(adID+" .title > li").eq(index).show().siblings().hide();
    $(adID+" .serial > li").eq(index).addClass("selected").siblings().removeClass();   
}  

function addCookie(name,url) // 加入收藏
{　 
	if (document.all) 
	{
		window.external.addFavorite(url,name);
	}
	else if (window.sidebar) 
	{
		window.sidebar.addPanel(name,url,"");
	}
}　　　
　　　
function setHomepage(url)  // 设为首页
{　
	if (document.all) 
	{
		document.body.style.behavior = 'url(#default#homepage)';
		document.body.setHomePage(url);
	}
	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',url);
	}　
}




