/*	JS Document 
 *	Author: Tashreek Jackson
 *	Overview: jQuery Functions.	
*/

$(document).ready(function() {
	//********** Image Rollover Captions **********//
	$("span.desc").hide()
	$("ul.grid-items li a").hover(
	  function () {
		$(this).find("span.desc").show();
	  }, 
	  function () {
		if(!$(this).hasClass("show-text"))
			$(this).find("span.desc").hide();
	  }
	);
	
	$("#grid-control li #text").click(function () {
	  $("#grid-control li a").removeClass("active");
	  $(this).addClass("active");
      $("span.desc").show();
	  $("ul.grid-items li a").toggleClass("show-text");
    });
	 
	$("#grid-control li #images").click(function () {
	  $("#grid-control li a").removeClass("active");
	  $(this).addClass("active");
      $("span.desc").hide();
	  $("ul.grid-items li a").removeClass("show-text");
    });
	
	$("#subForm").validation();
	
	jQuery('a[rel*=facebox]').facebox()
	
	//********** Main Slideshow Cycle **********//;
	$('#grid-content').cycle({ 
		fx:     'scrollHorz', 
		easing: 'swing',
		next:   '#next',
		prev:   '#prev',
		nowrap:	1,
		timeout: 0
	});
	
	$('#grid-articles').cycle({ 
		fx:     'scrollHorz', 
		easing:  'swing', 
		pager:  '.article-links',
		next:   '#next',
		prev:   '#prev',
		nowrap:	1,
		timeout: 0
	});
	
	//********** Lightbox **********//;
	
	$('a[rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
		

	//********** Input hints **********//
	// find all the input elements with title attributes
	var el = $('input[Title], textarea[Title]');
	// show the display text
	el.each(function(i) {
		$(this).attr('value', $(this).attr('title'));
	});
	
	// hook up the blur & focus
	el.focus(function() {
		if ($(this).attr('value') == $(this).attr('title'))
			$(this).attr('value', '');
	}).blur(function() {
		if ($(this).attr('value') == '')
			$(this).attr('value', $(this).attr('title'));
	}).submit(function() {
		if ($(this).attr('value') == 'Name' || $(this).attr('value') == 'Email' || $(this).attr('value') == 'Message')
			$(this).attr('value', '');
	});
	
});
