<?php
include_once 'admobile.php';

include_once("configMobile.php3");
include_once($BIB_DIR."bib_generic.php3");
include_once $CORE_DIR_FROM_MOBILE.'InitApp.core.php';

/**************** ADMOB ****************/
admob_setcookie();

?>
<html>
    <head>
        <title>Kestufoot</title>
        <link rel="stylesheet" href="jqtouch/jqtouch/jqtouch.min.css">
        <link rel="stylesheet" href="jqtouch/themes/jqt/theme.css">
        <link rel="stylesheet" href="Styles/styles.css">

		<script src="jqtouch/jqtouch/jquery.1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="jqtouch/jqtouch/jqtouch.min.js" type="application/x-javascript" charset="utf-8"></script>
        <script src="jqtouch/extensions/jqt.floaty.js" type="application/x-javascript" charset="utf-8"></script>
        <script src="php.js" type="application/x-javascript" charset="utf-8"></script>
        <link rel="apple-touch-icon" href="Images/iconektf2.png">

        <style type="text/css" media="screen">
            .floaty {
                width: 100%;
                height: 50px;
                background: rgba(255,255,255,0.9);
				color:#000000;
            }

            .empty {
                width: 100%;
                height: 60px;
            }
			

        </style>

    <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-2107280-44']);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		
		
		$(function() {
        function showNavBar() {
			var win_y = $(window).height();
			var scroll_y = $(window).scrollTop();
			//$(".floaty").css({ top: scroll_y + 366 + "px" });
			$('.floaty').scrollFloaty();
        }
        var showTimer = false;
        function maybeShowNavBar(evt) {
			if ( showTimer ) {
				clearTimeout( showTimer );
			}
			showTimer = setTimeout( showNavBar, 175 );
        }
        $(window).bind( "scroll", maybeShowNavBar );
        $(document).bind('touchstart', function(){
			$('.floaty').hide();
        });
        $(document).bind('touchend', function(){
			setTimeout( function(){$('.floaty').fadeIn()}, 150 );
        });
      });


		
      })();
	  
	  

    </script>

        
        <script type="text/javascript">
			
            var jQT = $.jQTouch({
                statusBar: 'black'
            });

            $(function(){
                $('.floaty').makeFloaty({
                    spacing: window.innerHeight - 50,
                    time: '0s'
                });
            });

            function majFloaty (){
                //jQT.getOrientation()
                
				//$('.floaty').scrollFloaty();
            }

            function loginDisplay() {
                jQT.goTo('#forms', 'flip');
            }

            function monCompteDisplay() {
                jQT.goTo("#monCompte", 'slide');
            }

            function matchsDisplay() {
                jQT.goTo("#matchs", 'slide');
            }

            function menuDisplay() {
                jQT.goTo("#menu", 'slide');
            }

            function ssMenuDisplay() {
                jQT.goTo("#ssMenuMonCompte", 'slide');
            }
            
            function kestubug() {
                jQT.goTo("#kestubug", 'slide');
            }





            function onSubmit() {
                $.ajax({
                    type: "POST",
                    url: "<?php echo $LOGIN_CORE; ?>",
                    data: "login="+$("#login").val()+"&pwd="+md5("<?php echo $PASSWORD_SECRET_KEY?>"+$("#pwd").val())+"&versionmobile=<?php echo $versionmobile; ?>&sessid=<?php echo $sess->sessid; ?>",
                    success: function(data) {
                        
                        if (data == "ErrorAuth"){
                            $('#infoCompte').html("Erreur d'authentification");
                            $('#error_login').html("Identifiant et/ou mot de passe incorrect !");

                        }
                        else {
                            $('#error_login').html("");
                            $('#infoCompte').html(data);
                           
                            $.ajax({
                                type: "POST",
                                url: "<?php echo $ACCOUNTTOOLBAR_CORE; ?>",
                                data: "param=globalScore&versionmobile=<?php echo $versionmobile; ?>&sessid=<?php echo $sess->sessid; ?>",
                                success: function(data) {
                                    majFloaty();
                                    if (data == 'ErrorSESSID'){
                                        $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                                        jQT.goTo("#home", "slide");
                                    }
                                    else {
                                        $('.AccountToolbar').html(data);
                                    }
                                }
                            });

                            $.ajax({
                                type: "POST",
                                url: "<?php echo $ACCOUNTTOOLBAR_CORE; ?>",
                                data: "param=infoAccount&versionmobile=<?php echo $versionmobile; ?>&sessid=<?php echo $sess->sessid; ?>",
                                success: function(data) {

                                    if (data == 'ErrorSESSID'){
                                        $('error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                                        jQT.goTo("#home", "slide");
                                    }
                                    else {
                                        $('#welcomePlayer').html(data);
                                    }
                                }
                            });

                            $.ajax({
                                type: "POST",
                                url: "<?php echo $ACCOUNTTOOLBAR_CORE; ?>",
                                data: "param=infoGeneral&versionmobile=<?php echo $versionmobile; ?>&sessid=<?php echo $sess->sessid; ?>",
                                success: function(data) {

                                    if (data == 'ErrorSESSID'){
                                        $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                                        jQT.goTo("#home", "slide");
                                    }
                                    else {
                                        $('#infoGeneral').html(data);
                                    }
                                }
                            });

                            
                            jQT.goTo("#menu", "slide");
                            
                        }
                  }
                });

            }

            function sendMailContact (){
                $.ajax({
                    type: "POST",
                    url: "<?php echo $CONTACT_CORE; ?>",
                    data: "message="+$("#message").val()+"&sujet_id="+$("#sujet_id").val()+"&versionmobile=<?php echo $versionmobile; ?>&sessid=<?php echo $sess->sessid; ?>",
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
                            $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
                            $('#error_contact').html(data);
                    }
                    }
                });
            }

            function sendMailKestubug (){
                $.ajax({
                    type: "POST",
                    url: "<?php echo $CONTACT_CORE; ?>",
                    data: "message="+$("#message_bug").val()+"&sujet_id="+$("#sujet_id_bug").val()+"&versionmobile=<?php echo $versionmobile; ?>&sessid=<?php echo $sess->sessid; ?>",
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
                            $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
                            $('#error_contact_bug').html(data);
                    }
                    }
                });
            }

            function containersResultsDisplay() {
                $.ajax({
                    type: "POST",
                    url: "<?php echo $CORE_DIR_FROM_MOBILE; ?>ContainersBets.core.php",
                    data: "sessid=<?php echo $sess->sessid; ?>&versionmobile=<?php echo $versionmobile; ?>",
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
                            $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
                            $('#contentContainersResultats').html(data);
                            jQT.goTo("#containersResultats", "slide");
                        }
                    }
                });
            }

            function containersPronosDisplay() {
				$.ajax({
                    type: "POST",
                    url: "<?php echo $BETS_CATEGORIES_CORE; ?>",
                    data: "sessid=<?php echo $sess->sessid; ?>&versionmobile=<?php echo $versionmobile; ?>",
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
							$('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
							$('#contentContainersPronos').html(data);
                            jQT.goTo("#containersPronos", "slide");
                        }
                    }
                });
            }
            
            function resultsDisplay(container){
                $.ajax({
                    type: "POST",
                    url: "<?php echo $BETS_RESULTS_CORE; ?>",
                    data: "sessid=<?php echo $sess->sessid; ?>&versionmobile=<?php echo $versionmobile; ?>&containerId="+container,
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
                            $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
                            $('#contentResultats').html(data);
                            setTimeout(jQT.goTo("#resultats", "slide"), 2000);
                        }
                    }
                });
            }


            function pronosDisplay(container){
                $.ajax({
                    type: "POST",
                    url: "<?php echo $BETS_LIST_CORE ?>",
                    data: "sessid=<?php echo $sess->sessid; ?>&versionmobile=<?php echo $versionmobile; ?>&containerId="+container,
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
                            $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
                            $('#contentPronos').html(data);	
							setTimeout(jQT.goTo("#pronos", "slide"), 2000);
                        }
                    }
                });
            }

            function pronosDisplayByCat(ContainerId,CategoryId){

				$.ajax({
                    type: "POST",
                    url: "<?php echo $BETS_GRID_CORE; ?>",
                    data: "sessid=<?php echo $sess->sessid; ?>&versionmobile=<?php echo $versionmobile; ?>&containerId="+ContainerId+"&categoryId="+CategoryId,
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
							$('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
							$('#contentPronos').html(data);
							jQT.goTo("#pronos", "slide");
                        }
                    }
                });
            }

            function currentPronoDisplay(match){
                $.ajax({
                    type: "POST",
                    url: "<?php echo $BETS_CHOICE ?>",
                    data: "sessid=<?php echo $sess->sessid; ?>&versionmobile=<?php echo $versionmobile; ?>&MatchId="+match,
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
                            $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
                            $('#contentCurrentProno').html(data);
                            setTimeout(jQT.goTo("#currentProno", "slide"), 2000);
                        }
                    }
                });
            }

            function validateBet(validate, amount, team1, team2, match,container){
                $.ajax({
                    type: "POST",
                    url: "<?php echo $BETS_CHOICE; ?>",
                    data: "sessid=<?php echo $sess->sessid; ?>&versionmobile=<?php echo $versionmobile; ?>&MatchId="+match+"&amount="+amount+"&validate="+validate+"&Team1="+team1+"&Team2="+team2+"&ContainerId="+container,
                    success: function(data) {
                        majFloaty();
                        if (data == 'ErrorSESSID'){
                            $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else {
                            $('#contentCurrentProno').html(data);
                            //setTimeout(jQT.goTo("#currentProno", "slide"), 2000);
                            if ($('#error_bet').html() == '')
                            pronosDisplay(container);
                        }
                    }
                });
            }

            function reglementDisplay(){
                jQT.goTo('#reglement', 'flip');
                majFloaty();
            }

            function submitForm(ContainerId, CategoryId) {

                var temp = $('#pronosForm').serialize();
                
                $.ajax({
                    type: "POST",
                    url: "<?php echo $BETS_GRID_CORE; ?>",
                    data: "sessid=<?php echo $sess->sessid; ?>&versionmobile=<?php echo $versionmobile; ?>&containerId="+ContainerId+"&categoryId="+CategoryId+"&"+temp,
                    success: function(data) {
                        majFloaty();
                        if (data.indexOf('ErrorSESSID',0)!= -1){
                            $('#error_login').html('Votre session a expir<?php echo formatStringUTF("é"); ?>');
                            jQT.goTo("#home", "slide");
                        }
                        else if (data.indexOf('OK;',0)!= -1){
                            alert('Vos pronostics ont \351t\351 pris en compte.');
                        }
                        else {
                            $('#contentPronos').html(data);
                        }
                    }
                });
            }

        </script>
    </head>
    <body onload="window.scrollTo(0, 1);">
        <!-- HOME -->
        <div id="home">
            <div class="toolbar">
                <h1>Kestufoot</h1>
            </div>
            <div style="background-color:#000000; height:375px">
                <center>
                    <img alt="Logo KTF"  src="Images/ktf_logo.jpg" />
                    
                    <div id="error_login" style="color:red" ></div>
                    <form>
                        <ul class="edit rounded" style="margin-top:3px;">
                            <li><input type="text" name="login" placeholder="identifiant" id="login" /></li>
                            <li><input type="password" name="pwd" placeholder="mot de passe" id="pwd" /></li>
                        </ul>
						<input type="submit" style="color:rgba(0,0,0,.9);width:100%;height:50px;padding-top:-15px;background-color:#000000;" value="Connexion" onclick="onSubmit();" class="submit whiteButton">
                        <!--<a style="margin-top:-10px;color:rgba(0,0,0,.9)" onclick="onSubmit();" class="submit whiteButton">Connexion</a>-->
                        <img style="margin-top:0px;" src="Images/ktfmobileimage.png" width="320" alt="Aide pour le raccourcis" />
                    </form>
                </center>
            </div>
            <div class="empty"></div>
        </div>

        <!-- MENU -->
        <div id="menu">
            <div class="toolbar">
                <h1>Menu</h1>
            </div>
            <div style="height:375px">
                <ul class="metal">
                    <li class="arrow"><a href="#" onclick="containersPronosDisplay();"><em>Mes Pronostics</em></a></li>
                    <li class="arrow"><a href="#" onclick="containersResultsDisplay();"><em>Mes R&eacute;sultats</em></a></li>
                    <li class="arrow"><a href="#" onclick="ssMenuDisplay();"><em>Mon Compte</em></a></li>
                    <li class="arrow"><a href="#" onclick="kestubug();"><em>Kestubug</em></a></li>
                </ul>
                <div id="welcomePlayer" ></div>
                <div class="AccountToolbar" ></div>
                <div id="infoGeneral" ></div>
            </div>
            <div class="empty"></div>
        </div>

        <!-- SOUS MENU -->
        <div id="ssMenuMonCompte">
            <div class="toolbar">
                <h1>Mon Compte</h1>
                <a class="button" onclick="menuDisplay();" >Menu</a>
                <a class="button back" href="#" >Retour</a>
            </div>
            <ul class="metal">
                <li class="arrow"><a href="#monCompte"><em>Mes infos</em></a></li>
                <li class="arrow"><a href="#reglement"><em>R&egrave;glement</em></a></li>
                <li class="arrow"><a href="#contact"><em>Contact</em></a></li>
            </ul>
            <div class="empty"></div>
        </div>

        <!-- CONTAINERS OF PRONOSTICS -->
        <div id="containersPronos">
            <div class="toolbar">
                <h1>Cat&eacute;gories</h1>
                <a class="button" onclick="menuDisplay();">Menu</a>
                <a class="button back" href="#" >Retour</a>
            </div>
            <div id="contentContainersPronos" ></div>
            <div class="empty"></div>
        </div>

        <!-- LIST OF PRONOS FOR THE CURRENT CONTAINER -->
        <div id="pronos">
		
		
            <div class="toolbar">
                <h1>Pronostics</h1>
                <a class="button" onclick="menuDisplay();" >Menu</a>
                <a class="button back" href="#" >Retour</a> <!--downFloaty();-->
            </div>
            <div id="validate_pronos" style="color:red" ></div>
            <div id="contentPronos" ></div>
            <br />
            <div class="AccountToolbar"></div>
            <div class="empty"></div>
        </div>

        <!-- CURRENT BET -->
        <div id="currentProno">
            <div class="toolbar">
                <h1>Pronostics</h1>
                <a class="button" onclick="menuDisplay();">Menu</a>
                <a class="button back" href="#" >Retour</a>
            </div>
            <div id="contentCurrentProno" ></div>
            <br />
            <div class="AccountToolbar"></div>
            <div class="empty"></div>
        </div>

        <!-- CONTAINERS OF RESULTS -->
        <div id="containersResultats">
            <div class="toolbar">
                <h1>Cat&eacute;gories</h1>
                <a class="button" onclick="menuDisplay();">Menu</a>
                <a class="button back" href="#" >Retour</a>
            </div>
            <div id="contentContainersResultats" ></div>
            <div class="empty"></div>
        </div>

        <!-- RESULTS -->
        <div id="resultats">
            <div class="toolbar">
                <h1>R&eacute;sultats</h1>
                <a class="button" onclick="menuDisplay();">Menu</a>
                <a class="button back" href="#" >Retour</a>
            </div>
            <div id="contentResultats" ></div>
            <br />
            <div class="AccountToolbar"></div>
            <div class="empty"></div>
        </div>
        
        <!-- REGLEMENT -->
        <div id="reglement">
            <div class="toolbar">
                <h1>R&egrave;glement</h1>
                <a class="button" onclick="menuDisplay();">Menu</a>
                <a class="button back" href="#" >Retour</a>
            </div>
            <div id="contentReglement" >
                <?php //include($ARCHIVES_DIR."fic_rules.html")
                include ($DATA_DIR."reglement_extrait_20100816.html");
                ?>
            </div>
            <br /><br />
            <div class="empty"></div>
            
        </div>

        <!-- MATCHS -->
        <div id="matchs">
            <div class="toolbar">
                <h1>Pronos</h1>
                <a class="button" onclick="menuDisplay();">Menu</a>
                <a class="button back" href="#" >Retour</a>
            </div>
            <ul class="edgetoedge">
                <li class="arrow"><a style="font-size: 12px" href="#match1"><small>25/05/2010</small> Bordeaux - Marseille</a></li>
                <li class="arrow"><a style="font-size: 12px" href="#match2"><small>25/05/2010</small> Paris - Toulouse</a></li>
            </ul>
            <div class="empty"></div>
        </div>

        <!-- LOGIN FORM -->
        <div id="forms">
            <div class="toolbar">
                <h1>Identification</h1>
            </div>
            <div id="error_login" style="color:red" ></div>
            <form>
                <ul class="edit rounded">
                    <li><input type="text" name="login" placeholder="identifiant" id="login" /></li>
                    <li><input type="password" name="pwd" placeholder="mot de passe" id="pwd" /></li>
                </ul>
                <a style="margin:0 10px;color:rgba(0,0,0,.9)" onclick="onSubmit();" class="submit whiteButton">Connexion</a>
            </form>
            <div class="empty"></div>
        </div>

        <!-- CONTACT FORM -->
        <div id="contact">
            <div class="toolbar">
                <h1>Contact</h1>
                <a class="button back" href="#">Retour</a>
            </div
            <div id="error_contact" style="color:red" ></div>
            <form>
                <ul class="edit rounded">
                    <!--<li><input type="text" name="email_expediteur" placeholder="Votre Email" id="email_expediteur" /></li>-->
                    <select class=inputBg2 name='sujet_id' id='sujet_id'>
                    <?php


                            for ($i = 0 ; $i < $NB_SUJETS ; $i++)
                            {
                                    if($i == $INDEX_SUJET_PAR_DEFAUT) {
                                            echo "<option selected class=smallDark value=\"".$i."\">".formatStringUTF($SUJET_APPARENT[$i])."</option>\n";
                                    } else {
                                            echo "<option class=smallDark value=\"".$i."\">".formatStringUTF($SUJET_APPARENT[$i])."</option>\n";
                                    }
                            }
                    ?>
                    </select>
                   <!--<li><input type="text" name="sujet" placeholder="Votre Sujet" id="sujet" /></li>-->
                    <li><textarea name="message" placeholder="Votre Message" id="message"></textarea></li>
                </ul>
                <a style="margin:0 10px;color:rgba(0,0,0,.9)" onclick="sendMailContact();" class="submit whiteButton">Envoyer</a>
            </form>
        </div>

        <!-- KESTUBUG FORM -->
        <div id="kestubug">
            <div class="toolbar">
                <h1>Contact</h1>
                <a class="button back" href="#">Retour</a>
            </div
            <div id="error_contact_bug" style="color:red" ></div>
            <div>Si vous souhaitez signaler un bug ou faire un commentaire sur la version mobile de Kestufoot, n'h&eacute;sitez pas !</div>
            <form>
                <ul class="edit rounded">
                    <input type="hidden" id="sujet_id_bug" value="6" name="sujet_id_bug" />
                    <!--<li><input type="text" name="email_expediteur" placeholder="Votre Email" id="email_expediteur" /></li>
                    <li><input type="text" name="sujet" placeholder="Votre Sujet" id="sujet" /></li>-->
                    <li><textarea name="message_bug" placeholder="Votre Message" id="message_bug"></textarea></li>
                </ul>
                <a style="margin:0 10px;color:rgba(0,0,0,.9)" onclick="sendMailKestubug();" class="submit whiteButton">Envoyer</a>
            </form>
            <div class="empty"></div>
        </div>

        <!-- ACCOUNT DISPLAY -->
        <div id="monCompte">
            <div class="toolbar">
                <h1>Mes Infos</h1>
                <a class="button back" href="#">Retour</a>
            </div>
            <div id="infoCompte" ></div>
            <div class="empty"></div>
        </div>
        
		
        <div class="floaty">
			<!--<div id="fixed_infos" style="color:#000000;"></div>-->
            <div style="vertical-align:bottom;">
				<?php
				//**************** ADMOB ****************//
				include 'ads.php'; ?>
			</div>
        </div>
		
		
    </body>
</html>