var alertTimerId = 0;
var featureNum = 2;

//Control code for the thumbnail pop-up feature.  Any image ending in imgSmallFlag
//should pop up an image of the same name but ending in the imgLargeFlag.  Currently
//this only works for images in the root folder.
$(function(){
	$("img[src*='_S.jpg']").thumbPopup({
		imgSmallFlag: "_S",
		imgLargeFlag: "_L"
	});
});

$(document).ready(  function()
                    {
                        $("#navigation a").hover(function()
                                                          {
                                                              $("div.feature").fadeOut();
                                                              $("div."+$(this).get(0).name).fadeIn();

                                                              $(".select_feature").removeClass("current");
                                                              $(document.getElementById("id_"+$(this).get(0).name)).parents("first").addClass("current");
                                                              $(document.getElementById("id_"+$(this).get(0).name)).parents("div:first").addClass("current");

                                                          },
                                                          function()
                                                          {
                                                              // go get some pizza ;)
                                                          });

                        $(".select_feature a").hover(function()
                                                          {
                                                              $("div.feature").fadeOut();
                                                              $("div."+$(this).get(0).name).fadeIn();

                                                              $(".select_feature").removeClass("current");
                                                              $(this).parents("first").addClass("current");
                                                              $(this).parents("div:first").addClass("current");

                                                          },
                                                          function()
                                                          {
                                                              // go get some pizza ;)
                                                          });
                        $(".index_box_b a").hover(function()
                                                          {
                                                              $("div.feature").fadeOut();
                                                              $("div."+$(this).get(0).name).fadeIn();

                                                              $(".select_feature").removeClass("current");
                                                              $(document.getElementById("id_"+$(this).get(0).name)).parents("first").addClass("current");
                                                              $(document.getElementById("id_"+$(this).get(0).name)).parents("div:first").addClass("current");

                                                          },
                                                          function()
                                                          {
                                                              // go get some pizza ;)
                                                          });

                        var needTimer = $("#features").size();

                        if(needTimer > 0)
                        {
                            alertTimerId = setTimeout("nextFeature.show(featureNum)", 10000);

                            $("#features").hover(           function()
                                                            {
                                                                clearTimeout ( alertTimerId );
                                                            },
                                                            function()
                                                            {
                                                                alertTimerId = setTimeout("nextFeature.show(featureNum)", 20000);
                                                            });

                            $(".select_feature").hover(function()
                                                            {
                                                                clearTimeout ( alertTimerId );
                                                            },
                                                            function()
                                                            {
                                                                alertTimerId = setTimeout("nextFeature.show(featureNum)", 20000);
                                                            });
                                                            
                            $(".index_box_b").hover(function()
                                                            {
                                                                clearTimeout ( alertTimerId );
                                                            },
                                                            function()
                                                            {
                                                                alertTimerId = setTimeout("nextFeature.show(featureNum)", 20000);
                                                            });
                        }

                    });

nextFeature = {
	show : function(number) {
		$("div.feature").fadeOut();
		$("div.feature-"+number).fadeIn();

		$(".select_feature").removeClass("current");
		$(".select_feature:eq("+(number-1)+")").addClass("current");


		if(featureNum < 8)
			featureNum++;
		else
			featureNum = 1;

		alertTimerId = setTimeout("nextFeature.show(featureNum)", 10000);
	}
}

function changeToRed(element)
{
    document.getElementById("id_index_a"+element).className = "hover";
}

function changeToBlack(element)
{
    document.getElementById("id_index_a"+element).className = "normal";
}


