﻿width=screen.availWidth; 
height=screen.availHeight; 
window.moveTo(0,0); 
window.resizeTo(width,height);  

function PictureError(img)
{
   img.src=img.getAttribute("sm");
   img.setAttribute("onerror","");
   img.setAttribute("onload","");
   var id = img.getAttribute("aid");
   var action = 1; //具体含义看后台代码
   var success = 0; 
   PostAction(action,id,success); 
   ViewAd(); 
}

function PictureLoad(img)
{
   
    var height =img.getAttribute("h");
    var width =img.getAttribute("w");
    var sm = img.getAttribute("sm");
    var action = 1; 
    var success = 1;
    var id = img.getAttribute("aid"); 
    if( (Math.abs(height - img.height)>5 || Math.abs(width -img.width)>5) )
    {
        img.src=img.getAttribute("sm");
        img.setAttribute("onerror","");
        img.setAttribute("onload","");           
        success = 0;
        ViewAd();               
    } 
    PostAction(action,id,success); 
    ResizeImage(img,716);

}
function ViewAd()
{
    var divImg =  window.document.getElementById("divImg");
    if(divImg!=null)
    {
//        var next = divImg.nextSibling;
//        var parent= divImg.parentNode;
//        var newNode= document.createElement('div');
//        newNode.style.marginBottom='20px';
//        newNode.innerHTML='';
//        parent.insertBefore(newNode,next);
       
    }
}
function PostAction(action,id,success)
{
    if(action==1)
    {
　　    try
	    {
	        var xmlhttp = new GetXmlHttp(); 
　　        var request_Page="/tool/Action.ashx?action="+action+"&id="+id+"&success="+success;
　　        xmlhttp.open("POST", request_Page, false);
     	
	        xmlhttp.send();   
            //var retVal = xmlhttp.responseText;
            //alert(retVal);
    
	    }
	    catch(e)
	    {
	    }
	}
}

function GetXmlHttp()
{
    var http_request;
    if (window.XMLHttpRequest)
    {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
        {
            http_request.overrideMimeType("text/xml");
        }
    }
    else if (window.ActiveXObject)
    {
        try
        {
            http_request = new ActiveXObject("Mscml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(ex)
            {}
        }
    }
//    if(!http_request){
//        window.alert("Your broswer not support XMLHttpRequest!");
//    }
    return http_request;
}

 
function ResizeImage(img,width)
{  
    if(img.width>width)
    {
        var o=new Image();  
        o.src=img.src;  
        img.width=width;  
        img.height=(o.height*width)/o.width;    
    }
} 


function ViewComplete(id)
{
    var img = document.getElementById(id);
    window.open(img.src);
}

function SendQQE()
{
    document.location = "http://mail.qq.com/cgi-bin/feed?u=http://www.mm62.com/rss.xml";
}
function SendQQBM()
{
    wopen('http://shuqian.qq.com/post?from=3&title='+title2+'&uri='+url+'&jumpback=2&noui=1');
}
