$(function(){	
	/*
		This block sets up the tabs in the content area. It degrades gracefully, those without javascript won't see the tab selectors, and all of the tabs will show by default.
	*/
	$(".primary-tab").hide();
	$(".primary-tab-1").show();
	//first, hide all the tabs, then show the first one only.
	
	$(".sub-nav").show();
	// .sub-nav is hidden by the css, then turned on by the javascript
	
	$(".sub-nav-tab").click(function(){
		subtabClick($(this));
	});
	//end the content-area tabs
	
	if(jQuery.browser.msie && jQuery.browser.version < 7){
		//alert("you are using IE6");
		//$(".no-thickbox-ie").removeClass("thickbox");// just remove them all!
		//$(".thickbox").removeClass("thickbox");
		tb_init('a.thickbox, area.thickbox, input.thickbox');
	}else{
		tb_init('a.thickbox, area.thickbox, input.thickbox');
	}
	
});

function subtabClick(element){
	var tab_requested = $(element).attr("rel");
	
	$(".sub-nav .active").removeClass("active");
	$(element).addClass("active");
	
	$(".primary-tab").hide();
	$(".primary-tab-"+tab_requested).show();
	return false;
}

function deeplinkShowTab(hash){
	subtabClick($(".sub-nav ." + hash));
}

function change_to(page){
	$(".sub-nav .active").removeClass("active");
	$(".sub-nav-tab-"+page).addClass("active");
	$(".primary-tab").hide();
	$(".primary-tab-"+page).show();
}


function active_page(page){
	if(page != $(".primary-nav li .active").attr("title")){
		$(".primary-nav li .active").removeClass("active");
		$(".primary-nav li a").each(function(i){
			if($(this).attr("title") == page){
				$(this).addClass("active");
			}
		});
	}
	return (page+" is active");
}

var home_tout_interval = 0;

function home_page_touts(){
	home_tout_interval = setTimeout("home_tout_fade_to('2')", 5000);
	home_tout_fade_to("1");
	$(".home-touts-nav li a").click(function(e){
		var request = $(this).attr("rel");
		home_tout_fade_to(request);
		
		return false;
	});
}

function home_tout_fade_to(request){
	clearTimeout(home_tout_interval);
	

	$(".home-touts-nav li a").removeClass("active");
	$(".home-touts-nav li a").each(function(){
		if($(this).attr("rel") == request){
			$(this).addClass("active");
		}
	});
	$(".home-touts li").fadeOut("normal");
	$(".home-tout-"+request).fadeIn("normal");
	
	try
	{
		request = ($(".home-tout-"+request).next().attr("class")).substr(10,1);
	}
	catch(err)
	{
		request = 1;
	}
	
	home_tout_interval = setTimeout("home_tout_fade_to('"+request+"')", 5000);
}


//Example for URL http://www.example.com/index.html?hello=bonjour&goodevening=bonsoir
//var hash = getUrlVars(); alert(hash['hello']); // prints 'bonjour' alert(hash['goodevening']); // prints 'bonsoir'
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    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;
}