	//============================================================================
	//-                   Copyright © 2006, 2009 Maxxcom Sas                     -
	//-                           All rights reserved.                           -
	//-                                                                          -
	//-    Questo codice sorgente è protetto da copyright in base alle leggi e   -
	//-    ai trattati internazionali. L'uso non autorizzato, la riproduzione    -
	//-    parziale o totale, l'alterazione, la distribuzione di questo codice   -
	//-    sorgente saranno perseguite in sede penale e civile in ottemperanza   -
	//-    alle leggi esistenti. Sono soggette alle rispettive licenze freeware, -
	//-    GPL, LGPL o di altro tipo, le parti di codice sorgente acquisite da   -
	//-    terze parte anche senza il consenso scritto. In tal caso i nomi degli -
	//-    autori sono riportati a monte delle procedure utilizzate e/o incluse. -
	//-    Eventuali omissioni o errori potranno essere comunicati all'indirizzo -
	//-    email info@maxxcom.it per una pronta correzione e/o integrazione.     -
	//-                                                                          -
	//-    www.maxxcom.it                                                        -
	//============================================================================

    if ( window!= top )
        top.location.href = location.href;

	function LTrim(str) {
   		var whitespace = new String(" \t\n\r");
   		var s = new String(str);
   		if (whitespace.indexOf(s.charAt(0)) != -1) {
      		var j=0, i = s.length;
      		while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         	j++;
      		s = s.substring(j, i);
   		}
   		return s;
	}

	function RTrim(str) {
	   var whitespace = new String(" \t\n\r");
   		var s = new String(str);
   		if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      		var i = s.length - 1;
      		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         	i--;
      		s = s.substring(0, i+1);
   		}
   		return s;
	}

	function Trim(str) {
   		return RTrim(LTrim(str));
	}

	function RetainChars(s, charList) {   
		var i;
    	var returnString = "";
    	for (i = 0; i < s.length; i++) {   
        var c = s.charAt(i);
        if (charList.indexOf(c) != -1) returnString += c;
    	}
    	return returnString;
	}

	function StripChars(s, charList) {   
		var i;
    	var returnString = "";
    	for (i = 0; i < s.length; i++) {   
            var c = s.charAt(i);
            if (charList.indexOf(c) == -1) returnString += c;
    	}
   	    return returnString;
	}

	function isEmpty(s) {   
		return ((s == null) || (s.length == 0))
	}

	function isWhitespace (s) {   
		var i;
		var whitespace = " \t\n\r";
    	if (isEmpty(s)) return true;
    	for (i = 0; i < s.length; i++) {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    	}
    	return true;
	}

 	function isNumeric(c) {
		var sNumbers = "01234567890";
		if (sNumbers.indexOf(c) == -1)
			return false;
		else 
		    return true;
	}
	function isNumericPoint(c) {
	    var sNumbers = "01234567890.";
	    if (sNumbers.indexOf(c) == -1)
	        return false;
	    else
	        return true;
	}  

    function isNumber2(str) {
var result = true;
 for (var i=0; i<str.length; i++)
     if (!isNumericPoint(str.substr(i, 1))) {
 result = false;
break;
 }
 return result;
 } 

	function isAlpha(c) {
		var lCode = c.charCodeAt(0);
		if (lCode >= 65 && lCode <= 122 ) {	
			return true;
      }
		else 
			return false;
	}  

	function isNumber(str) {
		var result = true;
		for (var i=0; i<str.length; i++)
			if (!isNumeric(str.substr(i, 1))) {
				result = false;
				break;
			}
		return result;
	}

	function isSpacedNumber(str) {
		var result = true;
		for (var i=0; i<str.length; i++)
			if (!(isNumeric(str.substr(i, 1)) || str.substr(i, 1) == ' ')) {
				result = false;
				break;
			}
		return result;
	}

	function isAlphabetical(str) {
		var result = true;
		str = str.toUpperCase();
		for (var i=0; i < str.length; i++)
			if (!isAlpha(str.substr(i, 1))) {
				result = false;
				break;
			}
		return result;
	}

	function isSpecedAlphabetical(str) {
		var result = true;
		str = str.toUpperCase();
		for (var i=0; i < str.length; i++)
			if (!(isAlpha(str.substr(i, 1)) || str.substr(i, 1) == ' ')) {
				result = false;
				break;
			}
		return result;
	}

	function isText(str) {
		var result = true;
		for (var i=0; i<str.length; i++)
			if (!(isAlpha(str.substr(i,1)) || isNumeric(str.substr(i,1)))) {
				result = false;
				break;
			}
		return result;
	}

	function isSpacedText(str) {
		var result = true;
		for (var i=0; i<str.length; i++)
			if (!(isAlpha(str.substr(i,1)) || isNumeric(str.substr(i,1)) || str.substr(i, 1) == ' ')) {
				result = false;
				break;
			}
		return result;
	}

	/*******************************************************
	This script and many more are available free online at
	The JavaScript Source!! http://javascript.internet.com
	V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com)
	Original:  Sandeep V. Tamhankar (stamhankar@hotmail.com)
	********************************************************/
	function isEmail (emailStr) {
		var checkTLD=1;
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
		if (matchArray == null) { return false; }
		var user = matchArray[1];
		var domain = matchArray[2];
		for (i = 0; i < user.length; i++) {
			if (user.charCodeAt(i) > 127) { return false; }
		}
		for (i = 0; i < domain.length; i++) {
			if (domain.charCodeAt(i) > 127) { return false; }
		}
		if (user.match(userPat) == null) { return false; }
		var IPArray = domain.match(ipDomainPat);
		if (IPArray != null) {
			for (var i = 1; i <= 4; i++) {
				if (IPArray[i] > 255) { return false; }
			}
			return true;
		}
		var atomPat = new RegExp("^" + atom + "$");
		var domArr = domain.split(".");
		var len = domArr.length;
		for (i = 0; i < len; i++) {
			if (domArr[i].search(atomPat) == -1) { return false; }
		}
		if (checkTLD && domArr[domArr.length-1].length != 2 && domArr[domArr.length-1].search(knownDomsPat) == -1) {
			return false;
		}
		if (len < 2) { return false; }
		return true;
	}

    function AdjustDate(value) 
    {
        value = Trim(value.replace("-", "/"));
        var d = new Date();
        var m = Trim(d.getMonth() + 1);
        var y = Trim(d.getFullYear()); 
        if (m.length == 1) { m = '0' + m; }
        if (value.length == 1) { value = '0' + value; }
        if (value.length == 2 && value.charAt(1) == "/") { value = '0' + value; }
        if (value.length == 2) { value = value + "/"; }
        if (value.length == 3 && value.charAt(2) == "/") { value = value + m + "/"; }
        if (value.length == 4 && value.charAt(2) == "/") { 
            value = value.substr(0, 3) + "0" + value.charAt(2) + "/"; 
        }
        if (value.length == 4) { value = value.substr(0, 2) + "/" + value.substr(2) + "/"; }
        if (value.length == 5 && value.charAt(2) == "/") { value = value.substr(0, 2) + "/" + value.substr(3) + "/"; }
        if (value.length == 6 && value.indexOf("/") == -1) { value = value.substr(0, 2) + "/" + value.substr(2, 2) + "/" + y.substr(0, 2) + value.substr(4); }
        if (value.length == 6) { value = value + y; }
        if (value.length == 8 && value.indexOf("/") == -1) { value = value.substr(0, 2) + "/" + value.substr(2, 2) + "/" + value.substr(4); }
        if (value.length == 8 && value.charAt(2) == "/" && value.charAt(5) == "/") { value = value.substr(0, 2) + "/" + value.substr(3, 2) + "/" + y.substr(0, 2) + value.substr(6); }
        return value;
    }

	function isValidDatePart(dayPart, monthPart, yearPart) 
	{
		month = eval(monthPart);
		if (isNaN(month)) { return -2; }; //mese non valido
		if (month < 1 || month > 12) { return -2; } //mese non valido
		year = eval(yearPart);
		if (isNaN(year)) { return -5; }; //anno non valido
		day = eval(dayPart);
		if (isNaN(day)) { return -3; }; //giorno non valido
		if (day < 1 || day > 31) { return -3; } //giorno non valido
		if ((month == 4 || month == 6 || month == 9 || month == 11) && day == 31) { return -4; } //giorni del mese errati
		if (month == 2) {
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day > 29 || ( day == 29 && !isleap )) { return -4; } //giorni del mese errati
		}
		return 0; //data valida
	}

    function AddDays(strDate, intDays){
        strDate = Date.parse(strDate);
        strDate = parseInt(strDate, 10);
        strDate = strDate + intDays * (24 * 60 * 60 * 1000);
        return new Date(strDate);
    }

	function getObjNN4(obj, name) {
		var x = obj.layers;
		var foundLayer;
		for (var i=0; i<x.length; i++) {
			if (x[i].id == name)
		 		foundLayer = x[i];
			else if (x[i].layers.length)
				var tmp = getObjNN4(x[i],name);
			if (tmp) foundLayer = tmp;
		}
		return foundLayer;
	}

	function getObject(name) {
	    var obj = null; 
		if (document.getElementById)
			obj = document.getElementById(name);
		else if (document.all)
			obj = document.all[name];
		else if (document.layers)
			obj = getObjNN4(document, name);
		if (obj == null) {
			for(i = 0; i < document.forms.length; i++) {
				if( typeof(document.forms[i].elements[name]) == "object") {
					obj = document.forms[i].elements[name];
					break;
				}
			}
		}
		return obj;
	}
	
	function IsObjectDefined(name) {
		var oB = getObject(name);
		if (oB != null)
			return true;
		else
			return false;
	}

    function focusFirst()  {
        var bFound = false;
        for (f=0; f < document.forms.length; f++) {
            for(i=0; i < document.forms[f].length; i++) {
                if (document.forms[f][i].type != "hidden") {
                    if (document.forms[f][i].disabled != true) {
                        document.forms[f][i].focus();
                        var bFound = true;
                    }
                }
                if (bFound == true)
                    break;
            }
            if (bFound == true)
                break;
        }
    }

    function SetCursor(style) {
        var Cursor =    document.layers ? document.cursor :
                        document.all ? document.all.cursor :
                        document.getElementById ? document.getElementById('cursor') : null; 
        Cursor = style;  
    }

    function doHourglass() {
        //document.body.style.cursor = 'wait';
        SetCursor('wait');
    }

    function doPointer() {
        //document.body.style.cursor = 'wait';
        SetCursor('default');
    }
    
	function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue)	{
		var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
		var arrReturnElements = new Array();
		var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
		var oCurrent;
		var oAttribute;
		for(var i=0; i<arrElements.length; i++)	{
			oCurrent = arrElements[i];
			oAttribute = oCurrent.getAttribute(strAttributeName);
			if(typeof oAttribute == "string" && oAttribute.length > 0) {
				if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
					arrReturnElements.push(oCurrent);
				}
			}
		}
		return arrReturnElements;
	}
	
	function getScrollXY() {
        var scrOfX = 0, scrOfY = 0;
        if( typeof( window.pageYOffset ) == 'number' ) {
            //Netscape compliant
            scrOfY = window.pageYOffset;
            scrOfX = window.pageXOffset;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
            //DOM compliant
            scrOfY = document.body.scrollTop;
            scrOfX = document.body.scrollLeft;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
            //IE6 standards compliant mode
            scrOfY = document.documentElement.scrollTop;
            scrOfX = document.documentElement.scrollLeft;
        }
        return [ scrOfX, scrOfY ];
    }

    function getClientDims() {
        var myWidth = 0, myHeight = 0;
        if( typeof( window.innerWidth ) == 'number' ) {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        }
        return [ myWidth, myHeight ];
    }

	function addDOMText(el, strText, newID) {
		eDIV = document.createElement("div");
		eDIV.setAttribute("id", newID);
		eDIV.appendChild(document.createTextNode(strText));
		if (typeof(el) == 'string')
			getObject(el).appendChild(eDIV);
		else
			el.appendChild(eDIV);
	}

	function clearDOMContent(el) {
		if (typeof(el) == 'string') {
			var oB = getObject(el);
			if (oB != null) {
				nEl = oB.cloneNode(false);
				oB.parentNode.insertBefore(nEl, oB);
				oB.parentNode.removeChild(oB);			
			}
		} else {
			nEl = el.cloneNode(false);
			el.parentNode.insertBefore(nEl, el);
			el.parentNode.removeChild(el);		
		}
	}

	function setDOMText(el, strText, newID) {
		if (typeof(el) == 'string') {
			oB = getObject(el);
			if (oB != null) {
				clearDOMContent(oB);
				addDOMText(oB, strText, newID);
			}
		} else {
			clearDOMContent(el);
			addDOMText(el, strText, newID);		
		}
	}

	function getDOMText(el) {
		var value = "";
		if (typeof(el) == 'string') {
			var oB = getObject(el);
			if (oB != null) {
				if (oB.childNodes.length != 0) {
					value = oB.firstChild.nodeValue;
				}
			}
		} else {
			if (el.childNodes.length != 0) {
				value = el.firstChild.nodeValue;
			}
		}
		return value;
	}

    function openPopup(url, name, attributes) {
        var nw=window.open(url, name, attributes || 'width=640px, height=480px, resizable, scrollbars=1');
        if (window.focus) {nw.focus()}
    }

	function checkSubmission(objNameOrId, msgText) {
		if (isEmpty(objNameOrId)) { objNameOrId = "conferma"; }
		if (document.getElementById)
			img = document.getElementById(objNameOrId);
		else if (document.all)
			img = document.all[objNameOrId];
		if (img != null) {
			if (img.name.toLowerCase() == "submitted") {
				alert(msgText);
				return false;
			}
			img.name = 'submitted';
		}
		return true;
	}

	function EnsureNumeric() {
		var keyCode=window.event.keyCode;
		if(!((keyCode > 47 && keyCode < 58) || keyCode==44 || keyCode == 45)) {
			window.event.returnValue = false;
		}
	}

    window.EnsureUpper = function()
    {
        key = window.event.keyCode;
        if ((key > 0x60) && (key < 0x7B))
        window.event.keyCode = key-0x20;
    }

    function Round(number, decimals) {
        decimals = (!decimals ? 2 : decimals);
        return Math.round(number*Math.pow(10, decimals))/Math.pow(10, decimals);
    }

    function fixedRound(num2round,digits) {
	    var num=num2round.toString();
	    if (num.length<=digits) { //>
		    var sep=num.indexOf(".");
		    if (sep==-1) {num+=".";sep=num.indexOf(".");}
		    var dec=num.substring(sep,num.length);
		    for (var x=0;x<eval((digits-dec.length)+1);x++)/*>*/{num=num+"0";}
		    return num;
	    }
	    else {
		    var sep=num.indexOf(".");
		    sep=sep+digits+1;
		    num=num.substring(0,sep);
			    if (parseInt(num.substring(eval(sep-1),sep))>=5) {movelastnum=true;}else {movelastnum=false;}
			    if (movelastnum) {var numbers=new Array();
				    for (var x=0;x<num.length;x++)/*>*/{numbers[numbers.length]=num.substring(x,eval(x+1));}
				    var long=numbers.length;
				    if (numbers[long]!=9) {numbers[long]=numbers[long]+1;}
				    else {
					    for(var y=long;y>0;y--) {
					    if (numbers[y]!=".");
						    if (parseInt(numbers[y])==9) {numbers[y]="0";}
						    else {numbers[y]=parseInt(numbers[y]);+1;}
					    }
					    }
			    for (var x=0;x<numbers.length;x++) {num+=numbers[x];}}
		    return num;
	    }
    }

    function AddEventHandler(target, eventName, handlerName) 
    { 
        if (target.addEventListener) 
            target.addEventListener(eventName, handlerName, false); 
        else if ( target.attachEvent ) 
            target.attachEvent("on" + eventName, handlerName); 
        else 
            target["on" + eventName] = handlerName; 
    }

    function AttachEvent(obj, evt, fnc, useCapture)
    {
	    if (!useCapture) useCapture = false;
	    if (obj.addEventListener)
	    {
		    obj.addEventListener(evt, fnc, useCapture);
		    return true;
	    } 
	    else if (obj.attachEvent) 
	        return obj.attachEvent("on"+evt,fnc);
	    else
	    {
		    MyAttachEvent(obj,evt,fnc);
		    obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
	    }
    } 

    //The following are for browsers like NS4 or IE5Mac which don't support either
    //attachEvent or addEventListener
    function MyAttachEvent(obj,evt,fnc)
    {
	    if (!obj.myEvents) obj.myEvents={};
	    if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
	    var evts = obj.myEvents[evt];
	    evts[evts.length]=fnc;
    }
    
    function MyFireEvent(obj,evt)
    {
	    if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
	    var evts = obj.myEvents[evt];
	    for (var i=0,len=evts.length;i<len;i++) evts[i]();
    }
    
    
    
