	//============================================================================
	//-                      Copyright © 2006 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                                                        -
	//============================================================================
	
	
	 function MM_openBrWindow(theURL,winName,features) { //v2.0
       window.open(theURL,winName,features);
       }
	

   //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 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 doHourglass() {
        document.body.style.cursor = 'wait';
    }

	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 CreateAlertBox(){
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: 'Flyonline ',
	                              autoOpen: false, 
		                          modal: true,
			                      buttons: {Ok: function() {$(this).dialog('close');}},
			                      draggable: false,
			                      width:300,
			                      height: 150
			                     // resizable : false,
			                      });
	return $dialog;
}


function CreateConfirmBox(){
	var $dialogConfirm=$('<div></div>').dialog({title: 'Flyonline ',
	                              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;
}



function CreateConfirmPostBox(idForm, location){
var $dialogConfirm=$('<div></div>').dialog({title: 'Flyonline ',
	                              autoOpen: false, 
		                          modal: true,
			                      buttons: {
    				                      'OK': function() {
    											enableOk(false);
    											//$(this).dialog('close');
    											$(this).html("Please Wait... ");
    				                            var myForm= $("#" + idForm);
    				                            if (location !="") myForm.attr("action",location);
    				                            myForm.attr("onsubmit","");
    				                            myForm.submit();
    				                            return true;
    				                            },
				                          Cancel: function() {$(this).dialog('close'); return false;}
				                          },
			                      draggable: false,
			                      width:300,
			                      height: 250,
			                      resizable: false
			                      });
			                      alreadySet= true;
			                      return $dialogConfirm;
//if (alreadySet){
//}
}	
	
function enableOk(enable)
{
    var dlgFirstButton = $('.ui-dialog-buttonpane').find('button:first');
    var dlgCancelButton = $('.ui-dialog-buttonpane').find(":button:contains('Cancel')"); 
    if (enable) {
        dlgFirstButton.attr('disabled', '');
        dlgFirstButton.removeClass('ui-state-disabled');
    } else {
        dlgFirstButton.attr('disabled', 'disabled');
        dlgFirstButton.addClass('ui-state-disabled');
        dlgCancelButton.attr('disabled', 'disabled');
        dlgCancelButton.addClass('ui-state-disabled');
    }
}

