﻿
function ChangeText(newSize)
{
var overviewDiv;
var subDivs;
var theClass;
var strReplace = "";
var showContents = "Contents: ";

    // only for the overview
    overviewDiv = document.getElementById("testimonial_overview");
    
    // continu working with only the Div's within testimonial_overview"
    subDivs = overviewDiv.getElementsByTagName("DIV");
         
    for (var i=0; i < subDivs.length; i++)
    {
        // get the className of each DIV
        theClass = subDivs[i].className;
    
        // For Testing purposes only
//        showContents = showContents + "\n" + theClass;
        
        // General code to replace all current classNames by the new requested
        if (theClass.startsWith("testimonialItem"))
        {
            // For Testing purposes only
            showContents = showContents + "\n" + theClass;

            if (theClass.endsWith("Large"))
            {
                strReplace = theClass.replace("Large", "");

                switch (newSize)
                {
	              case "small":
	                subDivs[i].className = strReplace;
		            break;
	              case "medium": 
	                subDivs[i].className = strReplace + "Medium";
		            break;
		          default:
		            break;
                }           
            }
            else
            {
                if (theClass.endsWith("Medium"))
                {
                    strReplace = theClass.replace("Medium", "");
                    
                    switch (newSize)
                    {
	                  case "small":
	                    subDivs[i].className = strReplace;
		                break;
	                  case "large":
                        subDivs[i].className = strReplace + "Large";
                        break;
                      default:
                        break;
                    }           
                }
                else
                {
                    switch (newSize)
                    {
	                  case "medium": 
	                    subDivs[i].className = theClass + "Medium";
		                break;
	                  case "large":
                        subDivs[i].className = theClass + "Large";
                        break;
                      default:
                        break;
                    }           
                }
            }
        }
        
    }
    alert(showContents);
}


// Generic code to change the font within Testimonials_Overview
function ChangeFont (toChange, newSize)
{
	var toChangeItem;
	var itsClass;

    if (toChange == "body")
    {
        toChangeItem = document.body;
    }
    
    if (toChange == "testimonials")
    {
		// get the overall div
        toChangeItem = document.getElementById("testimonials_overall");
    }
    
    if (toChangeItem != null)
    {
		// get it's className
		itsClass = toChangeItem.className;
		// browserspecific
		if (itsClass.endsWith(" IE"))
		{
			itsClass = itsClass.replace(" IE","");
		}
	    
		// code to change the classname
		if (itsClass.endsWith("Large"))
		{
			strReplace = itsClass.replace("Large", "");

			switch (newSize)
			{
			  case "small":
				toChangeItem.className = strReplace;
				break;
			  case "medium": 
				toChangeItem.className = strReplace + " Medium";
				break;
			  default:
				break;
			}           
		}
		else
		{
			if (itsClass.endsWith("Medium"))
			{
				strReplace = itsClass.replace(" Medium", "");
	            
				switch (newSize)
				{
				  case "small":
					toChangeItem.className = strReplace;
					break;
				  case "large":
					toChangeItem.className = strReplace + " Large";
					break;
				  default:
					break;
				}           
			}
			else
			{
				switch (newSize)
				{
				  case "medium": 
					toChangeItem.className = itsClass + " Medium";
					break;
				  case "large":
					toChangeItem.className = itsClass + " Large";
					break;
				  default:
					break;
				}           
			}
		}
	}
}


function ToggleHourGlass() {
	// hide banners when we show the hourglass
	ShowBanners(false);
	
	HourGlass = document.getElementById("hourGlass");
	if (HourGlass != null)
	{		
		// Move the hourglass to the center of the page
		HourGlass.style.top = GetScrollTop() + 150 +'px' ;
		HourGlass.style.display = "block";
	}
	window.onunload = ToggleHourGlassOff;
}

