document.execCommand("BackgroundImageCache", false, true);


function wgid(id)
{
	return self.document.getElementById(id);
}


function addFavorite(sURL, sTitle){
	try{ window.external.addFavorite(sURL, sTitle);}
		catch (e){
			try{window.sidebar.addPanel(sTitle, sURL, "");}
			catch (e)
				{alert("加入收藏失败，请使用Ctrl+D进行添加");}
		}
}

function setHome(obj,vrl,url){
    try{obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	this.style.behavior='url(#default#homepage)';this.setHomePage(url);}
        catch(e){
            if(window.netscape){
                try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}  
                   catch (e){alert("此操作被浏览器拒绝！请手动设置");}
                   var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                   prefs.setCharPref('browser.startup.homepage',vrl);
             }
      }
}

function redirect(url)
{
	document.location.href= url;
}

function getPosition() 
{ 
	var top    = document.documentElement.scrollTop; 
	var left   = document.documentElement.scrollLeft; 
	var height = document.documentElement.clientHeight; 
	var width  = document.documentElement.clientWidth; 
	return {top:top,left:left,height:height,width:width}; 
}


function urldecode(str){
	var i,temp;
	var result="";
	for(i=0;i<str.length;i++){
		if(str.charAt(i)=="%"){
			if(str.charAt(++i)=="u"){
				temp=str.charAt(i++) + str.charAt(i++) + str.charAt(i++) + str.charAt(i++) + str.charAt(i);
				result += unescape("%" + temp);
			}else{
				temp = str.charAt(i++) + str.charAt(i);
				if(eval("0x"+temp)<=160){
					result += unescape("%" + temp);
				}else{
					temp += str.charAt(++i) + str.charAt(++i) + str.charAt(++i);
					result += Decode_unit("%" + temp);
				}
			}
		}else{
			result += str.charAt(i);
		}
	}
	return result;
}

function Decode_unit(str)
{
	var p,q = "";
	if(str.GetCount("%")!=2) return str;
	p=eval("0x" + str.split("%")[1]);
	q=eval("0x" + str.split("%")[2]);
	if(p<160 || q<160) return unescape(str);
	str=str.replace(/%/g,"");
	execScript("temp=&H"+str, "vbscript");
	execScript("result=chr("+temp+")", "vbscript");
	return result;
}

function GetOffset(e)
{
    var x = e.offsetLeft , y = e.offsetTop;   
    while(e = e.offsetParent) 
    { 
       x+=e.offsetLeft;   
       y+=e.offsetTop;
    } 
    return {left:x,top:y}
}


// 热播大片slide
function Aotuplay(showid,showimgid,curimg,defimg){
	this.current=1; 
	this.step=5000;
	this.num=4;
	this.autoScroller=0;
	this.showid= showid;
	this.showimgid=showimgid;
	this.curImg= curimg!=undefined?curimg:URL_ROOT_PATH+'images/a_56.gif';
	this.defImg= defimg!=undefined?defimg:URL_ROOT_PATH+'images/a_58x.gif';
}
Aotuplay.prototype.start =function(){
	clearInterval(this.autoScroller);
	var selfobj = this;
	this.autoScroller = setInterval(function()
	{
		selfobj.play(selfobj.current == selfobj.num ? 1 : selfobj.current + 1);
	} , selfobj.step);
}
Aotuplay.prototype.play=function(index)
{
	clearInterval(this.autoScroller);
	if(this.current){
		wgid(this.showid+this.current).style.display='none';
		wgid(this.showimgid+this.current).src=this.defImg;
	}
	this.current = index;
	wgid(this.showid+index).style.display='block';
	wgid(this.showimgid+index).src=this.curImg;
	var selfobj = this;
	setTimeout(function(){selfobj.start();},selfobj.step);
}
Aotuplay.prototype.next=function()
{
	var index = this.current == this.num ? 1 : this.current + 1;
	this.play(index);
}
Aotuplay.prototype.prev=function()
{
	var index = this.current == 1 ? 4 : this.current - 1;
	this.play(index);
}
