
var params = {
	wmode: "window",
	menu: "false",
	play: "true" ,
	loop: "true",
	scale: "noscale",
	devicefont: "false" ,
	salign: "tl"
};
var attributes = {};




Cufon.replace('body.blastzone .game-box h2, body.blastzone .fb-box h2', { fontFamily: 'Stencil', color:'#ffe8c8' });

//Png Fix
	if ( $.browser.msie && $.browser.version.substr(0,1) == 6 ) {
			DD_belatedPNG.fix('h1#logo a, .tip img, #top-bar, #top-bar .fld, #top-bar .btnp input, .logo-stripe a.reg, .logo-stripe .user-fld, .logo-stripe .pass-fld,  .slider-frame, .game-box .top, .game-box .rep, .game-box .btm,  .game-box h2 a span, .game-box h2 a small, .game-box h2 a.hov span, #sidebar .leaderboard,  #sidebar .banner-holder, .fb-box .top,  .fb-box .btm, .fb-box .rep, #footer a.ftr-logo, .jcarousel-control a img, .jcarousel-next-horizontal, .jcarousel-prev-horizontal, .game-box .image img , .game-box .image .normal-state, #top-bar .cnt, #top-bar .cnt .holder h2.logo a, p.server-info, .logo-stripe a.play-game, .game-box .shop li , .game-box .shop li span img, .rules img, .game-box .shop li img, #large-cnt .top, #large-cnt .rep, #large-cnt .btm');
	}


jQuery(document).ready(function()
{
	jQuery('#mycarousel').jcarousel({
        scroll:1,
        wrap:"both",
		visible: 1,
		itemFallbackDimension: 963,
        initCallback: mycarousel_initCallback,
        animation:"slow",
        itemFirstInCallback: text_first,
        auto: 4
    });
	if(!FlashDetect.installed){
            $('.games-alternative-cnt').show();
        }

	bgLoad();

    //Tooltips
	var tip =null;
	$(".tip_trigger").hover(function(){

		//Caching the tooltip and removing it from container; then appending it to the body
		tip = $(this).find('.tip').remove();
		$('body').append(tip);

		tip.show(); //Show tooltip

	}, function() {

		tip.hide().remove(); //Hide and remove tooltip appended to the body
		$(this).append(tip); //Return the tooltip to its original position

	}).mousemove(function(e) {
	//console.log(e.pageX)
		if ( tip == null ) return;

		  var mousex = e.pageX + 20; //Get X coodrinates
		  var mousey = e.pageY + 20; //Get Y coordinates
		  var tipWidth = tip.width(); //Find width of tooltip
		  var tipHeight = tip.height(); //Find height of tooltip

		 //Distance of element from the right edge of viewport
		  var tipVisX = $(window).width() - (mousex + tipWidth);
		  var tipVisY = $(window).height() - (mousey + tipHeight);

		if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - tipWidth - 20;
			$(this).find('.tip').css({  top: mousey, left: mousex });
		} if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - tipHeight - 20;
			tip.css({  top: mousey, left: mousex });
		} else {
			tip.css({  top: mousey, left: mousex });
		}
	});
/* display all news*/

$('.news-bulletin a.display-all').click(
	function(){ $(this).fadeOut();  $('.other-news').slideDown(); $('.hide-all').fadeIn(); return false;}
);

$('.news-bulletin a.hide-all').click(
	function(){ $(this).fadeOut();  $('.other-news').slideUp(); $('.display-all').fadeIn(); return false;}
);

$('.game-box .shop li.linked').click(
	function(){ $(this).hide();  $(this).parent().parent().find('.hidden').show(); $('.hide-items').fadeIn(); return false;}
);

$('.game-box .shop li.hide-items').click(
	function(){ $(this).hide();  $(this).parent().parent().find('.hidden').hide(); $('.linked').fadeIn(); return false;}
);

$('a.view-full').click(
	function(){ $(this).fadeOut();  $('.full').show(); $('.hide-full').fadeIn(); return false;}
);

$('a.hide-full').click(
	function(){ $(this).hide();  $('.full').hide(); $('.view-full').fadeIn();  return false;}
);



