
function asp(){
  if (document.getElementById('asp'))
  {
    document.getElementById('aspdiv').style.display='none';
    document.getElementById('asp').value='rovax';
  }
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, "");
} 


function check(a){
  if (trim (a) == "" || a=="Jméno a příjmení..." || a=="E-mail..." || a=="Váš dotaz..."){
    return false;
  }else{
    return true;
  }
}

$(function() {
  $(".rel").lightBox();
}); 

$(document).ready(function(){
  $(document).pngFix();
  $(".mycarousel").jcarousel({});
  $(".carte").click(function(){
    id = ($(this).attr("id")).split("_");
    $(".carte").removeClass("active");
    $("#carte_"+id[1]).addClass("active");
    $(".cartediv").hide();
    $("#cartediv_"+id[1]).show();
  });   
  
  $(".click").click(function(){
    $(this).val("");
  });
  
  $("#ok_send").click(function(){
    var name = $("#name").val();
    var phone = $("#phone").val();
    var email = $("#email").val();
    var text = $("#text").val();
    if ( check(name)&& check(email)&& check(text)){
      
      $.ajax({
        type: "get",
        url: http_root+"ajax/sendmail.php",
        cache: false,
        data: "randval="+ Math.random()+"&name="+name+"&email="+email+"&phone="+phone+"&text="+text,
        success: function(j){
          $("#name").css("border", "1px green solid");
          $("#email").css("border", "1px green solid");
          $("#text").css("border", "1px green solid");        
          $("#echo").css("color", "green");
          $("#echo").html(j);
          $("#echo").show("slow");
          $("#name").val("");
          $("#phone").val("");
          $("#email").val("");
          $("#text").val("");       
        }
      });  
      
      
       return false;
    }else{
      $("#name").css("border", "1px red solid");
      $("#email").css("border", "1px red solid");
      $("#text").css("border", "1px red solid");
      $("#echo").css("color", "red");
      $("#echo").html("Vyplňte prosím červeně vyznačené rámečky.");
      $("#echo").show("slow");
      return false;
    }  
    
  
  }); 
  var fi = 1;
  $("#add_attachment").click(function(){
    $('<div><label><a class="cursor" onclick="$(this).parent().parent().remove();return false;"><img src="'+http_root+'img/times.png" alt="smazat" /></a> Další soubor:</label><input type="file" name="soubor'+fi+'" size="23" /></div>').appendTo('#attachment');
    fi++;
  });  

});