function GetScrollTop()
{
	if (self.pageYOffset) // all except Explorer
	{
		 return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	// Explorer 6 Strict
	{
		return document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollTop;
	}
}

function ToggleHourGlassOff() {
	// show banners when we hide the hourglass
	ShowBanners(true);
	
	HourGlass = document.getElementById("hourGlass");
	if (HourGlass != null)
	{		
		HourGlass.style.display = "none";
	}
}

function StoreTestimonialJudgement(usefulPagePath, testimonialId, isUseful)
{
	var theURL = usefulPagePath + '?testimonialId=' + testimonialId + '&isUseful=' + isUseful;
  showContentPopUp(theURL);
}


function reportAbuse(PagePath, testimonialId)
{	
	var theURL = PagePath + '?testimonialId=' + testimonialId;
	var pageNumber = 0;
	
	if (EndecaContext)
	{
		var sIndex = EndecaContext.CurrentQueryString.indexOf("No=");
		if (sIndex >= 0)
		{
			var eIndex = EndecaContext.CurrentQueryString.indexOf("&", sIndex);
			var firstResultIndex = 0;
			if (eIndex > 0)
			{
				firstResultIndex = (EndecaContext.CurrentQueryString.substring(sIndex, eIndex)).split('=')[1];
			}
			else
			{
				firstResultIndex = (EndecaContext.CurrentQueryString.substring(sIndex)).split('=')[1];
			}
			pageNumber = firstResultIndex / 10;
		}
	}
	theURL += '&tst_pgnr=' + pageNumber;
	
	showContentPopUp(theURL);
}
var APP = { AccoOwner : new AccoOwner() }

function AccoOwner() {
	var _service;
	this.modal_ids = {
		modal_bg: "AddReactionModalBg",
		main_container: "AddReactionModalMainContainer",
		html_container: "AddReactionModalContent"
	};
	this.get_service = function() {
		if (!_service)
			_service = new NetMatch.Zoover.Web.AccoOwner.Services.AccoOwnerService();

		return _service;
	};
	// we can't initialize this field on creation time (some of the scripts need to load first)
	this.is_acco_owner = null;
};

// check if the current request is done by an acco owner - on callback, populate is_acco_owner member
AccoOwner.prototype.isAccoOwner = function(acc_id, callback) {
	this.get_service().IsAccoOwner(acc_id, function(result) { isAccoOwner_success_callback(result, callback); });
}

// use this method to get the html of the add reaction form
AccoOwner.prototype.getAddReactionForm = function(tes_id, login_url) {	
	this.get_service().GetAddReactionForm(tes_id, getAddReactionForm_success_callback);		
}

// saves the reaction and gets back its html
AccoOwner.prototype.saveReaction = function(tes_id, user_name, text) {
	this.get_service().SaveReaction(tes_id, user_name, text, function(result) { return saveReaction_success_callback(result, tes_id) });
}

function isAccoOwner_success_callback(result, callback) {
	APP.AccoOwner.is_acco_owner = result;
	callback(result);
}

function getAddReactionForm_success_callback(client_result) {
	if (!client_result.success) {
		window.location = client_result.result;
		return;
	}

	if (client_result.result == '')
		return;
		
	CreateReactionModal();
	PopulateReactionModal(client_result.result);	
}

function saveReaction_success_callback(result, tes_id) {
	// if the reaction was saved successfuly
	if (result != '') {
		var lReactionContainer = $(".reaction-container[rel='" + tes_id + "']");
		if (lReactionContainer) {
			lReactionContainer.html(result);
			$("#button-" + tes_id).hide();
		}
	}
	CloseReactionModal();
}

function PopulateReactionModal(result) {
	$("#" + APP.AccoOwner.modal_ids.html_container).html(result);
}

function CreateReactionModal() {

	ShowDropDownsIE6(false);

	// generate the modal background
	var modalDiv = $get(APP.AccoOwner.modal_ids.modal_bg);
	if (modalDiv == null) {
		modalDiv = document.createElement("div");
		modalDiv.name = APP.AccoOwner.modal_ids.modal_bg;
		modalDiv.id = APP.AccoOwner.modal_ids.modal_bg;
		modalDiv.className = "modalBackground";
		modalDiv.style.width = document.body.offsetWidth + 'px';
		modalDiv.style.height = screen.height + 'px';

		if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) {
			modalDiv.className += " modalBackgroundIE";
			modalDiv.style.height = document.body.offsetHeight;
		}
		document.body.appendChild(modalDiv);
	}
	else {
		modalDiv.style.display = "block";
	}

	var popUpDiv = $get(APP.AccoOwner.modal_ids.main_container);
	if (popUpDiv == null) {
		// create main container
		popUpDiv = document.createElement("div");
		popUpDiv.name = APP.AccoOwner.modal_ids.main_container;
		popUpDiv.id = APP.AccoOwner.modal_ids.main_container;
		popUpDiv.className = "popUpDivClassAddReaction";

		// create html content div
		popUpWindow = document.createElement('div');
		popUpWindow.id = APP.AccoOwner.modal_ids.html_container;
		popUpWindow.className = "popUpDivClassAddReaction";

		popUpDiv.appendChild(popUpWindow);

		document.body.appendChild(popUpDiv);
	}
	else {
		popUpDiv.style.display = "block";
	}

	var left = (document.body.offsetWidth - 500) / 2;
	if (left < 0) left = 0;
	popUpDiv.style.left = left + "px";

	SetDefaultAddReactionModalTopPosition();
}

