// HOVER SCRIPTS
        
// Start jQuery

$(document).ready(function() {
	

/* Work Image - Hover qualities ***********************************************/
    
    $("div.casestudy:nth-child(1)").addClass("top");
    $("div.casestudy:nth-child(2)").addClass("top");
    $("div.casestudy:nth-child(3)").addClass("top");
    $("div.casestudy:nth-child(4)").addClass("top");
    
    $("div.casestudy img.hovered").hide();
    $("div.casestudy").hover(function() {
        $(this).find('img').fadeIn(300);
    }, function() {
        $(this).find('img.hovered').fadeOut(300);
    });
	
	
	// Social Images HOVER EFFECT
	
	$("div.socialIcons a").css({ opacity: 0.4 });
	$("div.socialIcons a").hover(function(){
    $(this).stop().animate({"opacity": 1},800);
},function(){
    $(this).stop().animate({"opacity": 0.4},800);
});

	// Copyright HOVER

	$("#copyright").css({ opacity: 0.4 });
	$("#copyright").hover(function(){
    $(this).stop().animate({"opacity": 1},400);
},function(){
    $(this).stop().animate({"opacity": 0.4},800);
});


	// Menu HOVER
$("#example-one li a").hover(function() {
$(this).animate({ color: "#FFF" }, 400);
},function() {
$(this).animate({color: "#888" }, 400);
});

	//Flickr badge HOVER

$(".flickr_badge_image img").animate({ opacity: 0.6 }, 400)
$(".flickr_badge_image img").hover(function() {
$(this).animate({ opacity: 1 }, 400);
},function() {
$(this).animate({opacity: 0.6 }, 400);
});


	//Submit HOVER
	$(document).ready(function(){
  $('p.button a')
    .css({  'backgroundPosition': '0 0' })
    .hover(
      function(){
        $(this)
          .stop()
          .animate({
            'opacity': 0
          }, 300);
      },
      function(){
        $(this)
          .stop()
          .animate({
            'opacity': 1
          }, 300);
      }
    );
	
});


$(document).ready(function(){
  $('p.buyButton a')
    .css({  'backgroundPosition': '0 0' })
    .hover(
      function(){
        $(this)
          .stop()
          .animate({
            'opacity': 0
          }, 300);
      },
      function(){
        $(this)
          .stop()
          .animate({
            'opacity': 1
          }, 300);
      }
    );
	
});

	//menu dropdown
var timeout         = 650;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $("#blab").find('ul').eq(0).css('visibility', 'visible');
}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{	$('#blab').bind('mouseover', jsddm_open);
	$('#blab').bind('mouseout',  jsddm_timer);});

document.onclick = jsddm_close;




function khm_open()
{	khm_canceltimer();
	khm_close();
	ddmenuitem = $("#blub").find('ul').eq(0).css('visibility', 'visible');
}

function khm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function khm_timer()
{	closetimer = window.setTimeout(khm_close, timeout);}

function khm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function()
{	$('#blub').bind('mouseover', khm_open);
	$('#blub').bind('mouseout',  khm_timer);});

document.onclick = khm_close;




	//Pagination HOVER 
	
	$(".pagination .normal").hover(function() {	
	$(this).animate({ backgroundColor: "#FF2716" }, 250);
	},function() {
	$(this).animate({ backgroundColor: "#3E3E3E" }, 250);
});



	//Breadcrumb HOVER

	$("#breadcrumb img").animate({ opacity: 0.5 }, 400)
	$("#breadcrumb img").hover(function() {
	$(this).animate({ opacity: 1 }, 400);
	},function() {
	$(this).animate({opacity: 0.5 }, 400);
	});
	
	$("#breadcrumb a").hover(function() {
	$(this).animate({ color: "#FFF" }, 400);
	},function() {
	$(this).animate({color: "#888" }, 400);
	});
	
	
	//Sort by dropdown
	
	        $(document).ready(function() {

            $(".dropdown dt a").click(function() {
                $(".dropdown dd ul").toggle();
            });
                        
            $(".dropdown dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown dt a span").html(text);
                $(".dropdown dd ul").hide();
              //  $("#result").html("Selected value is: " + getSelectedValue("sample")); returns value
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

            $(document).bind('click', function(e) {
                var $clicked = $(e.target);
                if (! $clicked.parents().hasClass("dropdown"))
                    $(".dropdown dd ul").hide();
            });


        });
		
		$(".dropdown dt a").hover(function() {	
	$(this).animate({ backgroundColor: "#FF2716" }, 400);
	},function() {
	$(this).animate({ backgroundColor: "#3E3E3E" }, 400);
	
	

});
});

