// JavaScript Document

/*Tabs*/
$(document).ready(function() {

	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
/*Tabs END*/	

/*Cart*/
	
	//When page loads...
	$(".cart_content").hide(); //Hide all content
	$(".cart_content:first").show(); //Show first cart content

	$("select.tabs option[value='tabs1']").attr('selected', 'selected');

	//On Click Event
	$("select.tabs").change(function() {
		$(".cart_content").hide(); //Hide all tab content

		var activeTab = $(this).attr("value"); //Find the attribute value to identify the active cart + content
		$('#' + activeTab).show(); //Show in the active ID content
		return false;
	});
	
/*Tables*/	
	$("table.tabdata").filter(function(){
		/* Apply THead Background*/
		$("thead tr:last-child th",this).css("background","#f1f1f1 url('images/tbl_th_bg.jpg') repeat-x bottom");
		/* Remove Extra Borders */	
		$("tbody tr:first-child td",this).css("border-top","none");	
		$("tbody tr td:last-child, thead tr th:last-child",this).css("border-right","none");
	});
	/* Apply odd Class - Only Works on Simple Tables*/
	$("table.tabdata:not(.no-odd)").each(function(){
			$("tbody tr:odd",this).addClass("odd");
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
	
	
	//Read More or Less
$('.trigger_content').hide();
	 
	 $('.trigger').click(function() {
		if($('.trigger_content').is(':visible')) {
			$('.trigger_content').slideUp();
			$('a.trigger').html('<a href="#" class="trigger">Read More</a>');	
		} else {
			$('.trigger_content').slideDown();		
			$('a.trigger').html('<a href="#" class="trigger">Read Less</a>');
		}

	 });


//Anchor Scroll
 $('a[rel=scrollTop]').click(function(){
   var scrollVal = $($(this).attr('href')).offset();
   $("html, body").animate({scrollTop: scrollVal.top});
   return false;
 });

});


