﻿function openwin(url)
        {
            top.window.open(url, "", "top=40,left=40,height=500,width=640,toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,status=0");
            return false;
        }
		
		
		function mOvr(src, clrOver) {
        if (!src.contains(event.fromElement)) {
            src.style.cursor = 'hand';
            src.bgColor = clrOver;
        }
    }
    function mOut(src, clrIn) {
        if (!src.contains(event.toElement)) {
            src.style.cursor = 'default';
            src.bgColor = clrIn;
        }
    }
	
	function mClk1(src, id) {
        window.location.href = src;
    }
	
	//创建xmlhttprequest对象
	var xmlHttpRequest = null;
	  function getXMLHttpRequest()
		{
			if(window.XMLHttpRequest)
			{
				return new XMLHttpRequest();
			}
			else if (window.ActiveXObject)
			{
				request = new ActiveXObject("Microsoft.XMLHTTP");
				
				if (!request)
				{
					request = new ActiveXObject("Msxml2.XMLHTTP");
				}
				
				return request;
			}

		}
		
		//去除字符串左端空格
                function LTrim(str)
				{
                    return str.replace(/^\s*/, '');
                }

                //去除字符串右端空格

               function RTrim(str) {
                      return str.replace(/\s*$/, '');
                }
				//去除字符串两端空格
                function Trim(str) 
				{
                     return LTrim(RTrim(str));
                }
				
				//是否为空值;
function IsEmpty(_str){
    var tmp_str = Trim(_str);
    return tmp_str.length == 0;
}
//是否有效的Email;
function IsMail(_str){
    var tmp_str = Trim(_str);
    var pattern = /^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$/;
    return pattern.test(tmp_str);
}
//是否有效的数字;
function IsNumber(_str){
    var tmp_str = Trim(_str);
    var pattern = /^[0-9]/;
    return pattern.test(tmp_str);
}
//是否有效的颜色值;
function IsColor(color){
    var temp=color;
    if (temp=="") return true;
    if (temp.length!=7) return false;
    return (temp.search(/\#[a-fA-F0-9]{6}/) != -1);
}
//是否有效的链接;
function IsURL(url){
    var sTemp;
    var b=true;
    sTemp=url.substring(0,7);
    sTemp=sTemp.toUpperCase();
    if ((sTemp!="HTTP://")||(url.length<10)){
        b=false;
    }
    return b;
}
//是否有效的手机号码;
function IsMobile(_str){
    var tmp_str = Trim(_str);
    var pattern = /13\d{9}/;
    return pattern.test(tmp_str);
}

function ResizeImage(imageid,limitWidth,limitHeight) 
        {     
            var image = new Image(); 
            image.src = imageid.src; 
             
            if(image.width <= 0 && image.height <= 0) return; 
             
            if(image.width/image.height >= limitWidth/limitHeight) 
            { 
                if(image.width > limitWidth) 
                { 
                    imageid.width = limitWidth; 
                    imageid.height = (image.height*limitWidth)/image.width; 
                } 
            } 
            else if(image.height > limitHeight) 
            { 
                    imageid.height = limitHeight; 
                    imageid.width = (image.width*limitHeight)/image.height;      
            } 
             
        }

        function InitImages() 
        { 
            var maxWidth = 300; 
            var maxHeight = 500; 
             
            var imgs = document.getElementsByTagName("img"); 
             
            for(var i=0; i < imgs.length; i++) 
            { 
                var img = imgs[i]; 
                
                if(img.width>maxWidth||img.height>maxHeight) 
                    ResizeImage(img, maxWidth, maxHeight); 
                if (img.parentElement.tagName != "A") 
                { 
                    img.onclick = function(){window.open(this.src);} 
                    img.style.cursor = "hand"; 
                } 
               
            } 
        }