$(document).ready(function() {

if ($.browser.msie) {
   // alert("this is ie!");
}
else {
    // Check for hash value in URL
    var hash = window.location.hash.substr(1);
    var href = $('.header li a').each(function(){
        var href = $(this).attr('href');
        if(hash==href.substr(0,href.length-5)){
            var toLoad = hash+'.html .content';
            $('#content').load(toLoad)
        }
    });

    $('.header li a').click(function(){

    var toLoad = $(this).attr('href')+' .content';
    $('.content').hide('highlight', 1000, loadContent);
    $('.container_12').append('<span id="load">LOADING...</span>');

    window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);

    function loadContent() {
    	$('#content').load(toLoad,'drop',showNewContent())
    }
    function showNewContent() {
    	$('#content').show('drop', { direction: "down" }, 1500, hideLoader());
    }
    function hideLoader() {
    	$('#load').fadeOut('normal');
    }
    return false;
    });
    
}   



});

function slideSwitch() {
    var $active = $('#catalog img.active');

    if ( $active.length == 0 ) $active = $('#catalog img:last');

    var $next =  $active.next().length ? $active.next()
        : $('#catalog img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});


// increase the default animation speed to exaggerate the effect
$.fx.speeds._default = 1000;
$(function() {
	$( "#dialog" ).dialog({
		autoOpen: false,
		show: "fadeIn",
		modal: true,
		width: 700,
		height: 525
	});

	$( "img.screenshot" ).live("click",function() {
		$( "#dialog" ).dialog( "open" );
		return false;
	});
}); 
