﻿function CreatePopUpMenu(prmWidth,prmHeight)
{
	var objPopupMenuToCreate = new Menu(prmWidth,prmHeight);

	objPopupMenuToCreate.Color = "black";
	objPopupMenuToCreate.BgColor = "white";
	objPopupMenuToCreate.HighlightedColor = "white";
	objPopupMenuToCreate.HighlightedBgColor = "#316AC5";
	objPopupMenuToCreate.BorderStyle = "outset 1px";			
	objPopupMenuToCreate.FontFamily = "Arial, Helvetica, sans-serif";
	objPopupMenuToCreate.FontWeight = "";
	objPopupMenuToCreate.FontSize = "12px";
	objPopupMenuToCreate.DimmedColor = "gray";
	objPopupMenuToCreate.ItemPadding = "0px";

	return objPopupMenuToCreate

}

function SendToClipboard(s)
{
  if( window.clipboardData && clipboardData.setData )
  {
     clipboardData.setData("Text", s);
  }
  else
  {
     alert("Internet Explorer required");
  }
}

function PutPleaseWait()
{
    jQuery.blockUI({ css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: '.5', 
            color: '#fff' 
        } }); 
}

function RemovePleaseWait()
{
    jQuery.unblockUI();
}

function GetPromptValue(prmMessage,prmDefault)
{
    return prompt(prmMessage,prmDefault);
}

function getASPElment(prmName,prmTag) {
     if ($get(prmName)) { return $get(prmName); }
     if (!prmTag) { var tag = '*'; }
     var e = document.getElementsByTagName(tag);
     for (var i=0; i < e.length; i++) {
          if (e[i].id) {
               if (e[i].id.indexOf(prmName) != -1) {
               return e[i];
               }
          }
     }
return null;
}

function ShowMessage(prmMessage)
{
    alert(prmMessage);
}

function OpenWindow(prmURL,prmHeight,prmWidth)
{
	var intLeftPosition = (screen.width) ? (screen.width-prmWidth)/2 : 0;
	var intTopPosition = (screen.height) ? (screen.height-prmHeight)/2 : 0;

	window.open(prmURL,'winWindow',"height=" + prmHeight + ",width=" + prmWidth + ",status=yes,toolbar=no,menubar=no,location=no,left=" + intLeftPosition + ",top=" + intTopPosition + ",resizable=no");
}

function OpenNewWindow(prmURL,prmHeight,prmWidth)
{
	var intLeftPosition = (screen.width) ? (screen.width-prmWidth)/2 : 0;
	var intTopPosition = (screen.height) ? (screen.height-prmHeight)/2 : 0;

	window.open(prmURL,"_blank","height=" + prmHeight + ",width=" + prmWidth + ",status=yes,toolbar=no,menubar=no,location=no,left=" + intLeftPosition + ",top=" + intTopPosition + ",resizable=no");
}

var _objWindow1 = null;
var _objWindow2 = null;
var _objWindow3 = null;
var _objWindow4 = null;

function HidePopup() {
    HidePopupInternal(1);
}

function HidePopup2()
{
    HidePopupInternal(2);
}

function HidePopup3()
{
    HidePopupInternal(3);
}

function HidePopup4()
{
    HidePopupInternal(4);
}

function ShowPopup(prmAddress,prmWidth,prmHeight,prmLeft,prmTop,prmTitle,prmCanDrag) 
{

    ShowPopUpInternal(1, prmAddress,prmWidth,prmHeight,false,prmLeft,prmTop,prmTitle,prmCanDrag);
}

function ShowPopup2(prmAddress,prmWidth,prmHeight,prmLeft,prmTop,prmTitle,prmCanDrag) 
{

    ShowPopUpInternal(2, prmAddress,prmWidth,prmHeight,false,prmLeft,prmTop,prmTitle,prmCanDrag);
}

function ShowPopup3(prmAddress,prmWidth,prmHeight,prmLeft,prmTop,prmTitle,prmCanDrag) 
{

    ShowPopUpInternal(3, prmAddress,prmWidth,prmHeight,false,prmLeft,prmTop,prmTitle,prmCanDrag);
}

