﻿//-----------------------------------------------------------------------
// Copyright (C) Motorwebs Corporation. All rights reserved.
//-----------------------------------------------------------------------

var __media_gallery = null;
var __contactForm = null;
var __quoteForm = null;
var __vehicleSearch = null;

function pageLoad() {
    $addHandler(window, 'resize', onGalleryResize);
    __contactForm = $find('contactForm');
    __quoteForm = $find('quoteForm');
    __vehicleSearch = $find('vehicleSearch');
}

function pageUnload() {
    $removeHandler(window, 'resize', onGalleryResize);
}

function onGalleryResize() {
    if (__media_gallery) __media_gallery.resize();
}

function onSuccess(state, context) {
    switch (context) {
        case 'quoteFormSend':
            __quoteForm.onServiceSuccess(state);
            break;
        case 'contactFormSend':
            __contactForm.onServiceSuccess(state);
            break;
        case 'vehicleSearch':
            __vehicleSearch.onServiceSuccess(state);
            break;
    }
}

function onFailure(error, context, methodName) {
    var msg = "The " + methodName + " method called by " + context + " Failed! - " + error.get_message();
    alert(msg);
}
