// JavaScript Document

$(function() {

	// set proper height of cell_content in IE browser
	if($.browser.msie){
		var h = $(window).height() - 196 - 115; //this is only important in high resoultions
		
		$('#cell_content').css("height", h);
	}
	
	//enable spotlight
	$('#spotlight_holder').spotlight({
		displayTime:5
	});
	
	$("#tab_navigation > li > a").click(function(event){
												 // select currently active tab and deactivate it
												 $("#tab_navigation > li.active").removeClass("active");
												 
												 // add .active class to the selected tab
												 $(this).parent().addClass("active");
												 
												 // get the #id of the tab to show
												 var href = $(this).attr("href");
												 
												 //it works only if the tab is visible and it's not the currently selected tab (in case the user selects already visible tab
												 $("#tabs_container > .tab:visible:not(" + href + ")").slideUp("normal", function(){
																																// show the selected tab
																											  					$("#tabs_container > " + href).slideDown("normal");
																											 					});
												 
												 //do not navigate to url + href...
												 event.preventDefault();
												 });


});


function initPage(index){
	var idx = 0;
	if (index) {
	    idx = index;

	    $('#mainMenu').lavaLamp({
	        fx: 'swing',
	        speed: 333,
	        returnHome: true,
	        startItem: idx
	    });
	}
	else {
	    $('#mainMenu').lavaLamp({
	        fx: 'swing',
	        speed: 333,
	        returnHome: true
	    });
	}
}

function startQuotes() {
    $('#quote_spotlight').spotlight({
        displayTime: 6
    });
}

function initSearch(search_id) {
    // set the deafult search box text
    var searchBoxDefault = 'SEARCH';
    $('#' + search_id).attr('value', searchBoxDefault);

    // when search textbox gets focus
    $('#' + search_id).focus(function() {
        if ($(this).attr('value') == searchBoxDefault)
            $(this).attr('value', '')
    });

    // when search textbox loses focus
    $('#' + search_id).blur(function() {
        if ($(this).attr('value') == '')
            $(this).attr('value', searchBoxDefault)
    });
}
