// Namespace object for fileupload functions
var modalObj = new Object();

modalObj.config = {
  storeId:    10001,
  catalogId:  10002,
  langId:     -3,
  widthUrl:   870,
  widthAlert: 555,
  css: {
    bg: {
      zIndex: 300,
      position: 'fixed',
      top: 0,
      left: 0,
      height: '100%',
      width: '100%'
    },
    wrapper: {
      zIndex: 301,
      position: 'fixed',
      top: '50%',
      left: '50%'
    },
    wrapper2: {
    },
    content: {
      overflow: 'auto'
    },
    loading: {
      zIndex: 302,
      position: 'fixed',
      top: '50%',
      left: '50%',
      marginTop: '-50px',
      marginLeft: '-50px'
    }
  }
};


modalObj.openErrorLayer = function(message) {
  $j.nyroModalManual({
    url: 'AlertView?storeId=' + modalObj.config.storeId + '&catalogId=' + modalObj.config.catalogId + '&langId=' + modalObj.config.langId + '&errormessage='+encodeURIComponent(message),
    forceType: null,        
    width: modalObj.config.widthAlert,
    css: modalObj.config.css,
    closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="close"></a>'
  }); 
};

modalObj.openUrlLayer = function(url, query, closeButtonId, width, height) {
  tmpWidth = modalObj.config.widthUrl;
  if (width) {
    tmpWidth = width;
  }
  
  var resizeable = true;
  var autoSizable = true;
            
  tmpHeight = 300;
  if (height) {
    tmpHeight = height;
    resizeable = false;
    autoSizable = false;
  }
  
  tmpClose = '<a href="#" class="nyroModalClose" id="closeBut" title="close"></a>';

  if (closeButtonId) {
    tmpClose = '<a href="#" class="nyroModalClose" id="' + closeButtonId + '" title="close"></a>'; 
  }
  
  
  options = {
    url: url + '?' + $j.param(query),
    forceType: null,        
    width: tmpWidth,
    minWidth: tmpWidth,
    minHeight: tmpHeight,
    height: tmpHeight,
    maxHeight: tmpHeight,
    css: {
      bg: modalObj.config.css.bg,
      wrapper:  {
        zIndex: 301,
        height: tmpHeight,
        position: 'absolute',
        top: '35px',
        left: '50%',
        marginTop: 1
      },
      wrapper2: modalObj.config.css.wrapper2,
      content: {
        overflow: 'auto',
        position: 'relative'
      },
      loading: modalObj.config.css.loading
    },
    closeButton: tmpClose,
    autoSizable: autoSizable,
    resizeable: resizeable,
    marginTop: 1
  };
  
  $j.nyroModalManual(options); 
};



;(function($) {

})(jQuery);
