function addEvent(elm, evType, fn, useCapture){if(elm.addEventListener){elm.addEventListener(evType, fn, useCapture);return true;}else if (elm.attachEvent){var r = elm.attachEvent('on' + evType, fn);return r;}else{elm['on' + evType] = fn;}}

var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	
	closeWin();
		
	type = type.toLowerCase();
	
	if (type == "fullscreen"){
		strWidth = screen.availWidth;
		strHeight = screen.availHeight;
	}
	var tools="";
	if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

function doPopUp(e)
{
//set defaults - if nothing in rel attrib, these will be used
var t = "standard";
var w = "780";
var h = "580";
//look for parameters
attribs = this.rel.split(" ");
if (attribs[1]!=null) {t = attribs[1];}
if (attribs[2]!=null) {w = attribs[2];}
if (attribs[3]!=null) {h = attribs[3];}
//call the popup script
popUpWin(this.href,t,w,h);
//cancel the default link action if pop-up activated
if (window.event) 
	{
	window.event.returnValue = false;
	window.event.cancelBubble = true;
	} 
else if (e) 
	{
	e.stopPropagation();
	e.preventDefault();
	}
}

function findPopUps()
{
var popups = document.getElementsByTagName("a");
for (i=0;i<popups.length;i++)
	{
	if (popups[i].rel.indexOf("popup")!=-1)
		{
		// attach popup behaviour
		popups[i].onclick = doPopUp;
		// add popup indicator
		if (popups[i].rel.indexOf("noicon")==-1)
			{
			//popups[i].style.backgroundImage = "url(pop-up.gif)";
			//popups[i].style.backgroundPosition = "0 center";
			popups[i].style.backgroundRepeat = "no-repeat";
			//popups[i].style.paddingLeft = "0px";
			}
		// add info to title attribute to alert fact that it's a pop-up window
		popups[i].title = popups[i].title;
		}
	}
}

addEvent(window, 'load', findPopUps, false);

var website_url = "http://www.londontourism.ca/"; // live 

/* SUBMIT SEARCH FORM */
function submit_search_form()
{
	document.search_creds.submit();
}

function submit_site_search_form() {
	document.site_search.submit();
}

// Calendar
function calendarMonth(intYear,intMonth,intCalendar)
{
	document.getElementById("ax_Calendar").innerHTML = "<div class='calendar_block'></div>";
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readCalendarFunction', intYear, intMonth, intCalendar, getCalendarResults);
}
function getCalendarResults(result)
{
	document.getElementById("ax_Calendar").innerHTML = result;
}
// Meeting Planners
function londonDestination(intMember)
{
	document.getElementById("ax_Destination").innerHTML = "";
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readLondonDestinationFunction', intMember, getlondonDestinationResults);
}
function getlondonDestinationResults(result)
{
	document.getElementById("ax_Destination").innerHTML = result;
}
// Meeting Planners Inside Thumbnails
function londonDestinationPhoto(intPhotoID)
{
	document.getElementById("ax_PhotoDestination").innerHTML = "<div align='center' style='height: 234px; width: 450px;'><br /><br /><br /><br /><img src='"+ website_url +"images/ajax-loader-transp.gif' style='border: 0px;' /></div>";
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readLondonDestingationPhotoFunction', intPhotoID, getLondonDestinationPhotoResults);
}
function getLondonDestinationPhotoResults(result)
{
	document.getElementById("ax_PhotoDestination").innerHTML = result;
}
// THINGS TO DO
function londonHotSpot(intMember)
{
	document.getElementById("ax_HotSpot").innerHTML = "";
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readLondonHotSpotFunction', intMember, getLondonHotSpotResults);
}
function getLondonHotSpotResults(result)
{
	document.getElementById("ax_HotSpot").innerHTML = result;
}

