window.count = 592;

function slideshow()
{
	//alert(window.count);
	if (window.count == -1184) { window.count = 592 }
	window.count-=592;
	$('#slideshow_content').animate({'margin-left' : window.count + 'px'});
	$('#slideshow_index a').removeClass('active');
	$('#' + window.count).addClass('active');
	window.t = setTimeout("slideshow()", 5000);
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if( $active.length == 0 ) $active = $('#slideshow IMG:last');
    if ($('#slideshow img').length <= 1) {
      clearInterval(intvl);
      return;
    }

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );

    $active.addClass('last-active');

    $next.css({opacity: 0})
        .addClass('active')
        .animate({opacity: 1}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function mainmenu(){
	$("#navigation ul").css({display:"none"});
	$("#navigation li").hoverIntent(makeTall,makeShort);
}

function makeTall(){$(this).find('ul:first').fadeIn('fast');}
function makeShort(){$(this).find('ul:first').fadeOut('fast');}

/* FIRE UP ALL FUNCTIONS WHEN PAGE LOAD COMPLETES */
var intvl;
$(document).ready(function(){	
	intvl=setInterval( "slideSwitch()", 5000 );
	mainmenu();
	hscroll.init();
	$('#twitter').click( function() {
		window.open('http://twitter.com/OtoKiwiHouse');
	});
});
