﻿if (window.addEventListener){
    window.addEventListener("load", centerImage, false)
    }
else if (window.attachEvent){
    window.attachEvent("onload", centerImage)
    }
else if (document.getElementById){
    window.onload=centerImage  
    }
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(centerImage);
window.onresize=centerImage;
function centerImage(){
    var screenWidth = 0;
    screenWidth = getWindowWidth();
    var imageHandle = new Image();
    imageHandle.onload = performAlignment;
    imageHandle.src = document.getElementById("ctl00_ContentPlaceHolder1_hfTitleImage").value;
    function performAlignment(){
        document.getElementById("ctl00_ContentPlaceHolder1_imgWindowTitle").style.marginLeft = ((screenWidth-imageHandle.width-30)/2)+"px";
    }
} 
function getWindowWidth(){
    var windowWidth = 0;
    if (window.innerWidth) {
        windowWidth = window.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientWidth) {
        windowWidth = document.documentElement.clientWidth;
    }
    else if (document.body.clientWidth) {
        windowWidth = document.body.clientWidth; 
    }
    return windowWidth;
}