/* display all news*/

	jQuery('#screenshot-carousel').jcarousel({
        scroll:4,
        wrap:"both",
        visible: 4,
        animation:"slow",
        itemFallbackDimension: 139
    });


	$('#mycarousel li').hover(
		function(){$(this).find('.slide').fadeIn('slow');
		 if ( $.browser.msie && $.browser.version.substr(0,1) == 6 ) {
				DD_belatedPNG.fix('#mycarousel li .slide');
			}
	},
		function(){ $(this).find('.slide').fadeOut('slow');}
	);

	$('.game-box h2 a ').hover(
		function(){$(this).addClass('hov'); $(this).find('small').show();
	},
		function(){$(this).removeClass('hov');  $(this).find('small').hide();}
	);

	$('.screens a').lightBox();


	$('.jcarousel-prev').hover(
		function(){ $(this).css('background','url(/templates/blue/css/images/prev-hover.png)')},
		function(){ $(this).css('background','url(/templates/blue/css/images/prev.png)')}
	);
	$('.jcarousel-next').hover(
		function(){ $(this).css('background','url(/templates/blue/css/images/next-hover.png)')},
		function(){ $(this).css('background','url(/templates/blue/css/images/next.png)')}
	);

	$('.jcarousel-skin-screen .jcarousel-prev').hover(
		function(){ $(this).css('background','url(/templates/blue/css/images/l-arr-hov.png)')},
		function(){ $(this).css('background','url(/templates/blue/css/images/l-arr.png)')}
	);
	$('.jcarousel-skin-screen .jcarousel-next').hover(
		function(){ $(this).css('background','url(/templates/blue/css/images/arrow-hov.png)')},
		function(){ $(this).css('background','url(/templates/blue/css/images/arrow.png)')}
	);

	$('.jcarousel-skin-shop .jcarousel-prev').hover(
		function(){ $(this).css('background','url(/templates/blue/css/images/l-arr-hov.png)')},
		function(){ $(this).css('background','url(/templates/blue/css/images/l-arr.png)')}
	);
	$('.jcarousel-skin-shop .jcarousel-next').hover(
		function(){ $(this).css('background','url(/templates/blue/css/images/arrow-hov.png)')},
		function(){ $(this).css('background','url(/templates/blue/css/images/arrow.png)')}
	);

	$('.game-box .image a').hover(
		function(){ $(this).addClass('hover-state'); $(this).removeClass('normal-state');},
		function(){ $(this).addClass('normal-state'); $(this).removeClass('hover-state');}
	);

	$('a.support').hover(
		function(){ $(this).find('.hov').removeClass('hidden');  $(this).find('.normal').addClass('hidden'); },
		function(){ $(this).find('.normal').removeClass('hidden');  $(this).find('.hov').addClass('hidden'); }
	);

	$('.logo-stripe a.reg').hover(
		function(){ $(this).addClass('reg-hov'); $(this).removeClass('reg');},
		function(){ $(this).removeClass('reg-hov'); $(this).addClass('reg');}
	);
	$('.logo-stripe a').hover(
		function(){$(this).find('.hover').removeClass('hidden'); $(this).find('.normal').addClass('hidden');},
		function(){$(this).find('.normal').removeClass('hidden'); $(this).find('.hover').addClass('hidden');}
	);

	/*if (!$('body').hasClass('blastzone')) {
	$('.logo-stripe a.bg').hover(
		function(){$(this).css('background-image','url(/templates/blue/css/images/main-play-bg-hover.png)')},
		function(){$(this).css('background-image','url(/templates/blue/css/images/main-play-bg.png)')}
	);}*/

/*************** Tooltips ******************/



$("#top-bar select").selectbox().bind('change',function(){
    game = $(this).val()
    if(game != "more")
      window.location = 'http://' + document.domain + '/' + currentLang+'/preview/'+game;
  });

});

function mycarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('name')));
        $('.jcarousel-control').children().removeClass('active');
        $(this).addClass('active');
        return false;
    });
};

function text_first(carousel, item, idx, state) {
 	var i = idx - 1;
 	$('.jcarousel-control a').removeClass('active');
 	$('.jcarousel-control a').eq(i).addClass('active');
};


