jQuery(function(){
	
	

	
	//stripes for table															
	$("table.trainees tr:nth-child(even)").addClass("even");

	//popup links
    $('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });

	//loads drop menu
	$("#nav ul").superfish();
	
	//cycle plugin
	$('#banner').cycle();
	
	//news ticker
	$("#newsticker").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: 3,
		auto:1000,
		speed:1500
	});
	
	
	//  list animation  
        var fadeDuration = 150; //time in milliseconds
        $('#sideBar li a').hover(function() {
          $(this).animate({ paddingLeft: '20px' }, fadeDuration);
          $(this).children('span').show().animate({ left: -5 }, fadeDuration);
        }, function() {
          $(this).animate({ paddingLeft: '15px' }, fadeDuration);
          $(this).children('span').animate({ left: -20 }, fadeDuration).fadeOut(fadeDuration);          
        });
	
	/*sets equal height columns
	$.fn.setAllToMaxHeight = function(){
		return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
	}
	$('div.column').setAllToMaxHeight()*/
	
	//form focus styling
	 $('input[type="text"]').focus(function() {  
		 $(this).addClass("focusField");  
		 if (this.value == this.defaultValue){  
			 this.value = '';  
		 }  
		 if(this.value != this.defaultValue){  
			 this.select();  
		 }  
	 });  
	 $('input[type="text"]').blur(function() {  
		 $(this).removeClass("focusField");  
	 });
	 
	//email spam protection
    $('.email').each(function() {
		var $email = $(this);
		var address = $email.text()
        .replace(/\s*\[at\]\s*/, '@')
        .replace(/\s*\[dot\]\s*/g, '.');
		$email.html('<a href="mailto:' + address + '">'
        + address +'</a>');
    });
	
    //Form Field Value Swap
    swapValues = [];
    $("div.subscribe .textbox, div.advanceds .textbox").each(function(i){
        swapValues[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });
	
	

	
	
	 //Web Apps
	 $('.add-item').click(function() {
		$('#add-item').toggle();
	 });
		$('.cat1').click(function() {
		$('#cat1').toggle();
	 });
		$('.cat2').click(function() {
		$('#cat2').toggle();
	 });
		$('.cat3').click(function() {
		$('#cat3').toggle();
	 });
	 
	 
	 		//add caption to longdesc
	$('img').jcaption();
		


});