function CreateAlertBox(elTofocus){
var box_wd = 300;
var box_hg= 150;
var wd = parseInt($(window).width())/2 -(box_wd /2);
var hg= parseInt($(window).height())/2 - (box_hg /2);
	 var $dialog = $('<div></div>').dialog({title: 'Viaggiofacile ',
	                              autoOpen: false, 
		                          modal: true,
			                      buttons: {Ok: function() {$(this).dialog('close'); if(elTofocus)$ (elTofocus).focus();}},
			                      draggable: false,
			                      width:300,
			                      height: 150,
			                      resizable: false,
			                      position:[wd,hg]
			                      });
			                    return $dialog;
}

function CreateAlertBoxNoModal(){
var box_wd = 300;
var box_hg= 150;
var wd = parseInt($(window).width())/2 -(box_wd /2);
var hg= parseInt($(window).height())/2 - (box_hg /2);
	 var $dialog = $('<div></div>').dialog({title: 'Viaggiofacile ',
	                              autoOpen: false, 
		                          modal: false,
			                      buttons: {Ok: function() {$(this).dialog('close');}},
			                      draggable: false,
			                      width:300,
			                      height: 150,
			                      resizable: false,
			                      position:[wd,hg]
			                      });
			                    return $dialog;
}
function CreateConfirmBox(){
	var $dialogConfirm=$('<div></div>').dialog({title: 'Viaggiofacile ',
	                              autoOpen: false, 
		                          modal: true,
			                      buttons: {
    				                      'OK': function() {
    				                            $(this).dialog('close');
    				                            return true;
    				                            },
				                          Cancel: function() {$(this).dialog('close'); return false;}
				                          },
			                      draggable: false,
			                      width:300,
			                      height: 150,
			                      resizable: false
			                      });
			                    return $dialogConfirm;
}


