﻿
// Bauer Media Limited
//Copyright 2008 Bauer Media Limited
//
// Created 10/11/2008 by Kaz Rudys
// Lead Developer
//
// Revision History
//===============================================
//
// Job Reference    Developer          Date
//-----------------------------------------------
// CR-016           Kaz Rudys          10/11/2008

function InitToggle(sourceId, targetId)
{
    var targetElement = $(targetId);
    var sourceElement = $(sourceId);

    if (sourceElement.length > 0 && targetElement.length > 0)
    {
        targetElement.hide();

        sourceElement.click(function()
        {
            targetElement.toggle(400);

            return false;
        });
    }
    else
    {
        alert('Unable to locate toggle elements:' + sourceId + ', ' + targetId);
    }
}

var MediaRateThisSingle = {
    ratingChangeFillSingle: function() {
        switch (this.className) {
            case "five":
                $("ul.mediaRateThisRatings a.five").addClass("hilight");
            case "four":
                $("ul.mediaRateThisRatings a.four").addClass("hilight");
            case "three":
                $("ul.mediaRateThisRatings a.three").addClass("hilight");
            case "two":
                $("ul.mediaRateThisRatings a.two").addClass("hilight");
            case "one":
                $("ul.mediaRateThisRatings a.one").addClass("hilight");
        }
    },

    ratingChangeClearSingle: function() {
    $("ul.mediaRateThisRatings a").each(function() {
            $(this).removeClass("hilight");
        });
    }
}

function SetDisplayImage(imageLinkControlId, imageUrl, imageHref, imageTitle)
{
    if (imageLinkControlId != null)
    {
        var targetLinkElement = $("#" + imageLinkControlId);
        var targetImageElement = $("#" + imageLinkControlId + "> img");

        if (targetLinkElement.length > 0)
        {
            targetLinkElement.attr("href", imageHref);
            targetLinkElement.attr("class", "");
        }

        if (targetImageElement.length > 0)
        {
            targetImageElement.attr({
                src: imageUrl,
                title: imageTitle,
                alt: imageTitle,
                style: ""
            });
        }
    }
}

function SetMissingImageClass(imageControl) 
{
    if (imageControl != null) 
    {
        $(imageControl).hide();
        $(imageControl).parent().addClass("missing");
    }
}

//$(document).ready(function()
//{
//    var links = $("a > img");

//    if (links.length > 0)
//    {
//        $(links).onerror(function()
//        {
//            SetMissingImageClass(this);
//        });
//    }
//}
//);
