﻿
    function clickButton(e, buttonid)
    {
          var evt = e ? e : window.event;
          var bt = document.getElementById(buttonid);

          if (typeof bt == 'object'){
              if (evt.keyCode == 13){
                    __doPostBack(buttonid,'');
                    return false;
              }
          }
    }

    function initialize(formname,values,id)
    {
        if (values=='Larger Text Version')
        {
            javascript:chooseStyle('css-medium', 60);        
            formname.elements[id].value='Smaller Text Version';        
        }
        else
        {
            javascript:chooseStyle('none', 60);        
            formname.elements[id].value='Larger Text Version';          
        }   
    }
    
    var w = 0;
    var h = 0;
    var screenheight = 0;
    var resizeCalled=false;

    function PlacePopup(isResizing) {
        if(!resizeCalled) {
            if(document.documentElement.clientHeight) {
                screenheight = document.documentElement.clientHeight;
            } else {
                screenheight = $(window).height();
            }
            w = ($(window).width());
            h = (screenheight); // <-- visible screen portion
            
            if((screenheight+100)<=$("html").height()) 
            {
                h_full = ($("html").height()); // <-- full length of scrollable content        
            } else {
                h_full = ($("body").height()); // <-- full length of scrollable content        
            }
            var scrollTop = window.pageYOffset || $.boxModel && document.documentElement.scrollTop || document.body.scrollTop;
            
            $(".cover").width(w);
            $(".cover").height(h_full);
            // place the popup in center of screen
            if(isResizing) $(".Popup").animate({top:(((h/2)-($(".Popup").height()/2)))-50+scrollTop, left:((w/2)-($(".Popup").width()/2))}, 250, "linear"); 
            else $(".Popup").css({top:(((h/2)-($(".Popup").height()/2)))-50+scrollTop, left:((w/2)-($(".Popup").width()/2))}); 
            
            
            //ie6 fix:
            resizeCalled = true;
            setTimeout("resizeCalled = false", 10)
        }
    }

    window.onresize = function() { PlacePopup(true); }

    function isVisible(obj) {
        var flag = true;
        //alert($(obj).attr("style"));
        if ($(obj).attr("style")) {
            var objStyle = $(obj).attr("style");
            if (objStyle.indexOf("opacity: 1") != -1) {//Firefox,opera,safari
                flag = false;
            }
            else if (objStyle.indexOf("opacity=100") != -1) {//IE
                flag = false;
            }
            else if (objStyle.toLowerCase().indexOf("display: none") != -1) {
                flag = false;
            }
        }
        return flag;
    }