$(document).ready(function() {
	// Vartical centrin main menu
	var aaa = 0;
	$('ul.main-nav li').each(function() {
		aaa += $(this).outerWidth();
	});
xxx = $('ul.main-nav li').length;
zzz = ((((762-aaa)/xxx))/ 2);

	$('ul.main-nav li span').each(function() {
		var p = ((82 - $(this).height()) / 2)+15;
		//alert ($(this).height());
		$(this).parent().css('height', 92 - p + 'px');
		$(this).parent().css('padding-top', p + 'px');
	});
	
//	$('ul.main-nav li a').each(function() {
//		$(this).css('padding-left', zzz + 'px');
//		$(this).css('padding-right', zzz + 'px');
//	});

	// Left menu
	$('.leftmenu ul').css('display', 'none');
	$('.leftmenu .current').parent().css('display', 'block');

});


	$('#language').click(function() {
		if ($('#languageSelect').css('display')	== "none") {
			$('#languageSelect').slideDown('slow');
		} else {
			$('#languageSelect').slideUp('slow');	
		}
		return false;
	});


$('.lightcell td').hover(
	function () {
		$(this).css('background','#F2F2F3');
	}, 
	function () {
		$(this).css('background','none');
	}
);



// LavaLamp
$(function() { $(".lavaLamp").lavaLamp({ fx: "backout", speed: 700 })});




// Showing different tabs and their content on click.
$('.tabs h2').click(function() {	
	var tabNo = 0;
	var thisHdr = this;
	$('.tabs h2').each(function() {
		$('#tab' + tabNo).css('display', 'none');
		$(this).removeClass("selected");
		if ($(thisHdr).hasClass('header-tab' + tabNo)) {
			$('#tab' + tabNo).css('display', 'block');
			$(thisHdr).addClass('selected');
		}
		tabNo++;
	});
});

$('.lavaLamp li a').click(function() {
    var href = $(this).attr('href').substr(1);
    var tabContent = $(this).parent().parent().parent();
    
    $('.lavaLamp-module', tabContent).each(function() {    
            if ($(this).css('display') == 'block') {
                $(this).hide();
                $('#' + href).show();    
            }
    });
    return false;
});

/* Permalink */
$('.tab-content a.link').each(function(){
	if ($(this).parent().parent().attr('id')){
		$(this).parent().attr('id');
		link = '?tab='+$(this).parent().parent().attr('id').substr(3,1)+'&slider='+$(this).parent().attr('id');
		$(this).attr('href',link);
	}
	else{
		link = '?tab='+$(this).parent().attr('id').substr(3,1)
		$(this).attr('href',link);
	}
});

/**
 * Currys a function and arguments. Takes a function as the first argument,
 * and returns a zero-arugument function that calls the provided function
 * with the provided arguments.
 */
function curryFunction() {
	var f = arguments[0];
	var args = [];
	for (i = 1; i < arguments.length; i++) {
		args[i-1] = arguments[i];
	}
	return function() {
		return f.apply(this, args);
	}
}

/* block optimize
$(document).ready(function() {
    $('#why').html( $('#optimize').html() );
    $('#optimize').remove();
    $('#foru').html( $('#optimize2').html() );
    $('#optimize2').remove();
});
*/

