/*!
 * Noker自己写的一些常用的效果 v20100424
 * 基于jQuery1.4.2
 */

/* 弹出窗口 */
function showbestrow(page,callback){
jQuery("<div id=\"showbestrow\" style=\"position:absolute;z-index:100;\"></div>").appendTo("body");
jQuery("<div id=\"bestrowcont\" style=\"position:absolute;z-index:101;\"></div>").insertAfter("#showbestrow");
jQuery("#showbestrow").css({left:"0",top:"0",background:"#000",filter:"alpha(opacity=30)","opacity":"0.3",width:jQuery(document).width(),height:jQuery(document).height()});
jQuery("select").css("visibility","hidden");
jQuery("#bestrowcont").load(page,function(){
var bleft=(jQuery(window).width()-jQuery("#bestrowcont").width())/2;if(parseInt(bleft)<0){bleft=30};
var btop=(jQuery(window).height()-jQuery("#bestrowcont").height())/2+jQuery(window).scrollTop();if(parseInt(btop)<0){btop=30};
jQuery("#bestrowcont").css({left:bleft,top:btop});
jQuery("#showbestrow").css({width:jQuery(document).width(),height:jQuery(document).height()});
jQuery("#down_list .close").one("click",function(){
jQuery("#bestrowcont,#showbestrow").remove();
jQuery("select").css("visibility","visible");
jQuery(window).unbind("resize",first_resetbestrow);
jQuery(".center_flash object").show();
return false;
});
});
jQuery(window).one("resize",first_resetbestrow);
};
function first_resetbestrow(){
jQuery("#showbestrow").css({width:jQuery(window).width(),height:jQuery(window).height()});
setTimeout(second_resetbestrow,0);
}
function second_resetbestrow(){
jQuery("#bestrowcont").css({left:(jQuery(window).width()-jQuery("#bestrowcont").width())/2,top:(jQuery(window).height()-jQuery("#bestrowcont").height())/2+jQuery(window).scrollTop()});
jQuery("#showbestrow").css({width:jQuery(document).width(),height:jQuery(document).height()});
jQuery(window).one("resize",first_resetbestrow);
}

;(function($){

/*
 * noker_lablechange插件方法说明：
 * 示例：$("??").noker_lablechange({s:$("??"),a:"mouseover",c:"active",b:2});
 * 参数：s=用于标签切换时对应显示出来的JQ对象组，必写
 * 参数：a=切换方式，仅允许"mouseover"和"click"，默认为"mouseover"
 * 参数：c=激活标签所具备的class样式名，默认为"mouseover"
 * 参数：b=默认激活标签的索引值，可不写
 * 注意本插件需要联合HTML及CSS一同实现效果
*/
$.fn.noker_lableChange=function(o){
	var t=this;
	var d={s:null,a:"mouseover",c:"active",b:0};
	var o=$.extend(d,o);
	if(!o.s||o.s.length!=t.length){
		alert("Tags correspondence does not hold, check!");
	}else{
		o.s.hide().eq(o.b%t.length).show();
		t.eq(o.b%t.length).addClass(o.c);
		t.bind(o.a,function(){
			o.s.hide().eq(t.removeClass(o.c).index($(this).addClass(o.c))).show();
		});
	}
	return this;
};

/*
 * noker_focusPictures插件方法说明：
 * 示例：$("??").noker_focusPictures({t:??,f:??});
 * 参数：t=图片自动切换的间隔时间毫秒数，建议3000~10000
 * 参数：f=切换时完成渐变效果的时间毫秒数，建议不超过1000，设为0则没有渐变效果
 * 注意本插件需要联合HTML及CSS一同实现效果
*/
$.fn.noker_focusPictures=function(o){
	var t=this;
	var d={t:5000,f:600};
	var o=$.extend(d,o);
	var i=$("img",t);
	var m=i.length;
	var u="<ul><li class=\"active\">1</li>";
	i.css({position:"absolute","z-index":0}).slice(1).hide().each(function(i){u+="<li>"+(i+2)+"</li>";});
	t.append(u+"</ul>");
	var l=$("li",t);
	var n=0;
	var w=$("#focus_word").html(i.eq(n).attr("title"));
	l.mouseover(function(){
		if($(this).index()!=n){
			l.eq(n).removeClass();
			i.stop(true,true);
			i.eq(n).fadeOut(o.f).css("z-index",0);
			i.eq(n=$(this).addClass("active").index()).fadeIn(o.f).css("z-index",1);
			w.html(i.eq(n).attr("title"));
		}
	});
	function fpc(){l.eq((n+1)%m).trigger("mouseover");
	noker_focusPictures_timer=window.setTimeout(fpc,o.t);}
	t.hover(function(){
		window.clearTimeout(noker_focusPictures_timer);
	},function(){
		noker_focusPictures_timer=window.setTimeout(fpc,o.t);
	}); 
	var noker_focusPictures_timer=window.setTimeout(fpc,o.t);
	return this;
};

})(jQuery);

/**   
 *    
 * @param {} sURL 收藏链接地址   
 * @param {} sTitle 收藏标题   
 */   
function AddFavorite(sURL, sTitle) {   
    try {   
        window.external.addFavorite(sURL, sTitle);   
    } catch (e) {   
        try {   
            window.sidebar.addPanel(sTitle, sURL, "");   
        } catch (e) {   
            alert("加入收藏失败，请使用Ctrl+D进行添加");   
        }   
    }   
} 

//写cookies函数
function SetCookie(name,value,days)//两个参数，一个是cookie的名子，一个是值
{
    var Days = days;
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    var timeStr = '';
    if(days!=0) timeStr = ";expires=" + exp.toGMTString();
    document.cookie = name + "="+ escape (value) + timeStr;
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