// Sliding Panel
$(document).ready(function() {
	
	// Expand Panel
	$("#open").click(function(){
		$("div#panel").slideDown("slow");
	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});	
	
		
	$(".tab a").hover(function() {
	$(this).animate({ color: "#FFF" }, 150);
	},function() {
	$(this).animate({color: "#666" }, 250);
	});
	
	//input hovers
		
	$(".ctnt input").hover(function() {
	$(this).animate({ color: "#F6F6F6"}, 250);
	},function() {
	$(this).animate({color: "#666" }, 250);
	});	
	
	$(".postCommentForm input").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#666" }, 250);
	});
	
	$(".downloadThis input").hover(function() {
	$(this).animate({ color: "#000" }, 250);
	},function() {
	$(this).animate({color: "#666" }, 250);
	});	
	
	$("input[type=button]").hover(function() {
	$(this).animate({ color: "#000" }, 250);
	},function() {
	$(this).animate({color: "#666" }, 250);
	});
	
	$("#submit").hover(function() {
	$(this).animate({ color: "#000" }, 250);
	},function() {
	$(this).animate({color: "#666" }, 250);
	});		
	
	$(".postCommentForm textarea").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#666" }, 250);
	});
	
	
	//Recent Projects Hover

	$(".recentImg").animate({ opacity: 0.6 }, 400)
	$(".recentImg").hover(function() {
	$(this).animate({ opacity: 1 }, 400);
	},function() {
	$(this).animate({opacity: 0.6 }, 400);
	});
	
	
	//li hover functions
	$(".listStyleGlobal li").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#888" }, 250);
	});
	
	$(".global li").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#CCC" }, 250);
	});
	
	$(".listStyleArrow li").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#CCC" }, 250);
	});
	
	$(".listStyleOrangeOk li").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#CCC" }, 250);
	});
	
	$(".listStyleCross li").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#CCC" }, 250);
	});
	
	$(".listStyleYes li").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#CCC" }, 250);
	});
	
	//faq sliding panel
	$(document).ready(function() {
  		$('#faqs li').each(function() {
    	var tis = $(this), state = false, answer = tis.next('div').hide().css('height','auto').slideUp();
    	tis.click(function() {
      	state = !state;
      	answer.slideToggle(state);
      	tis.toggleClass('active',state);
    	});
  	});
});

	//table tr hover
	$(".tableStyleLight tr").hover(function() {
	$(this).animate({ color: "#000" }, 250);
	},function() {
	$(this).animate({color: "#666" }, 250);
	});
	
	$(".tableStyleDark tr").hover(function() {
	$(this).animate({ color: "#FFF" }, 250);
	},function() {
	$(this).animate({color: "#F3F3F3" }, 250);
	});
	
	
	// hide text boxes on click^
	$('div.information').click(function() { 
	$(this).animate({ opacity:0}, 600);
	});
	
	$('div.success').click(function() { 
	$(this).animate({ opacity:0}, 600);
	});
	
	$('div.warning').click(function() { 
	$(this).animate({ opacity:0}, 600);
	});
	
	$('div.error').click(function() { 
	$(this).animate({ opacity:0}, 600);
	});
	
	//blog effects
	$(".continueReading").hover(function() {
	$(this).animate({ backgroundColor: "#FF2716", color:"#FFF" }, 250);
	},function() {
	$(this).animate({backgroundColor: "#333", color: "#CCC" }, 250);
	});
	
	$(".replyBtn").hover(function() {
	$(this).animate({ backgroundColor: "#FF2716", color:"#FFF" }, 250);
	},function() {
	$(this).animate({backgroundColor: "#333", color: "#CCC" }, 250);
	});
	

});



