$(document).ready(function(){

//Carousel///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	$("#hardware .specs a").click(function() {
										   
		var slideWidth = $("a.slide").width();	
		var slideID = $(this).attr("rel");
		var slide = slideID * slideWidth;
		var	activeWidth = '240';
		var activeSlide = slideID * activeWidth + 110;
		
		$("#hardware .reel").animate({ left : -slide });
		if ( slideID == '0' ) {
			$("#hardware .activemark").animate({ left: 110 });
		}
		else {
			$("#hardware .activemark").animate({ left: activeSlide });
		}
		$("#hardware .specs .col1_4").removeClass("active");
		$(this).parent().addClass("active");
	});
	
//FAQ Toggle///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	$("ul.faq li div").hide();
	$("ul.faq li div:first").show();
	$("ul.faq li h3:first").addClass("open");
	$("ul.faq li h3").click(function() {
		if( $(this).hasClass("open") ) {
		} else {
			$("ul.faq li h3").removeClass("open");
			$("ul.faq li div").slideUp();
			$(this).next().slideToggle();
		}
		$(this).addClass("open");
		return false;
	});
	
	
//GET URL PARAMETER///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	$.extend({
	  getUrlVars: function(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++)
		{
		  hash = hashes[i].split('=');
		  vars.push(hash[0]);
		  vars[hash[0]] = hash[1];
		}
		return vars;
	  },
	  getUrlVar: function(name){
		return $.getUrlVars()[name];
	  }
	});	
	
	var allVars = $.getUrlVars();

//TABS///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$(".tab_content").hide(); 
	$("ul.tabs li:first").addClass("active").show(); 
	$(".tab_content:first").show(); 

	//On Click Event
	$("ul.tabs li, #overview .specs .col1_4").click(function() {
		var allVars = "";
		var activeTab = $(this).find("a").attr("href"); 
		
		$("ul.tabs li").removeClass("active"); 
		$("ul.tabs li a[href=" + activeTab+ "]").parent().addClass("active");
		
		$(".tab_content").hide(); 
		$(activeTab).show(); 
		return false;
	});
	
	if ( allVars == "software") {
		$("ul.tabs li").removeClass("active"); 
		$("ul.tabs li a[href=#" + allVars+ "]").parent().addClass("active");
		$(".tab_content").hide(); 
		$("#"+allVars).show(); 
	} else if ( allVars == "hardware"){
		$("ul.tabs li").removeClass("active"); 
		$("ul.tabs li a[href=#" + allVars+ "]").parent().addClass("active");
		$(".tab_content").hide(); 
		$("#"+allVars).show(); 
	}

//MISC//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	$("ul.timeslot li:odd").addClass("even");
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
	$('a[href^="http://"].target')	.attr({ target: "_blank" });
	$('.ngg-galleryoverview img:nth-child(7n) ').css({'margin-right': '0'});
	
	$('.ngg-galleryoverview img').animate({
		opacity: 0.7								  
	}, 1); 
	
	$('.ngg-galleryoverview img').hover(function(){
		$(this).stop().animate({
		opacity: 1,
		}, 200);
	}, function() {
		$(this).stop().animate({
		opacity: 0.7								  
		}, 300);
	});
});