﻿// JScript File

var QS = GetParameters();

var myimages=new Array();
		
function preloadimages(){
    for (i = 0; i < preloadimages.arguments.length; i++){
        myimages[i] = new Image();
        myimages[i].src = preloadimages.arguments[i];
    }
}

function CreateXmlHttpRequest() {
    var XmlHttp = null;
    try {
        XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
        try {
	        XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch(oc) {
	        XmlHttp = null;
        }
    }
    if(!XmlHttp && typeof XMLHttpRequest != "undefined") {
        XmlHttp = new XMLHttpRequest();
    }
    return XmlHttp;
}

function clearDate(objCtrl) {
    objCtrl.value = "";
    objCtrl.style.backgroundColor = "#fff";
}

function format_MMDDYYYY(sDate) {
    if ((sDate != null) && (sDate != "")) {
        var objDate = sDate.split("/");
        if (objDate.length == 3) sDate = objDate[1] + "/" + objDate[0] + "/" + objDate[2];
        return sDate;
    }
    else return "";
}

function trim(sString) {
    if (sString != null) {
        while (sString.substring(0,1) == ' ')
            sString = sString.substring(1, sString.length);
        while (sString.substring(sString.length-1, sString.length) == ' ')
            sString = sString.substring(0,sString.length-1);
        return sString;
    }
    else {
        return "";
    }
}

function innerTrim(sString) {
    if (sString != null) {
        while (sString.indexOf(" ") != -1) {
            sString = sString.replace(" ", "");
        }
        return sString;
    }
    else {
        return "";
    }
}

function lCase(sString) {return (sString != null) ? sString.toLowerCase() : "";}

function IsCharsInBag(sString, sBag) {
    var i;
    var c;
    for (i = 0; i < sString.length; i++) {
        c = sString.substring(i, (i + 1));
        if (sBag.indexOf(c) == -1)
            return false;
    }
    return true;
}

function GetParameters() {
	var arg = new Object();
	var href = document.location.href;
	if ( href.indexOf( "?") != -1) {
		var params = href.split( "?")[1];
		var param = params.split("&");
		for (var i = 0; i < param.length; ++i) {
			var name = param[i].split( "=")[0];
			var value = param[i].split( "=")[1];
			arg[name] = value;
		}
	}
	return arg;
}

String.prototype.count = function(s1) { 
	return (this.length - this.replace(new RegExp(s1, "g"), '').length) / s1.length;
}

String.prototype.reverse = function(){
    splitext = this.split("");
    revertext = splitext.reverse();
    reversed = revertext.join("");
    return reversed;
}


function onlyNumbers(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if ((charCode > 47 && charCode < 58) || (charCode == 46) || (charCode == 8) || (charCode == 0))
        return true;
    else
        return false;
}

function onlyNumberswithSpace(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if ((charCode > 47 && charCode < 58) || (charCode == 46) || (charCode == 8) || (charCode == 0) || (charCode == 32))
        return true;
    else
        return false;
}

function onlyPhoneNumbers(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if ((charCode > 47 && charCode < 58) || (charCode == 32) || (charCode == 43) || (charCode == 44) || (charCode == 45) || (charCode == 8) || (charCode == 0))
        return true;
    else
        return false;
}

function onlyPincode(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if ((charCode > 47 && charCode < 58) || (charCode == 32) || (charCode == 0))
        return true;
    else
        return false;
}
 
function DateOnly(obj, evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if ((charCode == 0) || (charCode > 47 && charCode <= 57) || (charCode == 13))
        return true;
    else if (charCode == 47) {
        if (((obj.value.lastIndexOf("/") != (obj.value.length - 1))) && (obj.value.count("/") < 2))
            return true;
    }
    return false;
}

function NoEnter(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if (charCode == 13)
        return false;
    return true;
}
 
function NoKeyPress(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if (charCode >= 0)
        return false;
    return true;
}

function AlphabetsOnly(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if ((charCode == 8) || (charCode == 32) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) || (charCode == 46)) 
        return true;  
    else
        return false;
}