//creazione PopUp con informazioni call center
$(document).ready(function () {
    $('#popupCallCenter').bind('click', function () {
        var $dialog = $('<div></div>').dialog({ title: 'Viaggiofacile Call Center',
            autoOpen: false,
            modal: false,
            buttons: { Ok: function () { $(this).dialog('close'); return false; } },
            draggable: false,
            width: 600,
            height: 300,
            resizable: false
        });
        $dialog.html(testoPopup);
        $dialog.dialog('open');
    });

    //$('#popupAnimal').bind('hover',function () {$(this).addClass("hilite");}, function () {$(this).removeClass("hilite");})
    $('#popupCallCenter').hover(function () { $(this).addClass("hilite"); }, function () { $(this).removeClass("hilite"); });

    //Script per pulsante "Dillo ad un'amico" 



    email = $('input[name$="address"]');
    allFields = $([]).add(email);

    function checkLength(o, n, min, max) {
        if (o.val().length > max || o.val().length < min) {
            o.addClass("ui-state-error");
           return false;
        } else {
            return true;
        }
    }

    function checkRegexp(o, regexp, n) {
        if (!(regexp.test(o.val()))) {
            o.addClass("ui-state-error");
            return false;
        } else {
            return true;
        }
    }

    var good;
    var url = "www.viaggiofacile.it";

    m = "Ti segnalo questo sito";
    function checkEmailAddress(field) {
        var goodEmail = field.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
        if (goodEmail) {
            good = true
        } else {
            alert('Inserire un indirizzo e-mail valido.')
            email.focus();
            email.select();
            good = false;
        }
    }



    function mailThisUrl() {
        good = false
        checkEmailAddress(email.val())
        if (good) {
            window.location = "mailto:" + email.val() + "?subject=" + m + "&body=" + url + " " + document.title;
        }
    }

    $("#emailToFriend").dialog({
        autoOpen: false,
        height: 300,
        width: 350,
        modal: true,
        buttons: {
            "Invia": function () {
                var bValid = true;
                allFields.removeClass("ui-state-error");
                bValid = bValid && checkLength(email, "address", 6, 80);
                bValid = bValid && checkRegexp(email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "es: ui@viaggiofacile.it");
                if (bValid) {
                    mailThisUrl();
                    $(this).dialog("close");
                }
            },
            Cancel: function () {
                $(this).dialog("close");
            }
        },
        close: function () {
            allFields.val("").removeClass("ui-state-error");
        }
    });
    $('a[id$="link_downMailfriend"]').click(function (event) {
        event.preventDefault();
        $("#emailToFriend").dialog("open");
    });

    $('a[id$="link_downStampa"]').click(function (event) {
        event.preventDefault();
        window.print();
    });
});     