function SetDefaultAddReactionModalTopPosition() {
	var lScrollY, lDefaultY = 250;
	var lAddReactionMainModalContainer;

	if (window.scrollY)
		lScrollY = window.scrollY;
	else
		if (document.documentElement.scrollTop)
		lScrollY = document.documentElement.scrollTop;
	else
		lScrollY = document.body.scrollTop;

	lAddReactionMainModalContainer = $get(APP.AccoOwner.modal_ids.main_container);
	if (lAddReactionMainModalContainer != null) {
		lAddReactionMainModalContainer.style.top = lScrollY + lDefaultY + 'px';
	}
}

function CloseReactionModal() { 
		
	var modalDiv = $get(APP.AccoOwner.modal_ids.modal_bg)
	if (modalDiv != null) {
		modalDiv.style.display = "none";
	}

	var popUpDiv = $get(APP.AccoOwner.modal_ids.main_container)
	if (popUpDiv != null) {
		popUpDiv.style.display = "none";
	}

	ShowDropDownsIE6(true);
}

$(function() {
	if (window.APP == undefined)
		return;
	APP.AccoOwner.isAccoOwner(GetPageContext().EntityId, HideShowAccoOwnerButtons);
});

function CheckIsAccoOwner() {
	HideShowAccoOwnerButtons(APP.AccoOwner.is_acco_owner);
}

function HideShowAccoOwnerButtons(show)
{
	var lShowAddReactionBtn = $('#hfShowAddReactionButton').val();
	if (show && lShowAddReactionBtn == "True")
		$(".rea-buttton").css("display", "block");
	else
		$(".rea-buttton").css("display", "none");		
}

