﻿function LoadGallery(imageFile, captionText, pictureName, titleCaption, titleText) {
    
    var picture = document.getElementById(pictureName);
    picture.src = imageFile;
    picture.alt = titleText;
    picture.title = titleText;
    
    var strNewStringVariable = captionText.replace("`", "'");
    document.getElementById(titleCaption).innerHTML = "<p>" + strNewStringVariable + "</p>";
}

function openNewWindowVideo(url, windowName) {
    window.open(url, windowName, 'height=800,width=790,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
    return false;
}

function openNewWindow1(url, windowName) {
    window.open(url, windowName, 'height=650,width=800,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
    return false;
}

function openNewWindowIT(url, windowName) {
    window.open(url, windowName, 'height=650,width=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
    return false;
}

function Pop_Up(id) {
    document.getElementById(id).style.display = "block";
}

function Hide_Pop_Up(id) {
    document.getElementById(id).style.display = "none";
}

function pageUp() {
    if (window.scrollBy) {
        window.scrollBy(0, window.innerHeight ? -window.innerHeight : -document.body.clientHeight);
    }
}

function RedirectMainWindow(url) {
    var main = opener;
    if (opener.opener != null) {
        main = opener.opener;
        opener.close();
    }
    main.location = url;
    self.close();
}

function getShoreExcursions(port, container) {

    $.ajax({
        url: "http://webservices.carnivalukgroup.com/CunardShoreexCareers/ShoreExcursions.asmx/AjaxGetAllExcursionsDetailsByPort",
        dataType: "jsonp",
        jsonp: "callback",
        data: { port: port },
        success: function (json) {
            if (json.length == 0) {
                $("#" + container).html("There were no shore excursions.");
                return;
            }
            else {
                $("#" + container).html("<p>Please note: The excursion(s) listed are typical for this port. During the 12 weeks before departure, confirmed excursions can be viewed and pre-reserved via <a href='https://secure.pocruises.com/cp/index.asp?pageID=4&ABTA=V8764&brandCode=CU'>Voyage Personaliser</a></p>");

                $.get('/Templates/Cunard/Pages/ExcursionTeaser.htm', function (tmpl) {
                    $.each(json, function (i, val) {
                        $("#" + container).jqoteapp(tmpl, val);
                    });
                });
            }
        },
        error: function (thing, thing2) {
            alert("error = " + thing + " " + thing2);
        }
    });
}
     
