/*
jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
	random: function(a, i, m, r) {
	if (i == 0) {
		jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
	};
	return i == jQuery.jQueryRandom;
	}
}); 
*/

$(document).ready(function() {
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'dark_rounded'
	});
	
/*
	$(".quotes1:random").show();
	$(".quotes2:random").show();
*/

	$((jQuery(".quotes1").get().sort(function(){ 
	  return Math.round(Math.random())-0.5
	}).slice(0,1))).show();
	
	$((jQuery(".quotes2").get().sort(function(){ 
	  return Math.round(Math.random())-0.5
	}).slice(0,1))).show();

	
	$(".signin").click(function(e) {          
		e.preventDefault();
        $("fieldset#signin_menu").toggle();
		$(".signin").toggleClass("menu-open");
    });
	$("fieldset#signin_menu").mouseup(function() {
		return(false);
	});
	$(document).mouseup(function(e) {
		if($(e.target).parent("a.signin").length==0) {
			$(".signin").removeClass("menu-open");
			$("fieldset#signin_menu").hide();
		}
	});


window.api = $("div.scrollable").scrollable({
	size:1,
	easing: "swing",
	clickable: false,
	speed: 0,
	api:true,
	onStart: function() {
		index = this.getPageIndex();
		links(index);
	}
});

$("div.scrollable-produit").scrollable({
	size:1,
	easing: "swing",
	clickable: false, 
	speed: 600
});

if (window.api) {
	window.api.seekTo(1).setSpeed(600);
}


function links(index) {
	if (index == 0){
		$("div#overview_nav a.right").html("Home");
	}
	else if(index == 1) {
		$("div#overview_nav a.left").html("Seesmic for Android");
		$("div#overview_nav a.right").html("Seesmic For Windows");
	}
	else if(index == 2){
		$("div#overview_nav a.left").html("Home");
	}	
}

});
