jQuery(document).ready(function(){
	heavyImage1 = new Image(); 
	heavyImage1.src = "http://www.erdembilisim.com/bosch-kampanya.jpg";
	$('#adBlockRow1 img').attr('src', heavyImage1.src);
	
	heavyImage2 = new Image(); 
	heavyImage2.src = "http://www.erdembilisim.com/bosch-kampanya.jpg";
	$('#adBlockRow1 img').attr('src', heavyImage2.src);
	
	var ad = getCookie('ad_disabled');
	if(isNaN(ad))
	{
		displayAd();
	} else
	{
		if(ad == 0)
			displayAd();
	}
});

displayAd = function()
{
	$('#adContainer').css('position', 'fixed');
	$('#adContainer').css('background', '#7e9fc2');
	$('#adContainer').css('width', '100%');
	$('#adContainer').css('height', '100%');
	$('#adContainer').css('display', 'block');
	$('#adContainer').css('z-index', '999');
	$('#adContainer').css('opacity', '0.6');
	$('#adContainer').css('filter', 'alpha(opacity=60)');
	$('#adBlock').css('display', 'block');
	
	$('body').css('overflow', 'hidden');
	
	var count = getCookie('ad_counter');
	if(isNaN(count))
		count = 0;
	count++;
	setCookie('ad_counter', count, 360);
	
	if(count > 3)
	{
		$('#adBlockRow2').css('display', 'block');
	}
}

visitEshop = function()
{
	//window.location = 'http://www.erdembilisim.com';
	window.location = 'http://www.erdembilisim.com';
}
showSite = function()
{
	$('#adContainer').css('display', 'none');
	$('#adBlock').css('display', 'none');
	$('body').css('overflow', 'auto');
}

disableAd = function(obj)
{
	setCookie('ad_disabled', ((obj.checked == true)?1:0), 360);
}

setCookie = function( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if (expires)
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

getCookie = function(c_name)
{
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	{
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x=x.replace(/^\s+|\s+$/g,"");
		if (x==c_name)
		{
			return unescape(y);
		}
	}
}
