// Content to load on body load $(document).ready(function() { // Rotate splash banner //$('#info').cycle({ // fx: 'fade', // speed: 2500, // timeout: 5000 // }); $('#facebookMSG').hide(); $('#twitterMSG').hide(); $('#addthisMSG').hide(); $('#facebookMSGIMG').mouseover(function() { $('#facebookMSG').show(); $('#twitterMSG').hide(); $('#addthisMSG').hide(); }); $('#facebookMSGIMG').mouseleave(function() { $('#facebookMSG').hide(); }); $('#twitterMSGIMG').mouseover(function() { $('#twitterMSG').show(); $('#facebookMSG').hide(); $('#addthisMSG').hide(); }); $('#twitterMSGIMG').mouseleave(function() { $('#twitterMSG').hide(); }); $('#addthisMSGIMG').mouseover(function() { $('#addthisMSG').show(); $('#twitterMSG').hide(); $('#facebookMSG').hide(); }); $('#addthisMSGIMG').mouseleave(function() { $('#addthisMSG').hide(); }); //nav tabs $('#tablink0').click(function() { tabOne(); $('#li1').addClass('on2'); $('#rightIMG').removeClass('rightEnd2'); $('#leftIMG').removeClass('leftEnd'); $('#rightIMG').addClass('rightEnd'); $('#leftIMG').addClass('leftEnd2'); $('#li2, #li3, #li4, #li5').removeClass('on2'); return false; }); $('#tablink1').click(function() { tabTwo(); $('#li2').addClass('on2'); $('#li1, #li3, #li4, #li5').removeClass('on2'); $('#leftIMG').addClass('leftEnd');$('#rightIMG').addClass('rightEnd'); $('#leftIMG').removeClass('leftEnd2');$('#rightIMG').removeClass('rightEnd2'); return false; }); $('#tablink2').click(function() { tabThree(); $('#li3').addClass('on2'); $('#li2, #li1, #li4, #li5').removeClass('on2'); $('#leftIMG').addClass('leftEnd'); $('#rightIMG').addClass('rightEnd'); $('#leftIMG').removeClass('leftEnd2'); $('#rightIMG').removeClass('rightEnd2'); return false; }); $('#tablink3').click(function() { tabFour(); $('#li4').addClass('on2'); $('#li2, #li3, #li1, #li5').removeClass('on2'); $('#leftIMG').addClass('leftEnd');$('#rightIMG').addClass('rightEnd'); $('#leftIMG').removeClass('leftEnd2');$('#rightIMG').removeClass('rightEnd2'); return false; }); $('#tablink4').click(function() { tabFive(); $('#li5').addClass('on2'); $('#leftIMG').removeClass('leftEnd2'); $('#rightIMG').removeClass('rightEnd'); $('#leftIMG').addClass('leftEnd'); $('#rightIMG').addClass('rightEnd2'); $('#li2, #li3, #li4, #li1').removeClass('on2'); return false; }); addRoom("room1"); }); $(function() { // initialise the "Select date" link $('#date-pick') .datePicker( // associate the link with a date picker { createButton:false, startDate:'01/01/2005', endDate:'31/12/2012' } ).bind( // when the link is clicked display the date picker 'click', function() { updateSelects($(this).dpGetSelected()[0]); $(this).dpDisplay(); return false; } ).bind( // when a date is selected update the SELECTs 'dateSelected', function(e, selectedDate, $td, state) { updateSelects(selectedDate); } ).bind( 'dpClosed', function(e, selected) { updateSelects(selected[0]); } ); var updateSelects = function (selectedDate) { var selectedDate = new Date(selectedDate); $('#day option[value=' + ((selectedDate.getDate() < 10) ? "0"+selectedDate.getDate() : selectedDate.getDate()) + ']').attr('selected', 'selected'); $('#month option[value=' + (((selectedDate.getMonth()+1) < 10) ? "0"+(selectedDate.getMonth()+1) : (selectedDate.getMonth()+1)) + ']').attr('selected', 'selected'); $('#year option[value=' + (selectedDate.getFullYear()) + ']').attr('selected', 'selected'); } // listen for when the selects are changed and update the picker $('#day, #month, #year') .bind( 'change', function() { var d = new Date( $('#year').val(), $('#month').val()-1, $('#day').val() ); $('#date-pick').dpSetSelected(d.asString()); } ); // default the position of the selects to today // var today = new Date(); // updateSelects(today.getTime()); // and update the datePicker to reflect it... // $('#day').trigger('change'); }); function tabOne() { tabChanger("tab0", "tablink0"); } function tabTwo() { tabChanger("tab1", "tablink1"); } function tabThree() { tabChanger("tab2", "tablink2"); } function tabFour() { tabChanger("tab3", "tablink3"); } function tabFive() { tabChanger("tab4", "tablink4"); } // Add new room option function addRoom(roomid) { var adults = new Array(); var children = new Array(); var infants = new Array(); ca = new Array(); ia = new Array(); // Replace text var roomnum = roomid.replace("room",""); // Delete out any elements outside the room num range for(var room = 1; room <= 3; room = room+1) { if(document.getElementById(room+"_a") != null) { var oldChildAdults = document.getElementById(room+"_a"); oldChildAdults.parentNode.removeChild(oldChildAdults); } if(document.getElementById(room+"_c") != null) { var oldChildChildren = document.getElementById(room+"_c"); oldChildChildren.parentNode.removeChild(oldChildChildren); } if(document.getElementById(room+"_i") != null) { var oldChildInfants = document.getElementById(room+"_i"); oldChildInfants.parentNode.removeChild(oldChildInfants); } document.getElementById("room"+room).innerHTML = ""; document.getElementById("p_room"+room).style.display="none"; } for(var room = 1; room <= roomnum; room = room+1) { var x = document.getElementById("room"+room); // Create select element for adults var roomselect_adults = document.createElement("select"); roomselect_adults.id = room+"_a"; x.appendChild(roomselect_adults); x.innerHTML = "Adults "+x.innerHTML+" Children "; // Create select element for children var roomselect_children = document.createElement("select"); roomselect_children.id = room+"_c"; x.appendChild(roomselect_children); x.innerHTML = x.innerHTML+" Infants "; // Create select element for infants var roomselect_infants = document.createElement("select"); roomselect_infants.id = room+"_i"; x.appendChild(roomselect_infants); // Add options for adults for(var i=1;i<=10;i=i+1) { var rsoption1 = document.createElement("option"); var adultselected = false; rsoption1.text = i; rsoption1.value = i; rsoption1.id = room+"_opta_"+i; if(adults[room] != undefined) { if(adults[room] == i) { var adultselected = true; } else if(i==2) { var adultselected = true; } } else if(i==2) { var adultselected = true; } document.getElementById(room+"_a").options.add(rsoption1); if(adultselected) { document.getElementById(room+"_opta_"+i).setAttribute("selected","true"); } } // Add options for children for(var i=0;i<=4;i=i+1) { var rsoption2 = document.createElement("option"); var childselected = false; rsoption2.text = i; rsoption2.value = i; rsoption2.id = room+"_optc_"+i; if(children[room] != undefined) { if(children[room] == i) { childselected = true; addChildren(room,i); } } document.getElementById(room+"_c").options.add(rsoption2); if(childselected) { document.getElementById(room+"_optc_"+i).setAttribute("selected","true"); } } // Add options for infants for(var i=0;i<=3;i=i+1) { var rsoption3 = document.createElement("option"); var infantselected = false; rsoption3.text = i; rsoption3.value = i; rsoption3.id = room+"_opti_"+i; if(infants[room] != undefined) { if(infants[room] == i) { infantselected = true; addInfants(room,i); } } document.getElementById(room+"_i").options.add(rsoption3); if(infantselected) { document.getElementById(room+"_opti_"+i).setAttribute("selected","true"); } } document.getElementById(room+"_c").onchange = function(){ addChildren(this.id.replace("_c",""),this.value); }; document.getElementById(room+"_i").onchange = function(){ addInfants(this.id.replace("_i",""),this.value); }; document.getElementById(room+"_i").name = "ifts"+room; document.getElementById(room+"_a").name = "adts"+room; document.getElementById(room+"_c").name = "chrn"+room; // if(room > 1) document.getElementById("srchform").style.height="auto"; document.getElementById("p_room"+room).style.display="block"; } } // Add children function addChildren(room,childnum) { if(document.getElementById("room"+room+"_children") != null) { var oldChildrenSpan = document.getElementById("room"+room+"_children"); oldChildrenSpan.parentNode.removeChild(oldChildrenSpan); } if(childnum > 0) { // document.getElementById("srchform").style.height="auto"; var childrenspan = document.createElement("span"); childrenspan.name = "room"+room+"_children"; childrenspan.id = "room"+room+"_children"; childrenspan.innerHTML = "
Child ages? "; if(document.getElementById("room"+room+"_infants") != null) { var infants = document.getElementById("room"+room+"_infants"); document.getElementById("room"+room).insertBefore(childrenspan,infants); } else { document.getElementById("room"+room).appendChild(childrenspan); } var childagedropdown = new Array(); for(var i=1;i<=childnum;i=i+1) { // Create child age dropdown childagedropdown[i] = document.createElement("select"); childagedropdown[i].name = "ca"+room+"[]"; childagedropdown[i].id = "room"+room+i+"_childages"; document.getElementById("room"+room+"_children").appendChild(childagedropdown[i]); // Add child age options to dropdown for(var ii=2;ii<=16;ii=ii+1) { var caoption = document.createElement("option"); var setchildage = false; caoption.text = ii; caoption.value = ii; caoption.id = "cage_"+room+i+ii; if(eval(ca[room+"_"+i]) != undefined) { if(ca[room+"_"+i] == ii) { setchildage = true; } } document.getElementById("room"+room+i+"_childages").options.add(caoption); if(setchildage) { document.getElementById("cage_"+room+i+ii).setAttribute("selected","true"); } else { if(ii == 8 && !setchildage) { document.getElementById("cage_"+room+i+ii).setAttribute("selected","true"); } } } } } } // Add infants function addInfants(room,infantnum) { if(document.getElementById("room"+room+"_infants") != null) { var oldInfantsSpan = document.getElementById("room"+room+"_infants"); oldInfantsSpan.parentNode.removeChild(oldInfantsSpan); } if(infantnum > 0) { // document.getElementById("srchform").style.height="auto"; var infantsspan = document.createElement("span"); infantsspan.name = "room"+room+"_infants"; infantsspan.id = "room"+room+"_infants"; infantsspan.innerHTML = "
Infant ages? "; document.getElementById("room"+room).appendChild(infantsspan); var infantagedropdown = new Array(); for(var i=1;i<=infantnum;i=i+1) { // Create infant age dropdown infantagedropdown[i] = document.createElement("select"); infantagedropdown[i].name = "ia"+room+"[]"; infantagedropdown[i].id = "room"+room+i+"_infantages"; document.getElementById("room"+room+"_infants").appendChild(infantagedropdown[i]); // Add infant age options to dropdown for(var ii=0;ii<=1;ii=ii+1) { var iaoption = document.createElement("option"); var setinfantage = false; iaoption.text = ii; iaoption.value = ii; iaoption.id = "iage_"+room+i+ii; if(eval(ia[room+"_"+i]) != undefined) { if(ia[room+"_"+i] == ii) { setinfantage = true; } } document.getElementById("room"+room+i+"_infantages").options.add(iaoption); if(setinfantage) { document.getElementById("iage_"+room+i+ii).setAttribute("selected","true"); } } } } } function validateForm() { var myForm = document.form1; var errors = "\n"; var error = 0; if(myForm.w.value == '|') { document.getElementById("destination").innerHTML = "* required"; error = error+1; } else { document.getElementById("destination").innerHTML = "*"; } if(myForm.n.value == '|') { document.getElementById("duration").innerHTML = "* required"; error = error+1; } else { document.getElementById("duration").innerHTML = "*"; } if(document.getElementById("f1").value == '|') { document.getElementById("f1error").innerHTML = "* required"; error = error+1; } else { document.getElementById("f1error").innerHTML = "*"; } if(error > 0) { return false; } else { document.getElementById("form1").action = "/flightsx.php"; } } var yearChanged = false; function correctYear() { var d = new Date(); var smDay = d.getDate() + 1; var smMonth = d.getMonth() + 1; var smMonthPast = d.getMonth(); var smYear = d.getFullYear(); if(document.getElementById("month").value < smMonth && document.getElementById("year").value == smYear && yearChanged == false) { document.getElementById("year").selectedIndex = document.getElementById("year").selectedIndex + 1; yearChanged = true; } if(document.getElementById("day").value < smDay && document.getElementById("month").value == smMonthPast && document.getElementById("year").value == smYear) { document.getElementById("year").selectedIndex = document.getElementById("year").selectedIndex + 1; yearChanged = true; } } function checkYear() { var d = new Date(); var smYear = d.getFullYear(); if(document.getElementById("year").value == smYear) { yearChanged = false; } } function tabChanger(tab, tablink) { var tabs = new Array("tab0", "tab1", "tab2", "tab3", "tab4"); var tablinks = new Array("tablink0", "tablink1", "tablink2", "tablink3", "tablink4"); document.getElementById(tab).style.display="block"; for(var i = 0; i < tabs.length; i++) { if(tabs[i] != tab) { document.getElementById(tabs[i]).style.display="none"; document.getElementById(tablinks[i]).style.fontWeight="normal"; } } return false; } function loadTabs() { document.getElementById("bluebay").onclick = bluebay; document.getElementById("solcalas").onclick = solcalas; document.getElementById("hauza").onclick = hauza; document.getElementById("rehana").onclick = rehana; document.getElementById("mitsis").onclick = mitsis; document.getElementById("armar").onclick = armar; document.getElementById("brisa").onclick = brisa; document.getElementById("vasia").onclick = vasia; document.getElementById("sunrise").onclick = sunrise; } function dealsByEmailSubscribe(divId, email) { xmlhttpsm = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); xmlhttpsm.open('get', './data/email/emailreg.php?e=' + email); xmlhttpsm.onreadystatechange = function() { if((xmlhttpsm.readyState==4) && (xmlhttpsm.status ==200)) { if(xmlhttpsm.responseText == "added") { document.getElementById(divId).style.paddingTop = "24px"; document.getElementById(divId).innerHTML = "E-mail address, " + email + ", was added to the Deals By Email mailing list successfully."; } else { alert("The e-mail address you entered was rejected by our system. Please try again."); } } } xmlhttpsm.send(null); } function bookmarkthis(title,url) { if (window.sidebar) { // firefox window.sidebar.addPanel(title, url, ""); } else if (document.all) { // IE window.external.AddFavorite(url, title); } else if (window.opera && window.print) { // opera var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); } } function excellence() { ow('/excellence/', 'excellenceriviera'); return false; } function bluebay() { ow('/bluebay/', 'bluebay'); return false; } function solcalas() { ow('/solcalas/', 'solcalas'); return false; } function hauza() { ow('/hauza/', 'hauza'); return false; } function rehana() { ow('/rehana/', 'rehana'); return false; } function mitsis() { ow('/mitsis/', 'mitsis'); return false; } function armar() { ow('/armar/', 'armar'); return false; } function brisa() { ow('/brisa/', 'brisa'); return false; } function vasia() { ow('/vasia/', 'vasia'); return false; } function puntacana() { ow('/puntacana/', 'puntacana'); return false; } function sunrise() { ow('/sunrise/', 'sunrise'); return false; } function ow(url,wname) { window.open(url, wname, 'directories=no,height=780,width=760,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no'); return false; }