/**
 * @author Osvaldo Gonzalez
 */
//<![CDATA[
$(init);

function init() {
	$(slider);
	$(quotes);
}

function quotes() {
	$(quotevar);
	$(firstrun);
}

function quotevar() {
	window.quoteA = "";
	window.quoteB = "";
	window.index = 0
	window.number = 0
}

function fader() {
	$("#quote-box").delay(11000).fadeOut(1000, quoteswitch);
	$("#quote-box").fadeIn(1000, fader);
}

function quoteswitch () {
	$(random); // Either enable this function to randomize the quote, or...
//	$(quoteloop); //enable this one to advance it in a loop. Don't enable both, though.
	$("#quote").html("&ldquo;" + quoteA + "&rdquo;");
	$("#quotee").html("&#45;" + quoteB);
}

function firstrun() {
	var number = Math.ceil(Math.random() * 10);
		index = number;
		$(keyref);
		if (window.console) {
		console.log("First quote, #" + index);
		}
		$("#quote").html("&ldquo;" + quoteA + "&rdquo;");
		$("#quotee").html("&#45;" + quoteB);
		$(fader);
}

function random() {
	var number = Math.ceil(Math.random() * 10);
	if ( index == number ) {
		$(random);
	} else {
		index = number;
		$(keyref);
		if (window.console) {
		console.log("next random quote, #" + index);
		}
	}

}

function quoteloop() {
	if ( index < 11) {
		index = index +1;
		$(keyref);	
	} else{
		index = 1;
		$(keyref);
	}
	if (window.console) {
	console.log("next quote in sequence, #" + index);
	}
	
}
/////
/////
function keyref() {
	quoteA = quotable[index].quote;
	quoteB = quotable[index].quotee;
}


var quotable = {

1 :

{
quote : "If you throw a rock into a pack of dogs, chances are that the one that yelped is the one you hit",
quotee : "Arthur Donner"
},

2 :

{
quote : "Many people would rather die than think! In fact, they do!",
quotee : "Bertrand Russell"
},
 
3 :

{
quote : "I don&rsquo;t deny the Truth just because it doesn’t cheer me up!",
quotee : "Christopher Hitchens"
},
 
4 :

{
quote : "What can be asserted without proof can be dismissed without proof!",
quotee : "Christopher Hitchens"
},
 

5 :

{
quote : "The music business is a cruel and shallow money trench, a long plastic hallway where thieves and pimps run free and good men die like dogs! There&rsquo;s also a negative side!",
quotee : "Hunter S. Thompson"
},


6 :

{
quote : "I don&rsquo;t know anything about music. In my line you don&rsquo;t have to.",
quotee : "Elvis Presley"
},

 
7 :

{
quote : "I don&rsquo;t have pet peeves! I have major psychotic fucking hatreds!",
quotee : "George Carlin"
},


8 :

{
quote : "Even if you are a minority of one, the truth is the truth!",
quotee : "Gandhi"
},


9 :

{
quote : "Anything that is too stupid to be spoken is sung!",
quotee : "Voltaire "
},

10 :

{
quote : "Hell is full of musical amateurs",
quotee : "George Bernard Shaw"
},

11 :

{
quote : "If you tell people the truth, you better make them laugh or they will kill you",
quotee : "Oscar Wilde"
}
};


function slider() {
	$("li#slide-3").css("z-index", "2");
	$("li#slide-2").toggle().css("z-index", "0");
	$("li#slide-1").toggle().css("z-index", "0");
	$("li#slide-4").css("z-index", "1");
	$(slideA);
}

function slideA() {
	$("li#slide-3").css("z-index", "1");
	$("li#slide-2").css("z-index", "2");
	$("li#slide-4").toggle().css("z-index", "0");
	$("li#slide-2").delay(7000).show("slide", {
		direction: "right"
	}, 423, slideB);
}

function slideB() {
	$("li#slide-2").css("z-index", "1");
	$("li#slide-1").css("z-index", "2");
	$("li#slide-3").toggle().css("z-index", "0");
	$("li#slide-1").delay(7000).show("slide", {
		direction: "right"
	}, 423, slideC);
}

function slideC() {
	$("li#slide-1").css("z-index", "1");
	$("li#slide-4").css("z-index", "2");
	$("li#slide-2").toggle().css("z-index", "0");
	$("li#slide-4").delay(7000).show("slide", {
		direction: "right"
	}, 423, slideD);
}

function slideD() {
	$("li#slide-4").css("z-index", "1");
	$("li#slide-3").css("z-index", "2");
	$("li#slide-1").toggle().css("z-index", "0");
	$("li#slide-3").delay(7000).show("slide", {
		direction: "right"
	}, 423, slideA);
}

//]]>t
