

/* Copyright © Website Engineers Limited */

/* Global */
$(document).ready(
    function() {

        // Expander
        var moreText = "Show More...";
        var lessText = "Show Less...";
        function showExpander(id) {
            var setText = "";
            if ($.cookie(id) == "Show") {
                setText = lessText;
            }
            else {
                setText = moreText;
                $("." + id + "Hide").hide();
            }
            $("." + id + "Show").text(setText).show();
        }
        function toggleExpander(id) {
            var setText = "";
            var cookieValue = "";
            if ($("." + id + "Hide").is(":visible")) {
                setText = moreText;
                cookieValue = "Hide";
                $("." + id + "Hide").hide("fast");
            }
            else {
                $("." + id + "Hide").show("fast");
                setText = lessText;
                cookieValue = "Show";
            }
            $("." + id + "Show").text(setText);
            $.cookie(id, cookieValue, { path: '/', expires: 60 });
        }
        function vehicleExpander(id) {
            var items = 0;
            $("." + id + " .Vehicles .Vehicle").each(
                function(item) {
                    items = item;
                }
            );
            if (items > 2) {
                showExpander(id);
                $("." + id + "Show").click(
                    function() {
                        toggleExpander(id);
                    }
                );
            };
        }
        vehicleExpander("RecentlyViewed");
        vehicleExpander("WatchedVehicles");

        // Comments 
        $(".Comments ul").newsTicker();

        // Slides
        $("#SlideShow").cycle({ fx: 'fade', speed: 900, timeout: 9000, pause: 1 });

    }
);

function embedFlash(ID,
                    Movie,
                    Width,
                    Height) {
    var _Flash = '';
    _Flash += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + Width + '" height="' + Height + '" id="' + ID + '">';
    _Flash += '<param name="movie" value="' + Movie + '" />';
    _Flash += '<param name="menu" value="false" />';
    _Flash += '<param name="quality" value="high" />';
    _Flash += '<param name="bgcolor" value="#FFFFFF" />';
    _Flash += '<param name="wmode" value="transparent" />';
    _Flash += '<embed src="' + Movie + '" quality="high" menu="false" wmode="transparent" bgcolor="#FFFFFF" width="' + Width + '" height="' + Height + '" name="' + ID + '" type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></embed>';
    _Flash += '</object>';
    return _Flash
}

function embedYouTube(URL,
                      Width,
                      Height) {
    var _YouTube = '';
    _YouTube = '<object width="' + Width + '" height="' + Height + '"><param name="movie" value="' + URL + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + URL + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + Width + '" height="' + Height + '"></embed></object>';
    return _YouTube
}

/* End */