function CheckFormPageMenu() {
         var $dialog = CreateAlertBox();
        if  ($("#" + window.DataInizio).length>0 ) {
                 var oDataInizio = $("#" + window.DataInizio).val();
                 if (oDataInizio == "") {
                    $dialog.html('Seleziona una data di inizio!\n');
                    $dialog.dialog("option", "buttons", { "Ok": function () { $(this).dialog("close"); $("#" + window.DataInizio).focus(); } });
                    $dialog.dialog('open');

                    return false;
                }
            }
            if ($("#" + window.DataFine).length > 0) {
              var oDataFine = $("#" + window.DataFine).val();
              if (oDataFine == "") {
                $dialog.html('Seleziona una data di fine!\n');
                $dialog.dialog("option", "buttons", { "Ok": function () { $(this).dialog("close"); $("#" + window.DataFine).focus(); } });
                $dialog.dialog('open');
                return false;
            }
        }
  if ($("#" + window.VoliDtInizio).length > 0) {
              var oDataFine = $("#" + window.VoliDtInizio).val();
              if (oDataFine == "") {
                $dialog.html('Seleziona una data di inizio voli!\n');
                $dialog.dialog("option", "buttons", { "Ok": function () { $(this).dialog("close");$("#" + window.VoliDtInizio).focus(); } });
                $dialog.dialog('open');
                return false;
            }
             }
 if ($("#" + window.VoliDtFine).length > 0) {
              var oDataFine = $("#" + window.VoliDtFine).val();
              if (oDataFine == "") {
                $dialog.html('Seleziona una data di fine voli!\n');
                $dialog.dialog("option", "buttons", { "Ok": function () { $(this).dialog("close");$("#" + window.VoliDtFine).focus(); } });
                $dialog.dialog('open');
                return false;
            }

    }

    return true;
}

function nl2br(str, is_xhtml) {
    var breakTag = '<br />';  //(is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br/>';
    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}

