$(document).ready(function(){
  $('#homepage').parent().parent().css('background', '#fff');
});

$(document).ready(function(){
	$("ul.nav li").click(function() {
		var hrefValue = $(this).children().attr("href");
		$(location).attr('href',hrefValue);
    });		
});


$(document).ready(function(){
  var li = $("#quotes").find('div');
  var maxQuotesHeight = 0;

  li.each(function(){
    var el = $(this);
    var elHeight = el.height();
    if (maxQuotesHeight < elHeight) {
      maxQuotesHeight = elHeight;
    }
  });
  $(".quotes_area").css('height', maxQuotesHeight + 30);
}); 

jQuery.fn.random = function() {
    var randomIndex = Math.floor(Math.random() * this.length);
    if( randomIndex == this.length) {
        randomIndex = this.length - 1;
    }
    return jQuery(this[randomIndex]);
};

$(document).ready(function()
 {
     setupRotator();
 });
 var invalinterval;
 function setupRotator()
 {
     if($('#quotes > .textItem').length > 1)
     {
         textRotate();
         invalinterval = setInterval('textRotate()', 10000);
         $('#nextlink').click(function() {
             textRotate();
             clearInterval(invalinterval);
             invalinterval = setInterval('textRotate()', 10000);
         });
     }
 }

function textRotate()
{
    var currentQoute = $('#quotes:visible > .current');
    if(currentQoute.length != 0) {
        $(currentQoute).removeClass('current').fadeOut(1);
    }
    var randomQuote = $('#quotes:visible > .textItem').random();
    if(randomQuote.length == 0)
    {
        $('#quotes:visible .textItem:first-child').addClass('current').fadeIn(1);
    }
    else
    {
    	$(randomQuote).addClass('current').fadeIn(1);
    }
}

$(document).ready(function(){
	
	$(".thumbs li:first-child").addClass("active");
	$("#largeImg").attr({ src: $(".thumbs li:first-child a").attr("source"), alt: $(".thumbs li:first-child a").attr("title") });
	$("h1 .file_name").html($(".thumbs li:first-child a").attr("title"));
	//$(".all_categories a:first-child").find(".r_item").addClass("active");
	//$("h1 .category_name").html($(".all_categories .r_item:first-child").find("img").attr("title"));
	
	$(".thumbs a").hover(function(){
		
		$(this).parent().parent().find("li").removeClass("active");
		var largePath = $(this).attr("source");
		var largeAlt = $(this).attr("title");
		
		$(this).parent().addClass("active");
		
		$("#largeImg").attr({ src: largePath, alt: largeAlt });
		
		$("h1 .file_name").html(largeAlt); 
		return false;
	});
	
});

 // $(document).ready(function(){

	 // $(".all_categories .r_item").click(function(){
		
		 // $(this).parent().parent().find(".r_item").removeClass("active");
		 // $(this).addClass("active");

		 // var largeAlt = $(this).find("img").attr("title");
		
		 // $("h1 .category_name").html(largeAlt);  
	 // });
// });


$(document).ready(function () {	
	
	$('#nav li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(100);

		}, 
		function () {
			//hide its submenu
			$('ul', this).slideUp(100);			
		}
	);
	
});



