﻿// JScript 文件
function $(s){return document.getElementById(s);}
function $$(s){return document.frames?document.frames[s]:$(s).contentWindow;}
function  trim(str){ return str.replace(/(^\s*)|(\s*$)/g, "");  }
function myopen(_url,_height,_width,_top,_left)
{
window.open(_url,"",'height='+_height+',width='+_width+',top='+_top+',left='+_left+',location=no,menubar=no,resizable=yes,scrollbars=no,status=no,titlebar=no,toolbar=no,directories=no');
} 


function resizeImg2(_oObj, _w, _h){
	Imagesize(_oObj,_w,_h);
}

//按比例显示图片的大小
function Imagesize(ImgD,towidth,toheight)
{
        var mode = 'FixMax';   
             
        var image=new Image(); 
     
        image.src=ImgD.src; 
        var width = image.width;
        var height = image.height;      
        if(width >0 && height>0)
        {
        switch(mode)
        {
            case'FixMax': 
            if(toheight>0)
            {  
     
                if(width/height >= towidth/toheight)
                  {
                    if(width>towidth)
                      {
                        towidth = towidth;
                        toheight = (height*towidth)/width;
                      }
                      else
                      {
                        towidth = width;
                        toheight = height;
                      }
                  }
                 else
                 {
                    if(height>toheight)
                    {
                        towidth = (width*toheight)/height;
                       // toheight = height;
                    }
                    else
                    {
                        towidth = width;
                        toheight = height;
                    }
                 
                 }
           
           }
           else
           {
                if(towidth >0)                
                    {
                        if(width>towidth)
                            toheight = (height*towidth)/width; 
                        else
                        {
                            towidth = width;
                            toheight = height;
                        }  
                    }
                else
                    {
                        towidth = width;
                        toheight = height;
                    
                    }   
                    
           }
                 break;
              case"MaxW":
                    if(width>towidth)
                    break;
              case"FixW":
                 toheight = (height*towidth)/width;
                 break;
              case"FixH":
                 towidth = (width*toheight)/width;
                 break;
              case 'FixWH':
                    break;
            }  
          } 
          //alert(towidth);
            ImgD.width = towidth;
            ImgD.height = toheight;   
            
 }

function isIE(){
	                return gBrowesr.indexOf("ie") > -1;
                }
                function browserDetect() {
	                var sUA = navigator.userAgent.toLowerCase();
	                var sIE = sUA.indexOf("msie");
	                var sOpera = sUA.indexOf("opera");
	                var sMoz = sUA.indexOf("gecko");
	                if (sIE != -1) {
		                nIeVer = parseFloat(sUA.substr(sIE + 5));
		                if (nIeVer > 6) {
		                    return "ie7";
		                }else if(nIeVer> 5.99)
		                {
			                return "ie6";
		                } else if (nIeVer >= 5.5) {
			                return "ie55";
		                } else if (nIeVer >= 5 ) {
			                return "ie5";
		                }
	                }	
	                if (sOpera != -1) {
		                return "opera";
	                }
	                if (sMoz != -1) {
		                return "moz";
	                }	
	                return "other";
                }
                
function keydown()
{
    var e = event.srcElement; 
    var k = event.keyCode; 
    if (k == 13 && e.type != "textarea"&&e.type!="image") 
    { 
        event.returnValue = false; 
    } 
}
function reloadImg()
{
     var obj;
     obj=getElementsByClassName('userface','img'); 
        for(var i=0; i<obj.length; i++){ 
                resizeImg2(obj[i],48,48);
            }
    
    obj=getElementsByClassName('miface','img'); 
        for(var i=0; i<obj.length; i++){ 
                resizeImg2(obj[i],70,70);
            }
            
     obj=getElementsByClassName('boarduserface','img'); 
        for(var i=0; i<obj.length; i++){ 
                resizeImg2(obj[i],100,100);
            }  
      //我的圈子
     obj=getElementsByClassName('clublogo','img'); 
        for(var i=0; i<obj.length; i++){ 
                resizeImg2(obj[i],75,75);
            } 
       //首页
     obj=getElementsByClassName('milogo photo','img'); 
        for(var i=0; i<obj.length; i++){ 
                resizeImg2(obj[i],94,94);
            } 
       //首页控件
     obj=getElementsByClassName('hmlclubphoto','img'); 
        for(var i=0; i<obj.length; i++){ 
                resizeImg2(obj[i],100,75);
            } 
}