/************ Flash Sync **********/
function bgLoad(){
	$(window).load(function() {
		if ($('body').hasClass('original')) {
			swfobject.embedSWF("/templates/blue/flash/shark.swf", "bubbles-top", "329", "245", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#bubbles-top"}, params, attributes);
		};
  		if ($('body').hasClass('original')) {
  			//swfobject.embedSWF("/templates/blue/flash/smoke.swf", "smoke", "39", "89", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#smoke"}, params, attributes);
  		};

  		if ($('body').hasClass('belot')) {
  			//swfobject.embedSWF("/templates/blue/flash/belot_smoke.swf", "cigarette", "49", "129", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#cigarette"}, params, attributes);
  		};
  		if ($('body').hasClass('original')) {
  			swfobject.embedSWF("/templates/blue/flash/top-left-bubbles.swf", "bubbles-top-left", "50", "264", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#bubbles-top-left"}, params, attributes);
  		};

		/*Blastzone Flash*/
		if ($('body').hasClass('blastzone')) {
			swfobject.embedSWF("/templates/blue/flash/bz-fire-building.swf", "building-fire", "100", "110", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#building-fire"}, params, attributes);};
		if ($('body').hasClass('blastzone')) {
			swfobject.embedSWF("/templates/blue/flash/bz-tank-left.swf", "burning-tank", "50", "60", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#burning-tank"}, params, attributes);
		};
		/*if ($('body').hasClass('blastzone')) {
			swfobject.embedSWF("/templates/blue/flash/bz-fire-big.swf", "big-fire", "200", "74", "9.0.0","expressInstall.swf", flashvars, params, attributes);
		};*/
		if ($('body').hasClass('blastzone')) {
			swfobject.embedSWF("/templates/blue/flash/bz-dulo.swf", "duo-smoke", "64", "80", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#duo-smoke"}, params, attributes);
		};


		/*Blastzone Flash*/
		if ($('body').height() > 1588 && $('body').hasClass('original')){
		var h = $('body').height() ;
		$('#bubbles-btm-left').removeClass('hidden');
		swfobject.embedSWF("/templates/blue/flash/bottom-left.swf", "bubbles-btm-left", "50", "264", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#bubbles-btm-left"}, params, attributes);
	}

	if ($('body').height() > 1219 && $('body').hasClass('original')){
		var h = $('body').height();
		$('#bub-right').removeClass('hidden');
		swfobject.embedSWF("/templates/blue/flash/right-bubbles.swf", "bub-right", "50", "264", "9.0.0","/templates/blue/flash/expressInstall.swf", {id : "#bub-right"}, params, attributes);
	}

	swfobject.embedSWF("/templates/blue/flash/baner-logo.swf", "banner", "300", "250", "9.0.0","/templates/blue/flash/expressInstall.swf", {}, params, attributes);

	});
}

/*show flash*/

function showFlash(id, width, height){
	//alert(id + " " + width + " " + height);
	$(id).css('height', height);
	$(id).css('width', width);
}


$(function(){
    $.extend($.fn.disableTextSelect = function() {
        return this.each(function(){
            if($.browser.mozilla){//Firefox
                $(this).css('MozUserSelect','none');
            }else if($.browser.msie){//IE
                $(this).bind('selectstart',function(){return false;});
            }else{//Opera, etc.
                $(this).mousedown(function(){return false;});
            }
        });
    });
    $('.jcarousel-next-horizontal, .jcarousel-prev-horizontal').disableTextSelect();
});


/*$(window).load(function ( ) {
	if ($('body').hasClass('original')) {
	setTimeout(function() {
    $('#bubbles-top-left').css('height','245');
	$('#bubbles-top-left').css('width','49');
	}, 1500);}

	if ($('body').hasClass('original')) {
	setTimeout(function() {
    $('#bubbles-top').css('height','245');
	$('#bubbles-top').css('width','329');
	}, 1500);}

	/*setTimeout(function() {
    $('body.inner #bubbles-top').css('height','203');
	$('body.inner #bubbles-top').css('width','329');
	}, 1000);

	setTimeout(function() {
    $('#smoke').css('height','89');
	$('#smoke').css('width','39');
	}, 1500);

	if ($('body').hasClass('original')) {
	setTimeout(function() {
    $('#bub-right').css('height','245');
	$('#bub-right').css('width','49');
	}, 1500);}

	setTimeout(function() {
    $('#cigarette').css('height','129');
	$('#cigarette').css('width','49');
	}, 1500);

	setTimeout(function() {
    $('#building-fire').css('height','110');
	$('#building-fire').css('width','100');
	}, 1500);

	setTimeout(function() {
    $('#burning-tank').css('height','60');
	$('#burning-tank').css('width','50');
	}, 1500);

	/*setTimeout(function() {
    $('#big-fire').css('height','47');
	$('#big-fire').css('width','200');
	}, 1500);

	setTimeout(function() {
    $('#duo-smoke').css('height','80');
	$('#duo-smoke').css('width','64');
	}, 1500);

	setTimeout(function() {
    $('#mycarousel').css('height','255');
	$('#mycarousel').css('width','9000');
	}, 1500);

	setTimeout(function() {
    $('body.blastzone .game-box h2').css('text-indent','0');
    $('body.inner .fb-box h2').css('text-indent','0');
	}, 1000);


});*/
$(window).load(function ( ) {

 /*setTimeout(function() {
    $('#mycarousel').css('height','255');
 $('#mycarousel').css('width','9000');
 }, 1500);*/

 setTimeout(function() {
    $('body.blastzone .game-box h2').css('text-indent','0');
    $('body.inner .fb-box h2').css('text-indent','0');
 }, 1000);

});


$(window).resize(function() {
		if( $(window).width() < 1024 ) {
		$('#bubbles-top').css('height','0');
		$('#bubbles-top').css('width','0');
		$('#smoke').css('height','0');
		$('#smoke').css('width','0');
		$('#duo-smoke').css('height','0');
		$('#duo-smoke').css('width','0');
		$('#big-fire').css('height','0');
		$('#big-fire').css('width','0');
		$('#building-fire').css('height','0');
		$('#building-fire').css('width','0');
		$('#burning-tank').css('height','0');
		$('#burning-tank').css('width','0');
		}
		else if( $(window).width() > 1024){
			$('#smoke').css('height','89');
			$('#smoke').css('width','39');
			$('#bubbles-top').css('height','245');
			$('#bubbles-top').css('width','329');
			$('#burning-tank').css('height','60');
			$('#burning-tank').css('width','50');
			$('#building-fire').css('height','110');
			$('#building-fire').css('width','100');
			$('#duo-smoke').css('height','80');
			$('#duo-smoke').css('width','64');
		 	/*$('#big-fire').css('height','47');
			$('#big-fire').css('width','200');*/
		}
	});


