﻿//thumbnail pop-ups
var popbackground = "#000000" //specify backcolor or background image for pop window
var windowtitle = "James Sullivan | Gallery"  //pop window title

function detectexist(obj) {
    return (typeof obj != "undefined")
}

function popimage(imgpath, popwidth, popheight, textdescription) {

    function getpos() {
        leftpos = (detectexist(window.screenLeft)) ? screenLeft + document.body.clientWidth / 2 - popwidth / 2 : detectexist(window.screenX) ? screenX + innerWidth / 2 - popwidth / 2 : 0
        toppos = (detectexist(window.screenTop)) ? screenTop + document.body.clientHeight / 3 - popheight / 2 : detectexist(window.screenY) ? screenY + innerHeight / 2 - popheight / 2 : 0
        if (window.opera) {
            leftpos -= screenLeft
            toppos -= screenTop
        }
    }

    getpos()
    var winattributes = 'width=' + popwidth + ',height=' + popheight + ',resizable=yes,left=' + leftpos + ',top=' + toppos
    var bodyattribute = (popbackground.indexOf(".") != -1) ? 'background="' + popbackground + '"' : 'bgcolor="' + popbackground + '"'
    if (typeof popwin == "undefined" || popwin.closed)
        popwin = window.open("", "", winattributes)
    else {
        //getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
        //jkpopwin.moveTo(leftpos, toppos)
        popwin.resizeTo(popwidth, popheight + 30)
    }
    popwin.document.open()
    popwin.document.write('<html><title>' + windowtitle + '</title><body style="color:#ffffff;" ' + bodyattribute + '><center><img src="' + imgpath + '" style="margin-bottom: 2.5em;"><br />' + textdescription + '</center></body></html>')
    popwin.document.close()
    popwin.focus()
}

function wclose() {
    window.close()
}


// request form check

function chkfrm() {

    var nm = document.reqfrm.name.value
    if (nm == "") {
        alert("Please enter your name")
        document.reqfrm.name.focus()
        return;
    }
    var cm = document.reqfrm.phone.value
    if (cm == "") {
        alert("Please enter your phone Number")
        document.reqfrm.phone.focus()
        return;
    }
    
   document.reqfrm.submit()
}

// Reset Form
function resetfrm() {
    document.reqfrm.reset()
    document.reqfrm.name.focus()
}
