/*
  $Id: translate.js 3533 2012-01-19 20:36:20Z eric $

  Pro-Active Software
  http://www.pro-activesoftware.com
*/

var transApiKey;

function translate(transTo) {
	// set the cookie
	$.cookie('transTo', transTo, { expires: 7, path: '/' });

	// set the API key
	$.translate.load(transApiKey);

	// translate the page
	$('body').translate('en', transTo, { limit: 2000 });
}
	
function revertLanguage() {
	// delete the cookie
	$.cookie('transTo', null, { path: '/' });

	// refresh the page
	window.location.reload(true);
}

function translateOnBodyReady(apiKey) {
	var transTo = $.cookie('transTo');
	transApiKey = apiKey;

	if (transTo != null && transTo != "en" && transTo != "") {
		$(document).ready(function(){
				translate(transTo);
			}
		);
	}
}
