window.onerror=handle_error;function handle_error(){return true;};
function CP_getStyles(){var rs="<style>\ntd{font-family:arial,sans-serif;font-size:12px}\na.calhd{font-family:arial,sans-serif;font-size:12px;color:#FFFFFF;text-decoration:none}\n.calhd{font-family:arial,sans-serif;font-size:12px;color:#FFFFFF;text-decoration:none}\ntd.calmonth{font-family:arial,sans-serif;font-size:12px;text-align:center;background-color:#cacafe;padding-left:3px;padding-right:3px}\ntd.calmonthwe{background-color:#99CC99;font-family:arial,sans-serif;font-size:12px;text-align:center;color:white;padding-left:3px;padding-right:3px}\ntd.caltoday{font-family:arial,sans-serif;font-size:12px;color:white;text-align:center;background-color:#C0C0C0;border-width:1;border-type:solid;border-color:#800000;}\na.cal{text-decoration:none;color:#000000;}\ntd.cal{font-family:arial,sans-serif;font-size:12px;color:#000000;text-align:center;background-color:#cacafe;padding-left:3px;padding-right:3px}\ntd.calwe{font-family:arial,sans-serif;font-size:12px;color:#000000;text-align:center;background-color:#99CC99;padding-left:3px;padding-right:3px}\na.calthismonth{text-decoration:none;color:#000066}\na.calothermonth{text-decoration:none;color:#808080;}\n.calnotclickable{color:#ffffff;}\n</style>\n";return rs;}
function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false,use_css=false,use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi&&document.all){x=AP_getPageOffsetLeft(document.all[anchorname]);y=AP_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=o.offsetLeft;y=o.offsetTop;}else if(use_css){x=AP_getPageOffsetLeft(document.all[anchorname]);y=AP_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for (var i=0; i<document.anchors.length; i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0; coordinates.y=0; return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AP_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent)!=null){ol+=el.offsetLeft;};return ol;}
function AP_getWindowOffsetLeft(el){return AP_getPageOffsetLeft(el)-document.body.scrollLeft;}	
function AP_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent)!=null){ot+=el.offsetTop;};return ot;}
function AP_getWindowOffsetTop(el){return AP_getPageOffsetTop(el)-document.body.scrollTop;}
function PW_getXYPosition(anchorname){var coordinates;if(this.type=="WINDOW"){coordinates=getAnchorWindowPosition(anchorname);}else{coordinates=getAnchorPosition(anchorname);}this.x=coordinates.x;this.y=coordinates.y;}
function PW_setSize(width,height){this.width=width;this.height=height;}
function PW_populate(contents){this.contents=contents;this.populated=false;}
function PW_refresh(){if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).innerHTML=this.contents;}else if(this.use_css){document.all[this.divName].innerHTML = this.contents;}else if(this.use_layers){var d=document.layers[this.divName];d.document.open();d.document.writeln(this.contents);d.document.close();}}else {if(this.popupWindow!=null&&!this.popupWindow.closed){this.popupWindow.document.open();this.popupWindow.document.writeln(this.contents);this.popupWindow.document.close();this.popupWindow.focus();}}}		
function PW_showPopup(anchorname){this.getXYPosition(anchorname);this.x += this.offsetX;this.y+=this.offsetY;if(!this.populated &&(this.contents!="")){this.populated=true;this.refresh();}if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).style.left=this.x;document.getElementById(this.divName).style.top=this.y;document.getElementById(this.divName).style.visibility="visible";}else if(this.use_css){document.all[this.divName].style.left=this.x;document.all[this.divName].style.top=this.y;document.all[this.divName].style.visibility="visible";}else if(this.use_layers){document.layers[this.divName].left=this.x;document.layers[this.divName].top=this.y;document.layers[this.divName].visibility="visible";}}else{if(this.popupWindow==null||this.popupWindow.closed){if(screen&&screen.availHeight){if((this.y +this.height)>screen.availHeight){this.y=screen.availHeight-this.height;}}if(screen && screen.availWidth){if((this.x+this.width)>screen.availWidth){this.x=screen.availWidth-this.width;}}this.popupWindow = window.open("about:blank","window_"+anchorname,"toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable=no,alwaysRaised,dependent,titlebar=no,width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");}this.refresh();}}
function PW_hidePopup(){if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).style.visibility="hidden";}else if(this.use_css){document.all[this.divName].style.visibility="hidden";}else if(this.use_layers){document.layers[this.divName].visibility="hidden";}}else {if(this.popupWindow&&!this.popupWindow.closed){this.popupWindow.close();this.popupWindow = null;}}}
function PW_isClicked(e){if(this.divName!=null){if(this.use_layers){var clickX=e.pageX;var clickY=e.pageY;var t=document.layers[this.divName];if((clickX>t.left)&&(clickX<t.left+t.clip.width)&&(clickY>t.top)&&(clickY<t.top+t.clip.height)){return true;}else{return false;}}else if(document.all){var t=window.event.srcElement;while(t.parentElement!=null){if(t.id==this.divName){return true;}t=t.parentElement;}return false;}else if(this.use_gebi){var t=e.originalTarget;while(t.parentNode!=null){if(t.id==this.divName){return true;}t=t.parentNode;}return false;}return false;}return false;}
function PW_hideIfNotClicked(e){if(this.autoHideEnabled&&!this.isClicked(e)){this.hidePopup();}}
function PW_autoHide(){this.autoHideEnabled=true;}
function PW_hidePopupWindows(e){for(var i=0;i<popupWindowObjects.length;i++){if(popupWindowObjects[i]!=null){var p=popupWindowObjects[i];p.hideIfNotClicked(e);}}}
function PW_attachListener(){if(document.layers){document.captureEvents(Event.MOUSEUP);}window.popupWindowOldEventListener=document.onmouseup;if(window.popupWindowOldEventListener!=null){document.onmouseup=new Function("window.popupWindowOldEventListener();PW_hidePopupWindows();");}else {document.onmouseup = PW_hidePopupWindows;}}
function PopupWindow(){if(!window.popupWindowIndex){window.popupWindowIndex=0;}if(!window.popupWindowObjects){window.popupWindowObjects=new Array();}if(!window.listenerAttached){window.listenerAttached=true;PW_attachListener();}this.index=popupWindowIndex++;popupWindowObjects[this.index]=this;this.divName=null;this.popupWindow=null;this.width=0;this.height=0;this.populated=false;this.visible=false;this.autoHideEnabled=true;this.contents="";if(arguments.length>0){this.type="DIV";this.divName=arguments[0];}else{this.type="WINDOW";}this.use_gebi=false;this.use_css=false;this.use_layers=false;if(document.getElementById){this.use_gebi=true;}else if(document.all){this.use_css=true;}else if(document.layers){this.use_layers=true;}else{this.type="WINDOW";}this.offsetX=0;this.offsetY=0;this.getXYPosition=PW_getXYPosition;this.populate=PW_populate;this.refresh=PW_refresh;this.showPopup=PW_showPopup;this.hidePopup=PW_hidePopup;this.setSize=PW_setSize;this.isClicked=PW_isClicked;this.autoHide=PW_autoHide;this.hideIfNotClicked=PW_hideIfNotClicked;}
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}
function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0||d2==0){return -1;}else if(d1>d2){return 1;}return 0;}
function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var tk="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length<4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["d"]=d;value["dd"]=LZ(d);value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;} else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H>11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format<format.length){c=format.charAt(i_format);tk="";while((format.charAt(i_format)==c)&&(i_format<format.length)){tk+=format.charAt(i_format++);}if(value[tk]!=null){result=result+value[tk];}else{result=result+tk;}}return result;}
function _isInteger(val){var digits="1234567890";for(var i=0;i<val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}
function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var tk=str.substring(i,i+x);if(tk.length<minlength){return null;}if(_isInteger(tk)){return tk;}}return null;}
function getDateFromFormat(val,format){val=val+"";format=format+"";var iv=0;var i_format=0;var c="";var tk="";var tk2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=now.getDate();var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format<format.length){c=format.charAt(i_format);tk="";while((format.charAt(i_format)==c)&&(i_format<format.length)){tk+=format.charAt(i_format++);}if(tk=="yyyy"||tk=="yy"||tk=="y"){if(tk=="yyyy"){x=4;y=4;}if(tk=="yy"){x=2;y=2;}if(tk=="y"){x=2;y=4;}year=_getInt(val,iv,x,y);if(year==null){return 0;}iv+=year.length;if(year.length==2){if(year>70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(tk=="MMM"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(iv,iv+month_name.length).toLowerCase()==month_name.toLowerCase()){month=i+1;if(month>12){month-=12;}iv+=month_name.length;break;}}if((month<1)||(month>12)){return 0;}}else if(tk=="MM"||tk=="M"){month=_getInt(val,iv,tk.length,2);if(month==null||(month<1)||(month>12)){return 0;}iv+=month.length;}else if (tk=="dd"||tk=="d"){date=_getInt(val,iv,tk.length,2);if(date==null||(date<1)||(date>31)){return 0;}iv+=date.length;}else{if(val.substring(iv,iv+tk.length)!=tk){return 0;}else{iv+=tk.length;}}}if(iv!=val.length){return 0;}if(month==2){if(((year%4==0)&&(year%100!=0))||(year%400==0)){if(date>29){return false;}}else {if(date>28){return false;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date>30){return false;}}if(hh<12&&ampm=="PM"){hh+=12;}else if(hh>11&&ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}
function CalendarPopup(){var c;if(arguments.length>0){c=new PopupWindow(arguments[0]);}else{c=new PopupWindow();
c.setSize(150,140);}c.offsetX=-132;c.offsetY=23;c.autoHide();
c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
c.dayHeaders = new Array("S","M","T","W","T","F","S");c.rF="CP_tmprF";c.weekStartDay=1;c.isShowYearNavigation=false;c.displayType="date";c.disabledWeekDays=new Object();c.yearSelectStartOffset=2;c.currentDate=null;c.todayText="";window.CP_targetInputgg=null;window.CP_targetInputmm=null;window.CP_targetInputaa=null;window.CP_dateFormat="mm/dd/yyyy";c.setrF=CP_setrF;c.setMonthNames=CP_setMonthNames;c.setMonthAbbreviations=CP_setMonthAbbreviations;c.setDayHeaders=CP_setDayHeaders;c.setWeekStartDay=CP_setWeekStartDay;c.setDisplayType=CP_setDisplayType;c.setDisabledWeekDays=CP_setDisabledWeekDays;c.setYearSelectStartOffset=CP_setYearSelectStartOffset;c.setTodayText=CP_setTodayText;c.showYearNavigation=CP_showYearNavigation;c.showCalendar=CP_showCalendar;c.hideCalendar=CP_hideCalendar;c.getStyles=CP_getStyles;c.refreshCalendar=CP_refreshCalendar;c.getCalendar=CP_getCalendar;c.select=CP_select;return c;}
function CP_tmprF(y,m,d){var now=new Date();if(window.CP_targetInputgg!=null){window.CP_targetInputgg.options[d].selected=true;window.CP_targetInputmm.options[m].selected=true;window.CP_targetInputaa.options[y+1-now.getFullYear()].selected=true;window.CP_targetInputgg.focus;setNotti()}}
function CP_setrF(name){this.rF=name;}
function CP_setMonthNames(){for(var i=0;i<arguments.length;i++){this.monthNames[i]=arguments[i];}}
function CP_setMonthAbbreviations(){for(var i=0;i<arguments.length;i++){this.monthAbbreviations[i]=arguments[i];}}
function CP_setDayHeaders(){for(var i=0;i<arguments.length;i++){this.dayHeaders[i]=arguments[i];}}
function CP_setWeekStartDay(day){this.weekStartDay=day;}
function CP_showYearNavigation(){this.isShowYearNavigation=true;}
function CP_setYearSelectStartOffset(num){this.yearSelectStartOffset=num;}
function CP_setDisabledWeekDays(){this.disabledWeekDays=new Object();for(vari=0;i<arguments.length;i++){this.disabledWeekDays[arguments[i]]=true;}}
function CP_setTodayText(text){this.todayText=text;}
function CP_hideCalendar(){if(arguments.length>0){window.popupWindowObjects[arguments[0]].hidePopup();}else{this.hidePopup();}}
function CP_refreshCalendar(index){var calObject=window.popupWindowObjects[index];if(arguments.length>1){calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));}else {calObject.populate(calObject.getCalendar());}calObject.refresh();}
function CP_showCalendar(anchorname){this.populate(this.getCalendar());this.showPopup(anchorname);}
function CP_select(ggobj,mmobj,aaobj,linkname,format){window.CP_targetInputgg=ggobj;window.CP_targetInputmm=mmobj;window.CP_targetInputaa=aaobj;var now=new Date();if(ggobj.value!=""&&mmobj.value!=""&&aaobj.value!=""){var time=getDateFromFormat(ggobj.options.selectedIndex+'/'+mmobj.options.selectedIndex+'/'+eval(aaobj.options.selectedIndex+now.getFullYear()-1+(aaobj.value==" ")),'d/M/y');if(time==0){this.currentDate=null;}else{this.currentDate=new Date(time);}}else{this.currentDate=null;}window.CP_dateFormat=format;this.showCalendar(linkname);}
function CP_getCalendar(){var now=new Date();if(this.type=="WINDOW"){var windowref="window.opener.";}else {var windowref="";}var rs="";if(this.type=="WINDOW"){rs+="<html><head><title>Riviera Toscana&#174;</title>"+this.getStyles()+"</head><body marginwidth=0 marginheight=0 topmargin=0 rightmargin=0 leftmargin=0 bgcolor=#cacafe>";rs+='<center><table width=100% border=0 borderwidth=0 cellspacing=0 cellpadding=0>';}else{rs+='<center><table width=144 border=1 borderwidth=1 bordercolor="#808080" cellspacing=0 cellpadding=1>';rs+='<tr><td align=center><center>';}if(this.displayType=="date"||this.displayType=="week-end"){if(this.currentDate==null){this.currentDate=now;}if(arguments.length>0){var month=arguments[0];}else {var month=this.currentDate.getMonth()+1;}if(arguments.length>1){var year=arguments[1];}else{var year=this.currentDate.getFullYear();}var daysinmonth=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);if(((year%4==0)&&(year%100!=0))||(year%400==0)){daysinmonth[2]=29;}var cm=new Date(year,month-1,1);var dy=year;var dm=month;var dd=1;var weekday=cm.getDay();var offset=0;if(weekday>=this.weekStartDay){offset=weekday-this.weekStartDay;}else{offset=7-this.weekStartDay+weekday;}if(offset>0){dm--;if(dm<1){dm=12;dy--;}dd=daysinmonth[dm]-offset+1;}var nm=month+1;var nm_year=year;if(nm>12){nm=1;nm_year++;}var lm=month-1;var lm_year=year;if(lm<1){lm=12;lm_year--;}var date_class;if(this.type!="WINDOW"){rs+='<table width=144 border=0 borderwidth=0 cellspacing=0 cellpadding=0>';}rs+='<tr bgcolor=#000080>';var refresh='javascript:'+windowref+'CP_refreshCalendar';if(month==1&&year==now.getFullYear()){rs+='<td bgcolor="#000080" class="calhd" width=22 align=center valign=middle>&nbsp;</td>';}else{rs+='<td bgcolor=#000080 class="calhd" width=22 align=center valign=middle><b><a class="calhd" href="'+refresh+'('+this.index+','+lm+','+lm_year+');">&lt;&lt;</a></b></td>\n';}rs+='<td bgcolor=#000080 class="calhd" width=100 align=center>'+this.monthNames[month-1]+' '+year+'</td>';if(month==12&&year==now.getFullYear()+2){rs+='<td bgcolor=#000080 class="calhd" width=22 align=center valign=middle>&nbsp;</td>';}else{rs+='<td bgcolor=#000080 class="calhd" width=22 align=center valign=middle><b><a class="calhd" href="'+refresh+'('+this.index+','+nm+','+nm_year+');">&gt;&gt;</a></b></td>\n';}rs+='</tr></table><center><table width=120 border=0 cellspacing=1 cellpadding=0 align=center bgcolor=#dddddd><tr>';var td='<td class="cal" width=14% align=center><b><font color="#000066">';var td2='<td class="calwe" width=14% align=center><b><font color="#000066">';for(var j=0;j<7;j++){if(j<5){rs+=td+this.dayHeaders[(this.weekStartDay+j)%7]+'</font></b></td>'}else{rs+=td2+this.dayHeaders[(this.weekStartDay+j)%7]+'</font></b></td>'}}rs+='</tr>';for(var row=1;row<=6;row++){rs+='<tr>';for(var col=1;col<=7;col++){if(dm==month){date_class="calthismonth";}else {date_class="calothermonth";}if((dm==this.currentDate.getMonth()+1)&&(dd==this.currentDate.getDate())&&(dy==this.currentDate.getFullYear())){td_class="caltoday";}else{if(col<6){td_class="calmonth"}else{td_class="calmonthwe"}}if(this.disabledWeekDays[col-1]){date_class="calnotclickable";rs+='<td class="'+td_class+'"><span class="'+date_class+'">'+dd+'</span></td>';}else {var sl_date=dd;var sl_month=dm;var sl_year=dy;var d=new Date(sl_year,sl_month-1,sl_date,0,0,0,0);if(this.displayType=="week-end"){d.setDate(d.getDate()+(7-col));sl_year = d.getYear();if(sl_year<1000){sl_year+=1900;}sl_month=d.getMonth()+1;sl_date=d.getDate();}if(d.getTime()<now.getTime()){date_class="calnotclickable";rs += '<td class="'+td_class+'"><span class="'+date_class+'">'+dd+'</span></td>';}else{rs += '<td class="'+td_class+'"><a href="javascript:'+windowref+this.rF+'('+sl_year+','+sl_month+','+sl_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" class="'+date_class+'">'+dd+'</a></td>';}}dd++;if(dd>daysinmonth[dm]){dd=1;dm++;}if(dm>12){dm=1;dy++;}}rs += '</tr>';}var current_weekday = now.getDay();rs+='<tr><td colspan=7 align=center valign=top bgcolor=#cacafe>';rs+='<font style="font-size=9px" color=#000066>© rivieratoscana.com</font></td></tr></table></center></td></tr></table>';}if(this.type=="WINDOW"){rs+="</body></html>";}return rs;}
function CP_setDisplayType(type){if(type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year"){return false;}this.displayType=type;return true;}
function setNotti(){wLyr('Notti',datediff(document.myform.selGGInizio.value,document.myform.selMMInizio.value,document.myform.selAAInizio.value,document.myform.selGGFine.value,document.myform.selMMFine.value,document.myform.selAAFine.value)+' nights')}
