function setDefaultCookieValue(cookie_name, value)	{
	var cookie = $.cookie(cookie_name);
	// if not set, set to value
	if (cookie == null)	{
		$.cookie(cookie_name, value);
	}
}
function hideTip()	{
	$("#isp-tip").toggle();
}

this.imagePreview = function(){
	var timer = null;
	$(".tooltip").hover(
		function(e)	{
			if	(timer)	{
				clearTimeout(timer);
				timer=null;
			}
		},
		function()	{
			timer = setTimeout('hideTip()', 1000);
		}
	);
	$("a[rel=tooltip]").hover(
		function(e)	{
			if (timer)	{
				clearTimeout(timer);
				timer = null;
			}	
			this.tip_id = this.title;
			this.title = "";
			$("#isp-tip").appendTo("isp_wrap");
			$("#isp-tip").addClass("current").fadeIn("fast");
		},
		function()	{
			timer = setTimeout('hideTip()', 1000);
		}
	);
};

$(document).ready(function() {
	setDefaultCookieValue('footer_show', 'collapsed');
	var footer_show = $.cookie('footer_show');
	var winWidth = $(window).width();
	if (winWidth < 1024)	{
		$('#parent').addClass('narrow');
		$('form#form1').addClass('narrow');
	};
	$(window).bind('resize', function() {
		var winWidth = $(window).width();
		if (winWidth < 1024)	{
			if(!($('#parent').hasClass('narrow'))||($('form#form1').hasClass('narrow')))	{
				$('#parent').addClass('narrow');
				$('form#form1').addClass('narrow');
			};
		} else	{
			if($('#parent').hasClass('narrow')||$('form#form1').hasClass('narrow'))	{
				$('#parent').removeClass('narrow');
				$('form#form1').removeClass('narrow');
			};
		}
	});
	// set up initial state
	if (footer_show == 'collapsed')	{
		$('#footer-bar', '#footer').removeClass('hider');
		$('#footer-sections', '#footer').toggle();
		$('#footer-bar a.show', '#footer').html('Show Footer Quick Links');
		
	} else	{
		$('#footer-bar', '#footer').addClass('hider');
	}
	
	$('#footer-bar a.show', '#footer').click(
		function() {
			footer_show = $.cookie('footer_show');
			if (footer_show == 'collapsed') {
				$('#footer-sections', '#footer').slideToggle();
				$('#footer-bar a.show', '#footer').html('Hide Footer Quick Links');
				$('#footer-bar', '#footer').addClass('hider');
				$.cookie('footer_show', 'expanded');
			}
			if (footer_show == 'expanded') {
				$('#footer-bar', '#footer').removeClass('hider');
				$('#footer-sections', '#footer').slideToggle();
				$('#footer-bar a.show', '#footer').html('Show Footer Quick Links');
				$.cookie('footer_show', 'collapsed');
			}
			return false;
		}
	);
	imagePreview();
});	