function NoSpecialChar(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if ((charCode == 0) || (charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) || (charCode == 45) || (charCode == 95) || (charCode == 8) || (charCode == 32) || (charCode == 44) || (charCode == 46)) 
        return true;  
    else
        return false;
}

function OnlyEmail(obj, evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if ((charCode == 0) || (charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) || (charCode == 45) || (charCode == 95) || (charCode == 8)) {
        return true; 
    }
    else if (charCode == 46) {
        if (obj.value.lastIndexOf(".") != (obj.value.length - 1))
            return true;
    }
    else if (charCode == 64) {
        if (obj.value.indexOf("@") == -1)
            return true;
    }
    return false;
}

function checkEmail(strEmail){
    var filter = /^.+@.+\..{2,3}$/;
    if (filter.test(strEmail))
        return true;
    else 
        return false
}

function isInt(aNum) {
	strNo = "0123456789"
	for(var i=0;i<aNum.length;i++) {
	    if(strNo.indexOf(aNum.charAt(i)) == -1)
	        return false;
	}
    return true;
}

function isValidDate(strDate) {
	if (strDate.indexOf("-")!=-1) 
		return false;
	else 
		var sdate = strDate.split("/")
	if(sdate.length != 3) 
 		return false;
    if(!isInt(sdate[0]) || !isInt( sdate[1]) || !isInt( sdate[2])) 
		return false;
    if (sdate[2].length == 3 || sdate[2].length > 4  || sdate[2].length == 1) 
		return false;
	if(1*sdate[2]<50 ) {
		sdate[2] = "20"+sdate[2]
		strDate = sdate.join("/")
	}
	var tmpDate = sdate[0] + "/" + sdate[1] + "/" + sdate[2]
    var chkDate = new Date(Date.parse(tmpDate))
    var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+(sdate[2])
	var newDate=(1*sdate[0])+"/"+(1*sdate[1])+"/"+(sdate[2])
	if ((""+newDate)!= (""+cmpDate) || isNaN(chkDate)) 
		return false;
	return true;
}

function SelectMenu(iMenuIndex) {
    if ($("#MainMenu")[0] != null) {
        var i = 1;
        $("#MainMenu >ul>li").each(function(){
            if (i == iMenuIndex) {
                $("a", this)[0].style.backgroundPosition = "0 -52px";
            }
            i++;
        });
    }
}

function SelectMySfMenu(iMenuIndex) {
    if (typeof(iMenuIndex) != "undefined") {
        if (iMenuIndex != 0) {
            var sMenu = document.getElementById("Menu" + iMenuIndex);
            sMenu.style.backgroundPosition = "0 -26px";
        }
    }
}

function setTextArea_MaxLength() {
    var x = document.getElementsByTagName('textarea');
    var counter = document.createElement('div');
    for (var i=0;i<x.length;i++) {
        if (x[i].getAttribute('maxlength')) {
            var counterClone = counter.cloneNode(true);
            counterClone.relatedElement = x[i];
            counterClone.innerHTML = "(<span>" + x[i].getAttribute('maxlength') + "</span> Characters left)";
            x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
            x[i].relatedElement = counterClone.getElementsByTagName('span')[0];
            x[i].onkeyup = x[i].onkeydown = TestArea_CheckLength;
            x[i].onkeypress = TestArea_MaxLength;
            x[i].onkeyup();
        }
    }
}

function TestArea_MaxLength() {
    if (this.value.length == this.getAttribute('maxlength'))
        return false;
    else
        return true;
}

function TestArea_CheckLength() {
    if (this.value.length > this.getAttribute('maxlength')) 
        this.value = this.value.substring(0, this.getAttribute('maxlength'));
    this.relatedElement.firstChild.nodeValue = this.getAttribute('maxlength') - this.value.length;
}

function getElement(aID) {
    return (document.getElementById) ? document.getElementById(aID) : document.all[aID];
}

