﻿var g_PopUps = new Array();


function CPopUp() {
    m_strPopUpId = 'divPopUp' + g_PopUps.length;
    m_strTitleText = "Alert";
    m_strContentText = "Hello World";
    m_bIsModal = "True";
    m_strClassName = "jqmAlert";
    m_strOverlayClassName = "blackOverlay";
    m_iOverlay = 30;
    m_objContainer = $("<div />").jqm();
}

CPopUp.prototype.getPopUpId = function() {
    return this.m_strPopUpId;
}

CPopUp.prototype.getTitleText = function() {
    return this.m_strTitleText;
}

CPopUp.prototype.setTitleText = function(TitleText) {
    this.m_strTitleText = TitleText;
}
CPopUp.prototype.getContentText = function() {

    return this.m_strContentText;
}

CPopUp.prototype.setContentText = function(ContentText) {
    this.m_strContentText = ContentText;
}

CPopUp.prototype.getClassName = function() {
    return this.m_strClassName;
}

CPopUp.prototype.setClassName = function(ClassName) {
    this.m_strClassName = ClassName;
}

CPopUp.prototype.divContainer = function() {
    return this.m_objContainer;
}


CPopUp.prototype.CreateAlert = function() {


    /* overlay  0-100 (int) : 0 is off/transparent, 100 is opaque */
strHtml = "<div id=\"ex3b\" class=\"jqmAlertWindow\">";



strHtml += "<div class=\"jqmAlertTitle clearfix jqDrag\"><h1>" + this.m_strTitleText + "</h1><a href=\"#\" class=\"jqmClose\"><em>Close</em></a></div>";
    strHtml += "<div class=\"jqmAlertContent\"><p>" + this.m_strContentText + "</p></div></div>";

    var objDiv = $("<div />");
    objDiv.attr("id",m_strPopUpId );
    objDiv.addClass(m_strClassName);
    objDiv.html(strHtml);
    objDiv.insertAfter('form')
   
   // $('document');

    this.m_objContainer = objDiv.jqm({
        overlay: this.m_iOverlay,
        overlayClass: m_strOverlayClassName,
        onShow: function(h) {
        /* callback executed when a trigger click. Show notice */
        h.w.css('opacity', 0.92).slideDown();
        if (!contains(g_PopUps, h.w)) {
            g_PopUps.push(h.w);
        }},
      onHide: function(h) {
        /* callback executed on window hide. Hide notice, overlay. */
      h.w.slideUp("slow", function() { if (h.o) h.o.remove(); });
      if (contains(g_PopUps, h.w)) {
          g_PopUps.pop(h.w);
      }
        } 
      }).jqDrag('.jqDrag');

    //     /* make dialog draggable, assign handle to title */
    // Close Button Highlighting. IE doesn't support :hover. Surprise?

    
    if ($.browser.msie) {
        $('div.jqmAlert .jqmClose')
          .hover(
            function() { $(this).addClass('jqmCloseHover'); },
            function() { $(this).removeClass('jqmCloseHover'); });
    }
    $('input.jqmdX')
          .hover(
            function() { $(this).addClass('jqmdXFocus'); },
            function() { $(this).removeClass('jqmdXFocus'); })
          .focus(
            function() { this.hideFocus = true; $(this).addClass('jqmdXFocus'); })
          .blur(
            function() { $(this).removeClass('jqmdXFocus'); });
            
            
}

function contains(a, obj){ 
  for(var i = 0; i < a.length; i++) { 
    if(a[i] === obj){ 
      return true; 
    } 
  } 
  return false; 
} 