// FEATURED EVENTS
function londonEvents(intMember)
{
	document.getElementById("ax_FeaturedEvent").innerHTML = "";
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readLondonFeaturedEventFunction', intMember, getLondonFeaturedEventResults);
}
function getLondonFeaturedEventResults(result)
{
	document.getElementById("ax_FeaturedEvent").innerHTML = result;
}
function SwapImage(libraryID) {
	document.getElementById("SwapImageContainer").innerHTML = "<div align='center' style='height: 181px; width: 251px;'><br /><br /><br /><br /><br /><img src='"+ website_url +"images/ajax-loader.gif' /></div>";
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readPhotoSwapFunction', libraryID, subSwapImageResults);
}
function subSwapImageResults(result)
{
	document.getElementById("SwapImageContainer").innerHTML = "";
	document.getElementById("SwapImageContainer").innerHTML = result;
}

/* DYNAMIC LEADS */
function loadDynamicLead(dynamicLead, leadCategory) {
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readDynamicLeadFunction', dynamicLead, leadCategory, showDynamicLeadResults);
}

function showDynamicLeadResults(result) {
	document.getElementById("ax_Destination").innerHTML = result;
}

function hitDynamicLead(dynamicLead) {
	
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'hitDynamicLeadFunction', dynamicLead, noReturnResults);
	
}
function noReturnResults(result) {
	
}
/* SINGLE DYNAMIC LEAD */
function loadDynamicLeadSingle(dynamicLead, leadCategory) {
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readDynamicLeadSingleFunction', dynamicLead, leadCategory, showDynamicLeadSingleResults);
}

function showDynamicLeadSingleResults(result) {
	if (document.getElementById("ax_Destination")){
		document.getElementById("ax_Destination").innerHTML = result;
	}
}

/* SINGLE HOME DYNAMIC LEAD */
function loadDynamicLeadHomeSingle(dynamicLead, leadCategory) {
	
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readDynamicLeadHomeSingleFunction', dynamicLead, leadCategory, showDynamicLeadHomeSingleResults);
}

function showDynamicLeadHomeSingleResults(result) {
	
	if (document.getElementById("ax_Destination")){
		
		//jQuery(".discover_our_spirit").fadeOut("fast");
		
		//jQuery(".discover_our_spirit").fadeIn("fast");
		document.getElementById("ax_Destination").innerHTML = result;
	}
}

/* LOAD EVENTS CALENDAR */
function readEvents(EventStart,EventDay, EventMonth, EventYear, intCalendar) {
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readEventsFunction', EventStart, EventDay, EventMonth, EventYear, intCalendar, showEventsListing);
}
function showEventsListing(result) {
	
	document.getElementById("axEvents").innerHTML = result;
	jQuery("div#slider1").codaSlider();
	
}
function TripPlannerRemoveBookmark(id) {
	if (document.getElementById("trip_block_" + id)){
		var block_html = document.getElementById("trip_block_" + id).innerHTML;
		document.getElementById("trip_block_" + id).innerHTML = "<div style='height: 40px; text-align: center; padding-top: 20px;'><img src='"+website_url+"images/ajax-loader.gif' width='16' height='16' alt='' border='0'><br />~ Removing Bookmark ~</div>";
		DWREngine._execute(website_url+"function-ajax.cfm", null, 'removeBookmarkFunction', id, returnRemovedBookmark);
	}
}
function returnRemovedBookmark(result) {
	var valueArray = result.split(",");
	for(var i=0; i<valueArray.length; i++){
			 //do something by accessing valueArray[i];
		var snap = valueArray[i].replace(/flimflam/,",");
		var validate_removal = valueArray[0]; // remove or keep block
		var bookmark = valueArray[1]; // bookmark
		//var html_details = valueArray[2]; // html code 

	}
	
	if (validate_removal == 1) {
		document.getElementById("trip_block_" + bookmark).innerHTML = "";
		// renumber 
		var allHTMLTags=document.getElementsByTagName("*");
		var bookmark_count = 0;
		//Loop through all tags using a for loop
		for (i=0; i<allHTMLTags.length; i++) {
			//Get all tags with the specified class name.
			if (allHTMLTags[i].className=='current_count') {
				bookmark_count++
				allHTMLTags[i].innerHTML = bookmark_count;
			}
		}
		reloadDeleteBookMarkContainer();
		alert("Bookmark Removed");
	}
	else {
		//document.getElementById("trip_block_" + bookmark).innerHTML = html_details;
		alert("Bookmark Not Found");
	}
} 

