if(typeof(window.__WN)=="undefined"){var __WN=(function(doc){window.onload=function(){function addClass($elements,cls){if($elements instanceof Array){for(var i in $elements){if($elements.hasOwnProperty(i)){$elements[i].className+=(" "+cls)}}}else{$elements.className+=(" "+cls)}}function removeClass($elements,cls){var reg=new RegExp("(\\s|^)"+cls+"(\\s|$)");if($elements instanceof Array){for(var i in $elements){if($elements.hasOwnProperty(i)){$elements[i].className=$elements[i].className.replace(reg,"")}}}else{$elements.className.replace(reg,"")}}function hasClass($element,cls){var reg=new RegExp("(\\s|^)"+cls+"(\\s|$)");if(reg.test($element.className)){return true}else{return false}}function getElement(id_list){if(id_list instanceof Array){var $id_list=[];for(var i in id_list){if(id_list.hasOwnProperty(i)){$id_list.push(doc.getElementById(id_list[i]))}}return $id_list}return doc.getElementById(id_list)}function getDaysInMonth(month,year){if(year==-1){year=new Date().getFullYear()}if(month==11){return new Date(year,0,0).getDate()}return new Date(year,month+1,0).getDate()}function setYear(e,year,increment){var yearSelect=doc.getElementById(e);while(yearSelect.hasChildNodes()){yearSelect.removeChild(yearSelect.firstChild)}for(var i=0;i<=increment;i++){var $newNode=doc.createElement("option");var newValue=year+i;$newNode.setAttribute("value",newValue);$newNode.innerHTML=newValue;yearSelect.appendChild($newNode)}}var today=new Date(),$startDay=doc.getElementById("qp3_startday"),$startMonth=doc.getElementById("qp3_startmonth"),$startYear=doc.getElementById("qp3_startyear"),$residence=doc.getElementById("country-residence"),durationValues={"1d":"1 day","2d":"2 days","3d":"3 days","4d":"4 days","5d":"5 days","6d":"6 days","1w":"1 week","2w":"2 weeks","3w":"3 weeks","4w":"4 weeks","5w":"5 weeks","6w":"6 weeks","7w":"7 weeks","2m":"2 months","3m":"3 months","4m":"4 months","5m":"5 months","6m":"6 months","7m":"7 months","8m":"8 months","9m":"9 months","10m":"10 months","11m":"11 months","12m":"12 months","13m":"13 months","14m":"14 months","15m":"15 months","16m":"16 months","17m":"17 months","18m":"18 months"},durationRanges={USA:Array("1w","2w","3w","4w","5w","6w","7w","2m","3m","4m","5m","6m"),CAN:Array("2w","3w","4w","5w","6w","7w","2m","3m","4m","5m","6m"),NZL:Array("1w","2w","3w","4w","5w","6w","7w","2m","3m","4m","5m","6m","7m","8m","9m","10m","11m","12m","13m","14m","15m","16m","17m","18m"),IRL:Array("3d","5d","1w","2w","3w","4w","5w","6w","7w","2m","3m","4m","5m","6m","7m","8m","9m","10m","11m","12m","13m","14m","15m","16m","17m","18m"),"default":Array("2d","3d","5d","1w","2w","3w","4w","5w","6w","7w","2m","3m","4m","5m","6m","7m","8m","9m","10m","11m","12m")};durationRanges.AUS=durationRanges.NZL;durationRanges.GBR=durationRanges.IRL;var coverageKeys={including:"Worldwide - inc. USA, Canada & Japan",excluding:"Worldwide - ex. USA, Canada & Japan",including2:"Worldwide - inc. USA, Canada, The Caribbean, South East & Eastern Asia",excluding2:"Worldwide - ex. USA, Canada, The Caribbean, South East & Eastern Asia"};var coverageValues={AUS:Array("including","excluding"),GBR:Array("including2","excluding2")};coverageValues.NZL=coverageValues.AUS;coverageValues.IRL=coverageValues.GBR;var $countrySelect=getElement("country-residence"),$coverDisplay=getElement("cover-region"),$coverSelect=getElement("qp-coverage"),$durationSelect=getElement("qp3_duration"),$canadaProvinces=getElement("canadian-provinces"),$canadaSelect=getElement("qp-province"),countryCode;$countrySelect.onchange=function(){countryCode=this.value;if($coverDisplay){if(!coverageValues[countryCode]){$coverDisplay.style.display="none";$coverSelect.disabled="disabled"}else{$coverDisplay.style.display="block";$coverSelect.disabled="";changeOptions(countryCode,$coverSelect,coverageValues,coverageKeys)}}if($canadaProvinces){if(countryCode=="CAN"){$canadaProvinces.style.display="block";$canadaSelect.disabled=""}else{$canadaProvinces.style.display="none";$canadaSelect.disabled="disabled"}}if(!durationRanges[countryCode]){countryCode="default"}changeOptions(countryCode,$durationSelect,durationRanges,durationValues)};function changeOptions(country,$select,val,display){while($select.hasChildNodes()){$select.removeChild($select.firstChild)}var $newNode,newVal;for(var i in val[country]){if(val[country].hasOwnProperty(i)){$newNode=doc.createElement("option");newVal=val[country][i];$newNode.setAttribute("value",newVal);$newNode.innerHTML=display[newVal];$select.appendChild($newNode)}}}$startMonth.onchange=function(){var daysInMonth=getDaysInMonth($startMonth.value-1,today.getFullYear());while($startDay.hasChildNodes()){$startDay.removeChild($startDay.firstChild)}for(var i=1;i<=daysInMonth;i++){var $newNode=doc.createElement("option");$newNode.setAttribute("value",i);$newNode.innerHTML=i;$startDay.appendChild($newNode)}};$startDay.value=today.getDate();$startMonth.value=today.getMonth()+1;setYear("qp3_startyear",today.getFullYear(),1);var wnForm=doc.getElementById("wn_quote_panel");if(typeof(wnForm)!="undefined"){wnForm=wnForm.getElementsByTagName("form")[0];wnForm.onsubmit=function(){var errors=false;clearErrors();if($residence.options[$residence.selectedIndex].value===""){flagError($residence,"residenceError");errors=true}return !errors}}function flagError(elem,errorId){if(!doc.getElementById(errorId)){var $newNode=doc.createElement("em");$newNode.setAttribute("class","error");$newNode.setAttribute("id",errorId);$newNode.innerHTML="Required";elem.previousElementSibling.appendChild($newNode)}}function clearErrors(){var error=wnForm.getElementsByTagName("em");for(var i=0;i<error.length;i++){error[i].parentNode.removeChild(error[i])}}$countrySelect.onchange()}})(document)};
