// JavaScript Document
function addOnloadEvent(fnc){if ( typeof window.addEventListener != "undefined" )window.addEventListener( "load", fnc, false );else if ( typeof window.attachEvent != "undefined" ) {window.attachEvent( "onload", fnc );} else {if ( window.onload != null ) {var oldOnload = window.onload;window.onload = function ( e ) {oldOnload( e );window[fnc]();};} elsewindow.onload = fnc;}}
function setadhtml(obj,str){if(document.getElementById(obj)){document.getElementById(obj).innerHTML=str;}}
function open_ad(url,target,fun) {
	Mask="<img src=http://www.chinamendu.com/images/loading.gif>内容载入中";
 	var link;
	if (!document.getElementById) return false; 	
	if (window.ActiveXObject) {
  		link = new ActiveXObject("Microsoft.XMLHTTP");
 	} else if (window.XMLHttpRequest) link = new XMLHttpRequest();

 	if (link == undefined) return false;

 	link.onreadystatechange = function() { open_ad_response(link, url, target,fun); }
 	link.open("GET", url, true);
 	link.send(null);
}
function open_ad_response(link, url, target,fun) {
	if (link.readyState < 4) {
		Mask="<img src=http://www.chinamendu.com//images/loading.gif>内容载入中";
		document.getElementById(target).innerHTML =Mask;
		fun;
		//"<div class='pageload'><ul class='winNote f14'><li class='iLoad'>&nbsp;</li><li class='left'><ul><li>数据传输中...</li></ul></li></ul><ul class='winBtn'><li class='txtRig'></li></ul></div>";
	} else {
		if(link.status == 200){
			document.getElementById(target).innerHTML=link.responseText;
		}
		/*else{
		document.getElementById(target).innerHTML= "服务器错误，错误代码: " + link.status+"<br>"+link.responseText ;
		}*/
		loadErr=null;
		link=null;
		Mask=null;
		delete loadErr ; 
		delete link ; 

	}
}
function bookmark(title, url) {
  if (document.all)
    window.external.AddFavorite(url, title);
  else if (window.sidebar)
    window.sidebar.addPanel(title, url, "")
}
function SetHome(obj,vrl){
         try{
                 obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
         }
         catch(e){
                 if(window.netscape) {
                         try {
                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
                         }  
                        catch (e) 
  { 
                                 alert("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”，点击“加入收藏”后忽略安全提示，即可设置成功。");  
                         }
                         var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                  }
         }
}

function checkurl(aid,ty){
	var httpRequest1=new HttpRequest();
		with(httpRequest1){
			init();
			doSendResuest("/checkurl.asp?ID="+aid+"&ty="+ty,"GET",httpRequest1);
	}	
}
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    var image=new Image();
  //  var iwidth = 85;  //定义允许图片宽度
  //  var iheight = 85;  //定义允许图片高度
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
		
    if(image.width/image.height>= iwidth/iheight){
        if(image.width>iwidth){  
					ImgD.width=iwidth;
					ImgD.height=(image.height*iwidth)/image.width;
        }else{
					ImgD.width=image.width;  
					ImgD.height=image.height;
        }
					ImgD.alt=image.width+"×"+image.height;
        }
    else{
        if(image.height>iheight){  
					ImgD.height=iheight;
					ImgD.width=(image.width*iheight)/image.height;  
        }else{
					ImgD.width=image.width;  
					ImgD.height=image.height;
				
        }
				
        }
				if (ImgD.height<iheight){ImgD.style.marginTop=((iheight-ImgD.height)/2)+"px";}
    }
} 
/* 点击选中表单li */
function chk_iddiv(id,obj){
	var iNumChecked;
	iNumChecked=0
	var objc=document.getElementById(id);
	var obj=document.getElementById(obj);
	var box=document.getElementsByName("brandcheckbox");
	var leng=box.length;
	for (i=0;i<leng;i++){
		if(box.item(i).checked==true){
		iNumChecked++;
		}
	}

	if (objc.checked==false){
		if (iNumChecked==5){alert("您最多同时可以为5个品牌投票！"); return false}
		objc.checked=true;
		obj.style.backgroundColor="#ffb";
	}else{
		objc.checked=false;
		obj.style.backgroundColor="#f0f0f0";
	}
}

