﻿
  var modalWindow = {
    parent:"body",
    windowId:null,
    content:null,
    width:null,
    height:null,
    close:function()
    {
      $(".modal-window").remove();
      $(".modal-overlay").remove();
    },
    open:function()
    {
      var modal = "";
      modal += "<div class=\"modal-overlay\"></div>";
      modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:";
      modal += this.width + "px;height:" + this.height + "px;margin-top:-" + ((this.height /2) +10)  +"px;";
      modal += "margin-left:-" + (this.width / 2) + "px\">";
      modal += this.content;
      modal += "<br /></div>";
      
      $(this.parent).append(modal);
      
      $('.modal-overlay').fadeIn(1000);
      $('.modal-overlay').fadeTo(1000, 0.5);
      
      var dH = $(document).height();
      var dW = $(document).width();
      
     
      $('.modal-window').append("<a class=\"close-window\">X</a>");      
      $('.close-window').click(function(){modalWindow.close();});

    },
    openVideo:function(videoname, windowid, winwidth, winheight, headtext, caption)
    {    
      modalWindow.windowId = windowid;
      modalWindow.width = winwidth;
      modalWindow.height = winheight;
      modalWindow.content = this.videoText(videoname, headtext, caption, winwidth);
      modalWindow.open();
    },
    videoText: function(videoname, headtext, caption, winwidth)
    {
      var vidtext = '';
          vidtext = '<div style="height:40px;background-color:#333;width:' + winwidth + '">'+
          '<h1 style="color:#FFF;padding:10px 0 0 10px;">' + headtext + '</h1></div>';
      
      vidtext += '<div class="modal-video-div">';
      
      
      
      var htmlformovie = '<p id="preview">The player will show in this paragraph</p>';  
      htmlformovie += '<script type="text/javascript" src="/includes/videoplayer/swfobject.js"></script>';
      htmlformovie += "<script type='text/javascript'>";
      htmlformovie += "var s1 = new SWFObject('/includes/videoplayer/player.swf','player','400','300','9');";
      htmlformovie += "s1.addParam('allowfullscreen','true');";
      htmlformovie += "s1.addParam('allowscriptaccess','always');";
      htmlformovie += "s1.addParam('flashvars','file=/video-library/" + videoname + "');";
      htmlformovie += "s1.write('preview');";
      htmlformovie += "</script>";
      htmlformovie += "</div>";
      
      vidtext += htmlformovie;
      
      vidtext += '<div class="modal-caption" style="width:' + (winwidth - 20) + ';padding:10px;">' + caption + '</div>';
      
      return vidtext;
    }
    
    
  }
  
  var openMyModal = function(winid, wide, high, source)
  {
    modalWindow.windowId = winid;
    modalWindow.width = wide;
    modalWindow.height = high;
    modalWindow.content = source;
    modalWindow.open();    
  }
  
  
  

  // pop-up (non-modal) window code ***************************************************** 

    var newWin = null;
    function popUp(strURL, strType, strWidth, strHeight)
    {
      if(newWin != null && !newWin.closed)
        newWin.close();
        
      var strOptions="";
      if(strType=="console")
        strOptions="resizable,height=" + strHeight + ",width=" + strWidth;
      if(strType=="fixed")
        strOptions="status,height=" + strHeight + ",width=" + strWidth;  
      if(strType=="elastic")
        strOptions="toolbar,menubar,scrollbars,resizable,location,height=" + strHeight + ",width=" + strWidth;
        
      //   alert(strOptions);
        
      newWin = window.open(strURL, 'newWin', strOptions);
      newWin.focus();
    }