﻿
      jQuery(document).ready(function(){

            AddDialogEvent();
                     
      });
      
      
 function AddDialogEvent()
 {
    jQuery("[diaurl]").each(function(){
        
        var diaObj=jQuery(this);
        
           diaObj.click(function(){
           
           var title=diaObj.attr("diaTitle");
           var url=diaObj.attr("diaUrl");
           var width=diaObj.attr("diaWidth")+"px";
           var height=diaObj.attr("diaHeight")+"px";
           var top=diaObj.attr("diaTop")+"px";
                      
           Dialog(title,url,width,height,top); 
           
           return false;
            
           });
        
      });
 }


 function Dialog(title, pageUrl, width, height, top, closeFunction) {
     if (jQuery("#DialogBoxBg").length == 0) {
         var strfloat;
         strfloat = '<div id="DialogBoxBg" style="height:' + jQuery(document).height() + 'px;filter:alpha(opacity=0.5);opacity:0.5;"></div>';

         strfloat += '<div id="FloatBox">';
         strfloat += '<div id="FloatBoxTitle">';
         strfloat += '<div id="FloatBoxTitleText">' + title + '</div>';
         strfloat += '<span id="FloatBoxTitleClose">&nbsp;</span></div>';
         strfloat += '<div id="FloatBoxContent"></div>';
         strfloat += '</div>';

         jQuery("Form").append(strfloat);
         jQuery("#DialogBoxBg").hide();

         jQuery("#FloatBoxTitleClose").click(function() {
             jQuery("#DialogBoxBg").animate({ opacity: "0" }, "normal", function() { jQuery(this).hide(); });
             jQuery("#FloatBox").hide();

             if (closeFunction != null) {
                 closeFunction();
             }
         });
     }

     jQuery("#FloatBoxContent").html("<iframe src=\"" + pageUrl + "\" width=\"100%\" height=\"" + (parseInt(height) - 30) + "px" + "\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");

     jQuery("#FloatBoxTitleText").text(title);
     jQuery("#DialogBoxBg").show();
     jQuery("#DialogBoxBg").animate({ opacity: "0.5" }, "normal");

     jQuery("#FloatBox").css("left", (jQuery(document).width() / 2 - parseInt(width) / 2) + "px");
     jQuery("#FloatBox").css("width", width);
     jQuery("#FloatBox").css("height", height);
     jQuery("#FloatBox").show();

     jQuery("#FloatBox").css('top', jQuery(document).scrollTop() + parseInt(top) + 'px');
 }

function SetDialogSize(width,height)
{
  jQuery("#FloatBox").width(width);
  jQuery("#FloatBoxContent").find("iframe").height(height-30);
  jQuery("#FloatBox").height(height);
  
  jQuery("#FloatBox").css("left",(jQuery(document).width()/2-parseInt(width)/2)+"px");
}

function SetDialogTop(top)
{
   jQuery("#FloatBox").css('top', jQuery(document).scrollTop()+parseInt(top)+'px');
}

function CloseFloatBoxRefresh()
{
    jQuery("#Button_Refresh").click();
    
    jQuery("#DialogBoxBg").animate({opacity:"0"},"normal",function(){jQuery(this).hide();});
    jQuery("#FloatBox").hide();
}

function CloseFloatBoxNotRefresh()
{
    jQuery("#DialogBoxBg").animate({opacity:"0"},"normal",function(){jQuery(this).hide();});
    jQuery("#FloatBox").hide();
}

function RefreshPage()
{
   jQuery("#Button_Refresh").click();
}
    
