$(document).ready(function() {

	// INIT
	
	RunVisual();
	accordion();

	$("a[rel='external']").live('click', function() {
		window.open(this.href);
		track('External link', $(this).attr('href'));
		return false;
	});

	$("#search_submit").click(function(e) {

		e.preventDefault();

		$('.section').slideUp('fast');
		track('Search', $('#search_input').val());
		// populate the search results box
		$("#search-results").slideUp('fast').load('/search/html.aspx?search=' + escape($('#search_input').val()), function(data) {
			$(this).slideDown().append('<a href="#" class="close">Close</a>');
		});

	});

	$(".additional").append('<a href="#" class="close">Close</a>');

	$(".additional a.close").live('click', function(e) {
		e.preventDefault();
		$(this).parent(".additional").slideUp();	
	});
	
	function track(category, action, label, value ){
		_gaq.push(['_trackEvent', category, action, label, value]);
		//pageTracker._trackEvent(category, action, label, value );
	}

});

	
/*
// PageLoad function
// This function is called when:
// 1. after calling $.historyInit();
// 2. after calling $.historyLoad();
// 3. after pushing "Go Back" button of a browser
function pageload(hash) {
	// alert("pageload: " + hash);
	// hash doesn't contain the first # character.
	if(hash) {
		// restore ajax loaded state
		if($.browser.msie) {
			// jquery's $.load() function does't work when hash include special characters like aao.
			hash = encodeURIComponent(hash);
		}
		$("#load").load(hash + ".html");
	} else {
		// start page
		$("#load").empty();
	}
}

$(document).ready(function(){
	// Initialize history plugin.
	// The callback is called at once by present location.hash. 
	$.historyInit(pageload, "jquery_history.html");
	
	// set onlick event for buttons
	$("a[rel='history']").click(function(){
		// 
		var hash = this.href;
		hash = hash.replace(/^.*#/, '');
		// moves to a new page. 
		// pageload is called at once. 
		// hash don't contain "#", "?"
		$.historyLoad(hash);
		return false;
	});
});
*/