var dragapproved=false;
var minrestore=0;
var thepopuptop=0;
var thepopupleft=0;
var initialwidth,initialheight;
var ie5=document.all&&document.getElementById;
var ns6=document.getElementById&&!document.all;
var the_popupobj,the_maxminobj,the_contentobj;
function iecompattest(){
    return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function drag_drop(e){
    if(document.getElementById("popupAds"))
    {
        the_popupobj=document.getElementById("popupAds");
    }
    if (ie5&&dragapproved&&event.button==1){
        the_popupobj.style.left=tempx+event.clientX-offsetx+"px";
        the_popupobj.style.top=tempy+event.clientY-offsety+"px";
    }
    else if (ns6&&dragapproved){
        the_popupobj.style.left=tempx+e.clientX-offsetx+"px";
        the_popupobj.style.top=tempy+e.clientY-offsety+"px";
    }
}
function initializedrag(e){
    if(document.getElementById("popupAds"))
    {
        the_popupobj=document.getElementById("popupAds");
    }
    if(document.getElementById("popupMain"))
    {
        the_contentobj=document.getElementById("popupMain");
    }
    offsetx=ie5? event.clientX : e.clientX;
    offsety=ie5? event.clientY : e.clientY;
    tempx=parseInt(the_popupobj.style.left);
    tempy=parseInt(the_popupobj.style.top);
    dragapproved=true;
    the_popupobj.onmousemove=drag_drop;
}
function loadwindow(width,height){
    if(document.getElementById("popupAds"))
    {
        the_popupobj=document.getElementById("popupAds");
    }
    if (!ie5&&!ns6)
    {
    }
    else{
        the_popupobj.style.display='';
        the_popupobj.style.width=initialwidth=width+"px";
        the_popupobj.style.height=initialheight=height+"px";
        the_popupobj.style.left=thepopupleft+"px";
        the_popupobj.style.top=ns6? window.pageYOffset*1+thepopuptop+"px" : iecompattest().scrollTop*1+thepopuptop+"px";
    }
}
function maximize(){
    if(document.getElementById("popupAds"))
    {
        the_popupobj=document.getElementById("popupAds");
    }
    if(document.getElementById("popup_maxmin"))
    {
        the_maxminobj=document.getElementById("popup_maxmin");
    }
    if (minrestore==0){
        minrestore=1;
        the_maxminobj.setAttribute("src","/images/boxmin.jpg");
        the_popupobj.style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px";
        the_popupobj.style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px";
    }
    else{
        minrestore=0;
        the_maxminobj.setAttribute("src","/images/barresume.jpg");
        the_popupobj.style.width=initialwidth;
        the_popupobj.style.height=initialheight;
    }
    the_popupobj.style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px";
    the_popupobj.style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px";
}
function closeit(){
    if(document.getElementById("popupAds"))
    {
        the_popupobj=document.getElementById("popupAds");
    }
    the_popupobj.style.display="none";
}
function stopdrag(){
    if(document.getElementById("popupAds"))
    {
        the_popupobj=document.getElementById("popupAds");
    }
    if(document.getElementById("popupMain"))
    {
        the_contentobj=document.getElementById("popupMain");
    }
    dragapproved=false;
    the_popupobj.onmousemove=null;
    the_contentobj.style.display="";
}