function Bookmark(bookmarkID) {
	var strAddress = "";
	var strTitle = "";
	var strCategory = "";
	var strArea = "";
	
	var strAddress = document.getElementById(bookmarkID).value;
	if (document.getElementById("member_" + bookmarkID)){
		var strTitle = document.getElementById("member_" + bookmarkID).value;
		var strCategory = "member";
	}
	if (document.getElementById("event_" + bookmarkID)){
		var strTitle = document.getElementById("event_" + bookmarkID).value;
		var strCategory = "event";
	}
	if (document.getElementById("area_" + bookmarkID)){
		var strArea = document.getElementById("area_" + bookmarkID).value;
	}
//	alert("Website:"+strAddress);
//	alert("Member:"+strTitle);
//	alert("Category:"+strCategory);
//	alert("ID:"+bookmarkID);
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readBookMarkFunction', strAddress,strTitle,strCategory,bookmarkID,strArea, reloadBookMarkContainer);
}


function reloadBookMarkContainer() {
// lets give the bookmark block a nudge for our newly added bookmark.
	if (document.getElementById("bookmark_container")){
		DWREngine._execute(website_url+"function-ajax.cfm", null, 'reloadBookMarkContainerFunction', reloadBookMarkContainerResult);
	}
}
function reloadBookMarkContainerResult(result) {
	if (document.getElementById("bookmark_container")){
		document.getElementById("bookmark_container").innerHTML = result;
		DWREngine._execute(website_url+"function-ajax.cfm", null, 'readBookMarkCounterFunction', returnBookMarkValue);
	}
}
function returnBookMarkValue(result) {
	document.getElementById("BookMarkCounter").innerHTML = "[" + result + "]";
	alert("Bookmark Added");
}



function reloadDeleteBookMarkContainer() {
// lets give the bookmark block a nudge for our newly added bookmark.
	if (document.getElementById("bookmark_container")){
		DWREngine._execute(website_url+"function-ajax.cfm", null, 'reloadBookMarkContainerFunction', reloadDeleteBookMarkContainerResult);
	}
}
function reloadDeleteBookMarkContainerResult(result) {
	if (document.getElementById("bookmark_container")){
		document.getElementById("bookmark_container").innerHTML = result;
		DWREngine._execute(website_url+"function-ajax.cfm", null, 'readBookMarkCounterFunction', returnDeleteBookMarkValue);
	}
}
function returnDeleteBookMarkValue(result) {
	document.getElementById("BookMarkCounter").innerHTML = "[" + result + "]";
}


/* VALID EMAIL FOR FORM */
function validEmail(email) {
	invalidChars = ' !#$%^&*(){}[]+=~`?/:;,"'

	
	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) { //does it contain any invalid characters?
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)  		//there must be one "@" symbol
		if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) != -1) { //and only one "@"
		return false;
	}
	periodPos = email.indexOf(".",atPos+1)  //and at least one "." after the "@"
		if (periodPos == -1) {
		return false;
	}
	if (email.charAt(atPos+1) == ".") {	//is there a "." right after the "@"
		return false;
	}
	if (periodPos+3 > email.length) {  	//must be at least 2 characters after the "."
		return false;
	}
	return true;
}
/* TRIP PLANNER FORM */

