$(window).ready(function () {
    $('li.color').each(function () {
        var input = $(this).find('input'),
            label = $(this).find('label');

        input.hide();
        label.click(colorHandler(input));
    });

    $('#search-submit').hide();
    $('#search-link').click(function (e) {
        e.preventDefault();
        $('#search-submit').click();
    }).show();

	var min = $('#maincontainer').width(),
		max = 1024,
		minHeight = 800;
	
	$(window).resize( function () {
        var scaleY = $(window).height() / minHeight;
        var scaleX = $(window).width() / max;
        $('#background img').width(Math.ceil(max * Math.max(scaleX, scaleY)));

        /* Center background */
        $('#background img').css('left', ($(window).width() - $('#background img').width()) / 2 + 'px');
    }).resize();
	
	
	$("#eem").click(function(e){
		e.preventDefault();
		if (!$(".eemInput:visible").size()) {
			//$("#eemInput").css('display','block');
			$(".eemInput").slideDown("fast");
		} else {
			//$(".eemInput").css('display','none');
			$(".eemInput").slideUp("fast");
		}
		return false;
	});
});

function colorHandler (input) {
    return function (e) {
        e.preventDefault();
        input.click();
        $(this).toggleClass('active');
    };
}


