function CheckBooking() { { ///SET FORM ACTION LOCATION TO FAILTE OR GALWAY HOTEL GUIDE // get the chosen option selind = document.forms.findhotel.County.selectedIndex; // get the value selval = document.forms.findhotel.County[selind].value; //selval = 'http://www.failtehotels.ie/Ireland-Hotels-result2.php'; if (selval == "Galway") { selaction = 'http://www.galwayhotelguide.com/hotels-galway-hotels-query-result_Multiple.php'; } else { selaction = 'http://www.failtehotels.ie/Ireland-Hotels-result2.php'; } // now set this value as action for the form document.forms.findhotel.action=selaction; // and submit // document.forms.findhotel.submit(); } } function Regions(County){ var Counties = new Array(); //Counties["Please select"] = new Array(" "); Counties["Antrim"] = new Array(" ", " Belfast City"," Belfast International Airport","Aldergrove","Antrim Town","Ballymena","Carrickfergus","Castlereagh","Dunadry","Mallusk","Newtownabbey","Portballintrae","Portrush","Templepatrick"); Counties["Armagh"] = new Array(" ", "Armagh","Bessbrook","Camlough","Crossmaglen","Forkhill","Jonesborough","Keady","Lurgan","Markethill"); Counties["Carlow"] = new Array(" ", " Carlow","Ballon","Carlow Guest Houses","Killerig","Leighlinbridge","Tullow"); Counties["Cavan"] = new Array(" ", "Arvagh","Bailieborough","Ballyconnell","Belturbet","Cavan","Cootehill","Kingscourt","Mountnugent","Virginia"); Counties["Clare"] = new Array(" ", "Ballyvaughan","Bunratty","Clare Guest Houses","Doolin","Ennis","Ennistymon","Kilkee","Lehinch","Liscannor","Lisdoonvarna","Miltown Malby","Newmarket-on-fergus","Shannon","Shannon airport"); Counties["Cork"] = new Array(" ", "All Cork city","All County Cork","Ballincollig","Ballycotton","Baltimore","Bandon","Bantry","Blarney","Carrigaline","Castlemartyr","Clonakilty","Cobh","Cork airport","Dunmanway","Fota Island","Garryvoe","Glanmire","Glengarriff","Kinsale","Little Island","Macroom","Mallow","Midleton","Rosscarbery","Skibbereen","Youghal"); Counties["Derry"] = new Array(" ", "Coleraine","Derry","Dungiven","Eglinton"); Counties["Donegal"] = new Array(" ", "Ballybofey","Bunbeg","Bundoran","Donegal","Donegal Guesthouses","Dungloe","Glen","Gweedore","Inishowen","Letterkenny","Milford","Rathmullan","Stranorlar"); Counties["Down"] = new Array(" ", "Ballynahinch","Banbridge","Bangor","Carryduff","Comber","Donaghadee","Downpatrick","Dromore","Dundonald","Holywood","Kilkeel","Lisburn","Newcastle","Newry","Newtownards","Warrenpoint"); Counties["Dublin"] = new Array(" ", " All County Dublin"," All Dublin City"," All Dublin Towns"," Dublin Airport"," Dublin City Centre"," Dublin City North"," Dublin City Pheonix Park"," Dublin City Port"," Dublin City South"," Dublin Croke Park Area"," Dublin Guest Houses"," Merrrion Square Area"," North County Dublin"," South County Dublin"," Stephens Green Area"," Temple Bar Area","Balbriggan","Ballsbridge","Ballyfermot","Ballymun","Blackrock","Castlenock","Chapelizod","Christchurch","Clondalkin","Clontarf","Dalkey","Deansgrange","Dollymount","Donabate","Drumcondra","Dublin 1","Dublin 2","Dublin 3","Dublin 4","Dublin 5","Dublin 6","Dublin 7","Dublin 8","Dublin 9","Dublin 10","Dublin 11","Dublin 12","Dublin 13","Dublin 14","Dublin 15","Dublin 16","Dublin 17","Dublin 18","Dublin 20","Dublin 22","Dublin 24","Dublin Mountains","Dun Laoghaire","Dunlaoire","Foxrock","Howth","Killiney","Killiney village","Leixlip","Leopardstown","Loughlinstown","Lucan","Malahide","Monkstown","Mount merrion","Mt merrion","Naas Road","Newlands Cross","Rathmines","Sandycove","Sandyford","Sandymount","Santry","Shankill","Stillorgan","Swords","Tallaght"); Counties["Fermanagh"] = new Array(" ", "Belleek","Enniskillen","Irvinestown","Kesh"); Counties["Galway"] = new Array(" ", "Aran Islands","Athenry","Ballinasloe","Barna","Carna","Claddaghduff","Claregalway","Clarinbridge","Cleggan","Clifden","Clonbur","All Connemara","Dunmore","Galway City","Glenamaddy","Gort","Headford","Inis Boffin","Inverin","Kinvara","Leenane","Letterfrack","Loughrea","Milltown","Moycullen","Moylough","Mt Bellew","Oranmore","Oughterard","Portumna","Recess","Renvyle","Rossaveel","Roundstone","Salthill","Spiddal","Tuam","Woodford"); Counties["Kerry"] = new Array(" ", "Kerry Hotels","Ballybunion","Cahirciveen","Castleisland","Dingle","Dingle peninsula","Kenmare","Kerry airport","Kerry Guest Houses","Killarney","Listowel","Ring of kerry","Sneem","Tarbert","Tralee","Valentia island"); Counties["Kildare"] = new Array(" ", "Athy","Celbridge","Clane","Curragh","Kildare Town","Leixlip","Maynooth","Monasterevin","Moyvally","Naas","Naas Rd, Dublin","Newbridge","Punchestown Racecourse Hotels"); Counties["Kilkenny"] = new Array(" ","Kilkenny","Ballyfoyle","Ballyragget","Bennettsbridge","Callan","Castlecomer","Castlewarren","Clifden","Dungarvan","Freshford","Glenmore","Goresbridge","Gowran","Graiguenamanagh","Inistioge","Jenkinstown","Kells","Kilkenny City","Kilmanagh","Knocktopher","Mullinavat","Piltown","Slieverue","Thomastown","Tullaroan","Urlingford"); Counties["Laois"] = new Array("Abbeyleix","Ballacolla","Ballaghmore","Clogh","Donaghmore","Durrow","Killenard","Mountmellick","Mountrath","Portalington","Portlaoise"); Counties["Leitrim"] = new Array(" ", "Ballinamore","Carrick-on-shannon","Carrigallen","Dromahair","Drumshanbo","Mohill","Rooskey"); Counties["Limerick"] = new Array(" ", "Abbeyfeale","Adare","Castleconnell","Castletroy","Glin"," Limerick City","Newcastle West","Templeglantine"); Counties["Longford"] = new Array(" ", "Ballymahon","Edgeworthstown","Longford"); Counties["Louth"] = new Array(" ", "All Louth Guest Houses","All Louth Hotels","Ardee","Carlingford","Carlingford village","Drogheda","Dundalk","Dunleer","Omeath","Ravensdale","Termonfeckin"); Counties["Mayo"] = new Array("Achill","Ballina","Ballinrobe","Ballycastle","Belmullet","Castlebar","Charlestown","Clare Island","Claremorris","Cong","Crossmolina","Doohoma","Foxford","Killala","Kiltimagh","Knock","Louisburgh","Mayo Guest Houses","Mulranny","Mulrany","Newport","Pontoon","Swinford","Westport"); Counties["Meath"] = new Array(" ", "Ashbourne","Bettystown","Dunboyne","Enfield","Gormanstown","Kilmessan","Navan","Trim"); Counties["Monaghan"] = new Array(" ", "Carrickmacross","Castleblayney","Clones","Glaslough","Inniskeen","Monaghan"); Counties["Offaly"] = new Array(" ", "Banagher","Birr","Clara","Clonmacnoise","Ferbane","Kinnitty","Shannonbridge","Tullamore"); Counties["Roscommon"] = new Array(" ", "Athlone Town, Roscommon","Ballaghaderreen","Ballinlough","Ballyfarnon","Boyle","Castlerea","Cloonfad","Four Roads","Frenchpark","Knockcroghery","Roosky","Roscommon B&B's","Roscommon Guest Houses","Roscommon Town","Strokestown","Thomastown","Tulsk"); Counties["Sligo"] = new Array(" ", "Sligo Town","Ballincar","Ballygawley","Curry","Enniscrone","Rosses Point","Tubbercurry"); Counties["Tipperary"] = new Array(" ", "Ballina","Bansha","Borrisokane","Cahir","Carrick-on-suir","Cashel","Clonmel","Dundrum","Fethard","Holycross","Horse and Jockey","Nenagh","Newport","Roscrea","Templemore","Thurles","Tipperary Town"); Counties["Tyrone"] = new Array(" ", "Cookstown","Dungannon","Fivemiletown","Gortaclare","Omagh","Strabane"); Counties["Waterford"] = new Array(" ", "All County Waterford","All Waterford City","Ardmore","Butlerstown","Cappoquin","Dungarvan","Dunmore east","Furraleigh","Kilmeaden","Little Island","Slieverue","Tramore","Waterford","Woodstown"); Counties["Westmeath"] = new Array(" ", "Athlone","Glasson","Kilbeggan","Kinnegad","Mullingar","Rochfortbridge","Tyrrellspass","Westmeath Guest Houses/B&Bs","Westmeath Self Catering"); Counties["Wexford"] = new Array(" ", "Adamstown","Blackwater","Campile","Castlebridge","Churchtown","Clogh","Drinagh","Enniscorthy","Ferns","Gorey","New ross","Rosslare","Rosslare Harbour","Wexford"); Counties["Wicklow"] = new Array(" ", "Arklow","Aughrim","Bray","Delgany","Enniskerry","Greystones","Newtownmountkennedy","Wicklow","Woodenbridge"); //clear the location drop down document.findhotel.location.options.length = 0; document.findhotel.location.options[0]=new Option("All Regions",""); if (document.findhotel.County.value == 'Galway') { document.findhotel.location.options[0]=new Option("All Galway","All Galway"); } for(var g=0; g <= Counties[County].length-1; g++) { document.findhotel.location.options[g+1]=new Option(Counties[County][g+1], Counties[County][g+1]) } } $(function() { $("#Arrival").datepicker({showOn: 'button', buttonImage: 'http://ebookireland.com/images/calendar.gif', buttonImageOnly: true,showOn: 'both',beforeShow: customRange,dateFormat: 'yy/mm/dd'}); $("#Departure").datepicker({showOn: 'button', buttonImage: 'http://ebookireland.com/images/calendar.gif', buttonImageOnly: true,showOn: 'both',beforeShow: customRange,dateFormat: 'yy/mm/dd'}); $("#Arrival").change(function() { checkDates(); }); $("#Departure").change(function() { checkDates(); }); function customRange(input){ var min = new Date(); //Set this to your absolute minimum date var dateMin = min; var dateMax = null; var dayRange = 30; if (input.id == "Departure"){ if ($("#Arrival").datepicker("getDate") != null){ dateStart = $("#Arrival").datepicker("getDate"); dateMin = new Date(dateStart.getFullYear(), dateStart.getMonth(), dateStart.getDate()) var rangeMax = new Date(dateMin.getFullYear(), dateMin.getMonth(), dateMin.getDate() + dayRange); if(rangeMax < dateMax){ dateMax = rangeMax; } } } return { minDate: dateMin, maxDate: dateMax, value: min }; } function checkDates(){ var dtElem1 = document.getElementById("Arrival"); var dtElem2 = document.getElementById("Departure"); var resultElem = document.getElementById("Nights"); // Return if no such element exists if(!dtElem1 || !dtElem2 || !resultElem ) { return; } //assuming that the delimiter for dt time picker is a '/'. //get in correct format var x = dateFormat(dtElem1.value, "dd/mm/yyyy"); var y = dateFormat(dtElem2.value, "dd/mm/yyyy"); var arr1 = x.split('/'); var arr2 = y.split('/'); // If any problem with input exists, return with an error msg if(!arr1 || !arr2 || arr1.length != 3 || arr2.length != 3) { resultElem.value = "Invalid Input"; return; } /*for(var i=0;iarr1["+i+"] is =>"+arr1[i]+"
"); } for(var i=0;iarr2["+i+"] is =>"+arr2[i]+"
"); }*/ var dt1 = new Date(arr1[2], arr1[1]-1, arr1[0]); //alert("dt1>>>" + dt1); var dt2 = new Date(arr2[2], arr2[1]-1, arr2[0]); //alert("dt2>>>" + dt2); //alert(dt2.getTime() + "-" + dt1.getTime()); //resultElem.value = (dt2.getTime() - dt1.getTime()) / (60 * 60 * 24 * 1000); if(((dt2.getTime() - dt1.getTime()) / (60 * 60 * 24 * 1000))>0){ resultElem.value = (dt2.getTime() - dt1.getTime()) / (60 * 60 * 24 * 1000); }else{ resultElem.value = 1; } } }); var dateFormat = function () { var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, timezoneClip = /[^-+\dA-Z]/g, pad = function (val, len) { val = String(val); len = len || 2; while (val.length < len) val = "0" + val; return val; }; // Regexes and supporting functions are cached through closure return function (date, mask, utc) { var dF = dateFormat; // You can't provide utc if you skip other args (use the "UTC:" mask prefix) if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { mask = date; date = undefined; } // Passing date through Date applies Date.parse, if necessary date = date ? new Date(date) : new Date; if (isNaN(date)) throw SyntaxError("invalid date"); mask = String(dF.masks[mask] || mask || dF.masks["default"]); // Allow setting the utc argument via the mask if (mask.slice(0, 4) == "UTC:") { mask = mask.slice(4); utc = true; } var _ = utc ? "getUTC" : "get", d = date[_ + "Date"](), D = date[_ + "Day"](), m = date[_ + "Month"](), y = date[_ + "FullYear"](), H = date[_ + "Hours"](), M = date[_ + "Minutes"](), s = date[_ + "Seconds"](), L = date[_ + "Milliseconds"](), o = utc ? 0 : date.getTimezoneOffset(), flags = { d: d, dd: pad(d), ddd: dF.i18n.dayNames[D], dddd: dF.i18n.dayNames[D + 7], m: m + 1, mm: pad(m + 1), mmm: dF.i18n.monthNames[m], mmmm: dF.i18n.monthNames[m + 12], yy: String(y).slice(2), yyyy: y, h: H % 12 || 12, hh: pad(H % 12 || 12), H: H, HH: pad(H), M: M, MM: pad(M), s: s, ss: pad(s), l: pad(L, 3), L: pad(L > 99 ? Math.round(L / 10) : L), t: H < 12 ? "a" : "p", tt: H < 12 ? "am" : "pm", T: H < 12 ? "A" : "P", TT: H < 12 ? "AM" : "PM", Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] }; return mask.replace(token, function ($0) { return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); }); }; }(); // Some common format strings dateFormat.masks = { "default": "ddd mmm dd yyyy HH:MM:ss", shortDate: "m/d/yy", mediumDate: "mmm d, yyyy", longDate: "mmmm d, yyyy", fullDate: "dddd, mmmm d, yyyy", shortTime: "h:MM TT", mediumTime: "h:MM:ss TT", longTime: "h:MM:ss TT Z", isoDate: "yyyy-mm-dd", isoTime: "HH:MM:ss", isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" }; // Internationalization strings dateFormat.i18n = { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] }; // For convenience... Date.prototype.format = function (mask, utc) { return dateFormat(this, mask, utc); };