
//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;
}
//验证电子邮件
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); 
    }
}

function DrawImage(ImgD,MaxW,MaxH)
{
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0)
   {
		if(image.width>MaxW)
		{
			ImgD.width=MaxW
		}
		if(image.height>MaxH)
		{
			ImgD.height=MaxH
		}
   		
   		/*
		flag=true;
		if(image.width/image.height>= 120/80)
		{
			if(image.width>MaxW)
			{  
				ImgD.width=MaxW;
				ImgD.height=(image.height*80)/image.width;
			}
			else
			{
			     ImgD.width=image.width;  
			     ImgD.height=image.height;
		    }
		     ImgD.alt=image.width+"×"+image.height;
		}
		else
		{
		     if(image.height>80)
			 {  
			     ImgD.height=MaxH;
			     ImgD.width=(image.width*80)/image.height;     
			 }
			 else
			 {
			     ImgD.width=image.width;  
			     ImgD.height=image.height;
		     }
		     ImgD.alt=image.width+"×"+image.height;
	     }
	     */
	}
}
