//Load ambient graphic
var ambient_img = "bg.jpg";

function setAmbientCookie() {
	try {
		$j.cookie('ambientGraphic', null);
		$j.cookie('ambientGraphics',null);
	}
	catch(e){;}
	var cookie_status = ($j.cookie('ambient_Graphic') == "0")?1:0;
	$j.cookie('ambient_Graphic',cookie_status, {expires:365, path: "/", domain: domainname});
}
function loadAmbient() {
	var cssDef = {
		'background-image': 'url(http://'+hostname+'/images/modules/ambients/external/'+ambient_img+')',
		'background-repeat': 'no-repeat',
		'background-position': 'center top'
	}
	$j("body").css(cssDef);
}

function togglerAmbient() {
	$j(".ambient_toggler").show();
}

function decideAmbientGraphics() {
	if($j.cookie('ambient_Graphic') == "0")	$j('body').css({'background-image': 'url(http://'+hostname+'/images/modules/ambients/external/'+ambient_img+')'});
	else $j('body').css({'background-image': 'none'});
	setAmbientCookie();
}


window.onload = function () {
	if (screen.width > 1024) {
		loadAmbient();
		togglerAmbient();
		try {
			if($j.cookie('ambient_Graphic') == "0") {
					$j('body').css({'background-image':	'none'});
					$j('.ambient_toggler').addClass('on');
				}
		}
		catch(e) {;}
	}
}

$j(document).ready(function () {

	try {
		if (tm_ambient) {
			ambient_img = tm_ambient;
		}
	} catch(e){;}
	$j(".ambient_toggler").toggle(
	function () {
		try{
			decideAmbientGraphics();
		}
		catch(e){;}
		$j(this).addClass('on');
	},
	function () {
		try {
			decideAmbientGraphics();
		}
		catch(e) {;}
		$j(this).removeClass('on');
	});
	try {
		$j(".article").find('img').each(function(){processImage(this)});
	} catch(e) {;}
});


