/*
* Skeleton V1.1
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 8/17/2011
*/


$(document).ready(function() {

	/* Tabs Activiation
	================================================== */

	var tabs = $('ul.tabs');

	tabs.each(function(i) {

		//Get all tabs
		var tab = $(this).find('> li > a');
		tab.click(function(e) {

			//Get Location of tab's content
			var contentLocation = $(this).attr('href');

			//Let go if not a hashed one
			if(contentLocation.charAt(0)=="#") {

				e.preventDefault();

				//Make Tab Active
				tab.removeClass('active');
				$(this).addClass('active');

				//Show Tab Content & add active class
				$(contentLocation).show().addClass('active').siblings().hide().removeClass('active');

			}
		});
	});
	
	
		
		var filename = location.pathname.substr(location.pathname.lastIndexOf("/")+1,location.pathname.length);
		var fileNoExt = filename.replace(/\.(html|php)$/, "");
		
		if ($('ul#top-nav li').hasClass(fileNoExt)) {
			$('ul#top-nav li.'+ fileNoExt).addClass('active');
		} else {
			$('ul#top-nav li').removeClass('active');
		}
		
});

function languageSwap(language) {
	
	   var filename = location.pathname.substr(location.pathname.lastIndexOf("/")+1,location.pathname.length);	
	   var url = location.pathname.substr(location.pathname.lastIndexOf("/")+1,location.pathname.length);	
	   if (filename == 'index.php') {
		   if (language == 'en') {
		   location.href= url + '?english';
		   } else if (language == 'es') {
		  location.href= url + '?espanol';
		   }
		   
	   } else if (!(filename == 'index.php')) { 
		   if (language == 'en') {	 
		   var newUrl = url.replace(/-es/, '-en');
		   location.href= newUrl;
		   } else {
		   var newUrl = url.replace(/-en/, '-es');
		   location.href= newUrl;
		   }
	   }	
}
