﻿if (location.host.indexOf('espanol') == -1) {
	if($.cookie("espanol") === "true" && location.href.indexOf('clearlang') == -1 && document.referrer.indexOf('espanol') == -1){
		location.href = 'http://espanol.lakewood.cc';
	}
	else{
		$.cookie("espanol", null, {path: '/'});
	}
}
else{
	var from = $.query.get("fromeng");
	if(from.length > 0){
		$.cookie("fromeng", from, {expires: 30, path: '/'});
	}
} 

function toEnglish(){
	var domain = 'www.lakewood.cc';
	if($.cookie("fromeng") != null){
		domain = $.cookie("fromeng");
	}
	$.cookie("fromeng", null, {path: '/'});
	location.href = 'http://' + domain +'?clearlang=1';
}

function toEspanol(){
	$.cookie("espanol", "true", {expires: 30, path: '/'});
	location.href = 'http://espanol.lakewood.cc?fromeng=' + document.domain;
}

$(function(){
	$('#espanol-link').click(function(e){
		toEspanol();
		return false;
	});
	
	$('#english-link').click(function(e){
		toEnglish();
		return false;
	});
});


