$(document).ready(function() {

	$('#darkBkd').hide();
	$('#options').hide();

	
	$("#thumb0").click(function() {
		$('#largeFormat #picture0').fadeIn("slow");
		return false;
    });

	$("#thumb1").click(function() {
		$('#largeFormat #picture0').fadeOut("slow");
		$('#largeFormat #picture1').fadeIn("slow");
		return false;
    });

	$("#thumb2").click(function() {
		$('#largeFormat #picture0').fadeOut("slow");
		$('#largeFormat #picture1').fadeOut("slow");
		$('#largeFormat #picture2').fadeIn("slow");
		return false;
    });

    $("#thumb3").click(function() {
        $('#largeFormat #picture0').fadeOut("slow");
        $('#largeFormat #picture1').fadeOut("slow");
        $('#largeFormat #picture2').fadeOut("slow");
        $('#largeFormat #picture3').fadeIn("slow");
        $('#largeFormat #picture4').fadeOut("slow");
        $('#largeFormat #picture5').fadeOut("slow");
        $('#largeFormat #picture6').fadeOut("slow");
        $('#largeFormat #picture7').fadeOut("slow");
        $('#largeFormat #picture8').fadeOut("slow");
        return false;
    });
    
    $("#thumb4").click(function() {
        $('#largeFormat #picture0').fadeOut("slow");
        $('#largeFormat #picture1').fadeOut("slow");
        $('#largeFormat #picture2').fadeOut("slow");
        $('#largeFormat #picture3').fadeOut("slow");
        $('#largeFormat #picture4').fadeIn("slow"); 
        $('#largeFormat #picture5').fadeOut("slow");
        $('#largeFormat #picture6').fadeOut("slow");
        $('#largeFormat #picture7').fadeOut("slow");
        $('#largeFormat #picture8').fadeOut("slow");
        return false;
    });

    $("#thumb5").click(function() {
        $('#largeFormat #picture0').fadeOut("slow");
        $('#largeFormat #picture1').fadeOut("slow");
        $('#largeFormat #picture2').fadeOut("slow");
        $('#largeFormat #picture3').fadeOut("slow");
        $('#largeFormat #picture4').fadeOut("slow");
        $('#largeFormat #picture5').fadeIn("slow"); 
        $('#largeFormat #picture6').fadeOut("slow");
        $('#largeFormat #picture7').fadeOut("slow");
        $('#largeFormat #picture8').fadeOut("slow");    
        return false;
    });
    
    $("#thumb6").click(function() {
        $('#largeFormat #picture0').fadeOut("slow");
        $('#largeFormat #picture1').fadeOut("slow");
        $('#largeFormat #picture2').fadeOut("slow");
        $('#largeFormat #picture3').fadeOut("slow");
        $('#largeFormat #picture4').fadeOut("slow");
        $('#largeFormat #picture5').fadeOut("slow");
        $('#largeFormat #picture6').fadeIn("slow"); 
        $('#largeFormat #picture7').fadeOut("slow");
        $('#largeFormat #picture8').fadeOut("slow");
        return false;
    });
    
    $("#thumb7").click(function() {
        $('#largeFormat #picture0').fadeOut("slow");
        $('#largeFormat #picture1').fadeOut("slow");
        $('#largeFormat #picture2').fadeOut("slow");
        $('#largeFormat #picture3').fadeOut("slow");
        $('#largeFormat #picture4').fadeOut("slow");
        $('#largeFormat #picture5').fadeOut("slow");
        $('#largeFormat #picture6').fadeOut("slow");
        $('#largeFormat #picture7').fadeIn("slow");
        return false;
    });
    $("#thumb8").click(function() {
        $('#largeFormat #picture0').fadeOut("slow");
        $('#largeFormat #picture1').fadeOut("slow");
        $('#largeFormat #picture2').fadeOut("slow");
        $('#largeFormat #picture3').fadeOut("slow");
        $('#largeFormat #picture4').fadeOut("slow");
        $('#largeFormat #picture5').fadeOut("slow");
        $('#largeFormat #picture6').fadeOut("slow");
        $('#largeFormat #picture7').fadeOut("slow");
        $('#largeFormat #picture8').fadeIn("slow");
        return false;
    });
    
	$(".pleaseSelect").click(function() {
		$('#darkBkd').show();
		$('#options').fadeIn("slow");
		return false;
    });

	$("#options a").click(function() {
		$('#darkBkd').fadeOut("slow");
		$('#options').fadeOut("slow");
		return false;
    });

});

// Miguel: public function to close the modal window from anywhere
function CloseModalOptionImages()
{
	$('#darkBkd').fadeOut("fast");
	$('#options').fadeOut("fast");		
}


function SubmitRangeShoppingForm(price_min, price_max)
{
	ni = document.getElementById("shopRangePmin"); 	
	ni.setAttribute('value', price_min);	

	ni = document.getElementById("shopRangePmax"); 	
	ni.setAttribute('value', price_max);	

	document.rangeShoppingForm.submit();
}