function setFrameHeight(frmContent) {
    frmContent.height = "0px";
    var frmContentDoc = null;
    if (frmContent.contentDocument)
        frmContentDoc = frmContent.contentDocument;
    else
        frmContentDoc = document.frames[frmContent.getAttribute("id")].document;
    frmContent.height = frmContentDoc.body.offsetHeight;
}

function GenerateCaptcha() {
    var CaptchaImage = document.getElementById("CaptchaImage");
    CaptchaImage.src = "/CaptchaImage/JpegImage.aspx";
    CaptchaImage.width = 200;
    CaptchaImage.height = 50;
    return false;
}

function changeBGClr(sFlag, objCtrl) {
    if (trim(sFlag.toLowerCase()) == "on") {
        objCtrl.style.backgroundColor = "#EDF1FA";
    }
    else if (trim(sFlag.toLowerCase()) == "off") {
        objCtrl.style.backgroundColor = "#FFF";
    }
}

function SearchKeyword() {
    var sKey = trim(document.getElementById("SearchText").value)
    if (sKey != "") {
        setCookie("SearchPageIndex", 0, 1);
        window.top.location = "/search/search.aspx?skey=" + sKey;
    }
    else {
        alert("Please enter your keyword to begin search.");   
    }
}

function SearchKeyPress(evt) {
    var charCode = evt.which;
    if (typeof(charCode) == "undefined") charCode = evt.keyCode;
    if (charCode == 13) {
        SearchKeyword();
        return false;
    }
}

function setCookie(c_name, value, expiredays) {    
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function getCookie(c_name) {
    if (document.cookie.length>0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        }
    }
    return "";
}

function showLoading(bFlag) {
    var imgContainerId = "divLoading"
    var imgContainer = document.getElementById(imgContainerId);
    var AjaxContainer = document.getElementById("AjaxContainer");
    if (imgContainer == null && bFlag && AjaxContainer != null) {
        var ImgURL = "/uiimages/loading.gif";
        var imgLoading = new Image(); 
        imgLoading.src = ImgURL;
        imgContainer = document.createElement("div");
        imgContainer.id = imgContainerId;
        imgContainer.innerHTML = "<img src='" + ImgURL + "' alt=''>";
        imgContainer.style.position = "absolute";
        imgContainer.style.width = imgLoading.width + "px";
        imgContainer.style.height = imgLoading.height + "px";
        imgContainer.style.zIndex = 999;
        AjaxContainer.appendChild(imgContainer);
    }
    if (imgContainer != null && AjaxContainer != null) {
        if (bFlag) {
            $(imgContainer).css("top", $(window).scrollTop() + (($(window).height() / 2) - ($(imgContainer).height() / 2)) + "px");
            $(imgContainer).css("left", $(window).scrollLeft() + (($(window).width() / 2) - ($(imgContainer).width() / 2)) + "px");
            $(window).scroll(function() {
                $(imgContainer).animate({top:$(window).scrollTop() + (($(window).height() / 2) - ($(imgContainer).height() / 2)) + "px" },{queue: false, duration: 350});
            });
        }
        else { 
            AjaxContainer.removeChild(imgContainer);
        }
    }
}

function showWait(bFlag) {
    var imgContainerId = "divWait"
    var imgContainer = document.getElementById(imgContainerId);
    var AjaxContainer = document.getElementById("AjaxContainer");
    if (imgContainer == null && bFlag && AjaxContainer != null) {
        var ImgURL = "/uiimages/wait.gif";
        var imgLoading = new Image(); 
        imgLoading.src = ImgURL;
        imgContainer = document.createElement("div");
        imgContainer.id = imgContainerId;
        imgContainer.innerHTML = "<img src='" + ImgURL + "' alt='' />";
        imgContainer.style.position = "absolute";
        imgContainer.style.width = imgLoading.width + "px";
        imgContainer.style.height = imgLoading.height + "px";
        imgContainer.style.zIndex = 999;
        AjaxContainer.appendChild(imgContainer);
    }
    if (imgContainer != null && AjaxContainer != null) {
        if (bFlag) {
            $(imgContainer).css("top", $(window).scrollTop() + (($(window).height() / 2) - ($(imgContainer).height() / 2)) + "px");
            $(imgContainer).css("left", $(window).scrollLeft() + (($(window).width() / 2) - ($(imgContainer).width() / 2)) + "px");
            $(window).scroll(function() {
                $(imgContainer).animate({top:$(window).scrollTop() + (($(window).height() / 2) - ($(imgContainer).height() / 2)) + "px" },{queue: false, duration: 350});
            });
        }
        else { 
            AjaxContainer.removeChild(imgContainer);
        }
    }
}

