// redirect to splash page if cookie is not set
$(function(){
	cookieValue = $.cookie('splashRedirect');
	if (cookieValue == null && window.location.pathname != '/_scripts/index.asp') {
		window.location.href = "/_scripts/index.asp";
	} else if (cookieValue == null && window.location.pathname == '/') {
		//do nothing
		return false;
	}
});

// add google analytics event tracking for file downloads
// http://blog.rebeccamurphey.com/2008/12/04/update-tracking-outbound-clicks-with-google-analytics-and-jquery/
$(function() {
	var fileTypes = ['doc','xls','pdf','zip']; 
	$('a').click(function() {
		var $a = $(this);
		var href = $a.attr('href');
		var hrefArray = href.split('.');
		var extension = hrefArray[hrefArray.length - 1];
	 
		if ($.inArray(extension,fileTypes) != -1) {
			pageTracker._trackEvent('download', extension, href);
		}
	});
	
	var gfCookie = $.cookie('GF');
	if (gfCookie == null) {
		$('#cpspan').hide();
	}
});


setTimeout("gilliatGlobal_logVisit();", 1);

function gilliatGlobal_logVisit() {
    var parameters = "{'url':'" + document.URL + "'}";
    
    $.ajax({
        type: "POST",
        url: "/_scripts/GilliatWS.asmx/LogPageVisit",
        data: parameters,
        contentType: "application/json; charset=utf-8",
        dataType: "json"
    });
}

// clear search field on focus
/*$(function() {
	$('.search-field').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
});*/

// slidey menu
/*$(function(){
    $('#nav li ul').hide();
    $('#nav ul li').hover(function(){
        $(this).find('ul').slideDown(300);
    }, function(){
		$(this).find('ul').slideUp(150);
	});
});*/
