// how to use
// initializing..
// <script language="JavaScript" type="text/javascript" src="/js/popup.js"></script>
// executing..
// <a href="#" onClick="popupWindow('/url',100,100);return false;";>popup</a>
// <input type=button onClick="popupWindow('ownpage.php?id=293472983047298347',100,100)">
function popupWindow(wndURL,wndWidth,wndHeight)
{
    if (document.all) var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers) var xMax = window.outerWidth, yMax = window.outerHeight;
        else var xMax = 640, yMax=480;

    var xOffset = (xMax - wndWidth)/2, yOffset = (yMax - wndHeight)/2;

    window.open(wndURL, 'popup_name','width='+wndWidth+',height='+wndHeight+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',copyhistory=no,directories=no, menubar=no,location=no,scrollbars=yes,resizable=no');
}


//--- resizes popup window to specified dimensions ---//
function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w+8;
    top.outerHeight=h+29;
   }
   else 
   {
    top.resizeTo(400,300);
    wd = 400-document.body.clientWidth;
    hd = 300-document.body.clientHeight;
    top.resizeTo(w+wd,h+hd);
   }
 }
}

function img_popup (image_path) {
var ph = window.open("", "popup_img", "location=0,toolbar=0,resize=0,status=0,scrollbars=0");
ph.document.write('<'+'!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'+'>');
ph.document.write('<'+'html'+'>');
ph.document.write('<'+'head'+'><'+'title'+'><'+'/title'+'>');
ph.document.write('<'+'style type="text/css"'+'>body { text-align: center; margin: 0px; padding: 0px; }<'+'/style'+'>');
ph.document.write('<'+'script language="javascript" type="text/javascript"'+'>');
ph.document.write('window.onload = function ()');
ph.document.write('{ var a_img = document.getElementById("auto_img");');
ph.document.write('var NS = (navigator.appName == "Netscape") ? true : false;');
ph.document.write(
'if (a_img && NS) '
+'{ window.resizeTo(a_img.width + window.outerWidth - window.innerWidth, '
+'a_img.height + window.outerHeight - window.innerHeight); }'
);
ph.document.write(
'else { '
+ 'var x_ = a_img.width - document.body.clientWidth;'
+ 'var y_ = a_img.height - document.body.clientHeight;'
+ 'window.resizeBy(x_, y_);'
+ '}}'
);
ph.document.write('<'+'/script'+'><'+'/head'+'>');
ph.document.write(
'<'+'body'+'><'+'img id="auto_img" '
+'src=' + image_path + ' '
+'border="0" align="center" /'+'><'+'/body'+'><'+'/html'+'>'
);
ph.document.close();
}

function resizeWindowByImgSize (param_img_id) {
    var a_img = document.getElementById(param_img_id);
    var NS = (navigator.appName == "Netscape") ? true : false;
    if (a_img && NS) {
        window.resizeTo(a_img.width + window.outerWidth - window.innerWidth, a_img.height + window.outerHeight - window.innerHeight);
    } else {
        var x_ = a_img.width - document.body.clientWidth;
        var y_ = a_img.height - document.body.clientHeight;
        window.resizeBy(x_, y_);
    }
}