function setHighlight(name) {
    $(".WhatsHappening .Highlight").removeClass("Highlight");
    if (trim(name) == "" && trim(location.hash) != "") name = location.hash;
    if (trim(name) != "") {
        location.hash = name;
        $(name).addClass("Highlight");
    }
}

function setPageInfo(ModuleName, PageName) {
    if ($(".PageInfo")[0] != null && $(".ModuleName")[0] != null && $(".PageName")[0] != null) {
        if ((trim(ModuleName) != "" || trim(PageName) != "")) {
            $(".PageInfo")[0].style.padding = "5px";
            $(".PageInfo")[0].style.paddingBottom = "0px";
            $(".PageInfo")[0].childNodes[0].innerHTML = "You are in : ";
            if (trim(ModuleName) != "") {
                ModuleName = ModuleName.split("|");
                for (var i = 0; i < ModuleName.length; i++) {
                    $(".ModuleName")[0].innerHTML += (trim($(".ModuleName")[0].innerHTML) == "" ? "" : "&nbsp;|&nbsp;") + ModuleName[i];
                }
                $(".ModuleName")[0].innerHTML += trim(PageName) != "" ? "&nbsp;|&nbsp;" : "";
            }
            $(".PageName")[0].innerHTML = PageName;
        }
    }
}

var HMenu = {
    hideFlag : true, 
    transition : {overtime:300, outtime:300}, 
    showhidedelay : {showdelay: 100, hidedelay: 200}, 
    Initiate : function(setting){
	    jQuery(document).ready(function($){ 
	        var $mainmenu = $("#" + setting.mainmenuid + ">ul");
	        $mainmenu.parent().get(0).className = setting.classname || "HMenu"
    	    
	        var $headers = $mainmenu.find("ul").parent()
	        $headers.hover(
		        function(e){
			        $(this).children('a:eq(0)').addClass('selected')
		        },
		        function(e){
			        $(this).children('a:eq(0)').removeClass('selected')
		        }
	        )
    	    
	        $headers.each(function(i){ 
	            var izIndex = 200;
	            var $curobj = $(this).css({zIndex : izIndex-i}) 
		        var $subul = $(this).find('ul:eq(0)').css({display : 'block'})
		        $subul.data('timers', {})
		        this._dimensions = {w : this.offsetWidth, h : this.offsetHeight, subulw : $subul.outerWidth(), subulh : $subul.outerHeight()}
		        this.istopheader = $curobj.parents("ul").length == 1 ? true : false 
		        $subul.css({display : this.istopheader ? 'block' : 'none', top : this.istopheader ? this._dimensions.h + "px" : 5 + "px", left : this.istopheader ? "0px" : this._dimensions.w - 15 + "px"})
		        $curobj.hover(
			        function(e){
				        var $targetul = $subul 
				        var header = $curobj.get(0) 
				        clearTimeout($targetul.data('timers').hidetimer)
				        $targetul.data('timers').showtimer = setTimeout(function() {
				            header._offsets = {left : $curobj.offset().left, top : $curobj.offset().top}
					        var menuleft = header.istopheader ? 0 : header._dimensions.w - 15
					        menuleft = (header._offsets.left + menuleft + header._dimensions.subulw > $(window).width()) ? (header.istopheader ? -header._dimensions.subulw + header._dimensions.w : -header._dimensions.w) : menuleft 
					        if ($targetul.queue().length <= 1) { 
						        $targetul.css({left : menuleft + "px", width : header._dimensions.subulw + 'px'}).animate({height : 'show', opacity : 'show'}, HMenu.transition.overtime)
					        }
				        }, HMenu.showhidedelay.showdelay)
			        },
			        function(e){
			            if (HMenu.hideFlag) {
				            var $targetul = $subul
				            var header = $curobj.get(0)
				            clearTimeout($targetul.data('timers').showtimer)
				            $targetul.data('timers').hidetimer = setTimeout(function(){
					            $targetul.animate({height : 'hide', opacity : 'hide'}, HMenu.transition.outtime)
				            }, HMenu.showhidedelay.hidedelay)
				        }
			        }
		        ) 
	        }) 
	        $mainmenu.find("ul").css({display:'none', visibility:'visible'})
	    })
    }
} 

