sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

$(function() {
	$('A[rel="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	});

	//this gets the full url
	var url = document.location.href;
	//this removes the anchor at the end, if there is one
	url = url.substring(0, (url.indexOf("#") == -1) ? url.length : url.indexOf("#"));
	//this removes the query after the file name, if there is one
	url = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?"));
	//this removes everything before the last slash in the path
	url = url.substring(url.lastIndexOf("/") + 1, url.length);

	if (url == '' || url == 'index.php') { $('#nav ul li#home').addClass('activeNav'); }
	if (url == 'about-redant-it-support.php') { $('#nav ul li#about').addClass('activeNav'); }
	
	if (url == 'redant-company-background.php') {
		$('#nav ul li#about').addClass('activeNav');
		$('#nav ul li#company-background').addClass('activeSubNav');
	}
	
	if (url == 'what-we-do.php') {
		$('#nav ul li#about').addClass('activeNav');
		$('#nav ul li#what-we-do').addClass('activeSubNav');
	}
	
	if (url == 'founder-of-redant.php') {
		$('#nav ul li#about').addClass('activeNav');
		$('#nav ul li#the-founder').addClass('activeSubNav');
	}
	
	if (url == 'it-services.php') { $('#nav ul li#it-services').addClass('activeNav'); }
	if (url == 'why-redant.php') { $('#nav ul li#why-redant').addClass('activeNav'); }
	if (url == 'contact-redant.php') { $('#nav ul li#contact-redant').addClass('activeNav'); }

	var browser = navigator.userAgent;

	if (browser.indexOf('Firefox') != -1) {
		$('#nav li ul').css('margin-top','-5px');	
	}
	
	$('#banner').innerfade({
		animationtype: 'fade',
		speed: 2000,
		timeout: 6500,
		type: 'sequence',
		containerheight: '300px'
	});
	
	// See which font size the user wants
	$(".textResize a").click(function() {
		switch ($(this).attr("id")) {
			case 'small'	: setFontSize(.7);	break;
			case 'large'	: setFontSize(1.2);	break;
			case 'default'	: setFontSize(0.9);	break;
		}
		return false;
	});
	
	// Set the font size and set a cookie
	function setFontSize(size) {
	    $(".content").animate({fontSize: size+"em"}, 500).fadeIn("slow");
			createCookie(size);
		}
	
	// Create and read coookies
	function createCookie(value) {
		var date = new Date();
		date.setTime(date.getTime()+(30*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = "font_size="+value+expires+"; path=/";
	}
	var font_size = $.cookie('font_size');
	   if (font_size == '0.7') {
	        $('.content').css("font-size",".7em");
		}
	   if (font_size == '1.2') {
	        $('.content').css("font-size","1.2em");
		}
	   if (font_size == '0.9') {
	        $('.content').css("font-size",".9em");
		}
	
});

