(function($) {

	$.fn.animalsvetInterface = function(settings) {
		settings = jQuery.extend({
		  manufactInterval  : 3000,
		  manufactAnimation : 1000,
		  manufactRotation  : true
		},settings);
		
    var jQueryMatchedObj = this;

	function _initialize() {
	  _start(this,jQueryMatchedObj);
      return false; }
		
    function _start(objClicked,jQueryMatchedObj) {
      _set_interface();
      return; }
    
    function _set_interface() {
      $("#menu .btn").click(function(){
        if(!$(this).parent('.submenu').hasClass('active')) {
          $("#menu .submenu").removeClass('active');
          $(this).parent('.submenu').addClass('active'); }
        else {
          $("#menu .submenu").removeClass('active'); }
        return false;});
      $("#menu .options_cancel").click(function(){
        $("#menu .submenu").removeClass('active');
        return false; });
      $("#manufact a img:not(.hover)").css({'opacity':0.5});
      $("#manufact a").hover(function(){$(this).find('img.hover').show();},function(){$(this).find('img.hover').fadeOut();});
      
      $("#manufact_container").hover(function(){ settings.manufactRotation=false; },function(){ settings.manufactRotation=true; });
      
      $("#manufact_container .btn.next").click(function(){
        w = $("#manufact a:first").width()+parseInt($("#manufact a:first").css('margin-left'))+parseInt($("#manufact a:first").css('margin-right'));
        $("#manufact .slider").animate({'left':-w},settings.manufactAnimation,function() {
          $("#manufact span.slider").css({'left':0}).append($("#manufact a:first"));
          return; });
        return false; });
      $("#manufact_container .btn.prev").click(function(){
    	w = $("#manufact a:first").width()+parseInt($("#manufact a:first").css('margin-left'))+parseInt($("#manufact a:first").css('margin-right'));
    	$("#manufact span.slider").css({'left':-w}).prepend($("#manufact a:last")).animate({'left':0},settings.manufactAnimation);
    	return false; });
      
      function rotate() {
    	if(settings.manufactRotation) {
          w = $("#manufact a:first").width()+parseInt($("#manufact a:first").css('margin-left'))+parseInt($("#manufact a:first").css('margin-right'));
          $("#manufact .slider").animate({'left':-w},settings.manufactAnimation,function() {
            $("#manufact span.slider").css({'left':0}).append($("#manufact a:first"));
            return; });
        }
        return; }
      
      setInterval(rotate,settings.manufactInterval);
      
      $('#login_form #password_input,#login_form #login_input').focus(function(){ $(this).val('');$(this).css({'color':'#333333'}); });
      $('#login_form #password_input,#login_form #login_input').blur(function(){ if($(this).val()=='')$(this).val('e-mail');$(this).css({'color':'#999999'}); });
      
      $('#sidebar_manufact_select').change(function(){ $('#sidebar_manufact_form').submit(); });
      
      $('#podaj').hover(function(){$('#podaj').animate({'left':0});},function(){$('#podaj').animate({'left':'-60px'});});
      
      
      $('#menu > .submenu > .options > form > ul > li > input[type=checkbox]').click(function(){ 
    	if(! $(this).attr('checked')) {
    	  $(this).parent('li').find('ul input[type=checkbox]').attr('checked',''); 
    	}
    	else {
    	  $(this).parent('li').find('ul input[type=checkbox]').attr('checked','checked');
    	}
      });
      $('#menu > .submenu > .options > form > ul > li > ul input[type=checkbox]').click(function(){
      	if(! $(this).attr('checked')) {
      	  $(this).parent().parent().parent().children('input[type=checkbox]').attr('checked',''); 
      	}        
      });
      return; }

    this.each(function() {
      _initialize(); });

    return this; }

})(jQuery);
