
//checkbox,radio类型表单的取值
function rbvalue(rbname)
{
	allvalue='';
	for(var i=0; i<rbname.length;i++)
	{
		if(rbname[i].checked)
		{
			if(allvalue=='')
				{allvalue=rbname[i].value}
			else
				{allvalue+=','+rbname[i].value}
		}
	}
	return allvalue;
}
//清除checkbox，radio 选择
function clearradio(formitem)
{
	var Obj=formitem;
	for(i=0;i<Obj.length;i++)
	{
		Obj[i].checked=false;
	}
}

//验证电子邮件
function chkemail(theitem)
{
	returnemail='';
	var stremail=/^[0-9a-zA-Z\-\.\_]+@[0-9a-zA-Z\-]+\.[0-9a-zA-Z\-\.]+$/;//
	if (!theitem.value.match(stremail))
	{
		returnemail='nomatch';
	}
}
//删除空格
function del_space(s)
{
	for(i=0;i<s.length;++i)
	{
		if(s.charAt(i)!=" ")
		break;
	}
	for(j=s.length-1;j>=0;--j)
	{
		if(s.charAt(j)!=" ")
		break;
	}
	return s.substring(i,++j);
}
//固定位置隐藏或显示内容
function showdisc(theid)
{
	if(theid.style.display=='none')
	{
		theid.style.display="block";
	}
	else
	{
		theid.style.display='none';
	}
}
//跟随鼠标隐藏或显示内容
function showblogdisc(theid)
{
	if(theid.style.display=='none')
	{
		var obj=theid;
		GetMouseXY_ForLayer(obj);
		theid.style.display="block";
	}
	else
	{
		theid.style.display='none';
	}
}
//确定鼠标位置
function GetMouseXY_ForLayer(obj_div)
{
	x = document.body.scrollLeft + event.clientX;
	y = document.body.scrollTop + event.clientY;
	
	//获取屏幕宽度
	availWidth = parseInt(window.screen.availWidth);
	tblWidth = parseInt(obj_div.width);
	//获取位置x和菜单table的宽度相加之和			
	curWidth = x + tblWidth;
	//如果超出了屏幕右边则x左移动一个差量			
	if( curWidth > availWidth )
		x = x-(curWidth - availWidth);
	
	
	if( (x-300) < document.body.scrollLeft )
		x = document.body.scrollLeft
	else
		x = x-300;
	
	obj_div.style.top = y;
	obj_div.style.left = x;
	obj_div.style.display="";
	//alert("x="+x+" y="+y) ;
}

//-->
//弹开窗口
function p_open(url,t,l,w,h)
{
	window.open(url,'_blank','status=no,scrollbars=yes,top='+t+',left='+l+',width='+w+',height='+h+'');
}


function selectall(formitem)
{
	if(formitem.length==undefined)
	{
		formitem.checked=event.srcElement.checked;
	}
	else
	{
		for(i=0;i<formitem.length;i++) 
		{
			formitem[i].checked=event.srcElement.checked;
		}
	}
}

function change_tdbj(idname,idnum,maxid)
{
	if(idname=='gg'||idname=='img')
	{
		for (i=1;i<=maxid;i++)
		{
			//alert(i+"#"+idnum);
			if (i != idnum)
			{
				//alert("document.getElementById('"+idname+"_btn"+i+"').className='td_bgimg1'");
				eval("document.getElementById('"+idname+"_btn"+i+"').className='bgimg9 hand'");
				eval("document.getElementById('"+idname+"_div"+i+"').style.display='none'");
			}
			else
			{
				//alert("document.getElementById('"+idname+"_btn"+i+"').className='td_bgimg0'");
				eval("document.getElementById('"+idname+"_btn"+i+"').className='bgimg10 fb hand'");
				eval("document.getElementById('"+idname+"_div"+i+"').style.display='block'");
			}
		}
	}
	else
	{
		for (i=1;i<=maxid;i++)
		{
			//alert(maxid)
			if (i!=idnum)
			{
				//alert("document.getElementById('"+idname+"_btn"+i+"').className='bgimg1'");
				eval("document.getElementById('"+idname+"_btn"+i+"').className='bgimg1 hand'");
				eval("document.getElementById('"+idname+"_div"+i+"').style.display='none'");
			}
			else
			{
				//alert("document.getElementById('"+idname+"_btn"+i+"').className='bgimg0'");
				eval("document.getElementById('"+idname+"_btn"+i+"').className='bgimg0 fb hand'");
				eval("document.getElementById('"+idname+"_div"+i+"').style.display='block'");
			}
		}
	}
}

