﻿var width,height;
$(function()
{
    $.dialog();
    $(window).resize(function()
    {
        getsize();
        var winheight = parseInt($(document).height());
        var winwidth = parseInt($("body").width());
        $("#floatBoxBg").attr("style", "top:0px;width:" + winwidth + "px;height:" + winheight + "px;left:0px;opacity:0.5;display:block;filter:alpha(opacity=50);");
        var top = parseInt(($.pageHeight() - parseInt(height)) / 2) + parseInt($(document).scrollTop());
        var left = parseInt(Math.ceil($("body").width()) / 2 - (parseInt(width) / 2));
        $("#floatBox").attr("style", "top:" + top + "px;width:" + width + "px;height:" + height + "px;left:" + left + "px;display:block;");
        $("#findadoctor").css('height', (height - 33) + "px");
    });
    $(window).scroll(function()
    {
        $(window).resize();
    });
});

$.pageWidth = function()
{
    return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
}

$.pageHeight = function()
{
    return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
}



$.dialog = function(){ 
    getsize();
    var left = parseInt(Math.ceil($("body").width())/2-(parseInt(width)/2));
    var midleft = parseInt($("body").width())/2;
	var top = parseInt(($.pageHeight() - parseInt(height))/2) + parseInt($(document).scrollTop());
	var midtop = parseInt($.pageHeight()/2) + parseInt($(document).scrollTop());
	var winheight = parseInt($(document).height());
	var winwidth = parseInt($("body").width());
    isOpen = true;
	$("#floatBoxBg").attr("style","height:"+winheight+"px;width:"+winwidth+"px");
	$("#floatBoxBg").animate({"opacity":0.5},500);
	$("#floatBox").attr("style","top:"+midtop+"px;width:1px;height:1px;left:"+midleft+"px");
	$("#floatBox").animate({"width":width,"left":left,"top":top,"height":height},500);
	

    $("#Closed").click(function(){
          isOpen = false;
          $("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
          $("#floatBox").animate({opacity:"0"},500,function(){location.href="/default.aspx?return=true"})
      });

      $("#findadoctor").css('height', (height - 33) + "px");
}

function getsize()
{
    width = parseInt(parseInt($.pageWidth())*0.9);
    height = parseInt(parseInt($.pageHeight())*0.9);
    if(width > 885)
    {
        width = 885;
    }
    if(height > 710)
    {
        height = 710;
    }
}