//Tabs/////////////////////////////

$(document).ready(function(){
    $(".tabs").tabs();
  });
  
 $(document).ready(function(){
 	$(".tabs-rotate").tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 5000);
 	$('.tabs-rotate').hover(function(){
 			$(this).tabs('rotate', 0, false);
 		},function(){
 			$(this).tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 5000);
 		}
 	);
 });
 
 
//Slider///////////////////////////////

$(document).ready(function(){	
	$(".slider").easySlider({
		auto: true,
		continuous: true, 
		speed: 900,
		pause: 5000
	});
});
 

jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

$(document).ready(function() {
    $('.subscribebox').hide();
    $('a.subscribe-action').click(function() {
    $(".subscribebox").fadeToggle('fast');
  });
});

jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

$(document).ready(function() {
    $('.twitterbox').hide();
    $('footer a.twitter, .twitterbox a.close').click(function() {
    $(".twitterbox").fadeToggle('fast');
  });
});

jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

$(document).ready(function() {
    $('.linkedinbox').hide();
    $('footer a.linkedin, .linkedinbox a.close').click(function() {
    $(".linkedinbox").fadeToggle('fast');
  });
});

jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

$(document).ready(function() {
    $('.emailbox').hide();
    $('footer a.email, .emailbox a.close').click(function() {
    $(".emailbox").fadeToggle('fast');
  });
});

jQuery.fn.fadeToggle = function(speed, easing, callback) {
  return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};
 
$(document).ready(function() {
	$('#tellfriend').hide();
  	$('li.tellfriend a, #tellfriend a.close').click(function() {
    $("#tellfriend").fadeToggle('slow');
  });
  
}); 


//Expanding Nav/////////////////////////////

$(document).ready(function() { 
	
	$('#sidebar ul.generic li.show').click(function() {
	      $(this).toggleClass('hide')
	});	   
	 // add a class of hidden to any ul's that are the child of an li. As we set any elements with a class of hidden to have the property display: none, this will now hide these nested ul's when the page loads
	$('#sidebar ul.generic > li > ul').addClass("hidethis");

	 // select any a tags that are children of a ul that contains an li that has both ul and li children. Apply a function to the selected elements that will fire when it is clicked
	$('#sidebar ul.generic li:has(ul li)').children('a').click(function() {
												  
// toggle the class "hidden" on the child ul of the li containing the a tag that has been clicked										 
		$(this).parent().children('ul').toggleClass("hidethis");
		
		// return false so that the link is not followed	
		return false;

	});

});

  

  
//Form Labels/////////////////////////////


$(document).ready(function() {
				$.fn.setCursorPosition = function(pos) {
					if ($(this).get(0).setSelectionRange) {
						$(this).get(0).setSelectionRange(pos, pos);
					} else if ($(this).get(0).createTextRange) {
						var range = $(this).get(0).createTextRange();
						range.collapse(true);
						range.moveEnd('character', pos);
						range.moveStart('character', pos);
						range.select();
					}
				}
				
				// loop through all of the labels, grab the next form element and set the value to that of this label
				$(".formbox label").each(function (i) {
				$(this).next("input").attr("value",$(this).html());
					$(this).hide();
				});
	
				$(".formbox input.text").focus(function() {
					if($(this).prev("label").html() == this.value){
						$(this).addClass("focus").setCursorPosition(0);
					}
				});
				$(".formbox input.text").keypress(function() {
					if($(this).prev("label").html() == this.value){
						this.value = "";
						$(this).removeClass("focus").addClass("typing");
					}
				});
				$(".formbox input.text").blur(function() {
					$(this).removeClass("focus typing");
					if(this.value == ""){
						this.value = $(this).prev("label").html();
					}
				});

				$(".formbox label").each(function (i) {
					$(this).next("textarea").attr("value",$(this).html());
					$(this).hide();
				});

				$(".formbox textarea").focus(function() {
					if($(this).prev("label").html() == this.value){
					$(this).addClass("focus").setCursorPosition(0);
				}
				});

				$(".formbox textarea").keypress(function() {
					if($(this).prev("label").html() == this.value){
						this.value = "";
						$(this).removeClass("focus").addClass("typing");
					}
				});
	 
				$(".formbox textarea").blur(function() {
					$(this).removeClass("focus typing");
					if(this.value == ""){
						this.value = $(this).prev("label").html();
					}
				});
	 			
	 			var passwordInputs = $('.formbox input[type=password]');
	 			$(passwordInputs).each(function(i){
	 				$(this).after('<input id="' + $(this).attr('id') + 'Holder" type="text" value="' + $(this).attr('value') +'" class="text required passwordPlaceholder" autocomplete="off" />');
	 			});
	 			
	 			var placeHolders = $('input.passwordPlaceholder');
	 			
	 			$(placeHolders).show();
				$(passwordInputs).hide();

				$(placeHolders).focus(function() {
					$(this).hide();
					var passID = '#' + $(this).attr('id').slice(0, -6);
					$(passID).show().focus();
				});

				$(passwordInputs).blur(function() {
					var holderID = '#' + $(this).attr('id') + 'Holder';
					if($(this).prev("label").html() == this.value) {
						$(holderID).show();
						$(this).hide();
					}
				});

			});

//Colorbox/////////////////////////////

$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	$(".colorbox").colorbox();
	$(".colorboxvideo").colorbox({width:"750px", height:"464px"});
	
	});
	