var VMenu = {
    transition : {overtime:300, outtime:300}, 
    showhidedelay : {showdelay: 100, hidedelay: 200}, 
    Initiate : function(setting){
        jQuery(document).ready(function($){ 
            setting.orientation = 'v'
	        var $mainmenu = $("#" + setting.mainmenuid + ">ul");
	        $(">li:last", $mainmenu).css({marginBottom : "5px"});
	        if ($mainmenu[0] != null) {
	            $mainmenu.parent().get(0).className = setting.classname || "VMenu"
	            $(">LI:last", $mainmenu)[0].style.borderBottom = "0px";
	            var $headers = $mainmenu.find("ul").parent()
	            $headers.hover(
		            function(e){$(this).children('a:eq(0)').addClass('select')},
		            function(e){$(this).children('a:eq(0)').removeClass('select')}
	            )
	            $headers.each(function(i){ 
	                var izIndex = 100;
	                var $curobj = $(this).css({zIndex : izIndex-i}) 
	                $mainmenu.each(function() {
	                    if ($(this)[0] == $curobj.parent()[0]) {
	                        $(this).css({zIndex : izIndex-i})
	                    }
	                });
		            var $subul = $(this).find('ul:eq(0)').css({display : 'block'})
		            $subul.data('timers', {})
		            this._dimensions = {w : this.offsetWidth, h : this.offsetHeight, subulw : $subul.outerWidth(), subulh : $subul.outerHeight()}
		            this.istopheader = $curobj.parents("ul").length == 1 ? true : false 
		            $subul.css({top : (this.istopheader && setting.orientation != 'v'? (this._dimensions.h) : 0) + 8 + "px"})
		            $(">LI:last", $subul)[0].style.borderBottom = "0px";
		            $curobj.hover(
			            function(e){
				            var $targetul = $subul  
				            var header = $curobj.get(0) 
				            clearTimeout($targetul.data('timers').hidetimer)
				            $targetul.data('timers').showtimer = setTimeout(function() {
					            header._offsets = {left : $curobj.offset().left, top : $curobj.offset().top}
					            var menuleft = header.istopheader && setting.orientation != 'v' ? 0 : header._dimensions.w
					            menuleft = (header._offsets.left + menuleft + header._dimensions.subulw > $(window).width()) ? (header.istopheader && setting.orientation != 'v' ? -header._dimensions.subulw + header._dimensions.w : -header._dimensions.w) : menuleft 
					            if ($targetul.queue().length <= 1) { 
						            $targetul.css({left : menuleft - 40 + "px", width : header._dimensions.subulw + 'px'}).animate({height : 'show', opacity : 'show'}, VMenu.transition.overtime)
					            }
				            }, VMenu.showhidedelay.showdelay)
				            if ($("#calendar-container")[0] != null) {
				                $("#calendar-container .calendar").css("z-index", "-1");
				            }
			            },
			            function(e){
				            var $targetul = $subul
				            var header = $curobj.get(0)
				            clearTimeout($targetul.data('timers').showtimer)
				            $targetul.data('timers').hidetimer = setTimeout(function(){
					            $targetul.animate({height : 'hide', opacity : 'hide'}, VMenu.transition.outtime)
				            }, VMenu.showhidedelay.hidedelay)
				            if ($("#calendar-container")[0] != null) {
				                $("#calendar-container .calendar").css("z-index", "1");
				            }
			            }
		            ) 
	            }) 
	            $mainmenu.find("ul").css({display:'none', visibility:'visible'})
	        }
	        $("a", $mainmenu).each(function() {
	            var Bookmark = "";
	            if (trim($(this)[0].href.toLowerCase()).indexOf("#") != -1) {
	                var BookMarks = window.location.href.split("#");
	                Bookmark = ("#" + BookMarks[BookMarks.length - 1]).toLowerCase();
	                $(this)[0].onclick = function() {
	                    $(".VMenu A").removeClass('selected');
	                    $(this).parents("LI").children("A").addClass('selected');
	                }
	            }
	            if (trim($(this)[0].href.toLowerCase()).indexOf(trim(window.location.pathname.toLowerCase())) != -1 && trim($(this)[0].href.toLowerCase()).indexOf(Bookmark) != -1) {
                    $(this).parents("LI").children("A").addClass('selected');
                }
            });
	    })
    }
} 