function getElementsByClassName(clsName,htmltag){    
    var arr = new Array();    
    var elems = document.getElementsByTagName(htmltag);   
    for ( var cls, i = 0; ( elem = elems[i] ); i++ ){   
    if ( elem.className == clsName ){ //只能取到className完全相等的情况，为考虑有多个class的情况   
    arr[arr.length] = elem;   
    }   
    }   
    return arr;   
}


function getwidth(_oObj)
{
var img=new Image();
img.style.position="absolute";
img.style.visibility="hidden";
img.attachEvent("onreadystatechange",orsc);
document.body.insertAdjacentElement("beforeend",img);
img.src=_oObj.src;
    function orsc()
    {
    if(img.readyState=="complete")
    {
        return img.width
        }
    else
            return 0;  
    }
}

function getCookie(name){
	var result = null; 
	var myCookie = document.cookie + ";"; 
	var searchName = name + "="; 
	var startOfCookie = myCookie.indexOf(searchName); 
	var endOfCookie; 
	if (startOfCookie != -1)
	{ 
		startOfCookie += searchName.length; 
		endOfCookie = myCookie.indexOf(";", startOfCookie); 
		result = unescape(myCookie.substring(startOfCookie, endOfCookie)); 
	} 
	return result; 
}


function setCookie(name, value, expires, path, domain, secure){
	var expDays = expires * 24 * 60 * 60 * 1000;
	var expDate = new Date(); 
	expDate.setTime(expDate.getTime() + expDays); 
	var expString = ((expires == null) ? "" : (";expires=" + expDate.toGMTString())) 
	var pathString = ((path == null) ? "" : (";path=" + path)) 
	var domainString = ((domain == null) ? "" : (";domain=" + domain)) 
	var secureString = ((secure == true) ? ";secure" : "" )
	document.cookie = name + "=" + escape(value) + expString + pathString + domainString + secureString;
}

function isemail(txtemail)
{
	if (txtemail.length > 50 || txtemail.length<6)
     {
         return false;
     }
      var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$"
      var re = new RegExp(regu);
      if (txtemail.search(re) == -1){
                return false;
      }
      return true;
  }
 
function ispass(s)
{
    return checkBind(s,'content');
}


function resizeImg(_oObj, _iWidth){
	var tMark = true;
	var iWidth = 0;
	var sOuterHtml;
	var aNode = _oObj.attributes;
    if(aNode)
	{
	    for(var i = 0; i < aNode.length; i++)
	        {
	        if(aNode[i].specified)
	            {
	            if(aNode[i].name == "width" || aNode[i].name == "height")
	                {
	                tMark = false;
	                }
	            }
	        }
	 }
	 //
	 if(_iWidth=="0"){
	    var s = window.top.document.getElementById('myFrame');
	    if(s!=null){ 
	      if(s.cols=='450,12,*'){            
            _iWidth = "480";
            }
         else
            _iWidth = "1000";              
        }
        else{
            _iWidth = "480";
        }        
	 }
	 if(tMark){
	            if(_iWidth&&_oObj.width>400){    
	        	        if(_oObj.width > _iWidth){
	                        _oObj.width = _iWidth;      
	                    } 	                    
	                
	                setTimeout("resize()",1);
	            }
	        }	 
    	    
	        this.resize = function(){ 
	            if(_oObj.width > _iWidth){
	            _oObj.width = _iWidth;      
	            }
	        }
}
