var revide = revide || {};

revide = {
    init: function() {
		$("#tabs").tabs();
		
		$("#marquee").marquee("pointer").mouseover(function () {
		  $(this).trigger("stop");
		}).mouseout(function () {
		  $(this).trigger("start");
		});
	
        revide.hoverBox.init();
	revide.hoverBoxTeasers.init();
		
    },

    hoverBox: {
        init: function() {
            revide.hoverBox.buildhoverBox();
            $("a.hoverBoxClass").bind("mouseenter", function() {
                oImg = $(this).children("img");
                revide.hoverBox.imageHover(oImg, true);
                revide.hoverBox.show(oImg);
            }).bind("mouseleave", function() {
                oImg = $(this).children("img");
                revide.hoverBox.hide();
                revide.hoverBox.imageHover(oImg, false);
            });
        },

        buildhoverBox: function() {
            $('<div id="hoverBox"><div id="hoverBoxTop">&nbsp;</div><div id="hoverBoxMiddle"></div><div id="hoverBoxBottom">&nbsp;</div></div>').appendTo('body');
        },

        show: function(oImg) {
            ohoverBox = $("div#hoverBox");
            $("div#hoverBoxMiddle").html("<strong>" + oImg.attr("id") + "</strong> - " + oImg.attr("alt"));
            offset = oImg.offset();
            width = oImg.width();
            hoverBoxHeight = ohoverBox.height();
            ohoverBox.css({ left: ((offset.left + (width / 2)) - 131), top: (offset.top - (hoverBoxHeight - 15)) });
            ohoverBox.show();
        },

        hide: function() {
            ohoverBox.hide();
        },

        imageHover: function(oImg, state) {
            image = oImg.attr("src");
            if (!state) {
                var strExt = image.match(".gif");
                imageSrc = image.split(strExt);
                oImg.attr("src", imageSrc[0] + '' + strExt);
            } else {
                imageSrc = image.split('.');
                oImg.attr("src", imageSrc[0] + '.' + imageSrc[1]);
            }
        }
    },

	hoverBoxTeasers: {
        init: function() {
            //revide.hoverBoxTeasers.buildhoverBox();
            $("a.hoverBoxTeaserClass").bind("mouseenter", function() {
                oImg = $(this).children("img");
				oRoot = $(this);
                revide.hoverBoxTeasers.imageHover(oImg, true);
                //revide.hoverBoxTeasers.show(oImg, oRoot);
            }).bind("mouseleave", function() {
                oImg = $(this).children("img");
                //revide.hoverBoxTeasers.hide();
                revide.hoverBoxTeasers.imageHover(oImg, false);
            });
        },

    imageHover: function(oImg, state) {
            image = oImg.attr("src");
            if (!state) {
                var strExt = image.match(".gif");
                imageSrc = image.split(strExt);
                oImg.attr("src", imageSrc[0] + '_hover' + strExt);
            } else {
                imageSrc = image.split('_hover.');
                oImg.attr("src", imageSrc[0] + '.' + imageSrc[1]);
            }
        }
    }
}

// Start it!
$(document).ready(function(){
						   /*
   $("#accordion").accordion({
	change: function(event, ui) { 
	   $(".contactItem").hide();
	   $(".contactPersonItem").hide();
	   $(".contactFormIntroduction").hide();	
       $("#id_" + ui.newHeader.attr("id")).show();
	   $("#idFormIntroduction_" + ui.newHeader.attr("id")).show();
	   $("#id_" + ui.newHeader.attr("subid")).show();
	   $("#yourEmailId").val(ui.newHeader.attr("subid")); 
	}});

    $("a.contactPersonLink").bind("click", function() {
	    $(".contactPersonItem").hide();
        $("#id_" + $(this).attr("id")).show();
		$("#yourEmailId").val($(this).attr("id"));
	    return false;
    })
	   */
	$("a.FAQCategoryLink").bind("click", function() {
		$(".FAQAnswer").hide();
		$(".FAQCategoryLink").removeClass("selected");
	    $(".FAQQuestionLinkWrapper").hide();
        $("#id_" + $(this).attr("id")).show();

		$(this).addClass("selected");
		
		
	    $("#idAnswer_" + $(this).attr("id")).show();	
	    return false;
    })
	
	$("a.FAQQuestionLink").bind("click", function() {
	    $(".FAQAnswer").hide();
        $("#idAnswer_" + $(this).attr("id")).show();
	    return false;
    })
   
    revide.init();
})
