function getScreen(){
	var rootElement = (document.compatMode != 'BackCompat')?document.documentElement:document.body;
	this.windowheight = rootElement.clientHeight;
	this.windowwidth = rootElement.clientWidth;
}
function setSizes(){
	getScreen();
	if (document.getElementById('dimScreen') != undefined){
	document.getElementById('dimScreen').style.height = (windowheight) + "px";
	document.getElementById('dimScreen').style.width = (windowwidth) + "px";
	}
	if (document.getElementById('ak_modal_div') != undefined){
	document.getElementById('ak_modal_div').style.height = (windowheight - 150) + "px";
	document.getElementById('ak_modal_div').style.width = (windowwidth - 300) + "px";
	}
	if (document.getElementById('ak_modal_bio') != undefined){
	document.getElementById('ak_modal_bio').style.height = (windowheight - 184) + "px";
	document.getElementById('ak_modal_bio').style.width = (windowwidth - 300) + "px";
	}
	if (document.getElementById('ak_modal_table') != undefined){
	document.getElementById('ak_modal_table').style.width = (windowwidth - 300) + "px";
	}
}
jQuery.extend({
    dimScreen: function(speed, opacity, callback) {
        if(jQuery('#dimScreen').size() > 0) return;
        
        if(typeof speed == 'function') {
            callback = speed;
            speed = null;
        }
        if(typeof opacity == 'function') {
            callback = opacity;
            opacity = null;
        }
        if(speed < 1) {
            var placeholder = opacity;
            opacity = speed;
            speed = placeholder;
        }
        if(opacity >= 1) {
            var placeholder = speed;
            speed = opacity;
            opacity = placeholder;
        }
        speed = (speed > 0) ? speed : 500;
        opacity = (opacity > 0) ? opacity : 0.5;
        return jQuery("<div></div>").attr({
                id: 'dimScreen'
                ,fade_opacity: opacity
                ,speed: speed
            }).css({
            background: '#000'
            ,height: $(document).height() + 'px'
            ,left: '0px'
            ,opacity: 0
            ,position: 'absolute'
            ,top: '0px'
            ,width: $(document).width() + 'px'
            ,zIndex: 999
        }).appendTo(document.body).fadeTo(speed, 0.7, callback);
    },
    dimScreenStop: function(callback) {
        var x = jQuery('#dimScreen');
        var opacity = x.attr('fade_opacity');
        var speed = x.attr('speed');
        x.fadeOut(speed, function() {
            x.remove();
            if(typeof callback == 'function') callback();
        });
    }
});
jQuery.extend({
	showAkModal:function(navurl,title,bioDiv,box_width,box_height)
	{
		document.getElementsByTagName("html")[0].style.overflow = "hidden";
	    var offset={};
	    var options ={
	    margin:1,
	    border:1,
	    padding:1,
	    scroll:0
	    };
		var win_width =$(window).width();
	    var scrollToLeft=$(window).scrollLeft();
	    var win_height =$(window).height();
	    var scrollToBottom=$(window).scrollTop();
		var bio = $('#'+bioDiv).html();
		if(!navurl.match('.htm'))
		{
	    	$('body').append("<div id='ak_modal_div' style='padding-top:0px;border:1px solid black;background-color:#FFF;position: absolute;z-index:1000;display:none;'><table id='ak_modal_table' cellpadding='0' cellspacing='0' width='" + box_width + "'><tr><td style='width:100%'><strong>"+title+"</strong></td><td style='vertical-align:top'><div id='close'></div></td></tr></table><div class='bio' id='ak_modal_bio' style='width:" + box_width + "px;height:" + box_height + "px;overflow:scroll'><div class='wrapper' id='bodyBG'>" + bio + "</div>");
		}
		else {
			$('body').append("<div id='ak_modal_div' style='padding-top:0px;border:1px solid black;background-color:#FFF;position: absolute;z-index:1000;display:none;'><table cellpadding='0' cellspacing='0' width='" + box_width + "'><tr><td style='width:100%'><strong>"+title+"</strong></td><td style='vertical-align:top'><div id='close'></div></td></tr></table><iframe width='"+box_width+"' height='"+box_height+"'  frameborder=0 marginwidth='0' marginheight='0' scrolling='NO'  name='frmTest' src='"+navurl+"'></iframe></div>");
		}
	    $('#ak_modal_div').css({left:(((win_width/2-box_width/2))+scrollToLeft)+'px',top:(((win_height/2-box_height/2))+scrollToBottom)+'px'});
	    $('#close').click( function() {
			document.getElementsByTagName("html")[0].style.overflow = "auto";
	       $('#ak_modal_div').fadeOut(500);
	       $('#ak_modal_div').remove();
	        $.dimScreenStop();
	    });
	    $.dimScreen(500, 0.7, function() {
			$('#ak_modal_div').fadeIn(500);
	    });
		var offset = {}
	    offset=$("#ak_modal_div").offset({ scroll: false })
  	    X_left=offset.left+box_width-16;
	    X_top=offset.top;
	    $('#close').css({left:X_left,top:X_top});
	},
	akModalRemove:function()
	{
	   $('#ak_modal_div').fadeOut(100, function(){
			$(this).remove();
		});
	   document.getElementsByTagName("html")[0].style.overflow = "auto";
	  $.dimScreenStop();
	},
	akModalHideAndRedirect:function(redirect_url)
	{
	    $('#ak_modal_div').fadeOut(500);
	    $.dimScreenStop();
	    window.location=redirect_url;
	}
});	