
function regCheck(input,id)
								{
									var partern="";
							
									switch(id)
									{
										case 1:
											partern=/^.{6,20}$/;
											break;
										case 3:
											partern=/^(\w){6,18}$/;
											break;
										case 5:
											partern=/^\d{7,15}$/;break;
										case 6:
											partern=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;break;
										default :
											partern=/^.+$/;
											break;
									}
								//	debugger;
									if(id==1)
									{
									    if(strlen(input)>=6&&strlen(input)<=20)
									    {
									        return true;
									    }
									    else
									    {
									        return false;
									    }   
									}
									if (!partern.exec(input)) 
										return false;
									return true;
								}
								
function isChinese(str)
{
   var lst = /[u00-uFF]/;     
   return !lst.test(str);    
}
function strlen(str)
{
   var strlength=0;
   for (i=0;i<str.length;i++)
    {
        if (isChinese(str.charAt(i))==true)
            strlength=strlength + 2;
        else
            strlength=strlength + 1;
    }
    return strlength;
}

function trim(sInputString)
{   
	iType=0;
	var sTmpStr = ' ';
     var i = -1;
	 if(iType == 0 || iType == 1) 
	 { 
		 while(sTmpStr == ' ') 
		 {   
		 	  ++i;
			 sTmpStr = sInputString.substr(i,1);
		 }  
		 sInputString = sInputString.substring(i);
	}  
	if(iType == 0 || iType == 2) 
	{  
		sTmpStr = ' ';
		i = sInputString.length;
		while(sTmpStr == ' ')  
		{  
			--i;
			sTmpStr = sInputString.substr(i,1);
		} 
		sInputString = sInputString.substring(0,i+1);
	} 
	return sInputString;
}


function setMarginTop(){
	
	mainID="div.MainPanel"
	
	var h=$(window).height();
	var ph=$(mainID).height()/2;
	var pt=h/2 - ph;
	if(pt >=0)
	{
		$(mainID).css("margin-top",pt);
	}
	else
	{
		$(mainID).css("margin-top","0px");
	}
}


function $get(id)
{
	return	document.getElementById(id);
}


function resetImgSize(divClass,wth,hgh)
{
	var divColection=document.getElementsByTagName("div");
	//var divs=$get(divid);
	//debugger;
	for(j=0;j<divColection.length;j++)
	{
		var cssList=divColection[j].className.split(" ");
		var findFlag=false;
		for(k=0;k<cssList.length;k++)
		{
			if(cssList[k]==divClass)
			{
				findFlag=true;
				break;
			}
		}
		
		if(findFlag) 
		{
			var imgs=divColection[j].getElementsByTagName("img");	
			setHeight=hgh;
			setWidth=wth;
			//document.getElementById("sdf").style.paddingRight.paddingLeft.paddingBottom.paddingTop
			for(i=0;i<imgs.length;i++)
			{
				height=imgs[i].height;
				width=imgs[i].width;
				//alert(height+","+width+","+width/height+","+setWidth/setHeight)
				if(height>setHeight||width>setWidth)
				{
					if(width/height>setWidth/setHeight)
					{
						height=setWidth*height/width				
						width=setWidth;
					}
					else
					{	
						width=setHeight*width/height				
						height=setHeight;
					}
				}
	
				imgs[i].height=height;
				if(height<setHeight)
				{
					
					//imgs[i].style.marginTop=(setHeight-height)/2;
					imgs[i].style.paddingBottom=(setHeight-height);
					//alert(width+","+height)
				}
				imgs[i].width=width;
				if(width<setWidth)
				{
					imgs[i].style.paddingLeft=(setWidth-width)/2;
					imgs[i].style.paddingRight=(setWidth-width)/2;
					//alert(width+","+height)
				}
			}
		}
	}
}

