/*
 * Author: Martin Kappel
 * Company: Bioport.cz
 */
$(document).ready(function(){ 
	$("#contactForm").append('<input type="hidden" name="code" value="bl0' + '21" />')
});

function formEmailSubmit(form) {
  var state = true;
  var reqEl = $(form).find(".required");
  $.each( reqEl , function() { 	    
    if ( this.name == 'email' && !validateEmail(this.value) ) {				
	  modal(this,"Chyba","Prosíme vyplňte správnou emailovou adresu!","Close");	      
      state = false;
	  return false;
    } else if ($(this).val()=="" || $(this).val()==$(this).attr('rel')) {
		modal(this,"Chyba","Vyplňte všechny položky formuláře");		
		state = false;
		return false;
	}
  }) 
  return false;
  
}
/*
 * ------------------------------------------------------------
 * ---------------------- obecne funkce -----------------------
 * ------------------------------------------------------------
 * 
 * General
 * skript na kontrolu platne emailove adresy
 */
	function validateEmail(src) {
	    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	    return pattern.test(src);
	}
/*
 * General
 * logovani na firebug konzoli
 */
	var console;
	function log(hlaska) { if(console) { console.log(hlaska); } }
	function warn(hlaska) { if(console) { console.warn(hlaska); } }
	function info(hlaska) { if(console) { console.info(hlaska); } }
	function error(hlaska) { if(console) { console.error(hlaska); } }
	
	/*
 * modal window - disabled for ie6
 */
	function modal(el,titleM,contentM,buttonM){		
		//if ($.browser.msie && $.browser.version < 7) {
		if (true) {
			alert(titleM+": "+contentM);			
			if (el) {
				el.focus();
			}
		}
		else {
			$.fn.jmodal({
				title: titleM,
				content: contentM,
				buttonText: buttonM,				
				okEvent: function(e){
					if (el) {
						el.focus();
					}
				}
			});
		}
	}


