function fixIE6ImageFlicker(){
try {
 document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}
}

function getCookie(A){var F=document.cookie.split(";");var B="";var D="";var E="";var C=false;for(i=0;i<F.length;i++){B=F[i].split("=");D=B[0].replace(/^\s+|\s+$/g,"");if(D==A){C=true;if(B.length>1){E=unescape(B[1].replace(/^\s+|\s+$/g,""))}return E;break}B=null;D=""}if(!C){return null}};

function setCookie(C,E,A,H,D,G){var B=new Date();B.setTime(B.getTime());if(A){A=A*1000*60*60*24}var F=new Date(B.getTime()+(A));document.cookie=C+"="+escape(E)+((A)?";expires="+F.toGMTString():"")+((H)?";path="+H:"")+((D)?";domain="+D:"")+((G)?";secure":"")};

function clearCookie(name)
{
  var ThreeDays = 3 * 24 * 60 * 60 * 1000;
  var expDate = new Date();
  expDate.setTime (expDate.getTime() - ThreeDays);
  document.cookie = name + "=ImOutOfHere; expires="+ expDate.toGMTString();
}


function mCookie(name,value){
	setCookie(name,value,365,'/','.mazzogaming.com',''); 
}

var isMember = (getCookie('userStatus') == 'member') ? 1 : 0 ;
var mazzoLobbyWindow=null;

$(document).ready(function(){
fixIE6ImageFlicker();

$('.login').click(function(){loginNow();});

$('.inlineContentInnerPageSubNav').each(function(){
var contentDivs = $(this).find('.innerPageSubNav-Content > div');
var navLinks = $(this).find('.innerPageSubNav-Nav a');
contentDivs.hide().eq(0).show();
navLinks.click(function(){
var thisHref = $(this).attr('href');
contentDivs.hide();
$(thisHref).show();
$(this).parent().addClass('active').siblings().removeClass('active');
return false;
});
navLinks.eq(0).parent().addClass('active');
});


// begin dIFR config //
textToImage('.TrajanProBold18White', ['colour:ffffff','font:TrajanProB','size:18']);
textToImage('.TrajanProBold25White', ['colour:ffffff','font:TrajanProB','size:25']);
textToImage('.TrajanProBold32White', ['colour:ffffff','font:TrajanProB','size:32']);
textToImage('.TrajanProBold18DarkGold', ['colour:382806','font:TrajanProB','size:18']);
textToImage('.TrajanProBold23DarkGold', ['colour:382806','font:TrajanProB','size:23']);
textToImage('.TrajanProBold14Brown', ['colour:614924','font:TrajanProB','size:14']);
textToImage('.TrajanProBold30Brown', ['colour:614924','font:TrajanProB','size:30']);
// end dIFR config //


// begin CasinoGameChooser
			$("#casinoGameChooserList>li>a").click(function(){$('.casinoTypeGameList').removeClass('active');  $('#gameScrollPaneInner-ul').html($(this).parent().addClass('active').find(".casinoGameChooserList-ul-li-ul").eq(0).html()); 
return false;});
			$("#casinoGameChooserList").children().eq(0).addClass('active');
			$('.casinoGameChooserList-ul-li-ul').hide();
			$('#gameScrollPaneInner-ul').html($(".casinoGameChooserList-ul-li-ul").eq(0).html());
			
			$(".casinoGameChooserList-ul-li-a").click(function(){
				if(!$.boxModel){						   
					$('#gameScrollPaneInner-ul').html($(this).next().html());

				}else{
					$('#gameScrollPaneInner-ul').html($(this).next().html()).parent().css({overflow:'auto'});
				}
				return false;
			});



//end casinoGameChooser

});

function loginNow(type){
var member_server = "https://secure.mazzogaming.com/";
var popup_properties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=947,height=634';

if(!mazzoLobbyWindow || mazzoLobbyWindow.closed ){

if(!type){ var type="poker" }
	if (type=="poker"){
		mazzoLobbyWindow = window.open(member_server+"Poker.aspx"+"?mazzoLogin=1",'mazzoLobby',popup_properties);
	}
	if (type=="casino"){
		mazzoLobbyWindow = window.open(member_server+"en/Casino.aspx"+"?mazzoLogin=1",'mazzoLobby',popup_properties);
	}
	if (type=="bingo"){
		mazzoLobbyWindow = window.open(member_server+"en/Bingo.aspx"+"?mazzoLogin=1",'mazzoLobby',popup_properties);
	}
	if (type=="sports" || type=="betting"){
		mazzoLobbyWindow = window.open(member_server+"en/Sportsbetting.aspx"+"?mazzoLogin=1",'mazzoLobby',popup_properties);
	}


}else{

mazzoLobbyWindow.focus();

}

}


function playNow(type){
	if(isMember){
		loginNow(type);
	} else {
		var signUpUrl="/sign-up.html";
		if(!type){ var type="poker" }
			if (type=="poker"){
				location.href=signUpUrl+"?poker=1";
			}else if(type=="sports" || type=="betting"){
				location.href=signUpUrl+"?betting=1";
			}else if(type=="casino"){
				location.href=signUpUrl+"?casino=1";
			}else if(type=="bingo"){
				//location.href=signUpUrl+"?bingo=1";
				tb_show('', '/images/online-bingo/bingo-coming-soon.jpg', '')
			}
	}
}


function openGame(gamename,fullscreen,playmoney){
playNow('casino');
}

function ne_openGame(gamename,fullscreen,playmoney){
	if(!fullscreen){fullscreen=false;}
	if(!playmoney){playmoney=false;}
var mazzoLogin = (playmoney==false) ? 1 : 0 ;
	var popup_properties;
	var member_server = "https://secure.mazzogaming.com/";
	if(fullscreen==true){
		popup_properties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,type=fullWindow,fullscreen,scrollbars=yes';
		window.open(member_server+"Casino/Casino-GamePlay-Fullscreen.aspx?GameName="+gamename+"&mazzoLogin="+mazzoLogin, 'mzW_'+gamename ,popup_properties);
	}else{
		popup_properties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=947,height=634';
		window.open(member_server+"Casino/Advantage-Play.aspx?GameName="+gamename+"&mazzoLogin="+mazzoLogin,'mzW_'+gamename,popup_properties);
	}
}

function ww_openGame(gamename,playmoney){
	if(!playmoney){playmoney=false;}
var mazzoLogin = (playmoney==false) ? 1 : 0 ;
	var popup_properties;
	var member_server = "https://secure.mazzogaming.com/";

		popup_properties = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=947,height=634';
		window.open(member_server+"Casino/Premium-Play.aspx?GameName="+gamename+"&mazzoLogin="+mazzoLogin ,'mzW_'+gamename,popup_properties);

}
function bingo_openGame(gamename,playmoney){
playNow('bingo');
}

function casinoGameChooserGameLink(gamename,casinoname,casinotype){
$('.casinoGameChooserFeatLink').unbind('click');
$('.casinoGameChooserFeatLink').click(function(){
if(casinotype=='ne'){ ne_openGame(casinoname); }
else { ww_openGame(casinoname); }
return false;
});

$('#casinoGameChooserFeatImg').attr('src','/images/online-casino/games/features/'+casinotype+'/'+gamename+'.jpg');
}
