NMT = {
  initRemooz: function()
  {
    /**
     * Some options for the large photos.
     *
     * The first argument is the argument for $$ (can be an array of elements or a selector)
     */
    ReMooz.assign('.remooz', {
      'origin': 'img',
      'shadow': 'onOpenEnd', // fx is faster because shadow appears after resize animation
      'resizeFactor': 0.8, // resize to maximum 80% of screen size
      'cutOut': false, // don't hide the original
      'opacityResize': 0.4, // opaque resize
      'dragging': false, // disable dragging
      'centered': true // resize to center of the screen, not relative to the source element
    });
  }
};

function cloneFilename()
{
	$('fakeBrowse').value = $('realBrowse').value;			
}


function centerScreen(width, height)
{
		var coord = window.getCoordinates();
		
		var X = (coord.width - width) / 2;
		var Y = (coord.height - height) / 2;

		return {x: X, y: Y};
}

window.addEvent('domready', function()
{
  document.getElements('.tipimg').each(function(el)
  {
    if (el.tipPrepped) return; el.tipPrepped = true;
    el.addClass('tip');el.removeClass('tipimage');
    var txt = el.title.split(/::/);
    
    var html = '';
    if (txt[1])
    {
      var w = txt[2];
      var h = txt[3];
      var p = txt[4] ? txt[4] : 'center center';
      
      html += '<div style="width: ' + w + 'px; height: ' + h + 'px; background: url(/media/icons/indicator_snake.gif) center center no-repeat;">';
      html += '<div style="width: ' + w + 'px; height: ' + h + 'px; background: url(' + txt[1] + ') ' + p + ' no-repeat;">';
      html += '</div>';
      html += '</div>';
    }
    
    el.store('tip:title', txt[0] ? txt[0] : '');
    el.store('tip:text', html);
  });
  
  document.getElements('.tip').each(function(el)
  {
    if (el.tipPrepped) return; el.tipPrepped = true;
    
    var txt = el.title.split(/::/);
    el.store('tip:title', txt[0] ? txt[0] : '');
    el.store('tip:text', txt[1] ? txt[1] : '');
  });
  
  new Tips('.tip', {
     className: 'roflkid'
    ,onShow: function(tip){
        tip.fade('in');
    }
    ,onHide: function(tip){
      
        tip.fade('out');
    }
  });
  
	
	$('langChooser').addEvent('click', function() {

		if($('langChooser').getProperty('class') != 'langChoosing')
		{
		 $('langChooser').tween('background', 'url(/theme/default/css/images/langBg2.png)');
		 $('langChooser').morph('.langChoosing');
		 setTimeout(function(){
		 	$('langs').setStyle('display', 'inline');
		 }, 250);
		 $('langChooser').setProperty('class', 'langChoosing');
		}
		 else
		 {
		  $('langChooser').morph('.langChooser');
		  $('langs').setStyle('display', 'none');
		  setTimeout(function(){
			$('langChooser').tween('background', 'url(/theme/default/css/images/langBg.png)');
		  }, 350);
		  $('langChooser').setProperty('class', 'langChooser');
		 }
		
	});
	
	
	NMT.initRemooz();
	
	
	$$('.togglebox').each(function(el)
	{
		new NMT.ToggleBox(el);
	});
	
	$$('#topButtons a img').each(function(el)
	{
		el.addEvents({
			mouseenter: function()
			{
				$('onStatus').set('html', this.getProperty('alt'));
			}.bind(el)
			,mouseleave: function()
			{
				$('onStatus').set('html', '&nbsp;');
			}.bind(el)
		});
	});	
  
	if (window.ie && !window.ie7)
	{
	  $$('img').each(function(el)
	  {
	    if (-1 != el.src.search(/\.png$/))
			{
				el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + el.src + '\', sizingMethod=\'scale\')';
				el.setStyles({
					 width: el.getCoordinates().width
					,height: el.getCoordinates().height
				});
				el.src = '/media/blind.gif';
			}
	  });
	  
	  $$('div.pngfix').each(function(el)
	  {
	    el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + /url\((.*)\)/.exec(el.getStyle('background-image')).pop() + '\', sizingMethod=\'scale\')';
			el.style.backgroundImage = '';
	  });
	}
});
