/**
 * @author pclabs
 */

/*- Run On Load --------------------------------------------------------------*/

// window.onload listener to share event with multiple functions
// Based on runOnLoad function from 
// "JavaScript: The Definitive Guide", 5th ed, p.434, example 17-7

	
 function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = "";
     }
 }	
	
		/* JS for Content Slider*/
		var theInt = null;
		var $crosslink, $navthumb;
		var curclicked = 0;
		
		theInterval = function(cur){
			clearInterval(theInt);
			
			if( typeof cur != 'undefined' )
				curclicked = cur;
			
			$crosslink.removeClass("active-thumb");
			$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
			
			theInt = setInterval(function(){
				$crosslink.removeClass("active-thumb");
				$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
				curclicked++;
				if( 5 == curclicked )
					curclicked = 0;
				
			}, 8000);
		};
		
		$(function(){
			
			$("#main-content-slider").codaSlider();
			
			$navthumb = $(".nav-thumb");
			$crosslink = $(".cross-link");
			
			$navthumb
			.click(function() {
				var $this = $(this);
				theInterval($this.parent().attr('href').slice(1) - 1);
				return false;
			});
			
			theInterval();
		});

	$(document).ready(function() {
		$('#tabvanilla > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
		$('#featuredvid > ul').tabs();
		$.pop();

		navs = $('#nav > li');
	    subnavs = $('#subnav > div');
	    navs.each(function(idx) {
	            this.nav = subnavs[idx];
	        }).hover(
	        function() {
	            navs.removeClass('active');
	            subnavs.removeClass('active');             
	            $(this).addClass('active');  
	            $(this.nav).addClass('active');
	        });				
		
	});			

		
