function addFavorite(url,title){
if (document.all)
	window.external.addFavorite(url,title);
else if (window.sidebar)
	window.sidebar.addPanel(title,url,"");
}
function SetHome(obj,vrl){
	try{
		obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	}catch(e){
		if(window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch (e){
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
			}
			var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage',vrl);
		}
	}
} 
function SameH(leftDiv,rightDiv,isEqual,num){
	var a=G(leftDiv);
	var b=G(rightDiv);
	if (a.scrollHeight < b.scrollHeight)
		a.style.height= (b.scrollHeight-num)+"px";
	else
		if(isEqual==true) b.style.height= a.scrollHeight+"px";
}
//获取指定对象
function G(o) {return typeof(o)=='object'?o:document.getElementById(o);}
function autoSelect(itm, val){
var o=G(itm);
for (i=0;i<o.options.length;i++){
	if(o.options[i].value==val){
		o.selectedIndex = i;
		break;
	}
}
}
function addoptions(obj,text,val){
var o=G(obj);
var opt = document.createElement('OPTION');
opt.text = text;
opt.value = val;
o.options.add(opt, o.length);
}
function autoCheckbox(itm, val){
var o=document.getElementsByName(itm);
var vals=val.split(",");
for (var s=0;s<vals.length;s++){
	for (i=0;i<o.length;i++){
		if(o[i].value==vals[s]){
			o[i].checked= true;
			break;
		}
	}
}
}
function autoRadio(itm,val){
var o=document.getElementsByName(itm);
for(var i=0;i<o.length;i++){
	if(o[i].value==val){
		o[i].checked=true;
		break;
	}	
}
}
function autoInput(itm,val){
var o=G(itm);
o.value=val;
}
//弹出窗口
function wo(url,w,h,m){
	var left=(screen.width-w)/2;
	var top=m?(screen.height-h)/2:0;
	window.open(url,'','width='+w+',height='+h+',top='+top+',left='+left+',scrollbars=1,resizable=0,status=0');
	//return false;
}
//获取图片宽度
function getWidth(ele){
var image=new Image(); 
image.src=ele.src;
return image.width;
}
//获取图片高度
function getHeight(ele){
var image=new Image(); 
image.src=ele.src;
return image.height;
}
function updateimgs(Img,w,h){
	var widths = w;
	var heights = h;
	var objimg = Img;
	var iwidth=getWidth(objimg);
	var iheight=getHeight(objimg);
	if(iwidth<widths && iheight<heights){
		return;
	}
	if(iwidth/iheight>widths/heights)
	{
		objimg.width=widths;
		objimg.height=widths*iheight/iwidth;
		return;
	}else{
		objimg.width=heights*iwidth/iheight;
		objimg.height=heights;
		return;
	}
}
//自动绽放图片
function AutoImg(o,w){
var Imgs=G(o).getElementsByTagName("img");	
for(var j=0; j<Imgs.length; j++) {
	autoImgW(Imgs[j],w);
	Imgs[j].style.cursor= "pointer"; 
	Imgs[j].onclick = function() {window.open(this.src);};
	Imgs[j].onerror = function() {this.src='images/no_pic.gif';};
}
}
//自动缩放图片到指定宽度
function autoImgW(Img,w)
{
var widths = w;
var objimg = G(Img);
var iwidth=getWidth(objimg);
if(iwidth>widths) objimg.width=widths;
}
//自动缩放图片到指定高度
function autoImgH(Img,h)
{
var heights = h;
var objimg = G(Img);
var iheight=getHeight(objimg);
if(iheight>heights) objimg.height=heights;
}
function errImg(img){
	img.src="images/no_pic.gif";
}
//行高滚动
function startmarquee(lh,speed,delay,obj){
var t;
var p=false;
var o=G(obj);
o.innerHTML+=o.innerHTML;
o.onmouseover=function(){p=true}
o.onmouseout=function(){p=false}
o.scrollTop = 0;
function start(){
t=setInterval(scrolling,speed);
if(!p) o.scrollTop += 2;
}
function scrolling(){
if(o.scrollTop%lh!=0){
	o.scrollTop += 2;
	if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0;
}else{
	clearInterval(t);
	setTimeout(start,delay);
}
}
setTimeout(start,delay);
}
//左侧滚动
function lscroll(obj,speed)
{
var p=false;
var o=G(obj);
o.innerHTML+=o.innerHTML;
o.onmouseover=function(){p=true}
o.onmouseout=function(){p=false}
o.scrollLeft = 0;
setInterval(scrolling,speed);
function scrolling()
{
	if(!p)
	{
		o.scrollLeft+=1;
		if(o.scrollLeft>=o.scrollWidth-o.offsetWidth) o.scrollLeft=0;
	}
}
}
function lscroll2(speed,o,o1,o2){
	var obj=G(o);
	var obj1=G(o1);
	var obj2=G(o2);
	obj2.innerHTML=obj1.innerHTML;
	var MyMar=setInterval(Marquee,speed);
	obj.onmouseover=function(){clearInterval(MyMar);}
	obj.onmouseout=function(){MyMar=setInterval(Marquee,speed);}
	function Marquee(){
		if(obj.scrollLeft>=(obj1.scrollWidth)) obj.scrollLeft=0;
		else obj.scrollLeft++;
	}
}
//反选
function uchoose(form)
{
var checkbox=form.elements;
for (var i=0;i<checkbox.length;i++)
	if (checkbox[i].type=="checkbox")
	{
		var e = checkbox[i];
		if (e.checked==false)
			e.checked = true;
		else
			e.checked = false;
	}
} 
//全选
function choose(form)
{
var checkbox=form.elements;
for (var i=0;i<checkbox.length;i++)
	if (checkbox[i].type=="checkbox"){
		var e = checkbox[i];
		if (e.checked==false)
			e.checked = true;
	}
}
function FlashEmbed(fid,fn,wd,ht,para)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + wd + '" height="' + ht + '" id="' + fid + '" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain">');
	document.write('<param name="movie" value="' + fn + para + '">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="opaque">');
	document.write('<embed src="' + fn + para + '" menu="false" quality="high" wmode="opaque" width="' + wd + '" height="' + ht + '" name="' + fid + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}