﻿// JScript Common Function
  function createFrameDialog(id,url,t, h, w) {
    var output = "<div id='" + id + "' title='" + t + "'><iframe id='dlgframe' name='dlgframe' src='" + url + "' style='height:99%;width:99%;overflow-y:scroll;overflow-x:hide;' scrolling='auto' frameborder='0' marginheight='0' marginwidth='0'><\/iframe><\/div>";
    $('body').append($(output));
    $('#' + id).dialog({
      bgiframe: true,
      autoOpen: true,
      modal: true,
      height: h,
      width: w,
      position:  'center',	
      buttons: {
       Ok: function() {		       
         $('#' + id).dialog('destroy');
         $('#' + id).remove();
       }
      },  
      dragStart:function(){
        var divt=document.createElement('div');
        $(divt).attr('id','tempdragdiv');
        divt.style.height='93%';
        divt.style.width='100%';
        $(divt).css('position','absolute').css('left','0').css('top','0');                    
        $('#' + id).append(divt);//div where is iframe
      },
      dragStop:function(){
        $('#tempdragdiv').remove();
      },
      open:function(event, ui){      
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $(".ui-dialog").height();
        var popupWidth = $(".ui-dialog").width();
        $(".ui-dialog").css({
          "position": "absolute",
          "top": windowHeight/2-popupHeight/2,
          "left": windowWidth/2-popupWidth/2
        });
      }
    });      
  }
  
  function createMessageDialog(id,t,html, h, w, myaction) {
    var output = "<div id='" + id + "' title='" + t + "'>" + html + "<\/div>";
    $('body').append($(output));
    $('#' + id).dialog({
      bgiframe: true,
      autoOpen: true,
      modal: true,
      height: h,
      width: w,
      position:  'center',	
      buttons: {
       Ok: function() {		       
         myaction();
         $('#' + id).dialog('destroy');
         $('#' + id).remove();
       }
      },  
      open:function(event, ui){      
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $(".ui-dialog").height();
        var popupWidth = $(".ui-dialog").width();
        $(".ui-dialog").css({
          "position": "absolute",
          "top": windowHeight/2-popupHeight/2,
          "left": windowWidth/2-popupWidth/2
        });
      }
    });      
  }
  
  function getFileNameFormFullPath(path) {
    return path.match(/[-_\w]+[.][\w]+$/i)[0];
  }

  function getQueryStringHash (url) {
    return url.slice(url.indexOf('?') + 1)
  }      