function doSelectAll()
{
    var i=0;
    var idstr="";
    var obj=document.getElementById("selectAll");
    
    for(i=0;i<document.getElementsByName("selectone").length;i++)
    {
        if(obj.checked)
        {
            document.getElementsByName("selectone")[i].checked=true;
		    idstr+=document.getElementsByName("selectone")[i].value + ",";
		}
		else
		{
		    document.getElementsByName("selectone")[i].checked=false;
		    idstr="";
		}
	}
	if(idstr!="")
	{
  	  document.getElementById("hidSelect").value=idstr.substring(0,idstr.length-1);
	}
	else
	{
		document.getElementById("hidSelect").value=idstr;	
	}
}
function doSelect()
{
	 var i=0;
    var idstr="";
 
    for(i=0;i<document.getElementsByName("selectone").length;i++)
    {
        if(document.getElementsByName("selectone")[i].checked)
        {           
		    idstr+=document.getElementsByName("selectone")[i].value + ",";
		}		
	}
  if(idstr!="")
	{
  	  document.getElementById("hidSelect").value=idstr.substring(0,idstr.length-1);
	}
	else
	{
		document.getElementById("hidSelect").value=idstr;	
	}
}

function autoResizeImg(id,size,type)
{
	
	$("#"+id+" img").each(function()
								   {
									   switch(type)
									   {
										   case 1:
										   if($(this).width()>size)
										   {
											   $(this).width(size);
											   //alert($(this))
											   $(this).attr("rel","lytebox");
												$(this).removeAttr("height");
												
											}
											break;
											case 2:
											if($(this).height()>size)
										   {
											   $(this).height(size);
											   //alert($(this))
											   $(this).attr("rel","lytebox");
												$(this).removeAttr("width");
												
											}
											
											break;
									   }
									   
									}
								   );
}


function GetRandomNum(minNum,maxNum)
{       
        var Rand = Math.random();
		return Rand*(maxNum-minNum)+minNum       
}

function addFlash1(width,height,pics,links,texts)
{

                 var pic_width=width; //图片宽度//this param387
                    var pic_height=height; //图片高度//this param244

                    var button_pos=4; //按扭位置 1左 2右 3上 4下//this param
                    var stop_time=7000; //图片停留时间(1000为1秒钟)//this param
                    var show_text=0; //是否显示文字标签 1显示 0不显示//this param
                    var txtcolor="000000"; //文字色

                    var bgcolor="DDDDDD"; //背景色


                    var imag=new Array();
                    var link=new Array();//this param
                    var text=new Array();//this param

                    //可编辑内容结束
                    var swf_height=show_text==0?pic_height:pic_height;//this param

                    var pics=pics;
                    var links=links;
                    var texts=texts;

                    var wmode = 'movie';
                    var flashurl = 'focus.swf';
                    var htmlstr = '<embed wmode="transparent" style="position:relative;top:0px;" src="' + flashurl + '" wmode=' + wmode +
                    ' quality="high" FlashVars="pics='+pics
	                    +'&links='+links
	                    +'&texts='+texts+
	                    '&pic_width='+pic_width+
	                    '&pic_height='+pic_height+
	                    '&show_text='+show_text+
	                    '&txtcolor='+txtcolor+
	                    '&bgcolor='+bgcolor+
	                    '&button_pos='+button_pos+
	                    '&stop_time='+stop_time+
	                    '" quality="high" width="'+ pic_width +
	                    '" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
                    document.write(htmlstr);
                
  }
function addFlash2(width,height,pics,links,texts)
{
						var focus_width=width+1;
						var focus_height=height+1;
						var text_height=0;
						var swf_height = focus_height+text_height;
						var src="playswfnew.swf";
						  
						document.write('<object ID="focus_flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
						document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+src+'"><param name="quality" value="high"><param name="bgcolor" value="#ffffff">');
						document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
						document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
						document.write('<embed ID="focus_flash" src="'+src+'" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#ffffff" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');		document.write('</object>');
}

function addFlash(width,height,src)
{
  var htmlstr = '<embed wmode="transparent" style="position:relative;top:0px;" src="' + src + '"' +
                    ' quality="high" width="'+ width +'" height="'+ height 
                    +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
                              
                       document.write(htmlstr);
}