function change_newsimg(idname,idnum,maxid)
{
		for (i=1;i<=maxid;i++)
		{
			//alert(i+"#"+idnum);
			if (i != idnum)
			{
				//alert("document.getElementById('"+idname+"_btn"+i+"').className='td_bgimg1'");
				eval("document.getElementById('"+idname+"_btn"+i+"').className='flt_l bgan_0 box_1'");
				eval("document.getElementById('"+idname+"_div"+i+"').style.display='none'");
				//eval("document.getElementById('"+idname+"_topic"+i+"').style.display='none'");
			}
			else
			{
				//alert("document.getElementById('"+idname+"_btn"+i+"').className='td_bgimg0'");
				eval("document.getElementById('"+idname+"_btn"+i+"').className='flt_l bgan_1 box_1'");
				eval("document.getElementById('"+idname+"_div"+i+"').style.display='block'");
				//eval("document.getElementById('"+idname+"_topic"+i+"').style.display='block'");
			}
		}
}
//插入Flash防止虚线边框的出现
function insertFlash(elm, url, w, h) {
if (!document.getElementById(elm)) return;
var str = '';
str += '<object width="'+ w +'" height="'+ h +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
str += '<param name="movie" value="'+ url +'">';
str += '<param name="wmode" value="opaque">';
str += '<param name="quality" value="autohigh">';
str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
str += '</object>';
document.getElementById(elm).innerHTML = str;
}
//自动缩略
function Reset_ImgSize(obj, MaxW, MaxH)
{
    if (obj != null) imageObject = obj;
    var state=imageObject.readyState;
    var oldImage = new Image();
    oldImage.src = imageObject.src;
    var dW=oldImage.width; var dH=oldImage.height;
    if(dW>MaxW || dH>MaxH) {
        a=dW/MaxW; b=dH/MaxH; 
        if(b>a) a=b;
        dW=dW/a; dH=dH/a;
    }
    if(dW > 0 && dH > 0)
        imageObject.width=dW;imageObject.height=dH;
    if(state!='complete' || imageObject.width>MaxW || imageObject.height>MaxH) {
        setTimeout("ResizeImage(null,"+MaxW+","+MaxH+")",40); 
    }
}

//------------不间断左滚动----------------------
/*
<div id="demo" style='background: #FFF;overflow:hidden;border: 1px dashed #CCC;width: 500px;'>
	<div id="indemo" style="float: left;width: 800%;">
		<div id="demo1" style="float: left;">
		<a href="#"><img src="http://www.dcn.org.cn/UpLoadFiles/2010-5/201051983840.jpg" border="0" style='margin:3px' /></a>
		<a href="#"><img src="http://www.dcn.org.cn/UpLoadFiles/2010-5/201051983840.jpg" border="0"  style='margin:3px'/></a>
		<a href="#"><img src="http://www.dcn.org.cn/UpLoadFiles/2010-5/201051983840.jpg" border="0"  style='margin:3px'/></a>
		<a href="#"><img src="http://www.dcn.org.cn/UpLoadFiles/2010-5/201051983840.jpg" border="0"  style='margin:3px'/></a>
		<a href="#"><img src="http://www.dcn.org.cn/UpLoadFiles/2010-5/201051983840.jpg" border="0"  style='margin:3px'/></a>
		<a href="#"><img src="http://www.dcn.org.cn/UpLoadFiles/2010-5/201051983840.jpg" border="0"  style='margin:3px'/></a>
		</div>
		<div id="demo2" style="float: left;margin-left:8px;"></div>
	</div>
</div>
*/


function MarqueePage(demo,demo1,demo2)
{
	var speed=10; //数字越大速度越慢
	var tab=document.getElementById(demo);
	var tab1=document.getElementById(demo1);
	var tab2=document.getElementById(demo2);
	tab2.innerHTML=tab1.innerHTML;
	function Marquee()
	{
		if(tab2.offsetWidth-tab.scrollLeft<=0)
		{
			tab.scrollLeft-=tab1.offsetWidth
		}
		else
		{
			tab.scrollLeft++;
		}
	}
	var MyMar=setInterval(Marquee,speed);
	tab.onmouseover=function() {clearInterval(MyMar)};
	tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
}
//----------------------------------


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){
        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);
                 }
        }
}