function ShowPopup4(prmAddress,prmWidth,prmHeight,prmLeft,prmTop,prmTitle,prmCanDrag) 
{

    ShowPopUpInternal(4, prmAddress,prmWidth,prmHeight,false,prmLeft,prmTop,prmTitle,prmCanDrag);
}

function ShowModalPopup(prmAddress, prmWidth, prmHeight, prmLeft, prmTop, prmTitle, prmCanDrag, prmTheme) 
{
    ShowPopUpInternal(1, prmAddress, prmWidth, prmHeight, true, prmLeft, prmTop, prmTitle, prmCanDrag, prmTheme);
}

function ShowModalPopup2(prmAddress,prmWidth,prmHeight,prmLeft,prmTop,prmTitle,prmCanDrag) 
{
    ShowPopUpInternal(2, prmAddress,prmWidth,prmHeight,true,prmLeft,prmTop,prmTitle,prmCanDrag);
}

function ShowModalPopup3(prmAddress,prmWidth,prmHeight,prmLeft,prmTop,prmTitle,prmCanDrag) 
{
    ShowPopUpInternal(3, prmAddress,prmWidth,prmHeight,true,prmLeft,prmTop,prmTitle,prmCanDrag);
}

function ShowModalPopup4(prmAddress,prmWidth,prmHeight,prmLeft,prmTop,prmTitle,prmCanDrag) 
{
    ShowPopUpInternal(4, prmAddress,prmWidth,prmHeight,true,prmLeft,prmTop,prmTitle,prmCanDrag);
}

function HidePopupInternal(prmWindow)
{
    if (prmWindow == 2){
        objWindow = _objWindow2;
    }
    else if (prmWindow == 3){
        objWindow = _objWindow3;
    }
    else if (prmWindow == 4){
        objWindow = _objWindow4;
    }
    else{
        objWindow = _objWindow1;
    }
    if (objWindow != null) {
        objWindow.close();
    }
}

function ShowPopUpInternal(prmWindow, prmAddress,prmWidth,prmHeight,prmIsModal,prmLeft,prmTop,prmTitle,prmCanDrag,prmTheme)
{
    if(prmLeft==null || prmTop==null)
    {
        prmLeft=100;
        prmTop=30;
    }
    
    if(prmTitle==null)
       prmTitle='Romex'
       
    if(prmCanDrag==null)
        prmCanDrag = true;
    //debugger;
    if (prmTheme == null)
        prmTheme = 'silverxp';
        
    objWindow = Zapatec.Window.setup({
                modal:prmIsModal,
                theme: prmTheme,
			    left:prmLeft, 
			    top:prmTop, 
			    width:prmWidth, 
			    height: prmHeight,
			    onClose : function() {win = null;},
			    urlContent : prmAddress,
			    iframeContent: true,
			    showMinButton: false,
			    showMaxButton: false,
			    showStatus: false,
			    canResize: false,
			    showCloseButton: false,
			    title: prmTitle,
			    canDrag: prmCanDrag
		    });
		    
	if (prmWindow == 2){
        if(_objWindow2!=null)
            _objWindow2.close();
        _objWindow2 = objWindow;
    }
    else if (prmWindow == 3){
        if(_objWindow3!=null)
            _objWindow3.close();
        _objWindow3 = objWindow;
    }
    else if (prmWindow == 4){
        if(_objWindow4!=null)
            _objWindow4.close();
        _objWindow4 = objWindow;
    }
    else{
        if(_objWindow1!=null)
            _objWindow1.close();
        _objWindow1 = objWindow;
    } 	    
		    
    if(prmAddress=='')
        objWindow.hide();
}

function IsDisplayed(prmObject) {
    var body = document.body
    while (prmObject != body) {
        if (prmObject.style.display == "none")
            return false
        prmObject = prmObject.parentNode
    }
    return true
}


function log(message) {
    if (typeof (console) != "undefined" && console.log) {
        console.log(message);
    }
}


