var arrDisplayedGreenGarages=new Array();var arrSpecialsDescriptions=new Array("","EARLY-BIRD Specials","MID-DAY Specials","EVENING-NIGHT Specials");function LoadXML_AllSpecs(oDate,load_type){var centreBounds=gMap.getBounds();var bounds=new GLatLngBounds(new GLatLng(centreBounds.getSouthWest().lat()- AREA_CACHE_BORDER/671,centreBounds.getSouthWest().lng()- AREA_CACHE_BORDER/571),new GLatLng(centreBounds.getNorthEast().lat()+AREA_CACHE_BORDER/671,centreBounds.getNorthEast().lng()+AREA_CACHE_BORDER/571));var url=XML_ALLSPECIALS_URL+"?area="+bounds.getSouthWest().lng()+","+bounds.getSouthWest().lat()+","+bounds.getNorthEast().lng()+","+bounds.getNorthEast().lat()+"&mon="+oDate.getFullYear()+"-"+oDate.getMonth();if(load_type)url+="&type="+load_type;LoadingAllSpecs=-1;var xmlDoc=getXML(url,doneAllSpecs,1);}
function doneAllSpecs(xmlDoc){if(xmlDoc==null || xmlDoc.xml==""){alert("Could not retrieve All Specilas at this time.");DisplayElem("coupwait","none");return;}
var params=parseXML_AllSpecs(xmlDoc.documentElement);var load_type=params[0];LoadingAllSpecs=1;if(lastSelectedGarage)RefreshSpec(lastSelectedGarage);DisplayElem("detwait","none");DisplayElem("coupwait","none");if(parking_isMonthly ||
document.getElementById("search_results").style.display=="none")return;if(!params[2]){MinimizeCoups();DisplayElem("day_sp_min","none");}
else{if(typeof(PopulateDailyExpWin)=="function"){if(!PopulateDailyExpWin())DisplayElem("day_sp_min","none");}
else
DisplayElem("day_sp_min","block");if(load_type==2)PopulateCal(params[1]);}}
function parseXML_AllSpecs(xmlElem){var areaContainCS=false;var xmlGeneral=xmlElem.getElementsByTagName("General")[0];var month=xmlGeneral.getAttribute("month");var month_indx=month.replace("-","");var load_type=xmlGeneral.getAttribute("type");var xmlCoupGroups=xmlElem.getElementsByTagName("CoupGroup");for(c=0;c<xmlCoupGroups.length;c++){areaContainCS=true;var xmlCoup=xmlCoupGroups[c];var oCoupGroup=new CoupGroup();oCoupGroup.id=xmlCoup.getAttribute("id");oCoupGroup.rate=xmlCoup.getAttribute("rate");oCoupGroup.rateSUV=xmlCoup.getAttribute("rateSUV");oCoupGroup.description=xmlCoup.getAttribute("description");if(xmlCoup.getAttribute("description_abbr"))oCoupGroup.description_abbr=xmlCoup.getAttribute("description_abbr");oCoupGroup.link=xmlCoup.getAttribute("link");oCoupGroup.garages=xmlCoup.getAttribute("garages");arrAllCoupGroups[oCoupGroup.id]=oCoupGroup;}
var xmlGarages=xmlElem.getElementsByTagName("Garage");for(g=0;g<xmlGarages.length;g++){var xmlGar=xmlGarages[g];var gar_id=xmlGar.getAttribute("id");if(!garages[gar_id].arrSpecialsMonth[month_indx])garages[gar_id].arrSpecialsMonth[month_indx]=new Array();if(!garages[gar_id].arrSpecialsMonth[month_indx][1])garages[gar_id].arrSpecialsMonth[month_indx][1]=new Array();if(!garages[gar_id].arrCouponsMonth[month_indx])garages[gar_id].arrCouponsMonth[month_indx]=new Array();if(!garages[gar_id].arrCouponsMonth[month_indx][1])garages[gar_id].arrCouponsMonth[month_indx][1]=new Array();if(xmlGar.getAttribute("specialsmonth")){garages[gar_id].arrSpecialsMonth[month_indx][0]=xmlGar.getAttribute("specialsmonth");garages[gar_id].arrCouponsMonth[month_indx][0]=xmlGar.getAttribute("couponsmonth");}
if(load_type==2 || load_type==3){areaContainCS=true;var xmlExclusions=xmlGarages[g].getElementsByTagName("Exclusion");for(e=0;e<xmlExclusions.length;e++){var type=xmlExclusions[e].getAttribute("type");var day=xmlExclusions[e].getAttribute("day");var specs=xmlExclusions[e].getAttribute("specs");if(type=="s"){garages[gar_id].arrSpecialsMonth[month_indx][1][day]=specs;}
else if(type=="c"){garages[gar_id].arrCouponsMonth[month_indx][1][day]=specs;}}}
if(load_type==0 || load_type==1 || load_type==3){var xmlWeekdays=xmlGarages[g].getElementsByTagName("Weekday");for(w=0;w<xmlWeekdays.length;w++){areaContainCS=true;var wday=xmlWeekdays[w].getAttribute("day");var xmlSpecials=xmlWeekdays[w].getElementsByTagName("Item");var arr_coups=new Array();var arr_specs=new Array();for(s=0;s<xmlSpecials.length;s++){oSpec=parseXMLSpecial(xmlSpecials[s]);if(oSpec.type=="c")arr_coups[arr_coups.length]=oSpec;else if(oSpec.type=="s")arr_specs[arr_specs.length]=oSpec;}
garages[gar_id].arrAllCoupNew[wday]=arr_coups;garages[gar_id].arrAllSpecNew[wday]=arr_specs;if(load_type>0)garages[gar_id].spclsLoaded=1;}}}
return Array(load_type,month,areaContainCS);}
function parseXMLSpecial(xmlSpecial){var oSpec=new Special();oSpec.id=xmlSpecial.getAttribute("id");if(xmlSpecial.getAttribute("type"))oSpec.type=xmlSpecial.getAttribute("type");if(xmlSpecial.getAttribute("show"))oSpec.show=xmlSpecial.getAttribute("show");if(xmlSpecial.getAttribute("description"))oSpec.description=xmlSpecial.getAttribute("description");if(xmlSpecial.getAttribute("description_abbr"))oSpec.description_abbr=xmlSpecial.getAttribute("description_abbr");if(oSpec.type=="c")oSpec.rules=xmlSpecial.getAttribute("rules");oSpec.carr=xmlSpecial.getAttribute("carr");oSpec.clarr=xmlSpecial.getAttribute("clarr");var cdep=oSpec.cdep=xmlSpecial.getAttribute("cdep");oSpec.stay=xmlSpecial.getAttribute("stay");var sty=xmlSpecial.getAttribute("sty");oSpec.NoStay=(sty.charCodeAt(0)==8212);oSpec.rate=xmlSpecial.getAttribute("rate");oSpec.rateSUV=xmlSpecial.getAttribute("rateSUV");var dep=oSpec.dep=xmlSpecial.getAttribute("dep");var depEarl=xmlSpecial.getAttribute("depEarl");var str_dep=dep;if(!POP_SPEC_FULL && oSpec.type=="s"){if(depEarl=="&#8212;"){oSpec.headDep='Depart&nbsp;by';str_dep=dep;}
else if(dep=="&#8212;"){oSpec.headDep='Depart<br>after';str_dep=depEarl;}
else{oSpec.headDep='Depart';str_dep=depEarl+"-"+dep;}}
if(ACOUPONS && oSpec.type=="s"){oSpec.strArr=xmlSpecial.getAttribute("arr");oSpec.strDep=str_dep;oSpec.sty=sty;}
if(POP_SPEC_FULL && oSpec.type=="s")str_dep=depEarl+'</td><td>'+dep;oSpec.specStr="<nobr>"+xmlSpecial.getAttribute("arr")+"</nobr>"+"</td><td>"+str_dep+"</td><td><center>"+sty+"</center></td>";if(xmlSpecial.getAttribute("redir"))oSpec.redir=xmlSpecial.getAttribute("redir");return oSpec;}
function selectSpecsShow(arrSpecs,spec_type,gar,indx,day,show,bGarIsSpec){if(bGarIsSpec){var sv_arr=gar.spec_view.split(" ");var sv_type=sv_arr[0];var sv_id=sv_arr[1];}
var arrReturnSpecs=new Array();var i=0;var loc_spec_excl="";if(spec_type=="s")loc_spec_excl=gar.arrSpecialsMonth[indx][1][day];else if(spec_type=="c")loc_spec_excl=gar.arrCouponsMonth[indx][1][day];if(loc_spec_excl==null)loc_spec_excl="";for(var n=0;n<arrSpecs.length;n++){if(loc_spec_excl.indexOf(" "+arrSpecs[n].id+" ")>-1)continue;if(show==2 && trim(arrSpecs[n].description)=="")continue;if(arrSpecs[n].show>0)arrReturnSpecs[n]=arrSpecs[n];}
return arrReturnSpecs;}
