

// Filename: /dynamicbrochure/brochure.js
// Was: 7816, now: 5472, compression: 30%

function GetBrochureBaseUrl(){var base_url="";if(location.host!="olympic.offroadcode.com"&&location.host!="localhost")
{base_url="http://www.olympicholidays.com";}
return base_url;}
function AddToBrochure(url){window.open(GetBrochureBaseUrl()+"/dynamicbrochure/brochure.asp?"+url,"dynamicbrochure","width=700,height=450,scrollbars=yes").focus();}
function DeleteChecked(){if(confirm("Are you sure you want to delete all the selected pages?")){var hotel=null;var whichHotels=[];if(document.brochure.hotels&&document.brochure.hotels.length){for(var i=0;i<document.brochure.hotels.length;i++)
{hotel=document.brochure.hotels[i];if(hotel&&hotel.checked){whichHotels.push(hotel.value);}}}else{if(document.brochure.hotels.checked){whichHotels.push(document.brochure.hotels.value);}}
document.update.action.value="delete";document.update.id.value=whichHotels.join(",");document.update.submit();}}
function BuildAndSendBrochure(){if(CheckForEmail()){var shortlist=new ShortList();var url='action=addhotels';url+='&ids='+shortlist.Serialize();url+="&firstname="+$("firstname").getValue();url+="&surname="+$("surname").getValue();url+="&email="+$("email").getValue()+";"+$("additional_emails").getValue();AddToBrochure(url);}
return false;}
function SendBrochure(){}
function ViewBrochure()
{window.open(GetBrochureBaseUrl()+"/dynamicbrochure/brochure.asp","dynamicbrochure","width=700,height=450,scrollbars=yes").focus();}
function AddRegionToBrochure(url){window.open(GetBrochureBaseUrl()+"/dynamicbrochure/loading.asp?"+url,"dynamicbrochure","width=700,height=450,scrollbars=yes").focus();}
function CheckForEmail(){var shortlist=new ShortList();var errors=[];var fields_to_highlight=[];var emailsValid=true;var email=$("email")
if(email&&(email.value.search(/@/)==-1||email.value.length<5))
{errors.push("Please enter an email address.");fields_to_highlight.push(email);}
var firstname=$("firstname");if(firstname&&firstname.value.length==0)
{errors.push("Please enter your first name.");fields_to_highlight.push(firstname);}
var reply_to=$("additional_emails");if(reply_to&&(reply_to.value.search(/@/)==-1||reply_to.value.length<5))
{errors.push("Please enter the email address of who you would like to send the shortlist to.");fields_to_highlight.push(reply_to);}
if($('ids')){if(shortlist.Count()==0){errors.push("You do not have any hotels in your shortlist.");$("ids").value="";}else{$("ids").value=shortlist.Serialize();}}
if(errors.length>0){emailsValid=false;fields_to_highlight.each(function(field){field.setStyle("border","2px solid #FF0000");});alert(errors.join("\n"));}
return emailsValid;}
function PopPage(pageToPop,keepWindowOpenOnCompletion){keepWindowOpenOnCompletion=keepWindowOpenOnCompletion&&keepWindowOpenOnCompletion==true?true:false;if(pageToPop&&pageToPop!=null&&String(pageToPop)!="undefinded"&&String(pageToPop).length>0)
{if(window.opener&&!window.opener.closed)
{window.opener.location.href=pageToPop;window.opener.focus();}
else
{newWin=window.open('about:blank','parentwin','');newWin.location.href=pageToPop;newWin.focus();}
if(!keepWindowOpenOnCompletion)
{this.close();}}
else
{window.status="No url passed to popup function";}}
function UpdateTotals(whichHotel){var total=0;if(document.brochure.hotels&&document.brochure.hotels.length){for(i=0;i<document.brochure.hotels.length;i++){if(document.brochure.hotels[i].checked){total+=hotelFileSize;}}}else{if(document.brochure.hotels&&document.brochure.hotels.checked){if(document.brochure.hotels.checked){total+=hotelFileSize;}}}
if(document.brochure.regionFileSize){total+=parseInt(document.brochure.regionFileSize.value);}
if(document.brochure.resortFileSize){total+=parseInt(document.brochure.resortFileSize.value);}
if(document.brochure.includeTACInfo&&document.brochure.includeTACInfo.checked){total+=TACFileSize;}
if(document.brochure.includeFlightInfo&&document.brochure.includeFlightInfo.checked){total+=flightFileSize;}
var span=document.getElementById("totalFileSize");span.innerHTML=total+"kb";document.brochure.totalFileSize.value=total;document.update.action.value="check";document.update.id.value=whichHotel;document.update.submit();return false;}
function ChangeCheckBoxState(newState){var whichHotels="";if(document.brochure.hotels&&document.brochure.hotels.length){for(i=0;i<document.brochure.hotels.length;i++){if(document.brochure.hotels[i].checked!=newState){whichHotels+=i+",";document.brochure.hotels[i].checked=newState;}}}else{if(document.brochure.hotels&&document.brochure.hotels.checked!=newState){document.brochure.hotels.checked=newState;whichHotels+="0,";}}
if(document.brochure.includeTACInfo&&document.brochure.includeTACInfo.checked!=newState){document.brochure.includeTACInfo.checked=newState;whichHotels+="TACinfo,";}
if(document.brochure.includeFlightInfo&&document.brochure.includeFlightInfo.checked!=newState){document.brochure.includeFlightInfo.checked=newState;whichHotels+="flightinfo,";}
return UpdateTotals(whichHotels);}
function CheckForm()
{var errors="";var PageFound=false;if(document.brochure.hotels&&document.brochure.hotels.length)
{for(i=0;i<document.brochure.hotels.length;i++)
{if(document.brochure.hotels[i].checked)
{PageFound=true;break;}}}
else
{if(document.brochure.hotels&&document.brochure.hotels.checked)
{PageFound=true;}}
if(!PageFound)
{errors+="\nYou have not selected any brochure pages, you can do this by clicking on the boxes in the Include In My Brochure column.";}
if(errors!="")
{alert(errors);return false;}
return true;}
