// The following will run as soon as the page is loaded and the DOM is ready, but images might still be loading.
 jQuery.noConflict();
     
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
 
jQuery('#homeUL').innerfade({ speed: 'slow', timeout: 4000, type: 'sequence', containerheight: '197px' }); 

jQuery('#gCourse').accordion({ 
    autoHeight: false ,
	active:0
});

  jQuery("div.rssItem> div").hide();
  jQuery('div.rssItem> h3').click(function() {
	var $nextDiv = jQuery(this).next();
	var $visibleSiblings = $nextDiv.siblings('div:visible');
	if ($visibleSiblings.length ) {
	  $visibleSiblings.slideUp('fast', function() {
		$nextDiv.slideToggle('fast');
	  });
	} else {
	   $nextDiv.slideToggle('fast');
	}
  });



jQuery("#tabs").tabs({ fx: { opacity: 'toggle' } }).tabs();

jQuery("#tabs ul li").hover(
			function() {
				jQuery(this).animate({marginTop:'-10px'}, 200);
			},
			function() {
				jQuery(this).animate({marginTop:'0'}, 200);
			}
		);





jQuery('div.fpanel').hide();
jQuery('div.p1').show();
jQuery('a.fTab1').click(function() {
	jQuery('div.fpanel').hide();
	jQuery('div.p1').fadeIn(400);
    return false; 
  });
jQuery('a.fTab2').click(function() {
	jQuery('div.fpanel').hide();
	jQuery('div.p2').fadeIn(400);
    return false; 
  });
jQuery('a.fTab3').click(function() {
	jQuery('div.fpanel').hide();
	jQuery('div.p3').fadeIn(400);
    return false; 
  });
jQuery('a.fTab4').click(function() {
	jQuery('div.fpanel').hide();
	jQuery('div.p4').fadeIn(400);
    return false; 
  });
jQuery('a.fTab5').click(function() {
	jQuery('div.fpanel').hide();
	jQuery('div.p5').fadeIn(400);
    return false; 
  });


jQuery("body#home #mid ul li:odd").addClass("alt");
jQuery("table tr:odd").addClass("alt");


jQuery('.rmv-dft-val').click(
	function() {
	if (this.value == this.defaultValue) {
	this.value = '';
	}
});
jQuery('.rmv-dft-val').blur(
	function() {
	if (this.value == '') {
	this.value = this.defaultValue;
	}
});

jQuery("#header ul a").hover(function() {
	jQuery(this).animate({marginTop:'-4px' , paddingBottom:'16px' , backgroundColor:'#fff' }, 200);
	},
	function() {
		jQuery(this).animate({marginTop:'0'  , paddingBottom:'12px' , backgroundColor:'#444' }, 200);
	}
);


jQuery('a#m1').click(function() {
	jQuery(this).text(jQuery(this).text() == 'hide map' ? 'show map' : 'hide map'); // <- HERE
	jQuery('#mymap1').toggleClass('mshow');
    return false; 
  });

jQuery('a#m2').click(function() {
	jQuery(this).text(jQuery(this).text() == 'hide map' ? 'show map' : 'hide map'); // <- HERE
	jQuery('#mymap2').toggleClass('mshow');
    return false; 
  });

jQuery('a#m3').click(function() {
	jQuery(this).text(jQuery(this).text() == 'hide map' ? 'show map' : 'hide map'); // <- HERE
	jQuery('#mymap3').toggleClass('mshow');
    return false; 
  });


//grab all the anchor tag with rel set to shareit
	jQuery('a[rel=shareit], #shareit-box').mouseenter(function() {		
		
		//get the height, top and calculate the left value for the sharebox
		var height = jQuery(this).height();

		
		//grab the href value and explode the bar symbol to grab the url and title
		//the content should be in this format url|title
		var value = jQuery(this).attr('href').split('|');
		
		//assign the value to variables and encode it to url friendly
		var field = value[0];
		var url = encodeURIComponent(value[0]);
		var title = encodeURIComponent(value[1]);
		
		//assign the height for the header, so that the link is cover
		jQuery('#shareit-header').height(height);
		
		//display the box
		jQuery('#shareit-box').show();
		
		
		//assign the url to the textfield
		jQuery('#shareit-field').val(field);
		
		//make the bookmark media open in new tab/window
		jQuery('a.shareit-sm').attr('target','_blank');
		
		//Setup the bookmark media url and title
		jQuery('a[rel=shareit-mail]').attr('href', 'mailto:?subject=I saw this and thought of you: ' + title + '&Body=' + url);
		jQuery('a[rel=shareit-delicious]').attr('href', 'http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=' + url + '&title=' + title);
		jQuery('a[rel=shareit-designfloat]').attr('href', 'http://www.designfloat.com/submit.php?url='  + url + '&amp;title=' + title);
		jQuery('a[rel=shareit-digg]').attr('href', 'http://digg.com/submit?phase=2&amp;url=' + url + '&amp;title=' + title);
		jQuery('a[rel=shareit-stumbleupon]').attr('href', 'http://www.stumbleupon.com/submit?url=' + url + '&title=' + title);
		jQuery('a[rel=shareit-twitter]').attr('href', 'http://twitter.com/home?status=' + title + '%20-%20' + title);
		
	});

	//onmouse out hide the shareit box
	jQuery('#shareit-box').mouseleave(function () {
		jQuery('#shareit-field').val('');
		jQuery(this).hide();
	});
	
	//hightlight the textfield on click event
	jQuery('#shareit-field').click(function () {
		jQuery(this).select();
	});


});


