function goTo(Url){ document.location.href=Url; }
function obj(Id) { if(Id!='' && document.getElementById(Id)) return document.getElementById(Id); else return false; }
function objStyle(Id) { if(Id!='' && document.getElementById(Id)) return document.getElementById(Id).style; else return false; }
function objHide(Id) { if(Id!='' && document.getElementById(Id)) document.getElementById(Id).style.display='none'; }
function objShow(Id) { if(Id!='' && document.getElementById(Id)) document.getElementById(Id).style.display='block'; }
function isObj(Id) { if(Id!='' && document.getElementById(Id)) return true; else return false; }
function bgChange(Id, ImgSrc) { objStyle(Id).backgroundImage = "url("+ImgSrc+")"; }

var ObjPopupId = '';
function objPopup(Id){
  if( Id!=ObjPopupId ) objHide(ObjPopupId);
  if( objStyle(Id).display=='block' ) objStyle(Id).display='none';
  else  objStyle(Id).display='block';
  ObjPopupId = Id;
}

function new_window(url, name, width, height){
  var top = Math.round((screen.height-height)/2);
  var left = Math.round((screen.width-width)/2);
  window.open(url, name,'width=' + width + ',height=' + height + ',top='+top+',left='+left+',resizable=yes,scrollbars=yes,menubar=no');
}

/**********************/

window.addEvent('domready', function(){
  var ContLeft = $('container').getPosition().x;
  var ContWidth = $('container').getSize().x;
  var BodyWidth = $('body').getSize().x;
  var BodyHeight = $('body').getSize().y;
  $('marg_left').setStyles({ 'left':-ContLeft, 'width':ContLeft });
  $('marg_right').setStyles({ 'left':ContWidth, 'width':BodyWidth-ContLeft-ContWidth });

  $$('.foto_hover').each( function(el){
    el.addEvents({
      'mouseover': function(){ el.addClass('img_hover'); },
      'mouseout': function(){ el.removeClass('img_hover'); }
    });
  });

  var FooterHeight = BodyHeight-$('footer').getPosition().y;
  if( FooterHeight>0 )
    $('footer').style.height = FooterHeight+'px';


	if( isObj('login_top2') ){
    $('login_top').getElement('.login_link').addEvent('click', function(){
      var FxLogin = new Fx.Morph($('login_top2'), { duration: 1200, transition: Fx.Transitions.Quad.easeOut } );
      $('login_top2').setStyles({ 'opacity':0, 'display':'block' });
      FxLogin.start({ 'opacity' : [0,1] });
    });
	}

	if( $('print_preview') ){
		$('print_preview').addEvent('click', function(){
			new_window(this.get('rel')+'?mode=print', 'print_preview', 800, 640);
		});
	}

	if( $('product-query-form') ){
		$$('#product-query-form a.delete').each( function(el){
			el.addEvent('click', function(){
				$('product-query-form').getElement('input[name=del_category_id]').value = el.get('rel');
				$('product-query-form').submit();
			});
		});
	}

});