function showPrivacyPolicy() {
    showWait(true);
    $.ajax({
        url: "/mysf/privacypolicy.html?rnd=" + Math.random(),
        context: document.body,
        success: function(objResponse){
            showWait(false);
            showPopup("Privacy Policy", objResponse, "");
        }
    });
}

function showTellus() {
    showWait(true);
    $.ajax({
        url: "/tellusabout/tellusabout.aspx",
        context: document.body,
        success: function(objResponse){
            showWait(false);
            showPopup("Tell us", objResponse, "");
        }
    });
}

function showUserLicenseAgreement() {
    showWait(true);
    $.ajax({
        url: "/mysf/userlicenseagreement.html?rnd=" + Math.random(),
        context: document.body,
        success: function(objResponse){
            showWait(false);
            showPopup("User License Agreement", objResponse, "");
        }
    });
}

function openPressImage(sImageFileName, iYear) {
    var sImagePath = "/app_documents/images/newsroom/" + iYear + "/" + sImageFileName;
    openImage(sImagePath, "News Room");
}


function openKutcheriImage(sImageFileName, iYear) {
    var sImagePath = "/app_documents/images/kutcheri/" + iYear + "/" + sImageFileName;
    openImage(sImagePath, "Kutcheri Coverage");   
}

function openWeekendImage(sImageFileName, iYear) {
    var sImagePath = "/app_documents/images/weekend/" + iYear + "/" + sImageFileName;
    openImage(sImagePath, "Weekend Coverage");
}


function openVideo(sVideoPath, iWidth, iHeight, sTitle) {
    showPopup(sTitle, "<embed id=\"objVideo\" src=\"" + sVideoPath + "\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"false\" width=\"" + iWidth + "\" height=\"" + iHeight + "\"></embed>", "closeVideo()");
}

function closeVideo() {
    var objVideo = document.getElementById("objVideo");
    if (navigator.appName.toLowerCase() != "netscape") objVideo.stop();
}

//Added By Rajesh on 14 OCT 2011
function openImage(sImagePath, sTitle) {
    showWait(true);
    var myImage = new Image();
    myImage.src = sImagePath;
    if (myImage.complete) {
        showWait(false);
        showPopup(sTitle, "<img src=\"" + myImage.src + "\" alt=\"\" width=\"" + myImage.width + "\" height=\"" + myImage.height + "\" />", "");
    }
    else myImage.onload = function() {
        showWait(false);
        showPopup(sTitle, "<img src=\"" + myImage.src + "\" alt=\"\" width=\"" + myImage.width + "\" height=\"" + myImage.height + "\" />", "");
    }
} 

