function shoucang(){
	try {
		window.external.addFavorite('http://www.taoyatao.net', '淘呀淘 - 淘友共同参与互动的淘宝互动导购网');
	}catch(e){
	try{
			window.sidebar.addPanel('淘呀淘 - 淘友共同参与互动的淘宝互动导购网', 'http://www.taoyatao.net', "");
		}catch(e){
		alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
	return false;
}


//对联广告
function getdivid(id){ 
return document.getElementById(id); 
} 
function scrollBanner(timer,moveNumber){ 
function move(o){ 
var st=document.documentElement.scrollTop+o.t; 
var sl=document.documentElement.scrollLeft+(o.c==0?o.a:document.documentElement.clientWidth-o.a-o.offsetWidth); 
var tc=st-o.offsetTop,lc=sl-o.offsetLeft; 
with(o.style){ 
top=o.offsetTop+(tc!=0?tc/Math.abs(tc):0)*Math.min(Math.abs(tc),moveNumber)+"px"; 
left=o.offsetLeft+(lc!=0?lc/Math.abs(lc):0)*Math.min(Math.abs(lc),moveNumber)+"px"; 
} 
if(o.person){ 
with(o.person.style){ 
top=o.offsetTop+"px"; 
left=o.offsetLeft+o.offsetWidth-o.person.offsetWidth+"px"; 
} 
} 
} 
var hidden=function(){ 
var o=this.parent; 
window.clearInterval(o.interval); 
o.parentNode.removeChild(o); 
this.parentNode.removeChild(this); 
} 
this.add=function (to,t,a,c,lo){ 
/* 
to为object对象 
t为距离顶端距离 
当c=0的时候，a为距离左边的距离 
当c!=0的时候，a为距离右边的距离 
lo为关闭按钮 
*/ 
var div,exec=function (){ move(to); }; 
to.person=lo; 
to.t=t; 
to.a=a; 
to.c=c; 
with(to.style){ 
position="absolute"; 
display="block"; 
top=document.documentElement.scrollTop+t; 
left=document.documentElement.scrollLeft+(c==0?a:document.documentElement.clientWidth-a-to.offsetWidth); 
} 
if ("undefined" != typeof lo){ 
with(lo.style){ 
position="absolute"; 
display="block"; 
} 
lo.onmousedown=hidden; 
lo.parent=to; 
} 
exec(); 
to.interval=window.setInterval(exec,timer); 
}; 
} 
function duilian(){ 
var b=new scrollBanner(10,15); 
b.add(getdivid("lwc"),70,20,0,getdivid("lwc_c")); 
b.add(getdivid("rwc"),70,20,1,getdivid("rwc_c")); 
b=null; 

/*以下是标签云初始化*/
	var i=0;
	var oTag=null;
	oDiv=document.getElementById('div1');	
	aA=oDiv.getElementsByTagName('a');
	for(i=0;i<aA.length;i++)
	{
		oTag={};
		oTag.offsetWidth=aA[i].offsetWidth;
		oTag.offsetHeight=aA[i].offsetHeight;
		mcList.push(oTag);
	}
	sineCosine( 0,0,0 );
	positionAll();
	oDiv.onmouseover=function ()
	{
		active=true;
	};
	oDiv.onmouseout=function ()
	{
		active=false;
	};
	oDiv.onmousemove=function (ev)
	{
		var oEvent=window.event || ev;
		mouseX=oEvent.clientX-(oDiv.offsetLeft+oDiv.offsetWidth/2);
		mouseY=oEvent.clientY-(oDiv.offsetTop+oDiv.offsetHeight/2);
		mouseX/=5;
		mouseY/=5;
	};
	
	setInterval(update, 30);
}

/*自动缩略图*/
var flag=false;
function DrawImage(ImgD,w,h){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
  flag=true;
  if(image.width/image.height>= w/h){
    if(image.width>w){
      ImgD.width=w;
      ImgD.height=(image.height*w)/image.width;
    }else{
      ImgD.width=image.width;
      ImgD.height=image.height;
    }
  }else{
    if(image.height>h){
      ImgD.height=h;
      ImgD.width=(image.width*h)/image.height;
    }else{
      ImgD.width=image.width;
      ImgD.height=image.height;
    }
  }
}
}

/** 让图片垂直居中。使用前提：当前图片必须被包含在div中
* ImgD：原图
* maxWidth：允许的最大宽度(即包含本图片的div的父节点对象的宽度，一般是li)
* maxHeight：允许的最大高度
*/
function centerImage(imgD, maxWidth, maxHeight){
	var div = imgD.parentNode;//获取包含本图片的div
	if(imgD.height < maxHeight){
		var top = (maxHeight - imgD.height) / 2;
		div.style.marginTop = top + "px";
	}
	if(imgD.width < maxWidth){
		var left = (maxWidth - imgD.width) / 2;
		div.style.marginLeft = left + "px";
	}
}
