
/******************************************************************************
 *
 *	PROJECT: Flynax Classifieds Software
 *	VERSION: 4.X
 *	LICENSE: FL4HLD2A8696 - http://www.flynax.com/license-agreement.html
 *	PRODUCT: Real Estate Agency
 *	DOMAIN: gevimmo.com
 *	FILE: LIB.JS
 *
 *	The software is a commercial product delivered under single, non-exclusive,
 *	non-transferable license for one domain or IP address. Therefore distribution,
 *	sale or transfer of the file in whole or in part without permission of Flynax
 *	respective owners is considered to be illegal and breach of Flynax License End
 *	User Agreement.
 *
 *	You are not allowed to remove this information from the file without permission
 *	of Flynax respective owners.
 *
 *	Flynax Classifieds Software 2017 |  All copyrights reserved.
 *
 *	http://www.flynax.com/
 *
 ******************************************************************************/

$(document).ready(function(){
	if( CP_show_cookie_notice == true ){
		$('div#cookies_policy_big_form').fadeIn('normal');
		$('div.cookies_policy_icon').before('<div class="cookies_absolute_div hide" id="modal_mask" ></div>');
		$('div.cookies_absolute_div').fadeIn('normal');
		$('html, body').addClass('CP_lock_screen');
	}
	$('.cookies_policy_icon').click(function(){
		$('div#cookies_policy_big_form').fadeIn('normal');
		$('div.cookies_policy_icon').before('<div class="cookies_absolute_div hide" id="modal_mask" ></div>');
		$('div.cookies_absolute_div').fadeIn('normal');
		$('html, body').addClass('CP_lock_screen');
		if( CP_show_cookie_notice == false ){
			$('div.cookies_absolute_div').click(function(){
				$(this).fadeOut('normal');
				$(this).remove();
				$('div#cookies_policy_big_form').fadeOut('normal');
				$('html, body').removeClass('CP_lock_screen');
			})
		}
	})
	if( rlConfig['template_type'] == 'responsive_42' ) {
		enquire.register("screen and (max-width: 767px)", {
			match: function(){
				$(window).resize(function(){
					var box_height = $('div#cookies_policy_big_form').height()/2;
					var move_from_top = $(window).height()/2-box_height;
					$('div#cookies_policy_big_form').css({'top': move_from_top, 'bottom': 'auto'});
				})
			}
		}).register("screen and (min-width: 768px)", {
			match: function(){
				$('div#cookies_policy_big_form').css({'top': 'auto', 'bottom': '15px'});
			}
		})
	}
})

$('input.cookie_accept').click(function(){
	CP_setCookie('cookies_policy', true, 365);
	$('div.cookies_absolute_div').fadeOut('normal', function() { $(this).remove() } );
	$('div#cookies_policy_big_form').fadeOut('normal', function() { $(this).remove() } );
	$('html, body').removeClass('CP_lock_screen');
})

$('input.cookie_decline').click(function(){
	CP_clearListCookies();
})

if( CP_show_cookie_notice == false ){
	$('div.cookies_absolute_div').click(function(){
		$(this).fadeOut('normal');
		$(this).remove();
		$('div#cookies_policy_big_form').fadeOut('normal');
	})
}

function CP_setCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ";expires="+exdate.toUTCString()+";path=/";
	document.cookie=c_name + "=" + c_value;
}

/* remove all cookies */
function CP_clearListCookies(){
	var cookies = document.cookie.split(";");

	for ( var i = 0; i < cookies.length; i++ ){
		var spcook =  cookies[i].split("=");
		document.cookie = spcook[0] + "='';expires=Thu, 21 Sep 1979 00:00:01 UTC;path=/";                                
	}
	window.location.href = CP_redirect_url;
}