function showPopup(sTitle, sContent, sOnClose) {
    showSelect(true);
    var MaxWidth = 900;
    var MaxHeight = 500;
    var divPopup = $("#divPopup")[0];
    if (divPopup == null) {
        divPopup = document.createElement("div");
        divPopup.id = "divPopup";
    }
    var transBG = $("#transBG")[0];
    if (transBG == null) {
        transBG = document.createElement("div");
        transBG.id = "transBG";
        transBG.className = "TransparentBG";
    }
    divPopup.innerHTML = "<table class=\"PopupWindow\" cellpadding=\"0\" cellspacing=\"0\">" + 
                            "<tr>" + 
                                "<td>" + 
                                    "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">" + 
                                        "<tr>" +
                                            "<td class=\"PopupHeaderLeft\"></td>" + 
                                            "<td class=\"PopupHeaderCenter\" align=\"left\"><span class=\"Title\">" + sTitle + "</span></td>" + 
                                            "<td class=\"PopupHeaderCenter\" align=\"right\"><img src=\"/uiimages/pop_close.png\" border=\"0\" usemap=\"#m_blclose\" /><map name=\"m_blclose\" id=\"m_blclose\"><area shape=\"circle\" coords=\"9,9,8\" href=\"javascript:void(0);\" onclick=\"closePopup(" + sOnClose + ");\"></map></td>" + 
                                            "<td class=\"PopupHeaderRight\"></td>" + 
                                        "</tr>" + 
                                    "</table>" +  
                                "</td>" + 
                            "</tr>" + 
                            "<tr>" + 
                                "<td class=\"PopupContent\" align=\"left\">" + 
                                    "<div id=\"divPopupContent\" style=\"overflow: auto;\">" + sContent + "</div>" + 
                                "</td>" + 
                            "</tr>" + 
                        "</table>";
    divPopup.style.zIndex = 999;
    divPopup.style.position = "absolute";
    $("#AjaxContainer")[0].appendChild(divPopup);
    transBG.style.width = $(window).width() + "px";
    transBG.style.height = $(document).height() + "px";
    transBG.style.zIndex = 990;
    $("#AjaxContainer")[0].appendChild(transBG);
    var divPopupContent = $("#divPopupContent")[0];
    var iWidth = (divPopupContent.offsetWidth > MaxWidth) ? MaxWidth : divPopupContent.offsetWidth;
    iWidth = (divPopupContent.offsetHeight > MaxHeight) ? iWidth + 17 : iWidth;
    divPopupContent.style.width = iWidth + "px";
    var iHeight = (divPopupContent.offsetHeight > MaxHeight) ? MaxHeight : divPopupContent.offsetHeight;
    divPopupContent.style.height = iHeight + "px";
    $('#divPopup').css("top", $(window).scrollTop() + (($(window).height() / 2) - ($('#divPopup').height() / 2)) + "px");
    $('#divPopup').css("left", $(window).scrollLeft() + (($(window).width() / 2) - ($('#divPopup').width() / 2)) + "px");
    $(window).scroll(function() {
        $('#divPopup').animate({top:$(window).scrollTop() + (($(window).height() / 2) - ($('#divPopup').height() / 2)) + "px" },{queue: false, duration: 350});
    });
}

function showSelect(Flag) {
    if ($.browser.msie && $.browser.version < 7) {
        $("select:visible").each(function() {
            if (Flag) {
                if (trim($(this)[0].style.visibility.toLowerCase()) == "visible" || trim($(this)[0].style.visibility.toLowerCase()) == "") {
                    $(this).attr("Hide", "1");
                    $(this).css({visibility: "hidden"});
                }
            }
            else {
                if ($(this).attr("Hide") == "1") {
                    $(this).removeAttr("Hide");
                    $(this).css({visibility: "visible"});
                }
            }
        });
    }
}

function closePopup(sOnClose) {
    showSelect(false);
    if ($("#divPopup")[0] != null) $("#AjaxContainer")[0].removeChild($("#divPopup")[0]);
    if ($("#transBG")[0] != null) $("#AjaxContainer")[0].removeChild($("#transBG")[0]);
    if (trim(sOnClose) != "") {
        var func = eval("window." + sOnClose);
        if (func) func();
	}
}


