sfHover = function() {
	var sfEls = document.getElementById("top-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 switch_lang() {
	loc = window.location + '';
	f = loc.indexOf("/french");
	if (f == -1) {
		if (loc.indexOf("/test/") == -1)
			av = loc.replace("adventuresmart.ca","adventuresmart.ca/french")
		else
			av = loc.replace("adventuresmart.ca/test","adventuresmart.ca/test/french");
	}
	else {
		if (loc.indexOf("/test/") == -1)
			av = loc.replace("adventuresmart.ca/french","adventuresmart.ca")
		else
			av = loc.replace("adventuresmart.ca/test/french","adventuresmart.ca/test");
	}
	document.getElementById("toggle_lang").href = av;
	window.location = av;
}

function redirectToMobile(id_tag) 
{
	loc = window.location + '';
	f = loc.indexOf("adventuresmart.ca/test");
	if (f != -1) {
		av = loc.replace("adventuresmart.ca/test","adventuresmart.ca/test/m");
		setCookie('ignoremobileredirect', 'false', '/');
		if (id_tag != '')
			document.getElementById(id_tag).href = av;
		window.location = av;
	}
	else {
		av = loc.replace("adventuresmart.ca","adventuresmart.ca/m");
		setCookie('ignoremobileredirect', 'false', '/');
		if (id_tag != '')
			document.getElementById(id_tag).href = av;
		window.location = av;
	}
}

function redirectToTablet()
{
	if (getCookie("tabletnavigation") != "true") {
		setCookie("tabletnavigation","true","/");
		setCookie("ignoretabletredirect","true","/");
		window.location.reload(true);
	}
}

function redirectToStandard()
{
	if (getCookie("tabletnavigation") == "true") {
		setCookie("tabletnavigation","false","/");
		setCookie("ignoretabletredirect","true","/");
		window.location.reload(true);
	}
}

function tweet_this()
{
	a = document.getElementById('tweet');
	a.href = "http://twitter.com/share?text="+document.title+"&amp;url="+location.href+"&amp;via=adventure_smart";
}

function fb_like_this()
{
	a = document.getElementById('fb_like');
	u=location.href;
	t=document.title;
	a.href = 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t);
}

