$(document).ready(function(){
    $("h4").before("<hr />");
    $(".loading").fadeTo("slow", 0);
	$(".loading").css({"display" : "none"});
    $(".loggedin .loginlink a").text("Admin");


// randomly display the thumnails on the page

$('.work-container a').each(function(){
$(this).css({ 'top':randomXToY(0,500),
	 'left': randomXToY(0,700),
	 'display' : 'block'
	});
});

// Add fade effects to the thumbnails

$(".work-container a").fadeTo("fast", 0.6); // This sets the opacity of the thumbs to fade down to 60% when the page loads
$(".work-container a").css({zIndex: '1'}); 

/*$(".work-container a").hover(function(){
	$(this).stop().fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
	$(this).css({'zIndex': '10'}); 
},function(){
	$(this).stop().fadeTo("fast", 0.6); // This should set the opacity back to 60% on mouseout
	$(this).css({'zIndex': '1'}); 

}); 
*/

// in case it's useful, my random function is just:
 
function randomXToY(minVal,maxVal,floatVal){
  var randVal = minVal+(Math.random()*(maxVal-minVal));
  return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

// Group THumbnail hovers
function groupHover(selector, selectorthumb) { 
$(selector).hover(
	function(){ 
    $(selectorthumb).find("a").fadeTo("fast", 1.0);
	$(selectorthumb).find("a").css({zIndex: '10'});
	$(this).addClass("work");
	  }, 
      function () {
    $(selectorthumb).find("a").fadeTo("fast", 0.6);
	$(selectorthumb).find("a").css({zIndex: '1'}); 
	$(this).removeClass("work");
	  });
}
groupHover(".commercial-item", ".commercial-thumb");
groupHover(".residential-item", ".residential-thumb");
groupHover(".furniture-item", ".furniture-thumb");



//////////////////////////////////////////////////////////////////////SPLASH HOVERS ALL

function splashHover(selector) { 
$(selector).find("a").css({backgroundPosition: '0 -40px'}); // workaround for FF 2.0 bug 
$(selector).hover(
	function(){ 
     $(this).find("a").stop().animate({backgroundPosition: '(0px 0px)', height:"600px"}, {queue:false, duration:200 } );
	 $(this).animate({ 
			borderTopWidth:"10px",
			marginTop:"0px",
						}, {duration:200 } );

			 }, 
      function () {
      $(this).find("a").stop().animate({backgroundPosition: '(0px -40px)', height:"560px"}, {queue:false, duration:200 } );
	  $(this).animate({ 
			borderTopWidth:"1px",
			marginTop:"25px",
						}, {duration:200 } );
   });
}

splashHover(".home .splash li");

//////////////////////////////////////////////////////////////////////SPLASH HOVERS

function splashHoverSpecific(selector1, pagenum, hex, pagename) { 
$(selector1).hover(
      function () {
		 $(pagenum).find("a").addClass(pagename);
		 $('#navigation, #logo, #footer ul, #footer p').animate( { borderTopColor: hex }, 200);
		 $(pagenum).addClass("current_page_item");


      }, 
      function () {
		 $(pagenum).find("a").removeClass(pagename);
		 $(pagenum).removeClass("current_page_item");

      });

$(pagenum).hover(
	 function () {
		 		  $(this).addClass("current_page_item");
		 $('#navigation, #logo, #footer ul, #footer p').animate( { borderTopColor: hex }, 200);

		   $(selector1).find("a").stop().animate({backgroundPosition: '(0px 0px)', height:"600px"}, {queue:false, duration:200 } );
	   $(selector1).animate({ 
			borderTopWidth:"10px",
			marginTop:"0px",
						}, {duration:200 } );

			 }, 
       function () {
		   		  $(this).removeClass("current_page_item");

		   $(selector1).find("a").stop().animate({backgroundPosition: '(0px -40px)', height:"560px"}, {queue:false, duration:200 } );
	  $(selector1).animate({ 
			borderTopWidth:"1px",
			marginTop:"25px",
						}, {duration:200 } );
   });
}

splashHoverSpecific(".splash li.splash-blog", ".home .page-item-18", "#009d7e", "blog");
splashHoverSpecific(".splash li.splash-firm", ".home .page-item-16", "#019ee1", "firm");
splashHoverSpecific(".splash li.splash-process", ".home .page-item-13", "#e7435b", "process");
splashHoverSpecific(".splash li.splash-work", ".home .page-item-2", "#ef7f01", "work");


//////////////////////////////////////////////////////////////////////SUB CATEGORY

$(".sub-category").css('display','block');
$(".sub-category").fadeOut(0);


$(".category").click(
    function () {
		$(".category-title").removeClass("hovered");
	$(".sub-category").stop().fadeOut(200);
	$(this).find(".category-title").addClass("hovered");
	if ($(this).find(".sub-category").hasClass("default")) {}
	
	else {
		$(".default").fadeOut(100);
		$(this).find(".sub-category").stop().fadeIn(200);
	}
});


if ($("body").hasClass("parent-pageid-322")) {
	
	$(".commercial-item").find(".sub-category").stop().fadeIn(200);
	$(".commercial-item").find(".sub-category").addClass("default");
}
else if ($("body").hasClass("parent-pageid-324")) {
	
	$(".furniture-item").find(".sub-category").stop().fadeIn(200);
	$(".furniture-item").find(".sub-category").addClass("default");
}
else if ($("body").hasClass("parent-pageid-288")) {
	$(".residential-item").find(".sub-category").stop().fadeIn(200);
	$(".residential-item").find(".sub-category").addClass("default");
	 
} 



});
