﻿function OnTabSelected(sender, args) {
    var tab = args.get_tab()

    // Mapa.
    if (tab.get_index() == 3) {
        if (typeof SetMapLocation == 'function') {
            SetMapLocation();
        }
    }
}

function SelectImage(image, width, height) {
    var imageControl = $get("selectedImage");
    var linkControl = $get("linkSelectedImage");

    if (image == null) {
        var imageGallery = $get("imageGallery");

        // Primera imagen.
        image = imageGallery.getElementsByTagName("li")[0].getElementsByTagName("img")[0];
    }

    imageControl.src = image.src;
    imageControl.alt = image.alt;
    imageControl.title = image.alt;
    imageControl.width = width;
    imageControl.height = height;

    linkControl.href = image.src;
    linkControl.title = image.alt;
}

function HideImageGallery() {
    var imageGallery = $get("imageGallery");
    imageGallery.style.display = "none";
}

function openPhoneWindow(url) {
    radopen(url, "phoneWindow");
}

function openLegalWindow() {
    var legalWindow = radopen(legalWindowPath, "legalWindow");
    var boundsWindow = legalWindow.getWindowBounds()

    legalWindow.moveTo(boundsWindow.x, 10);
}

function openContactWindow() {
    radopen(contactWindowPath, "contactWindow");
}

function openPrintWindow() {
    radopen(printWindowPath, "printWindow");
}

function contactFailed() {
    radalert("<strong>" + failMessage + "</strong><br /><br /><br />", 500, 170, failWindowTitle);
}

function isValidEmail(email) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return filter.test(email);
}

function ShowValidationMessage(message, control) {
    var alertWindow = radalert("<strong>" + message + "</strong><br /><br /><br />", 500, 170, validationTitle);

    if (control) {
        validationControl = control;
    }

    alertWindow.add_close(focusControl);

    return false;
}

function focusControl() {
    if (validationControl) {
        validationControl.focus();
    }
}

