$(window).load(function(){			   
//external link to new window			   
$('body a').filter(function() { 
    return this.hostname && this.hostname !== location.hostname; 
  }).addClass('external')
  .click(function() { 
    window.open(this.href); 
    return false; 
  });
 });   
 
 
 
 
// katalog trachea 
function katalog_test(id) {
    $.get("ajax/ajax.katalog-trachea.php",{id:id}, function(data){         
      $("#dialog").html(data);
        $("#dialog").dialog({ dialogClass: 'alert', width: 800, height: 600, modal: true, buttons: {
						"Zavřít": function() { 
							$(this).dialog("close"); 
						}
			 } })        
    }); 
}
// katalog trachea - END 
                

$(document).ready(function(){  

  $(".lightbox").lightbox();
  var root = $('#root').attr('href');
  
  if($('#top_oddeleni').length && $('#top_oddeleni').text() != ""){
       
        var topsection = $('#top_oddeleni').text();
        var flash = root+"img/rs"+topsection+".swf";
        //alert(flash);
        $('.flash').flash({swf:flash,width:960,height:304});
  }
  $("[name=formdata[email]]").focus(function() {
        if($(this).val()==""){
          $("[name=formdata[email]]").val('@');
        }
    }); 
  var container = $("#validateTips");
  $("#objednavka").validate({
		errorLabelContainer: container,
		wrapper: 'p',
		rules: {		
			'formdata[jmeno]': {required: true, minlength: 3},
			'formdata[telefon]': {required: true, minlength: 9},
			'formdata[email]': {required: true, email: true}
			},
		messages: {
			'formdata[jmeno]': "Prosím uveďte jméno / firmu.",
			'formdata[telefon]': "Prosím uveďte telefon.",
			'formdata[email]': "Prosím, zadejte platný e-mail."
	     }

	});
	$("#addItem").live("click",function(){
  	$('.objednavka tbody>tr:last').clone(true).insertAfter('.objednavka tbody>tr:last');
    });    
    
});  
function resultDialog(val){
    $(document).ready(function(){
        $("div#dialog #d-text").html(val);
        $("div#dialog").show().animate({opacity: 1.0},4000).hide('fast');
        //close dialog manually
        $('div#dialog span').live ('click' , function() { 
            $(this).parent().hide();
	       }); 
     });
} 
