var allowSubmit = true;

$(function () {
    $('li').hover(
	function () {
	    $(this).addClass("hover")
	},
	function () {
	    $(this).removeClass("hover")
	});

    $('#form').submit(function () {
        if (!allowSubmit) {
            allowSubmit = true;
            return false;
        }
    });

    $("#searchSubmit").click(function () {
        redirectToSearch();
    });

    $("#searchTerm").keypress(function (e) {
        allowSubmit = true;
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            allowSubmit = false;
            redirectToSearch();
        }
    });

});

/* Init jQuery Fancybox */

jQuery(document).ready(function () {
    try {
        jQuery("a#fancy").fancybox();

        jQuery("a[rel=fancybox]").fancybox({
            'transitionIn': 'none',
            'transitionOut': 'none',
            'titlePosition': 'over',
            'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
                return '<span id="fancybox-title-over">' + imageLabel + ' ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
            }
        });
    } catch (e) { }

window.setInterval(function(){
	jQuery(".btn-next").trigger('click');
}, 7000);
});

//if (document.all && !window.opera) attachEvent("onload", initMenu);

function redirectToSearch() {
    var searchPageUrl = $("#searchPageUrl").val() + "?q=";
    var searchTerm = $("#searchTerm").val();
    var href = searchPageUrl + searchTerm;
    window.location.replace(href);
}
