﻿var popbackground="#5e5237"; //specify backcolor or background image for pop window
var windowtitle="الموقع الرسمى لأمانة نجران" ; //pop window title

function detectexist(obj)
{
    return (typeof obj !="undefined");
}


function jkpopimage(image,path,textdescription)
{
if(image != null & path == null)
{
    var imagePath = image.src;//'najranadmin/UserFiles'+ image.src.split('najranadmin/UserFiles')[1];
    function getpos(popwidth2,popheight2)
    {
        leftpos=(detectexist(window.screenLeft))? (screenLeft+document.body.clientWidth/2-popwidth2/2) -350 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth2/2 : 0;
        toppos=(detectexist(window.screenTop))? (screenTop+document.body.clientHeight/2-popheight2/2) + 300 : detectexist(window.screenY)? screenY+innerHeight/2-popheight2/2 : 0;
	if(leftpos < 0)
		leftpos =0;
	if(toppos < 0)
		toppos =0;
        if (window.opera)
        {
            leftpos-=screenLeft;
            toppos-=screenTop;
        }
    }
    var winattributes;
    getpos(image.width,image.height);
    winattributes='width='+image.width+',height='+image.height+',resizable=no,left='+leftpos+',top=0';
       
    var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"';
    if (typeof jkpopwin=="undefined" || jkpopwin.closed)
        jkpopwin=window.open("","",winattributes);
    else
    {
        //getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
        //jkpopwin.moveTo(leftpos, toppos)
        jkpopwin.resizeTo(image.width, image.height+30);
    }
    if(textdescription == null)
        textdescription="";
    
    jkpopwin.document.open();
    jkpopwin.document.write('<html>');
    jkpopwin.document.write('<head>');
    jkpopwin.document.write('<link rel="stylesheet" type="text/css" href="media/css/popup.css"/>');
    jkpopwin.document.write('<script>');
    jkpopwin.document.write('function closewindow(){window.close()}');
    
    jkpopwin.document.write(' var NS = (navigator.appName=="Netscape")?true:false; '+

                             'function FitPic()'+ 
                             '{'+ 
                               'iWidth = (NS)?window.innerWidth:document.body.clientWidth; '+
                               'iHeight = (NS)?window.innerHeight:document.body.clientHeight;'+ 
                               'iWidth = document.images[0].width - iWidth; '+
                               'iHeight = document.images[0].height - iHeight;'+ 
                               'window.resizeBy(iWidth+25, iHeight+28); '+
                               'self.focus();'+ 
                             '}'); 
    
    jkpopwin.document.write('</script>');
    jkpopwin.document.write('<title>'+windowtitle+'</title>');
    jkpopwin.document.write('</head>');
    jkpopwin.document.write('<body '+bodyattribute+' onload="FitPic();">'+
                               '<p align="center">'+
                                    '<a  href="javascript:;" onclick="closewindow();">'+
                                        '<img border="1" src="'+imagePath+'" style="border-color:#f2f4ed">'+
                                    '</a>'+
                                    '<span style="color:#f2f4ed;font-family:verdana;font-size:9px;font-weight:normal;padding-top:5px">'+
                                        '<br />'+
                                        textdescription+
                                    '</span>'+
                               '</p>'+
                             '</body>'+
                          '</html>');
    jkpopwin.document.close();
    jkpopwin.focus();
    }
    else
    {
         function getpos(popwidth2,popheight2)
        {
            leftpos=(detectexist(window.screenLeft))? (screenLeft+document.body.clientWidth/2-popwidth2/2) -350 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth2/2 : 0;
        toppos=(detectexist(window.screenTop))? (screenTop+document.body.clientHeight/2-popheight2/2) + 300 : detectexist(window.screenY)? screenY+innerHeight/2-popheight2/2 : 0;
            if(leftpos < 0)
		leftpos =0;
	if(toppos < 0)
		toppos =0;
            
            if (window.opera)
            {
                leftpos-=screenLeft;
                toppos-=screenTop;
            }
        }
        
        
        image = new Image();
        image.src = path;

        
        var winattributes;
            getpos(image.width,image.height);
            winattributes='width='+image.width+',height='+image.height+',resizable=no,left='+leftpos+',top=0';

        var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"';
        if (typeof jkpopwin=="undefined" || jkpopwin.closed)
            jkpopwin=window.open("","",winattributes);
        else
        {
            //getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
            //jkpopwin.moveTo(leftpos, toppos)
            jkpopwin.resizeTo(image.width, image.height+30);
        }
        jkpopwin.document.open();
        jkpopwin.document.write('<html>');
        jkpopwin.document.write('<head>');
        jkpopwin.document.write('<link rel="stylesheet" type="text/css" href="media/css/popup.css"/>');
        jkpopwin.document.write('<script>');
        jkpopwin.document.write('function closewindow(){window.close()}');
        
        jkpopwin.document.write(' var NS = (navigator.appName=="Netscape")?true:false; '+

                                 'function FitPic()'+ 
                                 '{'+ 
                                   'iWidth = (NS)?window.innerWidth:document.body.clientWidth; '+
                                   'iHeight = (NS)?window.innerHeight:document.body.clientHeight;'+ 
                                   'iWidth = document.images[0].width - iWidth; '+
                                   'iHeight = document.images[0].height - iHeight;'+ 
                                   'window.resizeBy(iWidth+25, iHeight+28); '+
                                   'self.focus();'+ 
                                 '}'); 
        
        jkpopwin.document.write('</script>');
        jkpopwin.document.write('<title>'+windowtitle+'</title>');
        jkpopwin.document.write('</head>');
        jkpopwin.document.write('<body '+bodyattribute+' onload="FitPic();">'+
                                   '<p align="center">'+
                                        '<a  href="javascript:;" onclick="closewindow();">'+
                                            '<img border="1" src="'+path+'" style="border-color:#f2f4ed">'+
                                        '</a>'+
                                        '<span style="color:#f2f4ed;font-family:verdana;font-size:9px;font-weight:normal;padding-top:5px">'+
                                            '<br />'+
                                            textdescription+
                                        '</span>'+
                                   '</p>'+
                                 '</body>'+
                              '</html>');
        jkpopwin.document.close();
        jkpopwin.focus();
    }
}