$(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; 
  });
 });
 
$(document).ready(function(){
          
		$(".lightbox").lightbox();
		
		root = $('#top h2 a').attr('href');
		
		//flash hlavicka
		var flash = $('#flash').attr('class');
	//	alert(flash); 
		$('#flash').flash({src:'http://'+location.hostname+'/swf/'+flash+'.swf',
                        height:275,
                        width:998, 
                        wmode: 'transparent'
                        });
                        
    
    openPanel = 0;
    
    	// Expand Panel
	$("#open").click(function(){
	   if(openPanel == 0){
		$("div#panel").slideDown("slow"); 
	     openPanel = 1;
	     $("#toggle a").toggle();
	   }
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");
        $("#toggle a").toggle(function(){
                openPanel = 0;
        });	
	});
   /* $("div#panel").mouseleave(function(){
        $("div#panel").slideUp("slow");
        $("#toggle a").toggle(function(){
                openPanel = 0;
        });
    });*/
    		
    container = $("#validateTip");               
    var validator = $("form#poptavka").validate({
		errorLabelContainer: container,
		wrapper: 'p',
		meta: "validate",
		rules: {		
			name: {required: true, minlength: 3} ,
			email: {required: true, email: true},
            text: {required: true, minlength: 3}  
			},
		messages: {
			name: "Prosím uveďte jméno.",
			email: "Prosím, zadejte platný e-mail.",
			text: "Prosím uveďte text zprávy."
	     },
	     submitHandler: function() { 
	     
	                var data = $("form#poptavka").serialize();
                
                    $.post(root+"process.php", {dataPoptavka: data}, function(vystup) { 
                                $("#infoResults").css('opacity', '1').html(vystup).show().animate({opacity: 0},4000).hide('fast'); 
                        $('form#poptavka')[0].reset();

                        return false;     
                     }) 
                     
                     }
	})

    var validForm = $("form#poptForm").validate({
		errorLabelContainer: $("#validateTips"),
		wrapper: 'p',
		meta: "validate",
		rules: {		
			name: {required: true, minlength: 3} ,
			email: {required: true, email: true},
            text: {required: true, minlength: 3}  
			},
		messages: {
			name: "Prosím uveďte jméno.",
			email: "Prosím, zadejte platný e-mail.",
			text: "Prosím uveďte text zprávy."
	     },
	     submitHandler: function() { 
	               var predmet = $('h1').text();  

	               var data = $("form#poptForm").serialize();

                    $.post(root+"process.php", {dataPoptavka: data,predmet:predmet}, function(vystup) { 
                                $("#infoResult").css('opacity', '1').html(vystup).show().animate({opacity: 0},4000).hide('fast'); 
                        $('form#poptForm')[0].reset();

                        return false;     
                     }) 
                     
                     }
	})
});

var message="Function Disabled!";
///////////////////////////////////
function clickIE() {if (document.all) {return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false");

