$(document).ready(function() {
  $("a[rel^='prettyPopin']:eq(0)").prettyPopin({width: 650,followScroll:false});

  $('#_type_send_advise').val('2');
/*
  $('form#sendAdvise').ajaxForm({
    beforeSubmit: clearOutput,
    success:      writeOutput
  });
*/
  $(".lightbox").lightbox({
    fitToScreen: true,
	  imageClickClose: true
	});

  $('#type_send_advise').attr("value", "2");

  // -- send message
  $("#bRecommendation").click(function(){					   				   

		var hasError = false;
		var q_name = $("#q_name_advise").val();
		var q_mail = $("#q_email_advise").val();
		var type_send = $("#type_send_advise").val();
    var bError = false;
    var sFocus = "";

    if (q_name == '') {
      bError = true;
      sFocus = "#q_name_advise";
    }

    mail=/^.+@.+\..{2,4}$/;
    if (mail.test(q_mail) == false) {
      bError = true; 
      if (sFocus == '') sFocus = "#q_email_advise";
    }   

    if (bError) {
      $(sFocus).focus();
      return false;
    }


		if(bError == false) {
			$.post("/_form_send_advise.php",
   				{ type_send_advise: type_send, q_name_advise: q_name, q_email_advise: q_mail},

   					function(data){
            eval('var obj='+data);  
            var nStatus = obj['status'];
            if (nStatus == 0) { // FALSE
              alert('Zprávu se nepodařilo odeslat !');
            }

            if (nStatus == 1) { // OK
          		$("#advise_sendInfo_info").hide("fast");
          		$("#advise_box_login_info").show("normal");
          		
              $("#q_name_advise").attr("value", "");
          		$("#q_email_advise").attr("value", "");
            }
          }
				 );
		}
		return false;
	});	
});
  $.setupJMPopups({
	 screenLockerBackground: "#000",
	 screenLockerOpacity: "0.7"
  });

  function openAjaxPopupSendForm(sLng) {
   $.openPopupLayer({
	  name: "ajaxContactForm",
	  width: 550,
		url: "/a_contact_form.php",
		parameters: {sLng:sLng},
     success: 
            function(data) {
              },
            beforeClose: 
            function(data) {
              var bReload = $("#bReload").val();
              },
            afterClose: 
            function() {
              }
					});
				}
/*
// pre-submit callback
function clearOutput(a, f, o) {
  
  var hasError = false;
  var file = $('#file').val();
  var q_name_advise = $('#_q_name_advise').val();
  var q_email_advise = $('#_q_email_advise').val();
  var q_text_advise = $('#_q_text_advise').val();
  var sFocus = "";
  
  if (q_name_advise == '') {
    hasError = true;    
    $("#_q_name_advise").attr("class", "error");
    sFocus = "#_q_name_advise";
  }
  else {
    $("#_q_name_advise").attr("class", "field");  
  }

  mail=/^.+@.+\..{2,4}$/;
  if (mail.test(q_email_advise) == false) {
    hasError = true; 
    $("#_q_email_advise").attr("class", "error");
    if (sFocus == '') sFocus = "#_q_email_advise";
  }   
  else
    $("#_q_email_advise").attr("class", "field");


  if (q_text_advise == '') {
    hasError = true;
    $("#_q_text_advise").attr("class", "errorA");
    if (sFocus == '') sFocus = "#_q_text_advise";
  }
  else
    $("#_q_text_advise").attr("class", "textA");


  if (!hasError) {
    $('#buttonArea').html('<img src="/images/loading.gif" />');
    return true;
  }
  else {
    $(sFocus).focus();
    return false;
  }
}

// success callback
function writeOutput(data) {
    eval("var obj="+data);

    var nStatus = obj['status'];
    if (nStatus == 1)
      $('#popupBody').html("<h3>Vaše zpáva byla úspěšně odeslána. Děkujeme.</h3>");
}
*/

