/*
	fn.hu sajat interstitial (nem hirdetes) megjelenites
*/

/* config START */
var interstitial_days = 4;
var interstitial_cookieName = 'fn_interstitial_d' + interstitial_days;
var interstitial_layer_id = '#fn_interstitial';
var interstitial_fn_layer_id1 = '#sky_advertisement_container';
var interstitial_fn_layer_id2 = '#container';
var interstitial_timeout = null;
/* config END */

function interstitial_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 interstitial_checkCookie(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 true;
	}
	return false;
}

function interstitial_show(layer_id, skip_cookie) {
	interstitial_layer_id = layer_id;
	
	var isCookie = interstitial_checkCookie(interstitial_cookieName);
	if ( (!isCookie) || (skip_cookie == true) ) {
		interstitial_createCookie(interstitial_cookieName,'fn_interstitial_cookie_set',interstitial_days);
		jQuery(interstitial_fn_layer_id1).css('display', 'none');
		jQuery(interstitial_fn_layer_id2).css('display', 'none');

		jQuery(document).ready(function(){
			jQuery(interstitial_layer_id).fadeIn('fast',function(){
				interstitial_timeout = setTimeout('interstitial_close()',7000);
			});
		});
	}
}

function interstitial_close() {
	if ( !interstitial_timeout ) cleartimeout(interstitial_timeout);
	jQuery(interstitial_fn_layer_id1).css('display', 'block');
	jQuery(interstitial_fn_layer_id2).css('display', 'block');
	jQuery(interstitial_layer_id).fadeOut('fast',function(){
		jQuery(interstitial_layer_id).css('display', 'none');
	});
}

