//LISTENERS

$(document).ready(function() {
	setFooter();
	setNews();
	setTips();
	setPlayers();
	setAd();
	setZoom();
	scrollTo();
	IEwarning();
});
$(window).resize(function() {
	setFooter();
});

// FUNCTIONS

function setFooter() {
	var wHeight = $(window).height();
	var xHeight = $('#content').height() + 320;
	if (wHeight > xHeight) {
		var pb = wHeight - xHeight;
		$('#content').css( {
			'padding-bottom' : pb
		});
	} else {
		$('#footer').css( {
			'padding-bottom' : 0
		})
	}
}

function setNews() {
	$('.entrymessage').hide();
	$('a.showmessage').click(function() {
		$(this).removeAttr('href');
		$(this).siblings('div.entrymessage').slideToggle();
	});
}

function setTips() {
	$('a.tip[title]').qtip( {
		style : {
			background : '#000000',
			name : 'dark',
			tip : true
		}
	});
}

function setPlayers() {
	$('.audioplayer').each(
			function() {

				var audiofile = $(this).attr('id');

				var flashvars = {
					flashvar : base_url + "files/" + audiofile
				};
				var params = {
					menu : "false"
				};
				var attributes = {};

				swfobject.embedSWF(base_url + "flash/sound.swf", audiofile,
						"75", "20", "9.0.0", "ei.swf", flashvars, params,
						attributes);

			});
}

function setAd() {
	var flashvars = {};
	
	var params = {
		menu : "false"
	};
	
	var attributes = {};

	swfobject.embedSWF(base_url + "flash/advertisement.swf", "advertisement", "185", "235",
			"9.0.0", "ei.swf", flashvars, params, attributes);
}

function setZoom() {
	$('.imghome .zoom').removeAttr('href');
	$('.imghome .zoom').click(function() {
		var src = $(this).siblings('img').attr('src');
		$.fancybox( {
			href : src
		});
	});
}

function scrollTo() {
	//$.scrollTo();
}

function IEwarning() {

	if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) < 8) {
		var warningText = 'The web browser that you are using is outdated and unsafe. Please click here to update to the latest version.';
		$('body').prepend($('<a/>', {
			id : 'IEwarning',
			text : warningText,
			href : 'http://www.browserchoice.eu/',
			target : '_blank'
		}));
		$('#IEwarning').css('margin-bottom', '200px');
		$('#IEwarning').hide().show();
	}
}
