﻿function ApplyJqTransform() {
    //find all form with class jqtransform and apply the plugin
    $("form.jqtransform").jqTransform();
};

function ShowFormPopup(containerId) {
    $("#" + containerId).css("display", "block");
    $("#GrayOutLayer").css("opacity", "0.0").css("display", "block").animate({ opacity: 0.50 }, 1000);
    return true;
};

function CloseFormPopup(containerId) {
    $("#GrayOutLayer").css("opacity", "0");
    $("#GrayOutLayer").css("display", "none");
    $("#" + containerId).css("display", "none");
    return true;
};

function ChangeImage(sender, url) {
    sender.src = url;
};

function SetShareLink(elementId, url, suffix) {
    document.getElementById(elementId).href = url + location.href + suffix;
};

function ShowAwardsPanel() {
    // Unless the url contains "/Wrap/" or "/SSAS/" then make the Awards panel visible
    var url = $(location).attr('href');
    var containsSSAS = url.toLowerCase().indexOf("ssas");
    var containsWrap = url.toLowerCase().indexOf("wrap");

    // Can't show it for sipp pages unless it's specifically sipp.index or partnershipSipp or literature/sipp
    var containsSipp = url.toLowerCase().indexOf("sipp");
    var containsPsipp = url.toLowerCase().indexOf("partnershipsipp");
    var containsSippIndex = url.toLowerCase().indexOf("\/sipp\/index");
    var containsLitSipp = url.toLowerCase().indexOf("\/literature\/sipp");

    if (containsSipp == -1) {
        if ((containsSSAS == -1) && (containsWrap == -1)) {
            $('#divAwards').css('display', 'block');
        }
    } else {
        // Does contain sipp, make sure it's partnership sipp, or the sipp index page...
        if ((containsPsipp != -1) || (containsSippIndex != -1) || (containsLitSipp != -1)) {
            $('#divAwards').css('display', 'block');
        }
    }

    // Show the second awards panel (Adviser Asset 2011 award for Wrap) if it's a wrap page...
    if (containsWrap != -1) {
        $('#divAwards1').css('display', 'block');
    }
};

function ShowContactBoxPanel() {
    // The Login page is a special case - we want to show a link to Isipp instead of the contact box 
    var url = $(location).attr('href');
    var containsLogin = url.toLowerCase().indexOf("\/login\/");

    // Determine whether to show text for search engine optimisation, or ggrpahical version...
    var seoFlag = 0;
    if ($('#seoFlag').hasClass('1')) { seoFlag = 1 };

    if (containsLogin == -1) {
        // Default to contact link
        if (seoFlag == 1) {
            $('.isipp').remove();
            $('#divContactBox').css('background', 'transparent url(../images/ContactBoxEmpty.gif) top left no-repeat');
        } else {
            $('.seoOn').remove();
            $('#divContactBox').css('background', 'transparent url(../images/ContactBox.gif) top left no-repeat');
        }
        $('#divContactBoxButton').text('Contact');
        $('#divContactBoxButton').attr('href', '/Contact/Index.aspx');

    } else {
        // Show the iSIPP link
        if (seoFlag == 1) {
            $('.contact').remove();
            $('#divContactBox').css('background', 'transparent url(../images/IsippBoxEmpty.gif) top left no-repeat');
        } else {
            $('.seoOn').remove();
            $('#divContactBox').css('background', 'transparent url(../images/IsippBox.gif) top left no-repeat');
        }
        $('#divContactBoxButton').text('iSIPP');
        $('#divContactBoxButton').attr('href', '/SIPP/iSIPP.aspx');
    }
    $('#divContactBox').css('visibility', 'visible');
};

function ShowSeoContent() {
    // Determine which DIVs to show for search engine optimisation...
    var seoFlag = 0;
    if ($('#seoFlag').hasClass('1')) { seoFlag = 1 };

    // If we're running Search Engine Optimised, then take out the graphical versions, and leave the text to display...
    if (seoFlag == 1) {
        $('.seoOff').remove();
    } else {
        // Otherwise remove the text versions...
        $('.seoOn').remove();
    }

    // The seo graphical / text content should be contained inside a hidden div
    // This makes it visible once we've removed the unneeded content.
    $('.divSeoContainer').css('visibility', 'visible');
};

