

$(function () {

	jQuery.GMTDHR.random();

	//jQuery.GMTDHR.ImageRotator();

	jQuery.GMTDHR.Compactor(".teamItem", "h4", ".rosterItem");
	jQuery.GMTDHR.Compactor(".videoItem", "h4", ".VDisplayItem");

	jQuery.GMTDHR.Hijacker("#videoMenu", "#hiJacker", "/video/hijack_video/");

});





jQuery.GMTDHR = {



	random : function(){

		var img_name = new Array(

		"http://gmt-dhr.com/public/img/banner.jpg",

		"http://gmt-dhr.com/public/img/banner2.jpg",

		"http://gmt-dhr.com/public/img/banner3.jpg",

		"http://gmt-dhr.com/public/img/banner4.jpg");

		var l = img_name.length;

		var rnd_no = Math.round((l-1)*Math.random());

		$("#rotateMe").find("img:first").attr("src", img_name[rnd_no]).end().fadeIn("slow");



	},



/*

	ImageRotator : function()

    {

        $("#rotateMe").append("<img class='rotate' src='http://gmt-dhr.com/public/img/banner.jpg'><img class='rotate' src='http://gmt-dhr.com/public/img/banner2.jpg'><img class='rotate' src='http://gmt-dhr.com/public/img/banner3.jpg'><img class='rotate' src='http://gmt-dhr.com/public/img/banner4.jpg'>");

        jQuery.GMTDHR.changeEm();

    },

    

	changeEm : function()

    {

        $("#rotateMe").find("img:first").fadeOut(9000).next("img").fadeIn(9000, function()

            {

                $(this).fadeOut(6000).next("img").fadeIn(6000, function()

                    {

                        $(this).fadeOut(6000).next("img").fadeIn(6000, function()

	                        {

	                            $(this).fadeOut(6000);

	                            $("#rotateMe").find("img:first").fadeIn(6000, function()

	                                {

	                                    jQuery.GMTDHR.changeEm();

	                                }

	                            );

	                        }

                        );

                    }

                 );

            }

         );

     },

*/

	Compactor : function ( list, link, item ) {

		if ($(list).length > 0 && location.hash) {

			var here = location.hash;

			$(here).parent("div:hidden").prev().click();

			$(here).next(":hidden").slideDown("fast");

		}

		$(list).find(link).addClass("link").hover( function () {

			$(this).addClass(" linkOver");

		}, function () {

			$(this).removeClass("linkOver");

		}).toggle( function () {

			$(this).addClass(" linkOn").next(item+":hidden").slideDown("slow");

		}, function () {

			$(this).removeClass("linkOn").next(item+":visible").slideUp("fast");

		});

	},



	Hijacker : function (menu, hijack, uri) {

		$(menu)

			.find("a:first").addClass("on").end()

			.find("a").click(function(){

				var newurl = uri+$(this).attr("href").split("/")[5];

				$(hijack).find("iframe").attr("src", newurl);

				$(menu).find("a").removeClass("on");

				$(this).addClass("on");

				return false;

		});

	

	}



};

