/*
 * author: M.Kasten
 * 17.06.2008
 */
 
var isMDActive = false;
 
function initModalDialog()
{
	/*
	if (typeof Ugc=='undefined'){
        alert("Exception: ModalDialog was not started from Ugc");
       throw("ModalDialog was not started from Ugc");
	}
	*/
	/*document.write('<script src="/webroot/src/ibox/ibox.js" type="text/javascript"><\/script>');
	document.write('<script type="text/javascript">iBox.setPath("/webroot/src/ibox/");<\/script>');*/
	document.write('<link rel=stylesheet href="/webroot/src/css/modaldialog.css" type="text/css">');
	
	
}


function activateModalDialog(){
	isMDActive = true;
}

/**
 * Opens a modal window
 * @param {String} content HTML content
 * @param {Object} params
 */
var ModalDialog = function()
{
  var title = "";
  //var params = {width:'294',height:'313',use_fade:'true',use_resize:'true'};
  var params = {use_fade:'true',use_resize:'true'};

  /* public methods */
  var _pub = {
    
    //close_label: 'Close',
    
    show: function(id, given_params){
      
      if(checkQuickLogin()){   
      	 _pub.hide();
         if( id.indexOf('#') == -1) id = '#' + id;
         //checkParams(given_params);
         iBox.showURL(id, title, given_params);
      } 
    },
    
    showText: function(text, given_params){
    	if(checkQuickLogin()){   
	   _pub.hide();
	   //checkParams(given_params);
	   iBox.show(text, title, params);
    	}
    },
    
    hide: function(){
    	if(checkQuickLogin()){  
		iBox.hide();
	}
    }
    
       
  };


  var checkQuickLogin = function()
  {
  
    
    if(!Ugc.QUICK_LOGIN_ON|| !isMDActive){
    	return false;
    }
    
    return true;

  }
    
  /* private methods */
  var checkParams = function(given_params)
  {
  	if(given_params){
  	
            if (given_params.width)     params.width = given_params.width;
	    if (given_params.height)    params.height = given_params.height;
	    if (given_params.fade_in)   params.fade_in = given_params.fade_in;
	    if (given_params.can_resize)params.can_resize = given_params.can_resize;
	    if (given_params.title)     title = given_params.title;
	    
  	}

  }
  
  return _pub;
}();
initModalDialog();
Event.observe(window, "load", activateModalDialog);
