﻿
// JScript 文件
function setCookie(name, value)		//cookies设置
{
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	if(expires!=null)
	{
		var LargeExpDate = new Date ();
		LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
	}
	document.cookie = name + "=" + escape (value) + "; path=/;" +((expires == null) ? "" : (" expires=" +LargeExpDate.toGMTString()));
}

function getCookie(Name)			//cookies读取
{
	var search = Name + "="
	if(document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search)
		if(offset != -1) 
		{
			offset += search.length
			end = document.cookie.indexOf(";", offset)
			if(end == -1) end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		 }else return ""
	 }
}



//***
//图片缩小
function ImgLoad(obj)
{
	var imgs = obj.getElementsByTagName("img");
	for(var i=0;i<imgs.length;i++){
		var o=imgs[i];
		if (o.width>imgMaxWidth){
			if (o.style.width){
				o.style.width="";
			}
			o.width=imgMaxWidth;
			o.removeAttribute("height");
			o.setAttribute("title","ctrl+鼠标滚轮缩放");
			o.style.cursor="pointer";
			o.style.display="block";
			o.vspace=5;
			o.resized=1;
			o.onclick=ImgClick;
			o.onmousewheel=bbimg;
		}
		// 点图片下一页
		var gp = document.getElementById("goPage");
		if (gp && imgs.length==1 && o.width>200){
			o.style.cursor="pointer";
			o.onclick=function(){pager.Next()};
		}
	}
}
function ImgClick()
{
	if (this.parentElement){
		if (this.parentElement.tagName!="A"){
			window.open(this.src);
		}
	}else{
		window.open(this.src);
	}
}
//图片缩放
function bbimg()
{
	if (event.ctrlKey){
		var zoom=parseInt(this.style.zoom, 10)||100;
		zoom+=event.wheelDelta/12;
		if (zoom>0) this.style.zoom=zoom+'%';
		return false;
	}else{
		return true;
	}
}
var isIE=(navigator.appVersion.toLowerCase().indexOf('msie')>=0)
function add_bookmark(url,title)
{
    if(url!=""&&isIE)
    {
        window.external.AddFavorite(url,title)
    }
}


function $By(s){return document.getElementById(s);}
String.prototype.trim = function(){return this.replace(/(^[ |　]*)|([ |　]*$)/g, "");}

function $ByID(id)
{
    return document.getElementById(id);
}
//获取广告脚本

function LoadAdScript(id)
{
    var xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
    xmlHTTP.open("POST",'/Weekly/News/Common/LoadAdScript.aspx?GroupID='+id,false);
    xmlHTTP.send("<a></a>");    
    document.write(xmlHTTP.responseText);
}
