
function verifyDate(str)

   {
   //var str = data;
   var format=0;
   var month=0;
   var day=0;
   var year=0;
   var err=false;
   if(str.length!=10)
      err=true;

   if(str.length==10)
      {
      // dd/mm/yyyy format
      if(str.charAt(2) == "/" && str.charAt(5) == "/" && str.length == 10)
         {
         format=1;
         // Check that day is a number.
         for (var i = 0; i < 2; i++) 
            { var ch = str.substring(i, i + 1); if(ch < "0" || "9" < ch) err=true; }
         // Check that month is a number.
         for (var i = 3; i < 5; i++) 
            { var ch = str.substring(i, i + 1); if(ch < "0" || "9" < ch) err=true; }
         // Check that year is a number.
         for (var i = 6; i < 10; i++) 
            { var ch = str.substring(i, i + 1); if(ch < "0" || "9" < ch) err=true; }
         // Set variables
         if(err==
             false){day=eval(str.substring(0,2));month=eval(str.substring(3,5));  year=eval(str.substring(6,str.length)); }
         }


      // Incorrect format.
      if(format !=1)
         var err=true;
      }

		   // Check that month is between 1 &12.
		   if(month<=0 || month>=13)
		      err=true;
		
		  // Check that day is right depending on month.
		   if( month==2 && ((year/4)==parseInt(year/4)) )
		      { if(day<=0 || day>29) err=true; }
		   if( month==2 && ((year/4)!=parseInt(year/4)) )
		      { if(day<=0 || day>28) err=true; }
		   if( month==4 || month==6 || month==9 || month==11 )
		      { if(day<=0 || day>30) err=true; }
		   if( month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12 )
		      { if(day<=0 || day>31) err=true; }
		
		
		   // If anything appears incorrect, display error message.
		   if(err==true)
		      {
		    //  alert("Inserire la data nel formato gg/mm/aaaa");
					
		      return false;
		      }
		
		   // If all is OK, return true.
		   return true;
		
	   }			
function checkMail(str){return str.search(/^([\w\.\-])+@(([\w\-]{2,})+\.)+([a-z0-9]{2,})+$/i)!=-1};

Number.prototype.format = function(n){
	n = n||2;
	var factor = Math.pow(10,n);
	var x = Math.round(this * factor) / factor;
	return x.toFixed(n).replace(/(\d{1,3})(?=(?:\d{3})+\.)|\./g,function($1){return $1=="."?",":$1+"."});
}
function facebookShare() {
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}
function sendRequestInfo(frm) {
	$(".required").removeClass("required");
	
	if(frm.infosection.value == "") {
		$("#infosection").addClass("required");
		$("#infosection").focus();
		return false;
	}
	if(frm.infoname.value == "") {
		$("#infoname").addClass("required");
		$("#infoname").focus();
		return false;
	}
	if(!checkMail(frm.infomail.value)) {
		$("#infomail").addClass("required");
		$("#infomail").focus();
		return false;
	}
	if(frm.infomsg.value == "") {
		$("#infomsg").addClass("required");
		$("#infomsg").focus();
		return false;
	}
	$("#contactmodule").hide();
	$("#waitimage").show();
	var postStr = "infosubject=" + escape($("#infosubject").val()) + "&infosection=" + escape($("#infosection").val()) + "&infoname=" + escape($("#infoname").val()) + "&infomail=" + $("#infomail").val() 
								+ "&infophone=" + $("#infophone").val() + "&infomsg=" + escape($("#infomsg").val().replace(/\n/gi, "<br/>"));
	try {
		$.post("ajaxFunctions.asp?f=sm", postStr, function(data) {
				if(data.indexOf("ERROR") < 0) {					
					$("#msgsended").show();
					
				}
				else {
					$("#msgerrorsend").html(data);
					$("#msgerrorsend").show();
				}
				$("#waitimage").hide();
			}
		);
	}
	catch(err) {
		$("#msgerrorsend").show();
	}
	finally {
		
	}
	
	return false;
}

