$(document).ready(function(){				   				   
		$(".error").hide();

var uzenetVal = "Type here the message you want to send.";
$('#uzenet').attr("value", uzenetVal); 
$('#uzenet').focus(function(){
if( $(this).val() == uzenetVal ) $(this).attr("value", ""); 
});
$('#uzenet').blur(function(){
if($(this).attr("value") == "") {$(this).attr("value", uzenetVal); }
});
  

var nevVal = "Enter your full name here.";
$('#nev').attr("value", nevVal); 
$('#nev').focus(function(){
if( $(this).val() == nevVal ) $(this).attr("value", ""); 
});
$('#nev').blur(function(){
if($(this).attr("value") == "") {$(this).attr("value", nevVal); }
});

var emailVal = "Your e-mail address goes here.";
$('#email').attr("value", emailVal); 
$('#email').focus(function(){
if( $(this).val() == emailVal ) $(this).attr("value", ""); 
});
$('#email').blur(function(){
if($(this).attr("value") == "") {$(this).attr("value", emailVal); }
});

var targyVal = "Write here the messages subject.";
$('#targy').attr("value", targyVal); 
$('#targy').focus(function(){
if( $(this).val() == targyVal ) $(this).attr("value", ""); 
});
$('#targy').blur(function(){
if($(this).attr("value") == "") {$(this).attr("value", targyVal); }
});


	$("#submit").click(function(){					   				   
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		var kicsodaVal = $("#nev").val();
		if(kicsodaVal == '') {
			$("#nev_error").show();
			hasError = true;
			}
		
		var emailFromVal = $("#email").val();
		if(emailFromVal == '') {
			$("#email_error").show();
			hasError = true;
		} 
		
		var subjectVal = $("#targy").val();
		if(subjectVal == '') {
			$("#targy_error").show();
			hasError = true;
		}
		
		var messageVal = $("#uzenet").val();
		if(messageVal == '') {
			$("#uzenet_error").show();
			hasError = true;
		}
		
		
		if(hasError == false) {
			$(this).hide();
			
			$.post("sendemail.php",
   				{ kicsoda: kicsodaVal, emailFrom: emailFromVal, subject: subjectVal, message: messageVal },
   					function(data){
						$("#sendEmail").fadeOut("slow", function() {
							
				$("#contact_form").html("<div id='kossz'></div>");
				$("#kossz").fadeIn("slow");
							$("#kossz").html('<div id="kossz"><h3 class="kozepre">Thank you for your input!</h3><p class="kozepre">The system have sent the message succesfully, I will reply as soon as I am able to.</p></div>');
							
						});
   					}
				 );
		}
		
		return false;
	});						   
});

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "kulso")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;