/*$(window).load(function(){			   
//external link to new window (target=_blank is not valid)			   
$('body a').filter(function() { 
    return this.hostname && (this.hostname !== location.hostname); 
  }).addClass('external')
  .click(function() { 
    window.open(this.href); 
    return false; 
  });
 }); */
 

$(document).ready(function(){ 
 Cufon.replace('.cufon');  	   
 Cufon.now();
 
 $('.ext').click(function() { 
    window.open(this.href); 
    return false; 
  });
 //newsletter
  $("[name=newsletter_mail]").live("click",function(){
      var email = $('[name=newsletter_mail]').val();
      if(email == "Váš email ..."){
              $('[name=newsletter_mail]').val('@'); 
      }
  });
  $("[name=newsletter]").live("click",function(){
      
      var email = $('[name=newsletter_mail]').val();
      if(email == "Váš email ..."){
              $('[name=newsletter_mail]').val('@'); 
           }else{                                               
      			$.ajax({
				type: "GET",  
		        	url: "/user/newsletter/",
				data: { newsletter:'Odeslat',email:email},  
				success: function(theResponse) {
                     //výpis stavu
					 $("#sendnews p").html(theResponse).css({opacity: 1}).show().animate({opacity: 0.01},1000,function(){
					   $(this).hide();
					 
					 } );
                     //$('[name=newsletter_mail]').val('Váš e-mail');       
				} 
				}); 
	  }	  
	  return false;              
  });
  
   //fce menu
 	$('div#menu>ul>li,div#menu>ul>li>ul>li').each(function(){

		// elements specifications
		var a = $(this).children('a');
		var li = $(this);
		var children = li.children("ul:first").length;

		// menu li hover
		li.hover(function(){
			// over
			if (children == 1) {
				li.children("ul:first").stop(false, true).slideDown(150);
			}
			a.addClass("hovered");
		}, function(){
			// out
			if (children == 0) {
				a.removeClass("hovered");
			} else {
				li.children("ul:first").stop(true, true).slideUp(100, function(){
					a.removeClass("hovered");
				});
			}
		});
	});
	if($("#slider").length > 0){
	//homepage slider
	$("#slider").sudoSlider({ 
        fade: false,
        prevNext: false,
        auto: true,
    	pause:'7000', 
        updateBefore: true,
    	fadespeed: '2000',
    	continuous:true,
    	autowidth:false,
    	slideCount:2
   });
   }
   		//dialogs 
	$('#dostupnost a,.iconDialogTop a').click(function(){ 
		    var dialogTitle = $(this).attr('title');
		    var url 		= $(this).attr('href'); 
		    if($('<div id="dialog"></div>').appendTo('body')){
				 $('#dialog').load(url);
			     $.fx.speeds._default = 500; // nastavíme výchozí rychlost animace - 1000 = 1 sekunda
			     
				 $( "#dialog" ).dialog({
     				show: "blind", // animace při zobrazování
     				hide: "explode", // animace při zavírání
     				title: dialogTitle, 
     				height: 500,
     				width: 430,
     				buttons: {
						"Zavřít": function() {
	       					$(this).dialog("close");
	       					$(this).remove();
							}
						},
     				close: function(){
					     $(this).remove(); //odstani #dialog a obsah z obsahu
						 }
     				/*,modal: true*/  //zamezi manipulaci s obsahem mimo dialog
				});			
			}
		  	return false;  
	});
	
	$('#producer a').hover(function(){
	      $('#imgvyrobce').show();
	})
	$('.selectProducers').change(function(){
	      $(this).parent().submit();
	})		
 });
