$(document).ready(function(){
				   
//jquery

      $.fn.clearForm = function() {
   
        return this.each(function() {
   
          var type = this.type, tag = this.tagName.toLowerCase();
   
          if (tag == 'form')
   
            return $(':input',this).clearForm();
   
          if (type == 'text' || type == 'password' || tag == 'textarea')
   
           this.value = '';
   
          else if (type == 'checkbox' || type == 'radio')
  
          this.checked = false;
  
        else if (tag == 'select')
  
            this.selectedIndex = -1;
  
        });

      }; //end clearForm
	  
	  

	
	$.fn.defaultvalue = function() {
		
		// Scope
		var elements = this;
		var args = arguments;
		var c = 0;
		
		return(
			elements.each(function() {				
				
				// Default values within scope
				var el = $(this);
				var def = args[c++];

				el.val(def).focus(function() {
					if(el.val() == def) {
						el.val("");
					}
					el.blur(function() {
						if(el.val() == "") {
							el.val(def);
						}
					});
				});
				
			})
		);
	};//end defaultvalue

	var val1='Το όνομα σας *';
	var val2='Το επίθετο σας *';
	var val3='Το τηλέφωνο σας *';
	var val4='Η διεύθυνση σας';
	var val5='Το e-mail σας';
	var val6='Το μήνυμα σας';
//$("#name, #lastname").defaultvalue("Το όνομα σας", "Textarea value");
$("#name, #lastname, #telephone, #address, #email, #message").defaultvalue(val1, val2, val3, val4, val5, val6);


	$("#contactform").submit(function(e){

//alert($('#name').val());
			var ok = true;
			
		if($('#name').val()==val1 || $('#lastname').val()==val2 || $('#telephone').val()==val3){ ok = false }	
			//alert(ok);
			if(!ok){
					alert('Παρακαλούμε συμπληρώστε όλα τα υποχρεωτικά πεδία!');
					return false;
					}
			
				$('#preloader').show();
				$.post('modules/contact/send.php',$(this).serialize(), 
																	
						function(data){
						//alert(data);
						
						if(parseInt(data)==-1){
						$("#messageerrors").html(data.substr(2));
							//$.validationEngine.buildPrompt("#captcha","* Wrong verification number!","error");
						}
						else
						{
							//$('#contactform').hide('slow');
							//$('#contactform').clearForm();
							$("#messageerrors").html(data);
							document.getElementById('siimage').src = 'modules/securimage2/securimage_show.php?sid=' + Math.random(); //return false
							//.after('<h1>Thank you!</h1>');
						}
						
						$('#preloader').hide();
					}
																	
																	);
				return false;
	})

});


