
$(document).ready(function(){
		$(".lightbox").lightbox();
		
		
 $('area').click(function(e) {
   var reg = $(this).attr('rel');
   if(reg > 0){
     $('#id_kraje').val(reg);
     $("#prodejciform").submit(); 
     e.preventDefault();
   }
 });
 
 
 $('a.kat_kosik').click(function(e) {

     $(this).parent().find("form").submit(); 
     e.preventDefault();

 });   
$('#dialogCompare a.kat_kosik').live("click",function(e) {
	 
     $(this).parent().find("form").submit(); 
     e.preventDefault();

 });
 $(".compare").live("click",function(){ 
	var compare = $("input#id_zbozi").val();
	$.get("compare.php", {compare: compare}, function(vystup) { $("#compare").html(vystup) } );
 });
  $("a.catCompare,a.kat_compare").live("click",function(){ 
	var compare = $(this).attr("rel");
	$.get("compare.php", {compare: compare}, function(vystup) { $("#compare").html(vystup) } );
 });
  $("a.delproduct").live("click",function(){ 
	var delproduct = $(this).attr("rel");
	$.get("compare.php", {delproduct:delproduct}, function(vystup) { $("#compare").html(vystup) } );
 });
 
 $('#dialogCompare').dialog ({ 
         bgiframe: true,
         stack: false,
			autoOpen: false,
			draggable: true,
			height: 600,
			width: 960,
			modal: true,
			buttons: {
				'Zavřít': function() {
					$(this).dialog('close');
					$("#dialogCompare").html('');
				}
			}     
     });

       $('#compareproducts').live("click",function(){        
            
            $.get("compare.php", {viewcompare:1}, function(vystup) { 
			$("#dialogCompare").html(vystup);  			
			 } ); 
            $('#dialogCompare').dialog('open'); 
         
            
        });
$('#nemail').click(function(){
    if ($(this).val()=='vložte Váš e-mail'){
      $(this).val('@'); 
    }
});		
$('#sendmail').live('click', function(){  

            var email = $('#nemail').val();   
            $.get('compare.php', {newsletter: 'newsletter', email: email}, function(vystup) {resultDialog(vystup);} );
  
        return false; 

});				
	}); 
	
function resultDialog(val){
    $(document).ready(function(){
        $("div#dialog #d-text").text(val);
        $("div#dialog").show().animate({opacity: 1.0},1000).hide('fast');
        //close dialog manually
        $('div#dialog span').live ('click' , function() { 
            $(this).parent().hide();
	       }); 
     });
}	