$(function() {
	$("div.reaction").each(function() {
		$(this).css("width", ($(this).parent().parent().width() - ($(this).outerWidth(true) - $(this).innerWidth())) + "px");
	});
});
Type.registerNamespace('NetMatch.Zoover.Web.Services.Testimonials');
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService = function() {
	NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.initializeBase(this);
	this._timeout = 0;
	this._userContext = null;
	this._succeeded = null;
	this._failed = null;
}
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.prototype = {
	_get_path: function() {
		var p = this.get_path();
		if (p) return p;
		else return NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.get_path();
	},
	AccommodationTestimonialQuery: function(serviceRequest, pageContext, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'AccommodationTestimonialQuery', false, { serviceRequest: serviceRequest, pageContext: pageContext }, succeededCallback, failedCallback, userContext);
	},
	PointOfInterestTestimonialQuery: function(serviceRequest, pageContext, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'PointOfInterestTestimonialQuery', false, { serviceRequest: serviceRequest, pageContext: pageContext }, succeededCallback, failedCallback, userContext);
	},
	DestinationTestimonialQuery: function(serviceRequest, pageContext, succeededCallback, failedCallback, userContext) {
		return this._invoke(this._get_path(), 'DestinationTestimonialQuery', false, { serviceRequest: serviceRequest, pageContext: pageContext }, succeededCallback, failedCallback, userContext);
	} 
}
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.registerClass('NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService', Sys.Net.WebServiceProxy);
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance = new NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService();
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.set_path = function(value) { NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.set_path(value); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.get_path = function() { return NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.get_path(); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.set_timeout = function(value) { NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.set_timeout(value); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.get_timeout = function() { return NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.get_timeout(); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.set_defaultUserContext = function(value) { NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.set_defaultUserContext(value); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.get_defaultUserContext = function() { return NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.get_defaultUserContext(); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.set_defaultSucceededCallback = function(value) { NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.set_defaultSucceededCallback(value); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.get_defaultSucceededCallback = function() { return NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.get_defaultSucceededCallback(); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.set_defaultFailedCallback = function(value) { NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.set_defaultFailedCallback(value); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.get_defaultFailedCallback = function() { return NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.get_defaultFailedCallback(); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.set_path("/Services/Testimonials/TestimonialQueryService.asmx");
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.AccommodationTestimonialQuery = function(serviceRequest, pageContext, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.AccommodationTestimonialQuery(serviceRequest, pageContext, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.PointOfInterestTestimonialQuery = function(serviceRequest, pageContext, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.PointOfInterestTestimonialQuery(serviceRequest, pageContext, onSuccess, onFailed, userContext); }
NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.DestinationTestimonialQuery = function(serviceRequest, pageContext, onSuccess, onFailed, userContext) { NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService._staticInstance.DestinationTestimonialQuery(serviceRequest, pageContext, onSuccess, onFailed, userContext); }
var gtc = Sys.Net.WebServiceProxy._generateTypedConstructor;
Type.registerNamespace('NetMatch.Zoover.Testimonials.Endeca');
if (typeof (NetMatch.Zoover.Testimonials.Endeca.EntityTestimonialsQueryInformation) === 'undefined') {
	NetMatch.Zoover.Testimonials.Endeca.EntityTestimonialsQueryInformation = gtc("NetMatch.Zoover.Testimonials.Endeca.EntityTestimonialsQueryInformation");
	NetMatch.Zoover.Testimonials.Endeca.EntityTestimonialsQueryInformation.registerClass('NetMatch.Zoover.Testimonials.Endeca.EntityTestimonialsQueryInformation');
}
Type.registerNamespace('NetMatch.Zoover.Web.Atlas');
if (typeof (NetMatch.Zoover.Web.Atlas.AtlasPageContext) === 'undefined') {
	NetMatch.Zoover.Web.Atlas.AtlasPageContext = gtc("NetMatch.Zoover.Web.Atlas.AtlasPageContext");
	NetMatch.Zoover.Web.Atlas.AtlasPageContext.registerClass('NetMatch.Zoover.Web.Atlas.AtlasPageContext');
}
if (typeof (NetMatch.Zoover.Testimonials.Endeca.TestimonialServiceResponse) === 'undefined') {
	NetMatch.Zoover.Testimonials.Endeca.TestimonialServiceResponse = gtc("NetMatch.Zoover.Testimonials.Endeca.TestimonialServiceResponse");
	NetMatch.Zoover.Testimonials.Endeca.TestimonialServiceResponse.registerClass('NetMatch.Zoover.Testimonials.Endeca.TestimonialServiceResponse');
}

/* Register the TestimonialQuery namespace */
Type.registerNamespace("TestimonialQuery");


/****************************************************************************************
TestimonialQuery object	
*****************************************************************************************/
TestimonialQuery.EndecaTestimonialService = function() {
	// Add the OnEndecaTestimonialServiceComplete function (see below) as event handler. This function displays the
	// web service results.
	this.add_endecaTestimonialServiceCompleteEvent(window.OnEndecaTestimonialServiceComplete);
}

// Raises the event specified by 'eventName'.
TestimonialQuery.EndecaTestimonialService.prototype._raiseEvent = function(eventName, eventArgs) {
	var handler = this.get_events().getHandler(eventName);
	if (handler) {
		if (!eventArgs) {
			eventArgs = Sys.EventArgs.Empty;
		}
		handler(this, eventArgs);
	}
}

// Gets all events registered with this object.
TestimonialQuery.EndecaTestimonialService.prototype.get_events = function() {
	if (!this._events) {
		this._events = new Sys.EventHandlerList();
	}
	return this._events;
}

/* Adding/removing event handlers */
TestimonialQuery.EndecaTestimonialService.prototype.add_endecaTestimonialServiceStartEvent = function(handler) {
	this.get_events().addHandler('endecaTestimonialServiceStartEvent', handler);
}

TestimonialQuery.EndecaTestimonialService.prototype.remove_endecaTestimonialServiceStartEvent = function(handler) {
	this.get_events().removeHandler('endecaTestimonialServiceStartEvent', handler);
}

TestimonialQuery.EndecaTestimonialService.prototype.add_endecaTestimonialServiceCompleteEvent = function(handler) {
	this.get_events().addHandler('endecaTestimonialServiceCompleteEvent', handler);
}

TestimonialQuery.EndecaTestimonialService.prototype.remove_endecaTestimonialServiceCompleteEvent = function(handler) {
	this.get_events().removeHandler('endecaTestimonialServiceCompleteEvent', handler);
}

// Exception event which is invoked when an exception occurs inside a web service
TestimonialQuery.EndecaTestimonialService.prototype.add_endecaTestimonialServiceExceptionEvent = function(handler) {
	this.get_events().addHandler('endecaTestimonialServiceExceptionEvent', handler);
}

TestimonialQuery.EndecaTestimonialService.prototype.remove_endecaTestimonialServiceExceptionEvent = function(handler) {
	this.get_events().removeHandler('endecaTestimonialServiceExceptionEvent', handler);
}

// Exception event which is invoked when calling a webservice has failed
TestimonialQuery.EndecaTestimonialService.prototype.add_endecaTestimonialServiceCallExceptionEvent = function(handler) {
	this.get_events().addHandler('endecaTestimonialServiceCallExceptionEvent', handler);
}

TestimonialQuery.EndecaTestimonialService.prototype.remove_endecaTestimonialServiceCallExceptionEvent = function(handler) {
	this.get_events().removeHandler('endecaTestimonialServiceCallExceptionEvent', handler);
}


/* Raising events */
TestimonialQuery.EndecaTestimonialService.prototype.OnEndecaTestimonialServiceStart = function() {
	BeginRequestHandler();
	TestimonialQuery.EndecaTestimonialService.getInstance()._raiseEvent('endecaTestimonialServiceStartEvent');
}

TestimonialQuery.EndecaTestimonialService.prototype.OnEndecaTestimonialServiceComplete = function(result) {
	TestimonialQuery.EndecaTestimonialService.getInstance()._raiseEvent('endecaTestimonialServiceCompleteEvent', result);
}

TestimonialQuery.EndecaTestimonialService.prototype.OnEndecaTestimonialServiceException = function(result) {
	TestimonialQuery.EndecaTestimonialService.getInstance()._raiseEvent('endecaTestimonialServiceExceptionEvent', result);
}

TestimonialQuery.EndecaTestimonialService.prototype.OnEndecaTestimonialServiceCallException = function(result) {
	TestimonialQuery.EndecaTestimonialService.getInstance()._raiseEvent('endecaTestimonialServiceCallExceptionEvent', result);
}

/*
Implementation of a 'Singleton' pattern
*/

TestimonialQuery.EndecaTestimonialService._Instance = null;
TestimonialQuery.EndecaTestimonialService.getInstance = function() {
if (TestimonialQuery.EndecaTestimonialService._Instance == null) {
		TestimonialQuery.EndecaTestimonialService._Instance = new TestimonialQuery.EndecaTestimonialService();
	}
	return TestimonialQuery.EndecaTestimonialService._Instance;
}


/*
This function executes an Endeca navigation query against the testimonials navigation engine + available fresh testimonials
The request is made using Atlas, through the NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService
webservice. When the request is completed, results are passed to the OnEndecaTestimonialServiceComplete function.
*/
TestimonialQuery.EndecaTestimonialService.prototype.AccommodationTestimonialQuery = function(language, partyFilter, currentPage, pageSize) {

	var TestimonialServiceRequest = this.GetTestimonialsServiceRequest(language, partyFilter, currentPage, pageSize);
	try 
	{
		// The GetPageContext() function is registered by the TestimonialUIController
		var ZooverPageContext = GetPageContext(language, partyFilter, currentPage, pageSize);

		// Call the webservice asynchronously and pass the request and the event handlers
		// Query:function(request,pageContext,succeededCallback, failedCallback, userContext)
		NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.AccommodationTestimonialQuery(TestimonialServiceRequest, ZooverPageContext,
			this.OnEndecaTestimonialServiceComplete, this.OnEndecaTestimonialServiceException, null);
	}
	catch (e) 
	{
		// Most likely the webservice is not available
		this.OnEndecaTestimonialServiceCallException(e);
	}
	return false;
}

function AccommodationTestimonialQuery(language, partyFilter, currentPage, pageSize) {
	TestimonialQuery.EndecaTestimonialService.getInstance().AccommodationTestimonialQuery(language, partyFilter, currentPage, pageSize);
}

TestimonialQuery.EndecaTestimonialService.prototype.PointOfInterestTestimonialQuery = function(language, partyFilter, currentPage, pageSize) {

	var TestimonialServiceRequest = this.GetTestimonialsServiceRequest(language, partyFilter, currentPage, pageSize);
	try {
		// The GetPageContext() function is registered by the TestimonialUIController
		var ZooverPageContext = GetPageContext(language, partyFilter, currentPage, pageSize);

		// Call the webservice asynchronously and pass the request and the event handlers
		// Query:function(request,pageContext,succeededCallback, failedCallback, userContext)
		NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.PointOfInterestTestimonialQuery(TestimonialServiceRequest, ZooverPageContext,
			this.OnEndecaTestimonialServiceComplete, this.OnEndecaTestimonialServiceException, null);
	}
	catch (e) {
		// Most likely the webservice is not available
		this.OnEndecaTestimonialServiceCallException(e);
	}
	return false;
}

function PointOfInterestTestimonialQuery(language, partyFilter, currentPage, pageSize) {
	TestimonialQuery.EndecaTestimonialService.getInstance().PointOfInterestTestimonialQuery(language, partyFilter, currentPage, pageSize);
}

TestimonialQuery.EndecaTestimonialService.prototype.DestinationTestimonialQuery = function(language, partyFilter, currentPage, pageSize) {

	var TestimonialServiceRequest = this.GetTestimonialsServiceRequest(language, partyFilter, currentPage, pageSize);
	try {
		// The GetPageContext() function is registered by the TestimonialUIController
		var ZooverPageContext = GetPageContext(language, partyFilter, currentPage, pageSize);

		// Call the webservice asynchronously and pass the request and the event handlers
		// Query:function(request,pageContext,succeededCallback, failedCallback, userContext)
		NetMatch.Zoover.Web.Services.Testimonials.TestimonialQueryService.DestinationTestimonialQuery(TestimonialServiceRequest, ZooverPageContext,
			this.OnEndecaTestimonialServiceComplete, this.OnEndecaTestimonialServiceException, null);
	}
	catch (e) {
		// Most likely the webservice is not available
		this.OnEndecaTestimonialServiceCallException(e);
	}
	return false;
}

function DestinationTestimonialQuery(language, partyFilter, currentPage, pageSize) {
	TestimonialQuery.EndecaTestimonialService.getInstance().DestinationTestimonialQuery(language, partyFilter, currentPage, pageSize);
}

TestimonialQuery.EndecaTestimonialService.prototype.TranslationPopUpTestimonialQuery = function(language, partyFilter, currentPage, pageSize) {

	var TestimonialServiceRequest = this.GetTestimonialsServiceRequest(language, partyFilter, currentPage, pageSize);
	try {
		// The GetPageContext() function is registered by the TestimonialUIController
		var ZooverPageContext = GetPageContext(language, partyFilter, currentPage, pageSize);

		// Call the webservice asynchronously and pass the request and the event handlers
		// Query:function(request,pageContext,succeededCallback, failedCallback, userContext)
		PageMethods.TranslationPopUpTestimonialQuery(TestimonialServiceRequest, ZooverPageContext,
			this.OnEndecaTestimonialServiceComplete, this.OnEndecaTestimonialServiceException, null);
	}
	catch (e) {
		// Most likely the webservice is not available
		this.OnEndecaTestimonialServiceCallException(e);
	}
	return false;
}

function TranslationPopUpTestimonialQuery(language, partyFilter, currentPage, pageSize) {
	TestimonialQuery.EndecaTestimonialService.getInstance().TranslationPopUpTestimonialQuery(language, partyFilter, currentPage, pageSize);
}

TestimonialQuery.EndecaTestimonialService.prototype.GetTestimonialsServiceRequest = function(language, partyFilter, currentPage, pageSize) {
	// Call the OnRequestStart so that the page can show some message or cool effect...
	this.OnEndecaTestimonialServiceStart();

	// Set up the request object
	var TestimonialServiceRequest = new NetMatch.Zoover.Testimonials.Endeca.EntityTestimonialsQueryInformation();
	TestimonialServiceRequest.CurrentLanguage = language;
	TestimonialServiceRequest.PartyFilter = partyFilter;
	TestimonialServiceRequest.CurrentPage = currentPage;
	TestimonialServiceRequest.PageSize = pageSize;

	return TestimonialServiceRequest;
}



TestimonialQuery.EndecaTestimonialService.prototype.QueryLatestTestimonials = function(currentPage, pageSize) {

	// Call the OnRequestStart so that the page can show some message or cool effect...
	this.OnEndecaTestimonialServiceStart();

	// Set up the request object
	var TestimonialServiceRequest = new NetMatch.Zoover.Testimonials.Endeca.LatestTestimonialsQueryInformation();
	TestimonialServiceRequest.CurrentPage = currentPage;
	TestimonialServiceRequest.PageSize = pageSize;

	try {
		// The GetPageContext() function is registered by the TestimonialUIController
		var ZooverPageContext = GetPageContext();

		if (typeof (NetMatch.Zoover.Testimonials.Endeca.LatestTestimonialsQueryInformation) === 'undefined') {
			NetMatch.Zoover.Testimonials.Endeca.LatestTestimonialsQueryInformation = gtc("NetMatch.Zoover.Testimonials.Endeca.LatestTestimonialsQueryInformation");
			NetMatch.Zoover.Testimonials.Endeca.LatestTestimonialsQueryInformation.registerClass('NetMatch.Zoover.Testimonials.Endeca.LatestTestimonialsQueryInformation');
	
		}
		// Call the web method asynchronously and pass the request and the event handlers
		// Query:function(request,pageContext,succeededCallback, failedCallback, userContext)
		PageMethods.LatestTestimonialQuery(TestimonialServiceRequest, ZooverPageContext, 
			this.OnEndecaTestimonialServiceComplete, this.OnEndecaTestimonialServiceException);
	}
	catch (e) {
		// Most likely the web method is not available
		this.OnEndecaTestimonialServiceCallException(e);
	}
	return false;
}

function QueryLatestTestimonials(currentPage, pageSize) {
	TestimonialQuery.EndecaTestimonialService.getInstance().QueryLatestTestimonials(currentPage, pageSize);
}

TestimonialQuery.EndecaTestimonialService.prototype.QueryTopAndFlopTestimonials = function(currentPage, pageSize, isTop) {

	// Call the OnRequestStart so that the page can show some message or cool effect...
	this.OnEndecaTestimonialServiceStart();

	// Set up the request object
	var TestimonialServiceRequest = new NetMatch.Zoover.Testimonials.Endeca.TopAndFlopTestimonialsQueryInformation();
	TestimonialServiceRequest.CurrentPage = currentPage;
	TestimonialServiceRequest.PageSize = pageSize;
	TestimonialServiceRequest.IsTopTestimonial = isTop;
	
	try {
		// The GetPageContext() function is registered by the TestimonialUIController
		var ZooverPageContext = GetPageContext();

		if (typeof (NetMatch.Zoover.Testimonials.Endeca.TopAndFlopTestimonialsQueryInformation) === 'undefined') {
			NetMatch.Zoover.Testimonials.Endeca.TopAndFlopTestimonialsQueryInformation = gtc("NetMatch.Zoover.Testimonials.Endeca.TopAndFlopTestimonialsQueryInformation");
			NetMatch.Zoover.Testimonials.Endeca.TopAndFlopTestimonialsQueryInformation.registerClass('NetMatch.Zoover.Testimonials.Endeca.TopAndFlopTestimonialsQueryInformation');
		}
		// Call the web method asynchronously and pass the request and the event handlers
		// Query:function(request,pageContext,succeededCallback, failedCallback, userContext)
		PageMethods.TopAndFlopTestimonialQuery(TestimonialServiceRequest, ZooverPageContext,
			this.OnEndecaTestimonialServiceComplete, this.OnEndecaTestimonialServiceException);
	}
	catch (e) {
		// Most likely the webservice is not available
		this.OnEndecaTestimonialServiceCallException(e);
	}
	return false;
}

function QueryTopAndFlopTestimonials(currentPage, pageSize, isTop) {
	TestimonialQuery.EndecaTestimonialService.getInstance().QueryTopAndFlopTestimonials(currentPage, pageSize, isTop);
}

/*
This function is called when a request to the webservice completes succesfully.
The result will contain an array of EndecaQueryServiceResponseItem objects.
Each object contains the new inner html for a particular EndecaQueryResultsPlaceHolder 
control on the page.
*/
function OnEndecaTestimonialServiceComplete(sender, result) {
	var lCurrentPlaceHolder;
	var lCurrentItem;

	/* Iterate over the result items and set the inner html of each related placeholder */
	for (i = 0; i < result.Items.length; i++) {
		// Each item contains an TestimonialServiceResponse object
		lCurrentItem = result.Items[i];

		lCurrentPlaceHolder = document.getElementById(lCurrentItem.PlaceHolderId);
			if (lCurrentPlaceHolder != null) {
				lCurrentPlaceHolder.innerHTML = lCurrentItem.InnerHtml;
				// evaluate any script that was inserted into the place holder
				for (var j = 0, e = lCurrentPlaceHolder.getElementsByTagName("script"); j < e.length; j++) {
					eval(e[j].innerHTML);
				}
			}
			else {
				alert('Could not find an testimonial place holder with placeholder id \"' +
					lCurrentItem.PlaceHolderId + '\".');
			}
	}

	// Call the OnAfterEndecaTestimonialServiceComplete so that the page can do any additional processing required
	if (window.OnAfterEndecaTestimonialServiceComplete)
		OnAfterEndecaTestimonialServiceComplete();
	if (typeof (MyZooverProfileEnabled) != 'undefined' && MyZooverProfileEnabled != null && MyZooverProfileEnabled) {
		GetMyZooverProfileInformation();
	}
	if (typeof (APP) != 'undefined' && typeof(APP.AccoOwner) != 'undefined') {
		CheckIsAccoOwner();
	}
	EndRequestHandler();
}

function OnEndecaTestimonialServiceCallException(sender, exception) {
	alert('Calling webservice failed: ' + exception.message);
}

function OnEndecaTestimonialServiceException(sender, exception) {
	alert('The webservice returned an exception: ' + exception.get_message());
}

function ScrollUp() {
	scrollToAnchor('upperPaging');
}

function BeginRequestHandler() {
	ToggleHourGlass();
}

function EndRequestHandler() {
	ToggleHourGlassOff();
	ScrollUp();
	//Make sure the translation is called
	if (typeof (ddlLanguages) != 'undefined' && ddlLanguages != null) {
		SaveReviewsTexts(); 
		TranslateReviews();
	}
}

function actionLinkRedirect(PagePath) {
	showContentPopUpExtended(PagePath, 700, 820);
}

function openTranslationPopup(PagePath) {
	showContentPopUpExtended(PagePath, 700, 740);
}

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();