var datePickerDivID="datepicker";var datePickerField=null;var datePickerClass="datepicker";var iFrameDivID="datepickeriframe";var embeddedDiv=false;var embeddedDivSet=false;var dayArrayShort=new Array("Su","Mo","Tu","We","Th","Fr","Sa");var monthArrayShort=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var dateSeparator="-";var dateFormat="ymd";var forwardLimitDays=2147483647;var backLimitDays=2147483647;function displayDatePicker(H,B,E,F,C){if(E){backLimitDays=E}if(F){forwardLimitDays=F}if(C){datePickerClass=C}datePickerField=document.getElementsByName(H).item(0);if(!B){B=datePickerField}var A=B.offsetLeft;var G=B.offsetTop+B.offsetHeight;var D=B;while(D.offsetParent){D=D.offsetParent;A+=D.offsetLeft;G+=D.offsetTop}drawDatePicker(A,G)}function drawDatePicker(A,F){var C=getFieldDate(datePickerField.value);var D=false;if(!document.getElementById(datePickerDivID)){var B=document.createElement("div");B.setAttribute("id",datePickerDivID);B.setAttribute("class","dpDiv");B.setAttribute("style","visibility: hidden;");document.body.appendChild(B);if(!embeddedDivSet){embeddedDiv=false;embeddedDivSet=true}D=true}else{if(!embeddedDivSet){embeddedDiv=true;embeddedDivSet=true}}if(!embeddedDiv){var E=document.getElementById(datePickerDivID);if(!D){D=E.style.visibility=="hidden"}E.style.position="absolute";E.style.left=A+"px";E.style.top=F+"px";E.style.visibility="hidden";E.style.display="none";E.style.zIndex=10000;refreshDatePicker(datePickerField.name,C.getFullYear(),C.getMonth(),C.getDate());if(D){E.style.visibility="visible";E.style.display="block"}adjustiFrame()}else{refreshDatePicker(datePickerField.name,C.getFullYear(),C.getMonth(),C.getDate())}}function refreshDatePicker(C,I,O,L){var E=new Date();if((O>=0)&&(I>0)){E=new Date(I,O,1)}else{L=E.getDate();E.setDate(1)}var N=new Date();var R=new Date(N.getTime()-(backLimitDays*24*60*60*1000));var P=new Date(N.getTime()+(forwardLimitDays*24*60*60*1000));var H='<table class="'+datePickerClass+'">';var Q=true;var A=true;var J=true;var D=true;if((new Date(E.getFullYear()-1,O,31)).getTime()<R){Q=false}if((new Date(E.getTime()-1)).getTime()<R){A=false}if((new Date(E.getTime()+(30*24*60*60*1000))).getTime()>P){J=false}if((new Date(E.getFullYear()+1,O,1)).getTime()>P){D=false}H+="<tr>";if(Q){H+='<td class="skip"><a href="javascript:'+getSkipAction(C,E,-12)+'"><img src="ssmap/styles/desktop/pagination_first.gif" alt="Previous year"/></a></td>'}else{H+='<td class="skip"></td>'}if(A){H+='<td class="skip"><a href="javascript:'+getSkipAction(C,E,-1)+'"><img src="ssmap/styles/desktop/pagination_prev.gif" alt="Previous month"/></a></td>'}else{H+='<td class="skip"></td>'}H+='<td class="title" colspan="3">'+monthArrayShort[E.getMonth()]+" "+E.getFullYear()+"</td>";if(J){H+='<td class="skip"><a href="javascript:'+getSkipAction(C,E,+1)+'"><img src="ssmap/styles/desktop/pagination_next.gif" alt="Next month"/></a></td>'}else{H+='<td class="skip"></td>'}if(D){H+='<td class="skip"><a href="javascript:'+getSkipAction(C,E,+12)+'"><img src="ssmap/styles/desktop/pagination_last.gif" alt="Next year"/></a></td>'}else{H+='<td class="skip"></td>'}H+="</tr>";H+="<tr>";var M;for(M=0;M<dayArrayShort.length;M++){H+="<th>"+dayArrayShort[M]+"</th>"}H+="</tr>";H+="<tr>";for(M=0;M<E.getDay();M++){H+="<td>&nbsp;</td>"}var F=1;do{var K=E.getDate();var S="updateDateField('"+C+"', '"+getDateString(E)+"');";var G=true;if(E.getTime()>P.getTime()||E.getTime()<R.getTime()){G=false}if(K==L){H+='<td class="date"><a href="javascript:'+S+'" class="selected">'+K+"</a></td>"}else{if(G){H+='<td class="date"><a href="javascript:'+S+'">'+K+"</a></td>"}else{H+='<td class="date-disabled">'+K+"</td>"}}var B=new Date(E.getTime());B.setDate(B.getDate()+1);if(E.getDay()==6&&B.getDate()>1){H+="</tr><tr>";F++}E.setDate(E.getDate()+1)}while(E.getDate()>1);if(E.getDay()>0){for(M=6;M>E.getDay();M--){H+="<td>&nbsp;</td>"}}H+="</tr>";while(F<6){H+="<tr><td>&nbsp;</td></tr>";F++}H+="</table>";document.getElementById(datePickerDivID).innerHTML=H;adjustiFrame()}function getSkipAction(E,A,C){var D=(A.getMonth()+C)%12;var B=A.getFullYear()+parseInt((A.getMonth()+C)/12);if(D<0){D+=12;B+=-1}return"refreshDatePicker('"+E+"', "+B+", "+D+");"}function getDateString(A){var C="00"+A.getDate();var B="00"+(A.getMonth()+1);C=C.substring(C.length-2);B=B.substring(B.length-2);switch(dateFormat){case"dmy":return C+dateSeparator+B+dateSeparator+A.getFullYear();case"ymd":return A.getFullYear()+dateSeparator+B+dateSeparator+C;case"mdy":default:return B+dateSeparator+C+dateSeparator+A.getFullYear()}}function getFieldDate(D){var B;var C;var F,A,G;try{C=splitDateString(D);if(C){switch(dateFormat){case"dmy":F=parseInt(C[0],10);A=parseInt(C[1],10)-1;G=parseInt(C[2],10);break;case"ymd":F=parseInt(C[2],10);A=parseInt(C[1],10)-1;G=parseInt(C[0],10);break;case"mdy":default:F=parseInt(C[1],10);A=parseInt(C[0],10)-1;G=parseInt(C[2],10);break}B=new Date(G,A,F)}else{if(D){B=new Date(D)}else{B=new Date()}}}catch(E){B=new Date()}return B}function splitDateString(B){var A;if(B.indexOf("/")>=0){A=B.split("/")}else{if(B.indexOf(".")>=0){A=B.split(".")}else{if(B.indexOf("-")>=0){A=B.split("-")}else{if(B.indexOf("\\")>=0){A=B.split("\\")}else{A=false}}}}return A}function updateDateField(D,A){var B=document.getElementsByName(D).item(0);if(A){B.value=A}if(!embeddedDiv){var C=document.getElementById(datePickerDivID);C.style.visibility="hidden";C.style.display="none";adjustiFrame();B.focus();if((A)&&(typeof (datePickerClosed)=="function")){datePickerClosed(B)}}else{drawDatePicker();if((A)&&(typeof (datePickerSelect)=="function")){datePickerSelect(B)}}}function adjustiFrame(F,B){if(!embeddedDiv){var D=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);if(D){return }try{if(!document.getElementById(iFrameDivID)){var C=document.createElement("iframe");C.setAttribute("id",iFrameDivID);C.setAttribute("src","javascript:false;");C.setAttribute("scrolling","no");C.setAttribute("frameborder","0");document.body.appendChild(C)}if(!F){F=document.getElementById(datePickerDivID)}if(!B){B=document.getElementById(iFrameDivID)}try{B.style.position="absolute";B.style.width=F.offsetWidth;B.style.height=F.offsetHeight;B.style.top=F.style.top;B.style.left=F.style.left;B.style.zIndex=F.style.zIndex-1;B.style.visibility=F.style.visibility;B.style.display=F.style.display}catch(E){}}catch(A){}}}var map;var ie6=false
/*@cc_on || @_jscript_version < 5.7 @*/
;function loadMap(){if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("map"));map.setCenter(new GLatLng(54.5,-3.5),5);var A=new Date();var B=A.getFullYear()+"-"+(A.getMonth()+1)+"-"+A.getDate();$("date").value=B;displayDatePicker("date",false);makeTimeZones();setCurrentTimeZoneById("UTC");populateTimeZoneList();GEvent.addListener(map,"click",function(D,C){if(C){setActivePoint(C)}});GEvent.addListener(map,"zoomend",function(D,C){updateApiLink()});if(initPoint&&initPoint!=null&&initZoom&&initZoom!=null){map.setCenter(initPoint,initZoom);setActivePoint(initPoint);if(initType&&initType!=null){if(initType=="hybrid"){map.setMapType(G_HYBRID_MAP)}else{if(initType=="satellite"){map.setMapType(G_SATELLITE_MAP)}else{if(initType=="terrain"){map.setMapType(G_PHYSICAL_MAP)}}}}}}}function panNorth(){if(map){$("pan-north").blur();map.panDirection(0,1)}}function panSouth(){if(map){$("pan-south").blur();map.panDirection(0,-1)}}function panEast(){if(map){$("pan-east").blur();map.panDirection(-1,0)}}function panWest(){if(map){$("pan-west").blur();map.panDirection(1,0)}}function zoomIn(){if(map){$("zoom-in").blur();map.zoomIn(null,null,true)}}function zoomOut(){if(map){$("zoom-out").blur();map.zoomOut(null,true)}}function typeNormal(){if(map){$("type-normal").blur();hideTypeSelection();$("type-select").innerHTML="Normal";map.setMapType(G_NORMAL_MAP)}}function typeSatellite(){if(map){$("type-satellite").blur();hideTypeSelection();$("type-select").innerHTML="Satellite";map.setMapType(G_SATELLITE_MAP)}}function typeHybrid(){if(map){$("type-hybrid").blur();hideTypeSelection();$("type-select").innerHTML="Hybrid";map.setMapType(G_HYBRID_MAP)}}function typeTerrain(){if(map){$("type-terrain").blur();hideTypeSelection();$("type-select").innerHTML="Terrain";map.setMapType(G_PHYSICAL_MAP)}}function typeSelect(){if($("type-selection").style.display=="block"){hideTypeSelection()}else{showTypeSelection()}}function showTypeSelection(){if($("type-selection").style.display!="block"){$("type-selection").setStyles({display:"block",opacity:0});$("type-selection").scrollTop=0;var A=new Fx.Tween($("type-selection"),{duration:300});A.start("opacity","0","0.75")}}function hideTypeSelection(){if($("type-selection").style.display=="block"){var A=new Fx.Tween($("type-selection"),{duration:300});A.start("opacity","0.75","0");setTimeout("$('type-selection').setStyles({ display:'none', opacity: 0 });",500)}}function loadApi(){if(initPoint&&initPoint!=null&&initZoom&&initZoom!=null){$("lat").value=apiCleanCoordinate(initPoint.lat());$("lon").value=apiCleanCoordinate(initPoint.lng());$("zoom").value=initZoom;if(initType&&initType!=null){$("type").value=initType}}apiUpdateExampleLink()}function apiCleanCoordinate(A){A=A+"";if(A.indexOf(".")>0&&A.length>A.indexOf(".")+5){return A.substring(0,A.indexOf(".")+5)}else{return A}}function apiUpdateExampleLink(){var B=checkFloat($("lat").value);var C=checkFloat($("lon").value);if(!(B===false)&&B>=-90&&B<=90&&!(C===false)&&C>=-180&&C<=180){var A="http://www.sunrisesunsetmap.com/?lat="+B+"&lon="+C+"&zoom="+$("zoom").value;if($("name").value.length>0){A+="&name="+escape($("name").value.substring(0,30))}A+="&type="+$("type").value+"&v=1.0";$("example-link").innerHTML=A;$("example-link").setAttribute("href",A)}else{$("example-link").innerHTML="Invalid latitude or longitude. Please check your values.";$("example-link").setAttribute("href","http://www.sunrisesunsetmap.com/")}}function checkFloat(A){if(A=="0"){return 0}else{if(isNaN(A)){return false}else{if(parseFloat(A)){return parseFloat(A)}else{if(parseInt(A)){return parseInt(A)}else{return false}}}}}var geocoder=new GClientGeocoder();var geocoderStatus=[];geocoderStatus[G_GEO_SUCCESS]="Success";geocoderStatus[G_GEO_MISSING_ADDRESS]="Missing Address";geocoderStatus[G_GEO_UNKNOWN_ADDRESS]="Unknown Address";geocoderStatus[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address";geocoderStatus[G_GEO_BAD_KEY]="Bad Key";geocoderStatus[G_GEO_TOO_MANY_QUERIES]="Too Many Queries";geocoderStatus[G_GEO_SERVER_ERROR]="Server Error";var currentActivePoint=null;var currentCountryCode=null;var currentMatchingTimeZoneIds=null;var currentTimeZone=null;var timeZoneLocked=false;var manualCountryCodeMap=new Object();var timeZones=new Array();function datePickerSelect(){if(currentActivePoint){loadData()}}function setActivePoint(A){map.clearOverlays();clearData();currentActivePoint=A;var B=new GIcon(G_DEFAULT_ICON);B.image="http://www.sunrisesunsetmap.com/ssmap/styles/desktop/pushpin.png";B.shadow="http://www.sunrisesunsetmap.com/ssmap/styles/desktop/pushpin_shadow.png";B.iconSize=new GSize(32,32);B.shadowSize=new GSize(59,32);B.iconAnchor=new GPoint(9,34);map.addOverlay(new GMarker(A,{icon:B}));geocoder.getLocations(A.lat()+","+A.lng(),function(C){if(C.Status.code==G_GEO_SUCCESS&&C.Placemark&&extractCountryCode(C)){currentCountryCode=extractCountryCode(C);currentMatchingTimeZoneIds=getTimeZonesByCountryCode(currentCountryCode);if(!timeZoneLocked){if(currentMatchingTimeZoneIds!=null&&currentMatchingTimeZoneIds.length==1){hideTimeZoneWarning();setCurrentTimeZoneById(currentMatchingTimeZoneIds[0])}else{showTimeZoneWarning()}}}else{currentCountryCode=null;currentMatchingTimeZoneIds=null;if(!timeZoneLocked){showTimeZoneWarning()}}loadData()})}function extractCountryCode(A){for(var B=0;B<A.Placemark.length;B++){if(A.Placemark[B].AddressDetails&&A.Placemark[B].AddressDetails.Country){return A.Placemark[B].AddressDetails.Country.CountryNameCode}}return null}function loadData(){clearData();var A=new Request.JSON({url:"ssmap/json/data.php",onComplete:function(C){if(initName&&initName!=null&&initName.length>0&&initName.length<=30){$("data-h2").style.display="block";$("data-h1").innerHTML=initName;$("data-h2").innerHTML=displayLatLon(C.location.lat,C.location.lon);initName=null}else{if(C.place){$("data-h2").style.display="block";$("data-h1").innerHTML=C.place.name;$("data-h2").innerHTML=displayLatLon(C.location.lat,C.location.lon)}else{$("data-h1").innerHTML=displayLatLon(C.location.lat,C.location.lon)}}if(C.sun.type=="RISEN"){$("sunspecial").style.display="block";$("sunspecial").innerHTML="Risen all day"}else{if(C.sun.type=="SET"){$("sunspecial").style.display="block";$("sunspecial").innerHTML="Set all day"}else{$("sunriseset").style.display="block";$("sunrise").style.display="block";$("sunset").style.display="block";if(C.sun.rise){$("sunrisevalue").innerHTML=C.sun.rise.time;$("sunrisetz").innerHTML=C.sun.rise.zoneShort}else{$("sunrisevalue").innerHTML="None";$("sunrisetz").innerHTML=""}if(C.sun.set){$("sunsetvalue").innerHTML=C.sun.set.time;$("sunsettz").innerHTML=C.sun.set.zoneShort}else{$("sunrisevalue").innerHTML="None";$("sunrisetz").innerHTML=""}}}if(C.moon.type=="RISEN"){$("moonspecial").style.display="block";$("moonspecial").innerHTML="Risen all day"}else{if(C.moon.type=="SET"){$("moonspecial").style.display="block";$("moonspecial").innerHTML="Set all day"}else{$("moonriseset").style.display="block";$("moonrise").style.display="block";$("moonset").style.display="block";if(C.moon.rise){$("moonrisevalue").innerHTML=C.moon.rise.time;$("moonrisetz").innerHTML=C.moon.rise.zoneShort}else{$("moonrisevalue").innerHTML="None";$("moonrisetz").innerHTML=""}if(C.moon.set){$("moonsetvalue").innerHTML=C.moon.set.time;$("moonsettz").innerHTML=C.moon.set.zoneShort}else{$("moonsetvalue").innerHTML="None";$("moonsettz").innerHTML=""}}}$("moonphasevalue").innerHTML=C.moon.phase;if(!ie6){$("moonimggraphic").setAttribute("src","/ssmap/styles/moonphase/moon-"+C.moon.image+".png")}else{$("moonimggraphic").setAttribute("src","/ssmap/styles/moonphase_ie6/moon-"+C.moon.image+".png")}var B="ssmap/year.php?lat="+C.location.lat+"&lon="+C.location.lon+"&tz="+currentTimeZone.id+"&year="+$("date").value.substring(0,4);$("exportyear").setAttribute("href",B);$("exportyear").setAttribute("target","_blank");$("exportyear").innerHTML=$("date").value.substring(0,4)+" sunrise/set calendar";$("loading").style.display="none";$("data").style.display="block";updateApiLink()},onFailure:function(B){}}).get({lat:currentActivePoint.lat(),lon:currentActivePoint.lng(),date:$("date").value,tz:currentTimeZone.id})}function updateApiLink(){if(currentActivePoint!=null){var A="api/?lat="+currentActivePoint.lat()+"&lon="+currentActivePoint.lng()+"&zoom="+map.getZoom();$("api-link").setAttribute("href",A);$("api-link").innerHTML="Link to this location"}}function clearData(){$("welcome").style.display="none";$("data").style.display="none";$("data-h2").style.display="none";$("sunriseset").style.display="none";$("sunspecial").style.display="none";$("sunrise").style.display="none";$("sunset").style.display="none";$("moonriseset").style.display="none";$("moonspecial").style.display="none";$("moonrise").style.display="none";$("moonset").style.display="none";$("loading").style.display="block"}function TimeZone(C,B,A){this.id=C;this.offset=B;this.name=A}function getTimeZone(B){for(var A=0;A<timeZones.length;A++){if(timeZones[A].id==B){return timeZones[A]}}return null}function toggleTimeZoneLock(){timeZoneLocked=!timeZoneLocked;$("timezonelock").innerHTML=timeZoneLocked?"&#187; Unlock":"&#187; Lock"}function setManualTimeZoneById(B){setCurrentTimeZoneById(B);if(currentCountryCode&&!currentMatchingTimeZoneIds){manualCountryCodeMap[currentCountryCode]=B}hideTimeZoneWarning();if($("tzselection").style.display=="block"){var A=new Fx.Tween($("tzselection"),{duration:300});A.start("opacity","0.9","0");setTimeout("$('tzselection').setStyles({ display:'none', opacity: 0 });",500)}if(currentActivePoint){loadData()}}function setCurrentTimeZoneById(A){currentTimeZone=getTimeZone(A);document.getElementById("zone-offset").innerHTML=currentTimeZone.offset;document.getElementById("zone-name").innerHTML=currentTimeZone.name}function getTimeZonesByCountryCode(A){if(manualCountryCodeMap[A]){return[manualCountryCodeMap[A]]}for(codes in countryCodeMap){if(codes.indexOf(A+",")>-1){return countryCodeMap[codes]}}return null}function showTimeZoneWarning(){if(currentMatchingTimeZoneIds){$("tzwarning-message").innerHTML="Found "+currentMatchingTimeZoneIds.length+" times zones in this country"}else{$("tzwarning-message").innerHTML="Time zone unknown for this location"}if($("tzwarning").style.display=="none"){$("tzwarning").setStyles({display:"block",opacity:0});var A=new Fx.Tween($("tzwarning"),{duration:300});A.start("opacity","0","0.85")}}function hideTimeZoneWarning(){if($("tzwarning").style.display=="block"){var A=new Fx.Tween($("tzwarning"),{duration:300});A.start("opacity","0.85","0");setTimeout("$('tzwarning').setStyles({ display:'none', opacity: 0 });",500)}}function showTimeZoneSelection(){hideTimeZoneWarning();hideCitySelection();$("tzmatchcontainer").style.display="none";var F=$("tzmatchlist");while(F.hasChildNodes()){F.removeChild(F.firstChild)}if(currentMatchingTimeZoneIds){$("tzmatchcontainer").style.display="block";var E=$("tzmatchlist");for(var D=0;D<currentMatchingTimeZoneIds.length;D++){var C=getTimeZone(currentMatchingTimeZoneIds[D]);var B=document.createElement("a");B.setAttribute("href","javascript:setManualTimeZoneById('"+C.id+"')");var G=document.createElement("span");G.appendChild(document.createTextNode(C.offset));B.appendChild(G);B.appendChild(document.createTextNode(" "+C.name));E.appendChild(B)}}$("tzselection").setStyles({display:"block",opacity:0});$("tzlistswrapper").scrollTop=0;var A=new Fx.Tween($("tzselection"),{duration:300});A.start("opacity","0","0.9")}function populateTimeZoneList(){var D=$("tzalllist");for(var C=0;C<timeZones.length;C++){var B=timeZones[C];var A=document.createElement("a");A.setAttribute("href","javascript:setManualTimeZoneById('"+B.id+"')");var E=document.createElement("span");E.appendChild(document.createTextNode(B.offset));A.appendChild(E);A.appendChild(document.createTextNode(" "+B.name));D.appendChild(A)}}function goTo(A){if(A=="gb"){map.setCenter(new GLatLng(54.5,-3.5),5)}if(A=="us"){map.setCenter(new GLatLng(39.6,-97.4),3)}if(A=="au"){map.setCenter(new GLatLng(-27.8,133),4)}if(A=="nz"){map.setCenter(new GLatLng(-42,172),5)}if(A=="fr"){map.setCenter(new GLatLng(47,2.6),5)}if(A=="es"){map.setCenter(new GLatLng(40.1,-3.2),6)}if(A=="de"){map.setCenter(new GLatLng(51.3,9.9),6)}if(A=="it"){map.setCenter(new GLatLng(42.3,12.6),6)}if(A=="mx"){map.setCenter(new GLatLng(23.9,-102.4),4)}if(A=="br"){map.setCenter(new GLatLng(-14.3,-56.6),4)}}var expandedCountryCode=null;function showCitySelection(){if($("tzselection").style.display=="block"){var A=new Fx.Tween($("tzselection"),{duration:300});A.start("opacity","0.9","0");setTimeout("$('tzselection').setStyles({ display:'none', opacity: 0 });",500)}if($("cityselection").style.display=="none"){$("cityselection").setStyles({display:"block",opacity:0});$("citylistwrapper").scrollTop=0;var A=new Fx.Tween($("cityselection"),{duration:300});A.start("opacity","0","0.9")}}function hideCitySelection(){if($("cityselection").style.display=="block"){var A=new Fx.Tween($("cityselection"),{duration:300});A.start("opacity","0.9","0");setTimeout("$('cityselection').setStyles({ display:'none', opacity: 0 });",500)}}function toggleCountry(A){if(expandedCountryCode){$("cities-"+expandedCountryCode).style.display="none";$("country-"+expandedCountryCode).className="inactive"}if(expandedCountryCode!=A){$("cities-"+A).style.display="block";$("country-"+A).className="active";expandedCountryCode=A}else{expandedCountryCode=null}}function showCity(A,B,C){hideCitySelection();initPoint=new GLatLng(B,C);initZoom=9;initName=A;map.setCenter(initPoint,initZoom);setActivePoint(initPoint)}var countryCodeMap=[];countryCodeMap["AS,WS,"]=["US/Samoa"];countryCodeMap["CA,"]=["US/Pacific","US/Mountain","US/Central","Canada/Saskatchewan","US/Eastern","Canada/Atlantic","Canada/Newfoundland"];countryCodeMap["US,"]=["US/Hawaii","US/Alaska","US/Pacific","US/Arizona","US/Mountain","US/Central","US/Eastern","US/East-Indiana"];countryCodeMap["MX,"]=["America/Tijuana","America/Chihuahua","America/Mexico_City"];countryCodeMap["CO,PE,EC,"]=["America/Bogota"];countryCodeMap["BR,"]=["America/Bogota","America/Manaus","Brazil/East"];countryCodeMap["VE,BO,"]=["America/La_Paz"];countryCodeMap["CL,"]=["America/Santiago"];countryCodeMap["AR,GY,"]=["America/Buenos_Aires"];countryCodeMap["GL,"]=["America/Godthab"];countryCodeMap["UY,"]=["America/Montevideo"];countryCodeMap["GS,"]=["Atlantic/South_Georgia"];countryCodeMap["CV,"]=["Atlantic/Cape_Verde"];countryCodeMap["IS,MA,LR,"]=["Atlantic/Reykjavik"];countryCodeMap["GB,PT,IE,"]=["Europe/London"];countryCodeMap["FR,ES,BE,DK,"]=["Europe/Paris"];countryCodeMap["DE,NL,IT,AT,CH,SE,NO,"]=["Europe/Amsterdam"];countryCodeMap["GR,TR,RO,"]=["Europe/Bucharest"];countryCodeMap["FI,UA,LV,BG,EE,LT,"]=["Europe/Helsinki"];countryCodeMap["PL,HR,BA,MK,"]=["Europe/Sarajevo"];countryCodeMap["CZ,SK,HU,SI,RS,"]=["Europe/Belgrade"];countryCodeMap["JO,"]=["Asia/Amman"];countryCodeMap["LB,"]=["Asia/Beirut"];countryCodeMap["EG,"]=["Africa/Cairo"];countryCodeMap["ZW,ZA,"]=["Africa/Harare"];countryCodeMap["IL,"]=["Asia/Jerusalem"];countryCodeMap["BY,"]=["Europe/Minsk"];countryCodeMap["IQ,"]=["Asia/Baghdad"];countryCodeMap["KW,SA,"]=["Asia/Kuwait"];countryCodeMap["RU,"]=["Europe/Moscow","Asia/Yekaterinburg","Asia/Novosibirsk","Asia/Krasnoyarsk","Asia/Ulaanbaatar","Asia/Yakutsk","Asia/Vladivostok","Asia/Magadan","Pacific/Fiji"];countryCodeMap["KE,"]=["Africa/Nairobi"];countryCodeMap["IR,"]=["Asia/Tehran"];countryCodeMap["AE,OM,"]=["Asia/Muscat"];countryCodeMap["AZ,"]=["Asia/Baku"];countryCodeMap["AM,"]=["Asia/Yerevan"];countryCodeMap["AF,"]=["Asia/Kabul"];countryCodeMap["PK,UZ,"]=["Asia/Tashkent"];countryCodeMap["IN,"]=["Asia/Calcutta"];countryCodeMap["NP,"]=["Asia/Katmandu"];countryCodeMap["KZ,BD,"]=["Asia/Dhaka"];countryCodeMap["MM,"]=["Asia/Rangoon"];countryCodeMap["TH,VN,"]=["Asia/Jakarta"];countryCodeMap["MN,"]=["Asia/Ulaanbaatar"];countryCodeMap["MY,"]=["Asia/Kuala_Lumpur"];countryCodeMap["JP,"]=["Asia/Tokyo"];countryCodeMap["KR,KP,"]=["Asia/Seoul"];countryCodeMap["PG,"]=["Pacific/Port_Moresby"];countryCodeMap["SB,NC,"]=["Asia/Magadan"];countryCodeMap["NZ,"]=["Pacific/Auckland"];countryCodeMap["CN,"]=["Asia/Hong_Kong"];countryCodeMap["AU,"]=["Australia/Perth","Australia/Adelaide","Australia/Darwin","Australia/Brisbane","Australia/Sydney","Australia/Hobart"];countryCodeMap["FJ,MH,"]=["Pacific/Fiji"];countryCodeMap["TO,"]=["Pacific/Tongatapu"];function makeTimeZones(){timeZones.push(new TimeZone("UTC","UTC","Coordinated Universal Time"));timeZones.push(new TimeZone("US/Samoa","GMT-11:00","Midway Island, Samoa"));timeZones.push(new TimeZone("US/Hawaii","GMT-10:00","Hawaii"));timeZones.push(new TimeZone("US/Alaska","GMT-09:00","Alaska"));timeZones.push(new TimeZone("US/Pacific","GMT-08:00","Pacific Time (US & Canada)"));timeZones.push(new TimeZone("America/Tijuana","GMT-08:00","Tijuana, Baja California"));timeZones.push(new TimeZone("US/Arizona","GMT-07:00","Arizona"));timeZones.push(new TimeZone("America/Chihuahua","GMT-07:00","Chihuahua, La Paz, Mazatlan"));timeZones.push(new TimeZone("US/Mountain","GMT-07:00","Mountain Time (US & Canada)"));timeZones.push(new TimeZone("US/Central","GMT-06:00","Central Time (US & Canada)"));timeZones.push(new TimeZone("America/Mexico_City","GMT-06:00","Guadalajara, Mexico City, Monterray"));timeZones.push(new TimeZone("Canada/Saskatchewan","GMT-06:00","Saskatchewan"));timeZones.push(new TimeZone("America/Bogota","GMT-05:00","Bogota, Lima, Quito, Rio Branco"));timeZones.push(new TimeZone("US/Eastern","GMT-05:00","Eastern Time (US & Canada)"));timeZones.push(new TimeZone("US/East-Indiana","GMT-05:00","Indiana (East)"));timeZones.push(new TimeZone("Canada/Atlantic","GMT-04:00","Atlantic Time (Canada)"));timeZones.push(new TimeZone("America/La_Paz","GMT-04:00","Caracas, La Paz"));timeZones.push(new TimeZone("America/Manaus","GMT-04:00","Manaus"));timeZones.push(new TimeZone("America/Santiago","GMT-04:00","Santiago"));timeZones.push(new TimeZone("Canada/Newfoundland","GMT-03:30","Newfoundland"));timeZones.push(new TimeZone("Brazil/East","GMT-03:00","Brasilia"));timeZones.push(new TimeZone("America/Buenos_Aires","GMT-03:00","Buenos Aires, Georgetown"));timeZones.push(new TimeZone("America/Godthab","GMT-03:00","Greenland"));timeZones.push(new TimeZone("America/Montevideo","GMT-03:00","Montevideo"));timeZones.push(new TimeZone("Atlantic/South_Georgia","GMT-02:00","Mid-Atlantic"));timeZones.push(new TimeZone("Atlantic/Azores","GMT-01:00","Azores"));timeZones.push(new TimeZone("Atlantic/Cape_Verde","GMT-01:00","Cape Verde Is."));timeZones.push(new TimeZone("Atlantic/Reykjavik","GMT","Casablanca, Monrovia, Reykjavik"));timeZones.push(new TimeZone("Europe/London","GMT","Dublin, Edinburgh, Lisbon, London"));timeZones.push(new TimeZone("Europe/Amsterdam","GMT+01:00","Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"));timeZones.push(new TimeZone("Europe/Belgrade","GMT+01:00","Belgrade, Bratislava, Budapest, Ljubliana, Prague"));timeZones.push(new TimeZone("Europe/Paris","GMT+01:00","Brussels, Copenhagen, Madrid, Paris"));timeZones.push(new TimeZone("Europe/Sarajevo","GMT+01:00","Sarajevo, Skopje, Warsaw, Zagreb"));timeZones.push(new TimeZone("Asia/Amman","GMT+02:00","Amman"));timeZones.push(new TimeZone("Europe/Bucharest","GMT+02:00","Athens, Bucharest, Istanbul"));timeZones.push(new TimeZone("Asia/Beirut","GMT+02:00","Beirut"));timeZones.push(new TimeZone("Africa/Cairo","GMT+02:00","Cairo"));timeZones.push(new TimeZone("Africa/Harare","GMT+02:00","Harare, Pretoria"));timeZones.push(new TimeZone("Europe/Helsinki","GMT+02:00","Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"));timeZones.push(new TimeZone("Asia/Jerusalem","GMT+02:00","Jerusalem"));timeZones.push(new TimeZone("Europe/Minsk","GMT+02:00","Minsk"));timeZones.push(new TimeZone("Asia/Baghdad","GMT+03:00","Baghdad"));timeZones.push(new TimeZone("Asia/Kuwait","GMT+03:00","Kuwait, Riyadh"));timeZones.push(new TimeZone("Europe/Moscow","GMT+03:00","Moscow, St. Petersburg, Volgograd"));timeZones.push(new TimeZone("Africa/Nairobi","GMT+03:00","Nairobi"));timeZones.push(new TimeZone("Asia/Tehran","GMT+03:30","Tehran"));timeZones.push(new TimeZone("Asia/Muscat","GMT+04:00","Abu Dhabi, Muscat"));timeZones.push(new TimeZone("Asia/Baku","GMT+04:00","Baku"));timeZones.push(new TimeZone("Asia/Yerevan","GMT+04:00","Yerevan"));timeZones.push(new TimeZone("Asia/Kabul","GMT+04:30","Kabul"));timeZones.push(new TimeZone("Asia/Yekaterinburg","GMT+05:00","Ekaterinburg"));timeZones.push(new TimeZone("Asia/Tashkent","GMT+05:00","Islamabad, Karachi, Tashkent"));timeZones.push(new TimeZone("Asia/Calcutta","GMT+05:30","Chennai, Kolkata, Mumbai, New Delhi"));timeZones.push(new TimeZone("Asia/Katmandu","GMT+05:45","Katmandu"));timeZones.push(new TimeZone("Asia/Novosibirsk","GMT+06:00","Novosibirsk"));timeZones.push(new TimeZone("Asia/Dhaka","GMT+06:00","Astana, Dhaka"));timeZones.push(new TimeZone("Asia/Rangoon","GMT+06:30","Yangon (Rangoon)"));timeZones.push(new TimeZone("Asia/Jakarta","GMT+07:00","Bangkok, Hanoi, Jakarta"));timeZones.push(new TimeZone("Asia/Krasnoyarsk","GMT+07:00","Krasnoyarsk"));timeZones.push(new TimeZone("Asia/Hong_Kong","GMT+08:00","Beijing, Chongqing, Hong Kong, Urumqi"));timeZones.push(new TimeZone("Asia/Ulaanbaatar","GMT+08:00","Irkutsk, Ulaan Bataar"));timeZones.push(new TimeZone("Asia/Kuala_Lumpur","GMT+08:00","Kuala Lumpur, Singapore"));timeZones.push(new TimeZone("Australia/Perth","GMT+08:00","Perth"));timeZones.push(new TimeZone("Asia/Taipei","GMT+08:00","Taipei"));timeZones.push(new TimeZone("Asia/Tokyo","GMT+09:00","Osaka, Sapporo, Tokyo"));timeZones.push(new TimeZone("Asia/Seoul","GMT+09:00","Seoul"));timeZones.push(new TimeZone("Asia/Yakutsk","GMT+09:00","Yakutsk"));timeZones.push(new TimeZone("Australia/Adelaide","GMT+09:30","Adelaide"));timeZones.push(new TimeZone("Australia/Darwin","GMT+09:30","Darwin"));timeZones.push(new TimeZone("Australia/Brisbane","GMT+10:00","Brisbane"));timeZones.push(new TimeZone("Pacific/Port_Moresby","GMT+10:00","Guam, Port Moresby"));timeZones.push(new TimeZone("Australia/Sydney","GMT+10:00","Canberra, Melbourne, Sydney"));timeZones.push(new TimeZone("Australia/Hobart","GMT+10:00","Hobart"));timeZones.push(new TimeZone("Asia/Vladivostok","GMT+10:00","Vladivostok"));timeZones.push(new TimeZone("Asia/Magadan","GMT+11:00","Magadan, Solomon Is., New Caledonia"));timeZones.push(new TimeZone("Pacific/Auckland","GMT+12:00","Auckland, Wellington"));timeZones.push(new TimeZone("Pacific/Fiji","GMT+12:00","Fiji, Kamchatka, Marshall Is."));timeZones.push(new TimeZone("Pacific/Tongatapu","GMT+13:00","Nuku'alofa"))}function displayLatLon(D,F){var E=Math.abs(D);var A=zeroPad(parseInt(E),2)+"&#176;";E=(E-parseInt(E))*60;A+=zeroPad(parseInt(E),2)+"'";if(D>0){A+="N"}else{A+="S"}var B=Math.abs(F);var C=zeroPad(parseInt(B),3)+"&#176;";B=(B-parseInt(B))*60;C+=zeroPad(parseInt(B),2)+"'";if(F>0){C+="E"}else{C+="W"}return A+" "+C}function zeroPad(A,B){A="000"+A;return A.substring(A.length-B)}var MooTools={version:"1.2.0",build:""};var Native=function(O){O=O||{};var S=O.afterImplement||function(){};var R=O.generics;R=(R!==false);var Q=O.legacy;var T=O.initialize;var M=O.protect;var N=O.name;var L=T||Q;L.constructor=Native;L.$family={name:"native"};if(Q&&T){L.prototype=Q.prototype}L.prototype.constructor=L;if(N){var K=N.toLowerCase();L.prototype.$family={name:K};Native.typize(L,K)}var P=function(D,B,C,A){if(!M||A||!D.prototype[B]){D.prototype[B]=C}if(R){Native.genericize(D,B,M)}S.call(D,B,C);return D};L.implement=function(A,B,C){if(typeof A=="string"){return P(this,A,B,C)}for(var D in A){P(this,D,A[D],B)}return this};L.alias=function(D,B,C){if(typeof D=="string"){D=this.prototype[D];if(D){P(this,B,D,C)}}else{for(var A in D){this.alias(A,D[A],B)}}return this};return L};Native.implement=function(F,G){for(var H=0,E=F.length;H<E;H++){F[H].implement(G)}};Native.genericize=function(F,E,D){if((!D||!F[E])&&typeof F.prototype[E]=="function"){F[E]=function(){var A=Array.prototype.slice.call(arguments);return F.prototype[E].apply(A.shift(),A)}}};Native.typize=function(C,D){if(!C.type){C.type=function(A){return($type(A)===D)}}};Native.alias=function(I,L,G,H){for(var J=0,K=I.length;J<K;J++){I[J].alias(L,G,H)}};(function(D){for(var C in D){Native.typize(D[C],C)}})({"boolean":Boolean,"native":Native,object:Object});(function(D){for(var C in D){new Native({name:C,initialize:D[C],protect:true})}})({String:String,Function:Function,Number:Number,Array:Array,RegExp:RegExp,Date:Date});(function(F,D){for(var E=D.length;E--;E){Native.genericize(F,D[E],true)}return arguments.callee})(Array,["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","toString","valueOf","indexOf","lastIndexOf"])(String,["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","replace","search","slice","split","substr","substring","toLowerCase","toUpperCase","valueOf"]);function $chk(B){return !!(B||B===0)}function $clear(B){clearTimeout(B);clearInterval(B);return null}function $defined(B){return(B!=undefined)}function $empty(){}function $arguments(B){return function(){return arguments[B]}}function $lambda(B){return(typeof B=="function")?B:function(){return B}}function $extend(E,D){for(var F in (D||{})){E[F]=D[F]}return E}function $unlink(I){var J;switch($type(I)){case"object":J={};for(var G in I){J[G]=$unlink(I[G])}break;case"hash":J=$unlink(I.getClean());break;case"array":J=[];for(var H=0,F=I.length;H<F;H++){J[H]=$unlink(I[H])}break;default:return I}return J}function $merge(){var K={};for(var L=0,H=arguments.length;L<H;L++){var N=arguments[L];if($type(N)!="object"){continue}for(var M in N){var I=N[M],J=K[M];K[M]=(J&&$type(I)=="object"&&$type(J)=="object")?$merge(J,I):$unlink(I)}}return K}function $pick(){for(var D=0,C=arguments.length;D<C;D++){if(arguments[D]!=undefined){return arguments[D]}}return null}function $random(D,C){return Math.floor(Math.random()*(C-D+1)+D)}function $splat(D){var C=$type(D);return(C)?((C!="array"&&C!="arguments")?[D]:D):[]}var $time=Date.now||function(){return new Date().getTime()};function $try(){for(var F=0,D=arguments.length;F<D;F++){try{return arguments[F]()}catch(E){}}return null}function $type(B){if(B==undefined){return false}if(B.$family){return(B.$family.name=="number"&&!isFinite(B))?false:B.$family.name}if(B.nodeName){switch(B.nodeType){case 1:return"element";case 3:return(/\S/).test(B.nodeValue)?"textnode":"whitespace"}}else{if(typeof B.length=="number"){if(B.callee){return"arguments"}else{if(B.item){return"collection"}}}}return typeof B}var Hash=new Native({name:"Hash",initialize:function(C){if($type(C)=="hash"){C=$unlink(C.getClean())}for(var D in C){this[D]=C[D]}return this}});Hash.implement({getLength:function(){var D=0;for(var C in this){if(this.hasOwnProperty(C)){D++}}return D},forEach:function(F,E){for(var D in this){if(this.hasOwnProperty(D)){F.call(E,this[D],D,this)}}},getClean:function(){var D={};for(var C in this){if(this.hasOwnProperty(C)){D[C]=this[C]}}return D}});Hash.alias("forEach","each");function $H(B){return new Hash(B)}Array.implement({forEach:function(G,F){for(var H=0,E=this.length;H<E;H++){G.call(F,this[H],H,this)}}});Array.alias("forEach","each");function $A(G){if(G.item){var F=[];for(var H=0,E=G.length;H<E;H++){F[H]=G[H]}return F}return Array.prototype.slice.call(G)}function $each(G,H,F){var E=$type(G);((E=="arguments"||E=="collection"||E=="array")?Array:Hash).each(G,H,F)}var Browser=new Hash({Engine:{name:"unknown",version:""},Platform:{name:(navigator.platform.match(/mac|win|linux/i)||["other"])[0].toLowerCase()},Features:{xpath:!!(document.evaluate),air:!!(window.runtime)},Plugins:{}});if(window.opera){Browser.Engine={name:"presto",version:(document.getElementsByClassName)?950:925}}else{if(window.ActiveXObject){Browser.Engine={name:"trident",version:(window.XMLHttpRequest)?5:4}}else{if(!navigator.taintEnabled){Browser.Engine={name:"webkit",version:(Browser.Features.xpath)?420:419}}else{if(document.getBoxObjectFor!=null){Browser.Engine={name:"gecko",version:(document.getElementsByClassName)?19:18}}}}}Browser.Engine[Browser.Engine.name]=Browser.Engine[Browser.Engine.name+Browser.Engine.version]=true;if(window.orientation!=undefined){Browser.Platform.name="ipod"}Browser.Platform[Browser.Platform.name]=true;Browser.Request=function(){return $try(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("MSXML2.XMLHTTP")})};Browser.Features.xhr=!!(Browser.Request());Browser.Plugins.Flash=(function(){var B=($try(function(){return navigator.plugins["Shockwave Flash"].description},function(){return new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")})||"0 r0").match(/\d+/g);return{version:parseInt(B[0]||0+"."+B[1]||0),build:parseInt(B[2]||0)}})();function $exec(D){if(!D){return D}if(window.execScript){window.execScript(D)}else{var C=document.createElement("script");C.setAttribute("type","text/javascript");C.text=D;document.head.appendChild(C);document.head.removeChild(C)}return D}Native.UID=1;var $uid=(Browser.Engine.trident)?function(B){return(B.uid||(B.uid=[Native.UID++]))[0]}:function(B){return B.uid||(B.uid=Native.UID++)};var Window=new Native({name:"Window",legacy:(Browser.Engine.trident)?null:window.Window,initialize:function(B){$uid(B);if(!B.Element){B.Element=$empty;if(Browser.Engine.webkit){B.document.createElement("iframe")}B.Element.prototype=(Browser.Engine.webkit)?window["[[DOMElement.prototype]]"]:{}}return $extend(B,Window.Prototype)},afterImplement:function(D,C){window[D]=Window.Prototype[D]=C}});Window.Prototype={$family:{name:"window"}};new Window(window);var Document=new Native({name:"Document",legacy:(Browser.Engine.trident)?null:window.Document,initialize:function(B){$uid(B);B.head=B.getElementsByTagName("head")[0];B.html=B.getElementsByTagName("html")[0];B.window=B.defaultView||B.parentWindow;if(Browser.Engine.trident4){$try(function(){B.execCommand("BackgroundImageCache",false,true)})}return $extend(B,Document.Prototype)},afterImplement:function(D,C){document[D]=Document.Prototype[D]=C}});Document.Prototype={$family:{name:"document"}};new Document(document);Array.implement({every:function(G,F){for(var H=0,E=this.length;H<E;H++){if(!G.call(F,this[H],H,this)){return false}}return true},filter:function(H,G){var I=[];for(var J=0,F=this.length;J<F;J++){if(H.call(G,this[J],J,this)){I.push(this[J])}}return I},clean:function(){return this.filter($defined)},indexOf:function(G,F){var E=this.length;for(var H=(F<0)?Math.max(0,E+F):F||0;H<E;H++){if(this[H]===G){return H}}return -1},map:function(H,G){var I=[];for(var J=0,F=this.length;J<F;J++){I[J]=H.call(G,this[J],J,this)}return I},some:function(G,F){for(var H=0,E=this.length;H<E;H++){if(G.call(F,this[H],H,this)){return true}}return false},associate:function(G){var F={},H=Math.min(this.length,G.length);for(var E=0;E<H;E++){F[G[E]]=this[E]}return F},link:function(I){var F={};for(var G=0,J=this.length;G<J;G++){for(var H in I){if(I[H](this[G])){F[H]=this[G];delete I[H];break}}}return F},contains:function(C,D){return this.indexOf(C,D)!=-1},extend:function(E){for(var F=0,D=E.length;F<D;F++){this.push(E[F])}return this},getLast:function(){return(this.length)?this[this.length-1]:null},getRandom:function(){return(this.length)?this[$random(0,this.length-1)]:null},include:function(B){if(!this.contains(B)){this.push(B)}return this},combine:function(E){for(var F=0,D=E.length;F<D;F++){this.include(E[F])}return this},erase:function(D){for(var C=this.length;C--;C){if(this[C]===D){this.splice(C,1)}}return this},empty:function(){this.length=0;return this},flatten:function(){var F=[];for(var H=0,E=this.length;H<E;H++){var G=$type(this[H]);if(!G){continue}F=F.concat((G=="array"||G=="collection"||G=="arguments")?Array.flatten(this[H]):this[H])}return F},hexToRgb:function(D){if(this.length!=3){return null}var C=this.map(function(A){if(A.length==1){A+=A}return A.toInt(16)});return(D)?C:"rgb("+C+")"},rgbToHex:function(F){if(this.length<3){return null}if(this.length==4&&this[3]==0&&!F){return"transparent"}var H=[];for(var E=0;E<3;E++){var G=(this[E]-0).toString(16);H.push((G.length==1)?"0"+G:G)}return(F)?H:"#"+H.join("")}});Function.implement({extend:function(C){for(var D in C){this[D]=C[D]}return this},create:function(D){var C=this;D=D||{};return function(B){var F=D.arguments;F=(F!=undefined)?$splat(F):Array.slice(arguments,(D.event)?1:0);if(D.event){F=[B||window.event].extend(F)}var A=function(){return C.apply(D.bind||null,F)};if(D.delay){return setTimeout(A,D.delay)}if(D.periodical){return setInterval(A,D.periodical)}if(D.attempt){return $try(A)}return A()}},pass:function(C,D){return this.create({arguments:C,bind:D})},attempt:function(C,D){return this.create({arguments:C,bind:D,attempt:true})()},bind:function(D,C){return this.create({bind:D,arguments:C})},bindWithEvent:function(D,C){return this.create({bind:D,event:true,arguments:C})},delay:function(F,E,D){return this.create({delay:F,bind:E,arguments:D})()},periodical:function(D,E,F){return this.create({periodical:D,bind:E,arguments:F})()},run:function(C,D){return this.apply(D,$splat(C))}});Number.implement({limit:function(D,C){return Math.min(C,Math.max(D,this))},round:function(B){B=Math.pow(10,B||0);return Math.round(this*B)/B},times:function(F,E){for(var D=0;D<this;D++){F.call(E,D,this)}},toFloat:function(){return parseFloat(this)},toInt:function(B){return parseInt(this,B||10)}});Number.alias("times","each");(function(D){var C={};D.each(function(A){if(!Number[A]){C[A]=function(){return Math[A].apply(null,[this].concat($A(arguments)))}}});Number.implement(C)})(["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","sin","sqrt","tan"]);String.implement({test:function(C,D){return((typeof C=="string")?new RegExp(C,D):C).test(this)},contains:function(C,D){return(D)?(D+this+D).indexOf(D+C+D)>-1:this.indexOf(C)>-1},trim:function(){return this.replace(/^\s+|\s+$/g,"")},clean:function(){return this.replace(/\s+/g," ").trim()},camelCase:function(){return this.replace(/-\D/g,function(B){return B.charAt(1).toUpperCase()})},hyphenate:function(){return this.replace(/[A-Z]/g,function(B){return("-"+B.charAt(0).toLowerCase())})},capitalize:function(){return this.replace(/\b[a-z]/g,function(B){return B.toUpperCase()})},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")},toInt:function(B){return parseInt(this,B||10)},toFloat:function(){return parseFloat(this)},hexToRgb:function(D){var C=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return(C)?C.slice(1).hexToRgb(D):null},rgbToHex:function(D){var C=this.match(/\d{1,3}/g);return(C)?C.rgbToHex(D):null},stripScripts:function(F){var D="";var E=this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){D+=arguments[1]+"\n";return""});if(F===true){$exec(D)}else{if($type(F)=="function"){F(D,E)}}return E},substitute:function(C,D){return this.replace(D||(/\\?\{([^}]+)\}/g),function(A,B){if(A.charAt(0)=="\\"){return A.slice(1)}return(C[B]!=undefined)?C[B]:""})}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(D){for(var C in this){if(this.hasOwnProperty(C)&&this[C]===D){return C}}return null},hasValue:function(B){return(Hash.keyOf(this,B)!==null)},extend:function(B){Hash.each(B,function(A,D){Hash.set(this,D,A)},this);return this},combine:function(B){Hash.each(B,function(A,D){Hash.include(this,D,A)},this);return this},erase:function(B){if(this.hasOwnProperty(B)){delete this[B]}return this},get:function(B){return(this.hasOwnProperty(B))?this[B]:null},set:function(C,D){if(!this[C]||this.hasOwnProperty(C)){this[C]=D}return this},empty:function(){Hash.each(this,function(D,C){delete this[C]},this);return this},include:function(F,E){var D=this[F];if(D==undefined){this[F]=E}return this},map:function(F,E){var D=new Hash;Hash.each(this,function(A,B){D.set(B,F.call(E,A,B,this))},this);return D},filter:function(F,E){var D=new Hash;Hash.each(this,function(A,B){if(F.call(E,A,B,this)){D.set(B,A)}},this);return D},every:function(F,E){for(var D in this){if(this.hasOwnProperty(D)&&!F.call(E,this[D],D)){return false}}return true},some:function(F,E){for(var D in this){if(this.hasOwnProperty(D)&&F.call(E,this[D],D)){return true}}return false},getKeys:function(){var B=[];Hash.each(this,function(A,D){B.push(D)});return B},getValues:function(){var B=[];Hash.each(this,function(A){B.push(A)});return B},toQueryString:function(C){var D=[];Hash.each(this,function(A,B){if(C){B=C+"["+B+"]"}var G;switch($type(A)){case"object":G=Hash.toQueryString(A,B);break;case"array":var H={};A.each(function(E,F){H[F]=E});G=Hash.toQueryString(H,B);break;default:G=B+"="+encodeURIComponent(A)}if(A!=undefined){D.push(G)}});return D.join("&")}});Hash.alias({keyOf:"indexOf",hasValue:"contains"});var Class=new Native({name:"Class",initialize:function(D){D=D||{};var C=function(B){for(var G in this){this[G]=$unlink(this[G])}for(var A in Class.Mutators){if(!this[A]){continue}Class.Mutators[A](this,this[A]);delete this[A]}this.constructor=C;if(B===$empty){return this}var H=(this.initialize)?this.initialize.apply(this,arguments):this;if(this.options&&this.options.initialize){this.options.initialize.call(this)}return H};$extend(C,this);C.constructor=Class;C.prototype=D;return C}});Class.implement({implement:function(){Class.Mutators.Implements(this.prototype,Array.slice(arguments));return this}});Class.Mutators={Implements:function(C,D){$splat(D).each(function(A){$extend(C,($type(A)=="class")?new A($empty):A)})},Extends:function(self,klass){var instance=new klass($empty);delete instance.parent;delete instance.parentOf;for(var key in instance){var current=self[key],previous=instance[key];if(current==undefined){self[key]=previous;continue}var ctype=$type(current),ptype=$type(previous);if(ctype!=ptype){continue}switch(ctype){case"function":if(!arguments.callee.caller){self[key]=eval("("+String(current).replace(/\bthis\.parent\(\s*(\))?/g,function(full,close){return"arguments.callee._parent_.call(this"+(close||", ")})+")")}self[key]._parent_=previous;break;case"object":self[key]=$merge(previous,current)}}self.parent=function(){return arguments.callee.caller._parent_.apply(this,arguments)};self.parentOf=function(descendant){return descendant._parent_.apply(this,Array.slice(arguments,1))}}};var Chain=new Class({chain:function(){this.$chain=(this.$chain||[]).extend(arguments);return this},callChain:function(){return(this.$chain&&this.$chain.length)?this.$chain.shift().apply(this,arguments):false},clearChain:function(){if(this.$chain){this.$chain.empty()}return this}});var Events=new Class({addEvent:function(E,F,D){E=Events.removeOn(E);if(F!=$empty){this.$events=this.$events||{};this.$events[E]=this.$events[E]||[];this.$events[E].include(F);if(D){F.internal=true}}return this},addEvents:function(C){for(var D in C){this.addEvent(D,C[D])}return this},fireEvent:function(E,F,D){E=Events.removeOn(E);if(!this.$events||!this.$events[E]){return this}this.$events[E].each(function(A){A.create({bind:this,delay:D,"arguments":F})()},this);return this},removeEvent:function(D,C){D=Events.removeOn(D);if(!this.$events||!this.$events[D]){return this}if(!C.internal){this.$events[D].erase(C)}return this},removeEvents:function(G){for(var F in this.$events){if(G&&G!=F){continue}var H=this.$events[F];for(var E=H.length;E--;E){this.removeEvent(F,H[E])}}return this}});Events.removeOn=function(B){return B.replace(/^on([A-Z])/,function(D,A){return A.toLowerCase()})};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent){return this}for(var B in this.options){if($type(this.options[B])!="function"||!(/^on[A-Z]/).test(B)){continue}this.addEvent(B,this.options[B]);delete this.options[B]}return this}});Document.implement({newElement:function(C,D){if(Browser.Engine.trident&&D){["name","type","checked"].each(function(A){if(!D[A]){return }C+=" "+A+'="'+D[A]+'"';if(A!="checked"){delete D[A]}});C="<"+C+">"}return $.element(this.createElement(C)).set(D)},newTextNode:function(B){return this.createTextNode(B)},getDocument:function(){return this},getWindow:function(){return this.defaultView||this.parentWindow},purge:function(){var E=this.getElementsByTagName("*");for(var F=0,D=E.length;F<D;F++){Browser.freeMem(E[F])}}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(D,F){var E=Element.Constructors.get(D);if(E){return E(F)}if(typeof D=="string"){return document.newElement(D,F)}return $(D).set(F)},afterImplement:function(C,D){if(!Array[C]){Elements.implement(C,Elements.multi(C))}Element.Prototype[C]=D}});Element.Prototype={$family:{name:"element"}};Element.Constructors=new Hash;var IFrame=new Native({name:"IFrame",generics:false,initialize:function(){var G=Array.link(arguments,{properties:Object.type,iframe:$defined});var I=G.properties||{};var J=$(G.iframe)||false;var H=I.onload||$empty;delete I.onload;I.id=I.name=$pick(I.id,I.name,J.id,J.name,"IFrame_"+$time());J=new Element(J||"iframe",I);var F=function(){var C=$try(function(){return J.contentWindow.location.host});if(C&&C==window.location.host){var A=new Window(J.contentWindow);var B=new Document(J.contentWindow.document);$extend(A.Element.prototype,Element.Prototype)}H.call(J.contentWindow,J.contentWindow.document)};(!window.frames[I.id])?J.addListener("load",F):F();return J}});var Elements=new Native({initialize:function(J,N){N=$extend({ddup:true,cash:true},N);J=J||[];if(N.ddup||N.cash){var I={},K=[];for(var M=0,H=J.length;M<H;M++){var L=$.element(J[M],!N.cash);if(N.ddup){if(I[L.uid]){continue}I[L.uid]=true}K.push(L)}J=K}return(N.cash)?$extend(J,this):J}});Elements.implement({filter:function(C,D){if(!C){return this}return new Elements(Array.filter(this,(typeof C=="string")?function(A){return A.match(C)}:C,D))}});Elements.multi=function(B){return function(){var J=[];var A=true;for(var H=0,I=this.length;H<I;H++){var G=this[H][B].apply(this[H],arguments);J.push(G);if(A){A=($type(G)=="element")}}return(A)?new Elements(J):J}};Window.implement({$:function(F,E){if(F&&F.$family&&F.uid){return F}var D=$type(F);return($[D])?$[D](F,E,this.document):null},$$:function(G){if(arguments.length==1&&typeof G=="string"){return this.document.getElements(G)}var H=[];var K=Array.flatten(arguments);for(var J=0,L=K.length;J<L;J++){var I=K[J];switch($type(I)){case"element":I=[I];break;case"string":I=this.document.getElements(I,true);break;default:I=false}if(I){H.extend(I)}}return new Elements(H)},getDocument:function(){return this.document},getWindow:function(){return this}});$.string=function(E,F,D){E=D.getElementById(E);return(E)?$.element(E,F):null};$.element=function(E,F){$uid(E);if(!F&&!E.$family&&!(/^object|embed$/i).test(E.tagName)){var H=Element.Prototype;for(var G in H){E[G]=H[G]}}return E};$.object=function(F,E,D){if(F.toElement){return $.element(F.toElement(D),E)}return null};$.textnode=$.whitespace=$.window=$.document=$arguments(0);Native.implement([Element,Document],{getElement:function(C,D){return $(this.getElements(C,true)[0]||null,D)},getElements:function(E,F){E=E.split(",");var G=[];var H=(E.length>1);E.each(function(B){var A=this.getElementsByTagName(B.trim());(H)?G.extend(A):G=A},this);return new Elements(G,{ddup:H,cash:!F})}});Element.Storage={get:function(B){return(this[B]||(this[B]={}))}};Element.Inserters=new Hash({before:function(D,C){if(C.parentNode){C.parentNode.insertBefore(D,C)}},after:function(F,D){if(!D.parentNode){return }var E=D.nextSibling;(E)?D.parentNode.insertBefore(F,E):D.parentNode.appendChild(F)},bottom:function(D,C){C.appendChild(D)},top:function(F,D){var E=D.firstChild;(E)?D.insertBefore(F,E):D.appendChild(F)}});Element.Inserters.inside=Element.Inserters.bottom;Element.Inserters.each(function(E,F){var D=F.capitalize();Element.implement("inject"+D,function(A){E(this,$(A,true));return this});Element.implement("grab"+D,function(A){E($(A,true),this);return this})});Element.implement({getDocument:function(){return this.ownerDocument},getWindow:function(){return this.ownerDocument.getWindow()},getElementById:function(F,G){var H=this.ownerDocument.getElementById(F);if(!H){return null}for(var E=H.parentNode;E!=this;E=E.parentNode){if(!E){return null}}return $.element(H,G)},set:function(F,H){switch($type(F)){case"object":for(var G in F){this.set(G,F[G])}break;case"string":var E=Element.Properties.get(F);(E&&E.set)?E.set.apply(this,Array.slice(arguments,1)):this.setProperty(F,H)}return this},get:function(D){var C=Element.Properties.get(D);return(C&&C.get)?C.get.apply(this,Array.slice(arguments,1)):this.getProperty(D)},erase:function(D){var C=Element.Properties.get(D);(C&&C.erase)?C.erase.apply(this,Array.slice(arguments,1)):this.removeProperty(D);return this},match:function(B){return(!B||Element.get(this,"tag")==B)},inject:function(D,C){Element.Inserters.get(C||"bottom")(this,$(D,true));return this},wraps:function(D,C){D=$(D,true);return this.replaces(D).grab(D,C)},grab:function(D,C){Element.Inserters.get(C||"bottom")($(D,true),this);return this},appendText:function(D,C){return this.grab(this.getDocument().newTextNode(D),C)},adopt:function(){Array.flatten(arguments).each(function(B){B=$(B,true);if(B){this.appendChild(B)}},this);return this},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this},clone:function(M,N){switch($type(this)){case"element":var U={};for(var V=0,X=this.attributes.length;V<X;V++){var O=this.attributes[V],Q=O.nodeName.toLowerCase();if(Browser.Engine.trident&&(/input/i).test(this.tagName)&&(/width|height/).test(Q)){continue}var R=(Q=="style"&&this.style)?this.style.cssText:O.nodeValue;if(!$chk(R)||Q=="uid"||(Q=="id"&&!N)){continue}if(R!="inherit"&&["string","number"].contains($type(R))){U[Q]=R}}var S=new Element(this.nodeName.toLowerCase(),U);if(M!==false){for(var T=0,W=this.childNodes.length;T<W;T++){var P=Element.clone(this.childNodes[T],true,N);if(P){S.grab(P)}}}return S;case"textnode":return document.newTextNode(this.nodeValue)}return null},replaces:function(B){B=$(B,true);B.parentNode.replaceChild(this,B);return this},hasClass:function(B){return this.className.contains(B," ")},addClass:function(B){if(!this.hasClass(B)){this.className=(this.className+" "+B).clean()}return this},removeClass:function(B){this.className=this.className.replace(new RegExp("(^|\\s)"+B+"(?:\\s|$)"),"$1").clean();return this},toggleClass:function(B){return this.hasClass(B)?this.removeClass(B):this.addClass(B)},getComputedStyle:function(D){if(this.currentStyle){return this.currentStyle[D.camelCase()]}var C=this.getWindow().getComputedStyle(this,null);return(C)?C.getPropertyValue([D.hyphenate()]):null},empty:function(){$A(this.childNodes).each(function(B){Browser.freeMem(B);Element.empty(B);Element.dispose(B)},this);return this},destroy:function(){Browser.freeMem(this.empty().dispose());return null},getSelected:function(){return new Elements($A(this.options).filter(function(B){return B.selected}))},toQueryString:function(){var B=[];this.getElements("input, select, textarea").each(function(D){if(!D.name||D.disabled){return }var A=(D.tagName.toLowerCase()=="select")?Element.getSelected(D).map(function(C){return C.value}):((D.type=="radio"||D.type=="checkbox")&&!D.checked)?null:D.value;$splat(A).each(function(C){if(C){B.push(D.name+"="+encodeURIComponent(C))}})});return B.join("&")},getProperty:function(G){var H=Element.Attributes,E=H.Props[G];var F=(E)?this[E]:this.getAttribute(G,2);return(H.Bools[G])?!!F:(E)?F:F||null},getProperties:function(){var B=$A(arguments);return B.map(function(A){return this.getProperty(A)},this).associate(B)},setProperty:function(H,G){var I=Element.Attributes,J=I.Props[H],F=$defined(G);if(J&&I.Bools[H]){G=(G||!F)?true:false}else{if(!F){return this.removeProperty(H)}}(J)?this[J]=G:this.setAttribute(H,G);return this},setProperties:function(C){for(var D in C){this.setProperty(D,C[D])}return this},removeProperty:function(F){var G=Element.Attributes,H=G.Props[F],E=(H&&G.Bools[F]);(H)?this[H]=(E)?false:"":this.removeAttribute(F);return this},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this}});(function(){var B=function(N,P,A,O,L,J){var M=N[A||P];var K=[];while(M){if(M.nodeType==1&&(!O||Element.match(M,O))){K.push(M);if(!L){break}}M=M[P]}return(L)?new Elements(K,{ddup:false,cash:!J}):$(K[0],J)};Element.implement({getPrevious:function(D,A){return B(this,"previousSibling",null,D,false,A)},getAllPrevious:function(D,A){return B(this,"previousSibling",null,D,true,A)},getNext:function(D,A){return B(this,"nextSibling",null,D,false,A)},getAllNext:function(D,A){return B(this,"nextSibling",null,D,true,A)},getFirst:function(D,A){return B(this,"nextSibling","firstChild",D,false,A)},getLast:function(D,A){return B(this,"previousSibling","lastChild",D,false,A)},getParent:function(D,A){return B(this,"parentNode",null,D,false,A)},getParents:function(D,A){return B(this,"parentNode",null,D,true,A)},getChildren:function(D,A){return B(this,"nextSibling","firstChild",D,true,A)},hasChild:function(A){A=$(A,true);return(!!A&&$A(this.getElementsByTagName(A.tagName)).contains(A))}})})();Element.Properties=new Hash;Element.Properties.style={set:function(B){this.style.cssText=B},get:function(){return this.style.cssText},erase:function(){this.style.cssText=""}};Element.Properties.tag={get:function(){return this.tagName.toLowerCase()}};Element.Properties.href={get:function(){return(!this.href)?null:this.href.replace(new RegExp("^"+document.location.protocol+"//"+document.location.host),"")}};Element.Properties.html={set:function(){return this.innerHTML=Array.flatten(arguments).join("")}};Native.implement([Element,Window,Document],{addListener:function(D,C){if(this.addEventListener){this.addEventListener(D,C,false)}else{this.attachEvent("on"+D,C)}return this},removeListener:function(D,C){if(this.removeEventListener){this.removeEventListener(D,C,false)}else{this.detachEvent("on"+D,C)}return this},retrieve:function(H,E){var F=Element.Storage.get(this.uid);var G=F[H];if($defined(E)&&!$defined(G)){G=F[H]=E}return $pick(G)},store:function(F,D){var E=Element.Storage.get(this.uid);E[F]=D;return this},eliminate:function(C){var D=Element.Storage.get(this.uid);delete D[C];return this}});Element.Attributes=new Hash({Props:{html:"innerHTML","class":"className","for":"htmlFor",text:(Browser.Engine.trident)?"innerText":"textContent"},Bools:["compact","nowrap","ismap","declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"],Camels:["value","accessKey","cellPadding","cellSpacing","colSpan","frameBorder","maxLength","readOnly","rowSpan","tabIndex","useMap"]});Browser.freeMem=function(C){if(!C){return }if(Browser.Engine.trident&&(/object/i).test(C.tagName)){for(var D in C){if(typeof C[D]=="function"){C[D]=$empty}}Element.dispose(C)}if(C.uid&&C.removeEvents){C.removeEvents()}};(function(F){var E=F.Bools,D=F.Camels;F.Bools=E=E.associate(E);Hash.extend(Hash.combine(F.Props,E),D.associate(D.map(function(A){return A.toLowerCase()})));F.erase("Camels")})(Element.Attributes);window.addListener("unload",function(){window.removeListener("unload",arguments.callee);document.purge();if(Browser.Engine.trident){CollectGarbage()}});Element.Properties.styles={set:function(B){this.setStyles(B)}};Element.Properties.opacity={set:function(C,D){if(!D){if(C==0){if(this.style.visibility!="hidden"){this.style.visibility="hidden"}}else{if(this.style.visibility!="visible"){this.style.visibility="visible"}}}if(!this.currentStyle||!this.currentStyle.hasLayout){this.style.zoom=1}if(Browser.Engine.trident){this.style.filter=(C==1)?"":"alpha(opacity="+C*100+")"}this.style.opacity=C;this.store("opacity",C)},get:function(){return this.retrieve("opacity",1)}};Element.implement({setOpacity:function(B){return this.set("opacity",B,true)},getOpacity:function(){return this.get("opacity")},setStyle:function(F,D){switch(F){case"opacity":return this.set("opacity",parseFloat(D));case"float":F=(Browser.Engine.trident)?"styleFloat":"cssFloat"}F=F.camelCase();if($type(D)!="string"){var E=(Element.Styles.get(F)||"@").split(" ");D=$splat(D).map(function(A,B){if(!E[B]){return""}return($type(A)=="number")?E[B].replace("@",Math.round(A)):A}).join(" ")}else{if(D==String(Number(D))){D=Math.round(D)}}this.style[F]=D;return this},getStyle:function(I){switch(I){case"opacity":return this.get("opacity");case"float":I=(Browser.Engine.trident)?"styleFloat":"cssFloat"}I=I.camelCase();var H=this.style[I];if(!$chk(H)){H=[];for(var J in Element.ShortStyles){if(I!=J){continue}for(var K in Element.ShortStyles[J]){H.push(this.getStyle(K))}return H.join(" ")}H=this.getComputedStyle(I)}if(H){H=String(H);var M=H.match(/rgba?\([\d\s,]+\)/);if(M){H=H.replace(M[0],M[0].rgbToHex())}}if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(H)))){if(I.test(/^(height|width)$/)){var N=(I=="width")?["left","right"]:["top","bottom"],L=0;N.each(function(A){L+=this.getStyle("border-"+A+"-width").toInt()+this.getStyle("padding-"+A).toInt()},this);return this["offset"+I.capitalize()]-L+"px"}if(Browser.Engine.presto&&String(H).test("px")){return H}if(I.test(/(border(.+)Width|margin|padding)/)){return"0px"}}return H},setStyles:function(D){for(var C in D){this.setStyle(C,D[C])}return this},getStyles:function(){var B={};Array.each(arguments,function(A){B[A]=this.getStyle(A)},this);return B}});Element.Styles=new Hash({left:"@px",top:"@px",bottom:"@px",right:"@px",width:"@px",height:"@px",maxWidth:"@px",maxHeight:"@px",minWidth:"@px",minHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"});Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(I){var J=Element.ShortStyles;var N=Element.Styles;["margin","padding"].each(function(B){var A=B+I;J[B][A]=N[A]="@px"});var K="border"+I;J.border[K]=N[K]="@px @ rgb(@, @, @)";var L=K+"Width",H=K+"Style",M=K+"Color";J[K]={};J.borderWidth[L]=J[K][L]=N[L]="@px";J.borderStyle[H]=J[K][H]=N[H]="@";J.borderColor[M]=J[K][M]=N[M]="rgb(@, @, @)"});var JSON=new Hash({encode:function(D){switch($type(D)){case"string":return'"'+D.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case"array":return"["+String(D.map(JSON.encode).filter($defined))+"]";case"object":case"hash":var C=[];Hash.each(D,function(A,B){var F=JSON.encode(A);if(F){C.push(JSON.encode(B)+":"+F)}});return"{"+C+"}";case"number":case"boolean":return String(D);case false:return"null"}return null},$specialChars:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},$replaceChars:function(B){return JSON.$specialChars[B]||"\\u00"+Math.floor(B.charCodeAt()/16).toString(16)+(B.charCodeAt()%16).toString(16)},decode:function(string,secure){if($type(string)!="string"||!string.length){return null}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null}return eval("("+string+")")}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this)}});var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:"ignore",transition:function(B){return -(Math.cos(Math.PI*B)-1)/2}},initialize:function(C){this.subject=this.subject||this;this.setOptions(C);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt();var D=this.options.wait;if(D===false){this.options.link="cancel"}},step:function(){var C=$time();if(C<this.time+this.options.duration){var D=this.options.transition((C-this.time)/this.options.duration);this.set(this.compute(this.from,this.to,D))}else{this.set(this.compute(this.from,this.to,1));this.complete()}},set:function(B){return B},compute:function(E,F,D){return Fx.compute(E,F,D)},check:function(B){if(!this.timer){return true}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(B.bind(this,Array.slice(arguments,1)));return false}return false},start:function(D,C){if(!this.check(arguments.callee,D,C)){return this}this.from=D;this.to=C;this.time=0;this.startTimer();this.onStart();return this},complete:function(){if(this.stopTimer()){this.onComplete()}return this},cancel:function(){if(this.stopTimer()){this.onCancel()}return this},onStart:function(){this.fireEvent("start",this.subject)},onComplete:function(){this.fireEvent("complete",this.subject);if(!this.callChain()){this.fireEvent("chainComplete",this.subject)}},onCancel:function(){this.fireEvent("cancel",this.subject).clearChain()},pause:function(){this.stopTimer();return this},resume:function(){this.startTimer();return this},stopTimer:function(){if(!this.timer){return false}this.time=$time()-this.time;this.timer=$clear(this.timer);return true},startTimer:function(){if(this.timer){return false}this.time=$time()-this.time;this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);return true}});Fx.compute=function(E,F,D){return(F-E)*D+E};Fx.Durations={"short":250,normal:500,"long":1000};Fx.CSS=new Class({Extends:Fx,prepare:function(H,G,J){J=$splat(J);var I=J[1];if(!$chk(I)){J[1]=J[0];J[0]=H.getStyle(G)}var F=J.map(this.parse);return{from:F[0],to:F[1]}},parse:function(B){B=$lambda(B)();B=(typeof B=="string")?B.split(" "):$splat(B);return B.map(function(A){A=String(A);var D=false;Fx.CSS.Parsers.each(function(C,G){if(D){return }var H=C.parse(A);if($chk(H)){D={value:H,parser:C}}});D=D||{value:A,parser:Fx.CSS.Parsers.String};return D})},compute:function(F,G,H){var E=[];(Math.min(F.length,G.length)).times(function(A){E.push({value:F[A].parser.compute(F[A].value,G[A].value,H),parser:F[A].parser})});E.$family={name:"fx:css:value"};return E},serve:function(E,F){if($type(E)!="fx:css:value"){E=this.parse(E)}var D=[];E.each(function(A){D=D.concat(A.parser.serve(A.value,F))});return D},render:function(E,F,G,H){E.setStyle(F,this.serve(G,H))},search:function(C){if(Fx.CSS.Cache[C]){return Fx.CSS.Cache[C]}var D={};Array.each(document.styleSheets,function(B,G){var H=B.href;if(H&&H.contains("://")&&!H.contains(document.domain)){return }var A=B.rules||B.cssRules;Array.each(A,function(E,J){if(!E.style){return }var F=(E.selectorText)?E.selectorText.replace(/^\w+/,function(I){return I.toLowerCase()}):null;if(!F||!F.test("^"+C+"$")){return }Element.Styles.each(function(I,L){if(!E.style[L]||Element.ShortStyles[L]){return }I=String(E.style[L]);D[L]=(I.test(/^rgb/))?I.rgbToHex():I})})});return Fx.CSS.Cache[C]=D}});Fx.CSS.Cache={};Fx.CSS.Parsers=new Hash({Color:{parse:function(B){if(B.match(/^#[0-9a-f]{3,6}$/i)){return B.hexToRgb(true)}return((B=B.match(/(\d+),\s*(\d+),\s*(\d+)/)))?[B[1],B[2],B[3]]:false},compute:function(E,F,D){return E.map(function(A,B){return Math.round(Fx.compute(E[B],F[B],D))})},serve:function(B){return B.map(Number)}},Number:{parse:parseFloat,compute:Fx.compute,serve:function(D,C){return(C)?D+C:D}},String:{parse:$lambda(false),compute:$arguments(1),serve:$arguments(0)}});Fx.Tween=new Class({Extends:Fx.CSS,initialize:function(D,C){this.element=this.subject=$(D);this.parent(C)},set:function(D,C){if(arguments.length==1){C=D;D=this.property||this.options.property}this.render(this.element,D,C,this.options.unit);return this},start:function(I,G,H){if(!this.check(arguments.callee,I,G,H)){return this}var J=Array.flatten(arguments);this.property=this.options.property||J.shift();var F=this.prepare(this.element,this.property,J);return this.parent(F.from,F.to)}});Element.Properties.tween={set:function(C){var D=this.retrieve("tween");if(D){D.cancel()}return this.eliminate("tween").store("tween:options",$extend({link:"cancel"},C))},get:function(B){if(B||!this.retrieve("tween")){if(B||!this.retrieve("tween:options")){this.set("tween",B)}this.store("tween",new Fx.Tween(this,this.retrieve("tween:options")))}return this.retrieve("tween")}};Element.implement({tween:function(D,E,F){this.get("tween").start(arguments);return this},fade:function(I){var G=this.get("tween"),H="opacity",F;I=$pick(I,"toggle");switch(I){case"in":G.start(H,1);break;case"out":G.start(H,0);break;case"show":G.set(H,1);break;case"hide":G.set(H,0);break;case"toggle":var J=this.retrieve("fade:flag",this.get("opacity")==1);G.start(H,(J)?0:1);this.store("fade:flag",!J);F=true;break;default:G.start(H,arguments)}if(!F){this.eliminate("fade:flag")}return this},highlight:function(E,D){if(!D){D=this.retrieve("highlight:original",this.getStyle("background-color"));D=(D=="transparent")?"#fff":D}var F=this.get("tween");F.start("background-color",E||"#ffff88",D).chain(function(){this.setStyle("background-color",this.retrieve("highlight:original"));F.callChain()}.bind(this));return this}});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},initialize:function(B){this.xhr=new Browser.Request();this.setOptions(B);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers)},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return }this.running=false;this.status=0;$try(function(){this.status=this.xhr.status}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML};this.success(this.response.text,this.response.xml)}else{this.response={text:null,xml:null};this.failure()}this.xhr.onreadystatechange=$empty},isSuccess:function(){return((this.status>=200)&&(this.status<300))},processScripts:function(B){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(B)}return B.stripScripts(this.options.evalScripts)},success:function(D,C){this.onSuccess(this.processScripts(D),C)},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain()},failure:function(){this.onFailure()},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr)},setHeader:function(C,D){this.headers.set(C,D);return this},getHeader:function(B){return $try(function(){return this.xhr.getResponseHeader(B)}.bind(this))},check:function(B){if(!this.running){return true}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(B.bind(this,Array.slice(arguments,1)));return false}return false},send:function(N){if(!this.check(arguments.callee,N)){return this}this.running=true;var P=$type(N);if(P=="string"||P=="element"){N={data:N}}var J=this.options;N=$extend({data:J.data,url:J.url,method:J.method},N);var R=N.data,L=N.url,M=N.method;switch($type(R)){case"element":R=$(R).toQueryString();break;case"object":case"hash":R=Hash.toQueryString(R)}if(this.options.format){var O="format="+this.options.format;R=(R)?O+"&"+R:O}if(this.options.emulation&&["put","delete"].contains(M)){var Q="_method="+M;R=(R)?Q+"&"+R:Q;M="post"}if(this.options.urlEncoded&&M=="post"){var K=(this.options.encoding)?"; charset="+this.options.encoding:"";this.headers.set("Content-type","application/x-www-form-urlencoded"+K)}if(R&&M=="get"){L=L+(L.contains("?")?"&":"?")+R;R=null}this.xhr.open(M.toUpperCase(),L,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this);this.headers.each(function(A,B){if(!$try(function(){this.xhr.setRequestHeader(B,A);return true}.bind(this))){this.fireEvent("exception",[B,A])}},this);this.fireEvent("request");this.xhr.send(R);if(!this.options.async){this.onStateChange()}return this},cancel:function(){if(!this.running){return this}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;this.xhr=new Browser.Request();this.fireEvent("cancel");return this}});(function(){var B={};["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(A){B[A]=function(){var D=Array.link(arguments,{url:String.type,data:$defined});return this.send($extend(D,{method:A.toLowerCase()}))}});Request.implement(B)})();Element.Properties.send={set:function(C){var D=this.retrieve("send");if(D){D.cancel()}return this.eliminate("send").store("send:options",$extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},C))},get:function(B){if(B||!this.retrieve("send")){if(B||!this.retrieve("send:options")){this.set("send",B)}this.store("send",new Request(this.retrieve("send:options")))}return this.retrieve("send")}};Element.implement({send:function(C){var D=this.get("send");D.send({data:this,url:C||D.options.url});return this}});Request.JSON=new Class({Extends:Request,options:{secure:true},initialize:function(B){this.parent(B);this.headers.extend({Accept:"application/json","X-Request":"JSON"})},success:function(B){this.response.json=JSON.decode(B,this.options.secure);this.onSuccess(this.response.json,B)}});