/* SUBMIT NEWSLETTER FORM */
function submit_trip_planner_form()
{
	if(document.trip_planner.onsubmit())
	{
	document.trip_planner.submit();
	}
}
function ValidateTripPlannerForm(form) {
	var lengthusername = form.username.value.length;
	var lengthpassword = form.password.value.length;
	var lengthconfirmpassword = form.confirm_password.value.length;
	if (form.firstname.value == '') {
		alert("Please fill in your first name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	
	if (form.lastname.value == '') {
		alert("Please fill in your last name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	
	if (form.username.value == '') {
		alert("Please fill in a username.");
		form.username.focus();
		form.username.select();
		return false;
	}
	if (lengthusername <= 5) {
		alert("Username must be at least 6 characters.");
		form.username.focus();
		form.username.select();
		return false;
	}
	if (form.password.value == '') {
		alert("Please fill in a password.");
		form.password.focus();
		form.password.select();
		return false;
	}
	if (lengthpassword <= 5) {
		alert("Password must be at least 6 characters.");
		form.password.focus();
		form.password.select();
		return false;
	}
	if (form.confirm_password.value == '') {
		alert("Please confirm your password.");
		form.confirm_password.focus();
		form.confirm_password.select();
		return false;
	}
	if (lengthconfirmpassword <= 5) {
		alert("Confirmation Password must be at least 6 characters.");
		form.confirm_password.focus();
		form.confirm_password.select();
		return false;
	}
	if (form.password.value != form.confirm_password.value) {
		alert("Password and Confirmation Password must match.");
		form.confirm_password.focus();
		form.confirm_password.select();
		return false;
	}
	
	return true;
}

function ValidateSubmitEmailPageTripPlannerForm(form) {
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;
}


function ValidateContactUsForm(form) {
	if (form.firstname.value == '') {
		alert("Please fill in your first name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	
	if (form.lastname.value == '') {
		alert("Please fill in your last name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	if (form.address.value == '') {
		alert("Please fill in your address.");
		form.address.focus();
		form.address.select();
		return false;
	}
	if (form.city.value == '') {
		alert("Please fill in your city.");
		form.city.focus();
		form.city.select();
		return false;
	}
	if (form.state.value == '') {
		alert("Please fill in your State/Province.");
		form.state.focus();
		form.state.select();
		return false;
	}
	if (form.postal.value == '') {
		alert("Please fill in your Zip/Postal Code.");
		form.postal.focus();
		form.postal.select();
		return false;
	}
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;
}

function ValidateProposalForm(form) {
	if (form.firstname.value == '') {
		alert("Please fill in your first name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	if (form.lastname.value == '') {
		alert("Please fill in your last name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	if (form.title.value == '') {
		alert("Please fill in your title.");
		form.title.focus();
		form.title.select();
		return false;
	}
	if (form.company.value == '') {
		alert("Please fill in your company.");
		form.company.focus();
		form.company.select();
		return false;
	}
	if (form.address.value == '') {
		alert("Please fill in your address.");
		form.address.focus();
		form.address.select();
		return false;
	}
	if (form.city.value == '') {
		alert("Please fill in your city.");
		form.city.focus();
		form.city.select();
		return false;
	}
	if (form.state.value == '') {
		alert("Please fill in your State/Province.");
		form.state.focus();
		form.state.select();
		return false;
	}
	if (form.postal.value == '') {
		alert("Please fill in your Zip/Postal Code.");
		form.postal.focus();
		form.postal.select();
		return false;
	}
	if (form.phone.value == '') {
		alert("Please fill in phone number.");
		form.phone.focus();
		form.phone.select();
		return false;
	}
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;
}


function ValidateSubmitEventForm(form) {
	if (form.firstname.value == '') {
		alert("Please fill in your first name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	if (form.lastname.value == '') {
		alert("Please fill in your last name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	if (form.title.value == '') {
		alert("Please fill in your title.");
		form.title.focus();
		form.title.select();
		return false;
	}
	if (form.company.value == '') {
		alert("Please fill in your company.");
		form.company.focus();
		form.company.select();
		return false;
	}
	if (form.address.value == '') {
		alert("Please fill in your address.");
		form.address.focus();
		form.address.select();
		return false;
	}
	if (form.city.value == '') {
		alert("Please fill in your city.");
		form.city.focus();
		form.city.select();
		return false;
	}
	
	if (form.postal.value == '') {
		alert("Please fill in your Zip/Postal Code.");
		form.postal.focus();
		form.postal.select();
		return false;
	}
	if (form.phone.value == '') {
		alert("Please fill in phone number.");
		form.phone.focus();
		form.phone.select();
		return false;
	}
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;
}



function ValidateSubmitVolunteerForm(form) {
	if (form.firstname.value == '') {
		alert("Please fill in your first name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	if (form.lastname.value == '') {
		alert("Please fill in your last name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	if (form.title.value == '') {
		alert("Please fill in your title.");
		form.title.focus();
		form.title.select();
		return false;
	}
	if (form.company.value == '') {
		alert("Please fill in your company.");
		form.company.focus();
		form.company.select();
		return false;
	}
	if (form.address.value == '') {
		alert("Please fill in your address.");
		form.address.focus();
		form.address.select();
		return false;
	}
	if (form.city.value == '') {
		alert("Please fill in your city.");
		form.city.focus();
		form.city.select();
		return false;
	}
	if (form.state.value == '') {
		alert("Please fill in your State/Province.");
		form.state.focus();
		form.state.select();
		return false;
	}
	if (form.postal.value == '') {
		alert("Please fill in your Zip/Postal Code.");
		form.postal.focus();
		form.postal.select();
		return false;
	}
	if (form.phone.value == '') {
		alert("Please fill in phone number.");
		form.phone.focus();
		form.phone.select();
		return false;
	}
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;
}



function ValidateSignNewsletterForm(form) {
	if (form.firstname.value == '') {
		alert("Please fill in your first name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	if (form.lastname.value == '') {
		alert("Please fill in your last name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;
}


function ValidateSubmitMemberForm(form) {
	
	if (form.title.value == '') {
		alert("Please fill in your establishment name.");
		form.title.focus();
		form.title.select();
		return false;
	}
	
	if (form.address.value == '') {
		alert("Please fill in your address.");
		form.address.focus();
		form.address.select();
		return false;
	}
	if (form.city.value == '') {
		alert("Please fill in your city.");
		form.city.focus();
		form.city.select();
		return false;
	}
	
	if (form.postal.value == '') {
		alert("Please fill in your postal code.");
		form.postal.focus();
		form.postal.select();
		return false;
	}
	if (form.phone.value == '') {
		alert("Please fill in phone number.");
		form.phone.focus();
		form.phone.select();
		return false;
	}
	if (form.firstname.value == '') {
		alert("Please fill in your first name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	if (form.lastname.value == '') {
		alert("Please fill in your last name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;

}

function ValidateVistorGuideOrderForm(form) {
	if (form.firstname.value == '') {
		alert("Please fill in your first name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	
	if (form.lastname.value == '') {
		alert("Please fill in your last name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	if (form.address.value == '') {
		alert("Please fill in your address.");
		form.address.focus();
		form.address.select();
		return false;
	}
	if (form.city.value == '') {
		alert("Please fill in your city.");
		form.city.focus();
		form.city.select();
		return false;
	}
	if (form.state.value == '') {
		alert("Please fill in your State/Province.");
		form.state.focus();
		form.state.select();
		return false;
	}
	if (form.postal.value == '') {
		alert("Please fill in your Zip/Postal Code.");
		form.postal.focus();
		form.postal.select();
		return false;
	}
	if (form.country.value == '') {
		alert("Please fill in your Country.");
		form.country.focus();
		form.country.select();
		return false;
	}
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	if (form.phone.value == '') {
		alert("Please fill in your Phone Number.");
		form.phone.focus();
		form.phone.select();
		return false;
	}
	if (form.quantity.value == '') {
		alert("Please fill in your Quantity.");
		form.quantity.focus();
		form.quantity.select();
		return false;
	}
	return true;
}

function submit_trip_planner_login()
{
	document.trip_planner_login.submit();
}

function submit_email_page_trip_planner_form()
{
	if(document.email_page_trip_planner_login.onsubmit())
	{
	document.email_page_trip_planner_login.submit();
	}
	
}


function submit_event_form()
{
	if(document.search_creds.onsubmit())
	{
	document.search_creds.submit();
	}
	
}


function submit_contact_us_form()
{
	if(document.search_creds.onsubmit())
	{
	document.search_creds.submit();
	}
	
}

function submit_request_form()
{
	if(document.search_creds.onsubmit())
	{
	document.search_creds.submit();
	}
	
}
function submit_volunteer_form()
{
	if(document.search_creds.onsubmit())
	{
	document.search_creds.submit();
	}
	
}
function submit_newsletter_sign_form()
{
	if(document.search_creds.onsubmit())
	{
	document.search_creds.submit();
	}
}
function submit_member_form()
{
	if(document.search_creds.onsubmit())
	{
	document.search_creds.submit();
	}
	
}


function submit_order_form()
{
	if(document.search_creds.onsubmit())
	{
	document.search_creds.submit();
	}
	
}



function updateTripPlannerDate(id) {
	
	var strTitle = document.getElementById("date_picker_" + id).value;
	//alert(strTitle)
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'updateTripPlannerDateFunction', id, strTitle, returnupdateTripPlannerDate);
	
}

function returnupdateTripPlannerDate(result) {
	//document.getElementById("BookMarkCounter").innerHTML = "[" + result + "]";
	//alert(result);
}
/* TESTIMONIAL */
function loadPlannerTestimonial_1(planner, testimonial) {
	
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readPlannerTestimonialFunction', planner, testimonial, returnTestimonial_1);
}
function returnTestimonial_1(result) {
	document.getElementById("ax_testimonial_1").innerHTML = result;
}
function loadPlannerTestimonial_2(planner, testimonial) {
	
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readPlannerTestimonialFunction', planner, testimonial, returnTestimonial_2);
}
function returnTestimonial_2(result) {
	document.getElementById("ax_testimonial_2").innerHTML = result;
}

/* FORGOT EMAIL */

function ValidateTripPlannerForgotEmailForm(form) {
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;
}

/* BEGIN MEDIA LIBRARY */
function loadCurrentGalleryPhoto(gallery, photo) {
	$('#library_small a img').css('border', '1px solid #A8A8A8');
	$('#image_library_'+photo).css('border', '2px solid #db4495');
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readCurrentGalleryPhotoFunction', gallery, photo, returnCurrentGalleryPhotoFunction);
}
function returnCurrentGalleryPhotoFunction(result) {
	document.getElementById("media_gallery").innerHTML = result;
}

function LoadHighRezImage(photo) {
	document.getElementById("HighRezContainer").innerHTML = "<img src='"+ website_url +"images/ajax-loader.gif' style='border: 0px;' />&nbsp;Processing..";
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readHighRezImageFunction', photo, returnHighRezConainerResult);
	
}
function returnHighRezConainerResult(result){

	document.getElementById("HighRezContainer").innerHTML = result;
}
/* END MEDIA LIBRARY */



/* BEGIN VIRTUAL TOUR IMAGE LIBRARY */
function loadCurrentVirtualTourGalleryPhoto(gallery, photo) {
	$('#library_small a img').css('border', '1px solid #A8A8A8');
	$('#image_library_'+photo).css('border', '2px solid #db4495');
	DWREngine._execute(website_url+"function-ajax.cfm", null, 'readCurrentVirtualTourGalleryPhotoFunction', gallery, photo, returnCurrentVirtualTourGalleryPhotoFunction);
}
function returnCurrentVirtualTourGalleryPhotoFunction(result) {
	document.getElementById("media_gallery").innerHTML = result;
	$('#pane1').jScrollHorizontalPane({showArrows:true});
}

/* END VIRTUAL TOUR IMAGE LIBRARY */


/* BEGIN HOTEL SEARCH */
var urlwebsite = new Array();
    urlwebsite["room"] = "https://www.londontourismreservations.ca/English/availability_check.asp";
    urlwebsite["package"] = "https://www.londontourismreservations.ca/English/Pkg_Availability_Check.asp";

function showHideById(id, show) {
	    var e = GetRef(id);
		if (e == null) return;
		var display = (show) ? "block" : "none";
		e.style.display = display;
	}

/* SHOW OR HIDE AGE DROPDOWNS WHEN CHOOSING NUMBER OF CHILDREN */
    function DisplayChildrenAges(numChildren) {
        var idPrefix = "opt_child_";
        var maxChildren = GetRef("no_child").options.length - 1;
        
        // reset all age dropdowns
        showHideById("specifyAgeContainer", false);
        for (var i=1; i<=maxChildren; i++) {
            showHideById(idPrefix + i, false);
            
            if (i > numChildren) {
                var s = GetRef(idPrefix + i);
                s.selectedIndex = 0;
            }
        }
        
        // SHOW THE NECESSARY DROPDOWNS
        if (numChildren > 0) {
            showHideById("specifyAgeContainer", true);
            for (var i=1; i<=numChildren; i++) {
                showHideById(idPrefix + i, true);
            }
        }
    }

function GetRef(id) {
	return (document.all) ? document.all[id] : (document.getElementById) ? document.getElementById(id) : null;
}

function GetSelectedValue(id) {
	var o = GetRef(id);
	if (o == null) return null;
	return o.options[o.selectedIndex].value;
}
/* END HOTEL SEARCH */

/* SUBMIT FORM SEARCH */
function search_submit(search_type) {
	var url = urlwebsite[search_type];
	if (url == null) return;
	
	var query_string = "?Pkg_Only_Type=&room_types=All";
	query_string += "&monthList="+ GetSelectedValue("monthList");
	query_string += "&daysList="+ GetSelectedValue("daysList");
	query_string += "&yearList="+ GetSelectedValue("yearList");
	query_string += "&no_nights="+ GetSelectedValue("no_nights");
	query_string += "&no_rooms="+ GetSelectedValue("no_rooms");
	query_string += "&no_adult="+ GetSelectedValue("no_adult");
	
	var oChildren = GetRef("no_child");
	var numChildren = GetSelectedValue("no_child");
	var maxChildren = oChildren.options[oChildren.options.length - 1].value;
		
	var validAges = 0;
	var qstringAge = "";
	for (var i=1; i<=numChildren; i++) {
		var val = GetSelectedValue("opt_child_" + i);
		var age = -1;
		if (val > 0) {
			age = val;
			validAges++;
		}
		qstringAge += "&opt_child_"+ (i - 1) +"="+ age;
	}
	query_string += "&no_child="+ validAges + qstringAge;

	window.open(url + query_string);
}





function PrintDiscover(intPackage) {
	 window.open (website_url+"PrintDiscoverPackage.cfm?TLGP="+intPackage,"DiscoverOurSpirit","menubar=1,resizable=1,width=600,height=600");
}
function PrintPackages(intPackage) {
	 window.open (website_url+"PrintGetawayPackage.cfm?TLGP="+intPackage,"LondonGetawayPackage","menubar=1,resizable=1,width=600,height=600");
}


/*
function submit_form(){
	if(top.frames['prettyphoto'].document.forms['search_creds'].onsubmit())
	{
		top.frames['prettyphoto'].document.forms['search_creds'].submit();
	}

//top.frames['prettyphoto'].document.forms['search_creds'].submit();
//parent.frames['topFrame'].window.frames['editframe'].document.forms['myform'].submit();
}

*/

function submit_form(){
	if(document.search_creds.onsubmit())
	{
	document.search_creds.submit();
	}
}



