/* userAgent=window.navigator.userAgent.toLowerCase();

if (
userAgent.indexOf('firefox') >= 1
){ alert("您使用的是火狐浏览器，浏览本站可能显示不完整或出错，推荐您使用IE浏览器");
	}*/
 
        lazyLoad = (function () {
            var map_element = {};
            var element_obj = [];
            var download_count = 0;
            var last_offset = -1;
            var doc_body;
            var doc_element;
            var lazy_load_tag;
            
            function initVar(tags) {
                doc_body = document.body;
                //判断是否为IE的"怪异模式"
                doc_element = document.compatMode == 'BackCompat' ? doc_body : document.documentElement;
                lazy_load_tag = tags || ["img", "iframe"];
            };

            function initElementMap() {
                //var all_element = [];
                //从所有相关元素中找出需要延时加载的元素  
                for (var i = 0, len = lazy_load_tag.length; i < len; i++) {
                    var el = document.getElementsByTagName(lazy_load_tag[i]);
                    for (var j = 0, len2 = el.length; j < len2; j++) {
                        if (typeof (el[j]) == "object" && el[j].getAttribute("lazy_src")) {
                            element_obj.push(el[j]);
                        }
                    }
                }
				

                for (var i = 0, len = element_obj.length; i < len; i++) {
                    var o_img = element_obj[i];
                    var t_index = getAbsoluteTop(o_img); //得到图片相对document的距上距离  
                    if (map_element[t_index]) {
                        map_element[t_index].push(i);
                    } else {
                        //按距上距离保存一个队列  
                        var t_array = [];
                        t_array[0] = i;
                        map_element[t_index] = t_array;
                        download_count++;
						 //需要延时加载的图片数量  
                    }
                }

            };

            function initDownloadListen() {
                if (!download_count) return;
              		var offset=0;		
if(document.body.scrollTop){
  offset=document.body.scrollTop;
}
else{
  offset=document.documentElement.scrollTop;
}

                //可视化区域的高=offtset+document的高  
                var visio_offset = offset + doc_element.clientHeight;
                if (last_offset == visio_offset) {
                    setTimeout(initDownloadListen, 200);//每隔0.2秒检测一次，这玩意儿感觉有些耗资源的
                    return;
                }
                last_offset = visio_offset;
                var visio_height = doc_element.clientHeight;
                var img_show_height = visio_height + offset;
                for (var key in map_element) {
                    if (img_show_height > key) {
                        var t_o = map_element[key];
                        var img_vl = t_o.length;
                        for (var l = 0; l < img_vl; l++) {
                            element_obj[t_o[l]].src = element_obj[t_o[l]].getAttribute("lazy_src");
                        }
                        delete map_element[key];
                        download_count--;
                    }
                }
                setTimeout(initDownloadListen, 200);
            };

            function getAbsoluteTop(element) {
                if (arguments.length != 1 || element == null) {
                    return null;
                }
                var offsetTop = element.offsetTop;
                while (element = element.offsetParent) {
                    offsetTop += element.offsetTop;
                }
                return offsetTop;
            }

            function init(tags) {
                initVar(tags);
                initElementMap();
                initDownloadListen();
            };

            return {
                init: init
            }
        })();




/**flash广告**/
function swf(Flash,Width,Height){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://www.macrolist.com/swflash.cab#version=9,0,0,0" width="' + Width +' " height="' + Height + ' "><param name="movie" value="' + Flash + '" /><param name="quality" value="high" /><param name="menu" value="false"/><param name="wmode" value="opaque" />'); 
document.write('<embed src="' + Flash + '" wmode="opaque" quality="high" menu="false" pluginspage=http://www.macromedia.com/go/getflashplayer type="application/x-shockwave-flash" width="' + Width + '" height="' + Height + '"></embed>'); 
document.write('</object>'); 
}


/**菜单轮换**/
function Show_Tabs(tab_name,tab_index,tab_count)
{	
	for(var i=1;i<tab_count+1;i++)
		{
			document.getElementById(tab_name+"_"+i).style.display="none";
			document.getElementById(tab_name+"_menu_"+i).className="";
		}
	document.getElementById(tab_name+"_"+tab_index).style.display="block";
	document.getElementById(tab_name+"_menu_"+tab_index).className="current";
}
 


	function openwindows(htmlurl,width,height) {
 window.open(htmlurl,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=2,left=20,width='+width+',height='+height+'');
return false;}


//图片等比例缩小显示
//参数：imgID（图片的标识ID）
//参数：maxWidth（图片的最大宽度，值为0则表示不限制宽度）
//参数：maxHeight（图片的最大高度，值为0则表示不限制高度）

function ReSizeImg(Img,width,height,mod)
{
    var image=new Image(); 
    image.src=Img.src; 
    //width=236;//预先设置的所期望的宽的值
    //height=170;//预先设置的所期望的高的值
    if(image.width>width||image.height>height)    //现有图片只有宽或高超了预设值就进行js控制
    {
        w=image.width/width;
        h=image.height/height;
        if(w<h)
        {
            //比值比较大==>宽比高大
            //定下宽度为width的宽度
            Img.width=width;
            //以下为计算高度
            Img.height=image.height/w;
        }
        else
        {
            //高比宽大
            //定下宽度为height高度
            Img.height=height;
            //以下为计算高度
            Img.width=image.width/h;
        }
    }
}
function ReSizeImg2(Img,width,height,mod)
{
    var image=new Image(); 
    image.src=Img.src; 

    if(image.width>width||image.height>height)   
    {
        w=image.width/width;
        h=image.height/height;
        if(w>h)
        {
            Img.width=width;
            Img.height=image.height/w;
        }
        else
        {
            Img.height=height;
            Img.width=image.width/h;
        }
    }
}



