var langueForFlash = $('html').attr('lang');
var isInGame = false;

	var confirm_Statut = '';
	var confirm_up = '';
	var confirm_uma = '';

$(document).ready(function(){

	
	/*UPDATE BROWSER IF IE6 ou IE5.5 et IE7*/
	if (($.browser.name == 'msie') && ($.browser.versionNumber < 8)) {
		$('#body').after('<div id="UpdateIE"><a href="javascript:void(0)" id="CloseUpdateIE"><strong>Fermer [x]</b></strong><br /><a href="http://www.microsoft.com/windows/Internet-explorer/worldwide-sites.aspx"><img src="'+URL_STATICS+'images/ie8_logo.gif" alt="Telechargez IE8" /><br /><br /><strong>Pour profiter pleinement de l\'exp&eacute;rience REN, T&eacute;l&eacute;charger la derniere version d\'Internet Explorer ici</strong></div></a>');
		$('#UpdateIE').slideDown("slow");
		
		$("#CloseUpdateIE").click(function(){
			$('#UpdateIE').slideUp("slow");
		});
	}
	/*UPDATE BROWSER IF FIREFOX < 3*/
	if (($.browser.name == 'firefox') && ($.browser.versionNumber < 3)) {
		$('#body').after('<div id="UpdateIE"><a href="javascript:void(0)" id="CloseUpdateIE"><strong>Fermer [x]</b></strong><br /><a href="http://www.mozilla-europe.org/fr/firefox/"><img src="'+URL_STATICS+'images/firefox.gif" alt="Telechargez FIREFOX 3" /><br /><br /><strong>Pour profiter pleinement de l\'exp&eacute;rience REN, T&eacute;l&eacute;charger la derniere version de votre navigateur ici</strong></div></a>');
		$('#UpdateIE').slideDown("slow");
		$("#CloseUpdateIE").click(function(){
			$('#UpdateIE').slideUp("slow");
		});
	}
	// PAGINATION PERSO
	if ($("p.pagination").length > 0){
	var NbNumPage = ($("p.pagination > a").size())+1;
	var WidthPagination = NbNumPage*26;
	$("p.pagination").css('width', WidthPagination)
	}
	
	/// COOKIE SCROLL Plugin jquery.cookie.js
	if ($.cookie('sroll') == null){$("html").scrollTop(0)}else{$("html").scrollTop($.cookie('sroll'))}
	$("a").click(function()
	{
		$.cookie('sroll', $("html").scrollTop(), { expires: 1, path: '/', domain: URL_DOMAIN2, secure: false });
	});
	
	//VAR COOKIES POUR CREA PERSO
	if ($.cookie('pseudo')){var PseudoCookie = $.cookie('pseudo');}else{var PseudoCookie = 'Pseudo';}
	if ($.cookie('people')){var PeopleCookie = $.cookie('people');}else{var PeopleCookie = null;}
	if ($.cookie('sexe')){var SexeCookie = $.cookie('sexe');}else{var SexeCookie = null;}
	if ($.cookie('body')){var BodyCookie = $.cookie('body');}else{var BodyCookie = null;}
	if ($.cookie('head')){var HeadCookie = $.cookie('head');}else{var HeadCookie = null;}
	if ($.cookie('eyes')){var EyesCookie = $.cookie('eyes');}else{var EyesCookie = null;}
	if ($.cookie('hair')){var HairCookie = $.cookie('hair');}else{var HairCookie = null;}
	if ($.cookie('symetrie')){var SymetrieCookie = $.cookie('symetrie');}else{var SymetrieCookie = null;}
	if ($.cookie('hairColor')){var HairColorCookie = $.cookie('hairColor');}else{var HairColorCookie = null;}
	if ($.cookie('ptsNord')){var ptsNordCookie = $.cookie('ptsNord');}else{var ptsNordCookie = null;}
	if ($.cookie('ptsSud')){var ptsSudCookie = $.cookie('ptsSud');}else{var ptsSudCookie = null;}
	if ($.cookie('ptsEst')){var ptsEstCookie = $.cookie('ptsEst');}else{var ptsEstCookie = null;}
	if ($.cookie('ptsOuest')){var ptsOuestCookie = $.cookie('ptsOuest');}else{var ptsOuestCookie = null;}

     	//DELETEUSER COMMAND
	$('.AnimDeleteUser').media({
    width:     10,
    height:    10,
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/DeleteUser.swf',
    attrs:     {id: 'AnimDeleteUser', wmode: 'transparent' },  // object/embed attrs
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs
    caption:   false // supress caption text
	});
     	//PARRAIN COMMAND
	$('.AnimParrainCommand').media({
    width:     10,
    height:    10,
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/ParrainCommand.swf',
    attrs:     {id: 'AnimParrainCommand', wmode: 'transparent' },  // object/embed attrs
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs
    caption:   false // supress caption text
	});
     	//TOURNOI COMMAND
	$('.AnimTournoiCommand').media({
    width:     10,
    height:    10,
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/TournoiCommand.swf',
    attrs:     {id: 'AnimTournoiCommand', wmode: 'transparent' },  // object/embed attrs
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs
    caption:   false // supress caption text
	});
	//EDITEUR MINI
	$('.AnimCreateAccount').media({ 
    width:     10, 
    height:    10, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/CreateUser.swf', 
    attrs:     {id: 'AnimCreateAccount', wmode: 'transparent' },  // object/embed attrs
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs 
    caption:   false // supress caption text 
	}); 	
	
		//COMMANDES DE GUILDE
	$('#AnimGuildCommand').media({ 
    width:     10, 
    height:    10, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/GuildCommand.swf', 
    attrs:     {id: 'AnimGuildCommand', wmode: 'transparent' },  // object/embed attrs
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs 
    caption:   false // supress caption text 
	});

        	//COMMANDES DE BOUTIQUE
	$('#AnimBoutiqueCommand').media({
    width:     10,
    height:    10,
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/StoreCommand.swf',
    attrs:     {id: 'AnimBoutiqueCommand', wmode: 'transparent' },  // object/embed attrs
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs
    caption:   false // supress caption text 
	});
	
	//COMMANDES DE MARCHE
	$('#AnimMarketCommand').media({ 
    width:     10, 
    height:    10, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/MarketCommand.swf', 
    attrs:     {id: 'AnimMarketCommand', wmode: 'transparent' },  // object/embed attrs
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs 
    caption:   false // supress caption text 
	}); 	
		
	//BASES DU JEU ANIM CREA CARTE
	$('.flashAnimBasesDuJeu').media({ 
    width:    547, 
    height:    488, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/EditorGuide.swf', 
    attrs:     {id: 'AnimBaseCreaCarte', wmode: 'transparent', flashvars: 'lang='+langueForFlash },  // object/embed attrs
	flashvars:     {lang: langueForFlash},
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs 
    caption:   false // supress caption text 
	});
	
	//BANNIERE HEADER
	$('.BanniereHeaderLog').media({
	width:    "100%",
    height:    471, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/BannierePerso.swf', 
    attrs:     {id: 'BanniereHeader', wmode: 'transparent' },  // object/embed attrs 
	flashvars:     {lang: langueForFlash},
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs 
    caption:   false // supress caption text 
	});
	//BANNIERE HEADER
	$('.BanniereHeader').media({
	width:    "100%",
    height:    471, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/Banniere.swf', 
    attrs:     {id: 'BanniereHeader', wmode: 'transparent' },  // object/embed attrs 
	flashvars:     {lang: langueForFlash},
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs 
    caption:   false // supress caption text 
	});
	
	//BANNIERE INSCRIPTION
	$('.BanniereInscription').media({ 
    width:    810, 
    height:    173, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/BanniereInscrip.swf', 
    attrs:     {id: 'BanniereInscription', wmode: 'transparent' },  // object/embed attrs 
	flashvars:     {pseudo: PseudoCookie, people: PeopleCookie, sexe: SexeCookie, body: BodyCookie, head: HeadCookie, eyes: EyesCookie, hair: HairCookie, hairColor: HairColorCookie, symetrie: SymetrieCookie, lang: langueForFlash, ptsNord: ptsNordCookie, ptsSud: ptsSudCookie, ptsEst: ptsEstCookie, ptsOuest: ptsOuestCookie},
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs 
    caption:   false // supress caption text 
	});
	
	//LOADER R
	$('.LoaderR').media({ 
    width:    60, 
    height:    60, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/LoaderR.swf', 
    attrs:     {id: 'LoaderR', wmode: 'transparent' },  // object/embed attrs 
	//flashvars:     {pseudo: PseudoCookie, people: PeopleCookie, sexe: SexeCookie, body: BodyCookie, head: HeadCookie, eyes: EyesCookie, hair: HairCookie, hairColor: HairColorCookie, symetrie: SymetrieCookie, lang: langueForFlash, ptsNord: ptsNordCookie, ptsSud: ptsSudCookie, ptsEst: ptsEstCookie, ptsOuest: ptsOuestCookie},
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, // object params/embed attrs 
    caption:   false // supress caption text 
	});
	
	//EDITEUR
	$('.flashAnimCreaPerso').media({ 
    width:     810, 
    height:    530, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/CharacterEditor.swf', 
    attrs:     {id: 'creaPerso', wmode: 'transparent' },  // object/embed attrs 
	flashvars:     {pseudo: PseudoCookie, people: PeopleCookie, sexe: SexeCookie, body: BodyCookie, head: HeadCookie, eyes: EyesCookie, hair: HairCookie, hairColor: HairColorCookie, symetrie: SymetrieCookie, lang: langueForFlash},
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, 
    caption:   false // supress caption text 
	});
	
	//EDITEUR MINI
	$('.flashAnimCreaPersoMini').media({ 
    width:     200, 
    height:    403, 
    autoplay:  true,
	bgColor:   'transparent',
    src:       URL_STATICS+'flash/MiniCharacterEditor.swf', 
    attrs:     {id: 'creaPersoMini', wmode: 'transparent' }, 
	flashvars:     {pseudo: PseudoCookie, people: PeopleCookie, sexe: SexeCookie, body: BodyCookie, head: HeadCookie, eyes: EyesCookie, hair: HairCookie, hairColor: HairColorCookie, lang: langueForFlash},
    params:    { wmode: 'transparent', allowScriptAccess: 'always' }, 
    caption:   false // supress caption text 
	}); 
	

	
	/// FORMULAIRE LOGIN
	$("#submitConnexion").click(function() 
	{
		$("#f_login_err_global").empty();
		$("#f_login_err_global").append("<img src='"+URL_STATICS+"/images/site/mon_compte/loader.gif' alt='Loader' />");
		resultat = $('#f_login').serializeArray();	

		$.ajax({
			dataType:'jsonp',
			url: URL_SECU+$('html').attr('lang')+'/user',
			data: resultat,
			success:function(response) {
				if(response.auth_status == 'valide_ok'){
					$("#f_login_err_global").remove();
					$("#connexion").css("display","none");
					//window.location.reload();
					window.location.href=JS_URL_REDIRECTONCONNEXION;
				}else if(response.auth_status == 'valide_no'){
					$("#f_login_err_global img").remove();
					FORM_VALIDATOR_f_login.CleanForm();
					//PopMyMsg('POP_ERROR',response.titre,response.erreur,null, false);
					$("#f_login_err_global").append(response.erreur);
					$("#f_login_err_global").css("display","block");
				}else if(response.auth_status == 'invalid'){
					$("#f_login_err_global img").remove();
					FORM_VALIDATOR_f_login.UpdateForm(response);
				}
			}
		});
		;
		return false;
	});
	
	/// FORMULAIRE LOGIN XL
	
	$("#submitConnexion2").click(function() 
	{    
		resultat = $('#f_login_2').serializeArray();		
		$.ajax({
			dataType:'jsonp',
			url: URL_SECU+$('html').attr('lang')+'/userXl',
			data: resultat,
			success:function(response) {
				if(response.auth_status == 'valide_ok')
				{
					//PopMyMsg('POP_INFO',response.titre,response.erreur,function(){document.location.href=JS_URL_HOME;}, true);
                                        //document.location.href=JS_URL_HOME;
                                        window.location.href=JS_URL_REDIRECTONCONNEXION;
				}
				else if(response.auth_status == 'valide_no'){
					FORM_VALIDATOR_f_login.CleanForm();
					PopMyMsg('POP_ERROR',response.titre,response.erreur,null,false);
				}
				else if(response.auth_status == 'invalid')
				{
					FORM_VALIDATOR_f_login_2.UpdateForm(response);
				}
			}
		});
		return false;
	});
	
	// FORMULAIRE AJOUT USER
	$("#submitInscription").click(function(){
		

		if( !checkCGU() )
		{
			return;	
		}

		var CaptachaOrigin = $.cookie('captcha_response');
		var CaptchaRes=sha1(strtoupper(document.getElementById('uc').value));

		if (CaptachaOrigin==CaptchaRes){
		var pseudo = document.getElementById('up').value;
		var pwd = document.getElementById('upw').value;
		
		var resultat = $('#f_ajout_user').serializeArray();
		
		FORM_VALIDATOR_f_inscription.CleanForm( function( elem )
			{
				$(elem).parent().parent().removeClass('f_ajout_user_styleBlocActif');
				$(elem).parent().parent().addClass('f_ajout_user_styleBloc');
				$(elem).parent().parent().children(':last').prev().hide();
				$(elem).parent().parent().children(':last').hide();
			});
		$.ajax({
			dataType:'jsonp',
			url: URL_SECU+$('html').attr('lang')+'/inscription',
			data: resultat,
			success:function(response) {
				if(response.auth_status == 'valide_ok')
				{
      		$("#submitInscription").remove();
      		$("#InscriptionLoader").remove();
      		$("#DivPushInscription").append("<div id='InscriptionLoader' class='textaligncenter' style='margin-top:10px;'><img src='"+URL_STATICS+"/images/site/mon_compte/loader.gif' alt='Loader' /></div>");
      		
					$.cookie('pseudo', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('people', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('sexe', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('body', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('head', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('eyes', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('hair', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('hairColor', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('symetrie', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('ptsNord', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('ptsSud', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('ptsEst', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					$.cookie('ptsOuest', null, {expires: -1, path: '/', domain: URL_DOMAIN, secure: false });
					
					confirm_Statut = response.Statut;
					confirm_up = response.up;
					confirm_uma = response.uma;
					
					
					function thisMovie(movieName) {
						if (navigator.appName.indexOf('Microsoft') != -1) {
							return window[movieName];
						} else {
							return document[movieName];
						}
					 }
					 var Cible = thisMovie('AnimCreateAccount');

					//alert(response.Parrain);
					Cible.createUser(
							  response.up,
								response.uma,
								langueForFlash,
								response.us,
								response.ub,
								response.upa,
								response.upw,
								response.salt,
								response.ip,
								response.PeupleCard,
								response.SexeCard,
								response.BodyCard,
								response.HeadCard,
								response.EyesCard,
								response.HairCard,
								response.HairColorCard,
								response.PtsNCard,
								response.PtsSCard,
								response.PtsECard,
								response.PtsWCard,
								response.SymetrieCard,
								response.Statut,
                                                                $("#cuk").val(),
								response.Facebookid,
								response.Partnername,
                                                                response.Partnerid,
                                                                response.Parrain);
				}
				else if(response.auth_status == 'valide_no') 
				{
					FORM_VALIDATOR_f_inscription.CleanForm();
					PopMyMsg('POP_ERROR',response.titre,response.erreur,null,false);	
				}
				else if(response.auth_status == 'invalid')
				{
					FORM_VALIDATOR_f_inscription.UpdateForm(response,
						function( elem )
						{
							$(elem).parent().parent().removeClass('f_ajout_user_styleBloc');
							$(elem).parent().parent().addClass('f_ajout_user_styleBlocActif');
							$(elem).parent().parent().children(':last').prev().show();
							$(elem).parent().parent().children(':last').show();
						},
						null);
						$("#f_ajout_user").removeClass("f_ajout_user_styleBlocActif");
				}
				else if(response.auth_status == 'already_exist')
				{
					FORM_VALIDATOR_f_inscription.UpdateForm(response,
						function( elem )
						{
							$(elem).parent().parent().removeClass('f_ajout_user_styleBloc');
							$(elem).parent().parent().addClass('f_ajout_user_styleBlocActif');
						},
						null);
					PopMyMsg('POP_ERROR',response.titre,response.erreur,null,false);
				}
				else if(response.auth_status == 'password_is_pseudo')
				{
					$('#upw').addClass('pwd_error_pseudo_is_pwd');
					//PopMyMsg('POP_ERROR',response.titre,response.erreur,null,false);
                                        if(langueForFlash=="fr"){var TitreErreur="Erreur"; var ContenuErreur="Le mot de passe ne doit pas être identique au pseudo";}
                                        else if (langueForFlash=="en"){var TitreErreur="Error"; var ContenuErreur="Le mot de passe ne doit pas être identique au pseudo";}
                                        else if (langueForFlash=="es"){var TitreErreur="Error"; var ContenuErreur="Le mot de passe ne doit pas être identique au pseudo";}
                                        else if (langueForFlash=="de"){var TitreErreur="Error"; var ContenuErreur="Le mot de passe ne doit pas être identique au pseudo";}
                                        PopMyMsg('POP_ERROR',TitreErreur,ContenuErreur,null,false);
				}
			}
		});
		
		return false;
		
		}else{
			if(langueForFlash=="fr"){var TitreCaptcha="Captcha"; var ContenuCaptcha="Le code saisie ne correspond pas &agrave; l\'image";}
			else if (langueForFlash=="en"){var TitreCaptcha="Captcha"; var ContenuCaptcha="Entered code does not correspond to picture";}
			else if (langueForFlash=="es"){var TitreCaptcha="Captcha"; var ContenuCaptcha="El codigo introducido no corresponde a la imagen";}
			else if (langueForFlash=="de"){var TitreCaptcha="Captcha"; var ContenuCaptcha="Der eingef&uuml;hrte Kode entspricht dem Bild nicht";}
			PopMyMsg('POP_ERROR',TitreCaptcha,ContenuCaptcha,null,false);
		}
		
		
	});
	
	function VerifDispo()
		{
			if (document.f_ajout_user.up.value.length >= 3)
			{
				var pseudo = 'up='+document.f_ajout_user.up.value;
				$.ajax({
					dataType:'jsonp',
					url: URL_SECU+$('html').attr('lang')+'/user_access',
					data: pseudo,
					success:function(response){
						if (response.callback_status == 'ok'){
							$('input#up').css('background','#FFFFFF');
							$('span#f_ajout_user_err_pseudo').html('* DISPO');
						}else if (response.callback_status == 'bad'){
							$('input#up').css('background','#B9121B');
							$('span#f_ajout_user_err_pseudo').html('* BAD');
						}
					}
				});
			}
			else{
				$('input#up').css('background','#FFFFFF');
				$('span#f_ajout_user_err_pseudo').html('*');
			}
		}
			
		
		
});

function gotoURL ( url )
{
    document.location.href = url;
}

function addLoaderAnimation ( jqueryselector )
{ 
$( jqueryselector ).empty();
$( jqueryselector ).append("<img src='"+URL_STATICS+"/images/site/mon_compte/loader.gif' alt='Loader' />");
}

function removeLoaderAnimation( jqueryselector )
{	
$( jqueryselector + " img" ).remove();
}

function SWF_AuthentificationFailed ()
{
window.location = window.location.href;
}

function SWF_NoConnexion ()
{
window.location = window.location.href;
}

function SWF_ConnexionLost ()
{
window.location = window.location.href;
}

function SWF_Home () 						
{
    if( isInGame )
    {
    ConfirmInGameBrowseTo( JS_URL_VESTIAIRE, confirm_ingame_title, confirm_ingame_message );
    }
    else
    {
    window.location = JS_URL_HOME;
    }
}

function SWF_ReloadPage () 						
{
window.location = window.location.href;
}

function SWF_listTower () 						
{
window.location = JS_URL_JOUER;
}

function SWF_Deck () 						
{
window.location = JS_URL_DECK;
}

function SWF_Vestiaire () 						
{
    if( isInGame )
    {
    ConfirmInGameBrowseTo( JS_URL_VESTIAIRE, confirm_ingame_title, confirm_ingame_message );
    }
    else
    {
    window.location = JS_URL_VESTIAIRE;
    }
}

function SWF_Guilde () 						
{
    if( isInGame )
    {
    ConfirmInGameBrowseTo( JS_URL_DOJO, confirm_ingame_title, confirm_ingame_message );
    }
    else
    {
    window.location = JS_URL_GUILDE;
    }
}

function SWF_AutreGuilde (guildName) 						
{
window.location = JS_URL_AUTRE_GUILDE(guildName);
}

function SWF_GuildeAvantages () 						
{
    if( isInGame )
    {
    ConfirmInGameBrowseTo( JS_URL_DOJO, confirm_ingame_title, confirm_ingame_message );
    }
    else
    {
    window.location = JS_URL_GUILDE_AVANTAGES;
    }
}

function SWF_Dojo () 						
{
    if( isInGame )
    {
    ConfirmInGameBrowseTo( JS_URL_DOJO, confirm_ingame_title, confirm_ingame_message );
    }
    else
    {
    window.location = JS_URL_DOJO;
    }
}

function SWF_InventoryDojo ()
{
    window.location = JS_URL_DOJO_INVENTORY;
}

function SWF_UseInventoryDojo (type)
{
    window.location = JS_URL_DOJO_INVENTORY_USE (type);
}

function SWF_AutreDojo (pseudo) 						
{
window.location = JS_URL_AUTRE_DOJO(pseudo);
}

function SWF_reGame ()
{
window.location = window.location.href;
}

function SWF_ShopCard ()
{
window.location = JS_URL_SHOP_CARD;
}

function SWF_ShopItem ()
{
window.location = JS_URL_SHOP_ITEM;
}

function SWF_Credits ()
{
window.location = JS_URL_CREDITS;
}

function SWF_InGame ( is )
{
isInGame = is;
}

function InGameBrowseTo( link )
{
    window.location = link;
}

function ConfirmInGameBrowseTo ( link, title, message )
{
        PopMyMsg('POP_VALIDATION',
        title, message,
        function(){ InGameBrowseTo(link) }, true);
}

var version=0;
function checkVersion(version_h, version_l)
{
    version=version_h+"."+version_l;
}

// For MouseWheel

var flashWithScroll = new Array("AnimDECK", "AnimGEDITOR", "AnimVES", "AnimGPOS", "AnimGMAN", "AnimSCROLLINV", "AnimGAMP", "AnimGAM");

$(document).ready(function()
{
    $(window).mousewheel(function(event, delta)
    {
        var elem = event.target;
        if (elem.nodeName.toLowerCase() == "object" || elem.nodeName.toLowerCase() == "embed")
        {
            if (elem.getAttribute("type") == "application/x-shockwave-flash")
            {
                for(i = 0; i < flashWithScroll.length; i++)
                {
                    if(elem.id == flashWithScroll[i])
                    {
                        event.preventDefault();
                        var cible = thisMovie(elem.id);
                        var offset = $(cible).offset();
                        cible.handleWheel(event.pageX - offset.left, event.pageY - offset.top, delta);
                    }
                }
            }
        }

    });
});

function thisMovie(movieName)
{

	if (navigator.appName.indexOf('Microsoft') != -1)
	{
		return window[movieName];
	}
	else
	{
		return document[movieName];
	}

}