$(function() {

	// Disable scroll
	
	$('body').css({'overflow-y':'visible'});

    var switchy = 'true';
    var viewType = $.cookie('viewType');
    
    function ignite() {
	
		if (viewType == 'off') {
			
			// Hide Imgs
			$('.imgr img').fadeTo(0, 1);
    		
    	} else {
			
			// Hide Imgs
			$('.imgr img').fadeTo(0, 0);
    		
    	}
    	
    }

    // Image Load
	$('.imgr img').load(function(){ 
	    if (viewType == 'off') {
	    	$(this).fadeTo(0, 1);
	    } else {
	    	$(this).fadeTo(0, 1).fadeTo(200, 0.99).fadeTo(200, 0);
	    }
	    
	});
	
	// Hover Function
	$('.imgr img').hover(function(event) {
		if (viewType == 'off') {
	    	//$(this).fadeTo(0, 1);
	    } else {
	    	$(this).fadeTo(0, 1);
	    }
        
    }, function(event) {
    	if (viewType == 'off') {
        	//$(this).fadeTo(400, 0);
        } else {
        	$(this).fadeTo(400, 0);
        }
        
    });
    
    // Visual Preview
	$('#switch').click(function(event) {

		if (switchy == 'true') {
			$("#switch").html("On");
			$.cookie('viewType', 'off', {path: "/"}, {expires: 21});
			viewType = 'off';
			switchy = 'false';
			ignite();
		} else {
			$("#switch").html("Off");
			$.cookie('viewType', 'on', {path: "/"}, {expires: 21});
			viewType = 'on';
			switchy = 'true';
			ignite();
		}
		
    });
    
    if (viewType == 'off') {
    	$("#switch").html("On");
		switchy = 'false';
		ignite();
    } else {
    	$("#switch").html("Off");
		switchy = 'true';
		ignite();
    }
	
	return false;

	
});
