// JavaScript Document



$(document).ready(function(){
	if(show_ar_legal == true){ // show t's and c's in an iframe using thickbox api
		if(!readCookie('ar_agree')){ //if the cookie hasn't been set.
			tb_show(null, '/message/lang/'+site_dir+'/?&KeepThis=true&TB_iframe=true&height=375&width=760&modal=true',null);
		}
	}
	highlightMenu();
	
	columns_ajax = new FS_ajaxFeed(['shareInfo','leftData'],"/ajax/columns/"+site_dir+"/",60000);
	columns_ajax.loadAjaxData();
});


function highlightMenu(){ // attempt to highlight the current item in the navigation
	$("#leftNav").find("a").each(function (i) {
		if($(this).attr('href') == location.pathname) {
			$(this).addClass("leftCurrent");
		} 
	});
	$("#siteTopBar").find("a").each(function (i) {
		if($(this).attr('href') == location.pathname) {
			$(this).addClass("topCurrent");
		} 
	});
}
function trim(str){
	return str.replace(/^\s+|\s+$/g, '');	
}


// used only for the US site.
function createCookie(name,value,days) 
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}
