$.ajaxSetup({  cache: false});



//BOUTON DE CONNECTION

$(document).ready( function () {
ifconnect();
});
	


function ifconnect()
{
			$.ajax({	
			async: true,
			type: "POST",
			data: "action=ifconnect",
			url: "php/login/ifconnect.php",
  		    success: function(msg){
			//alert(msg);
			if(msg !='0')
			{
			$('#acces').html(msg);
			}
			
			}
			});

}

function login()
{
var shapass = SHA256($('#motdepasse').val());
//alert(shapass);	
	$.ajax({	
			async: true,
			type: "POST",
			url: "php/login/login.php",
			data: "action=login&loginftp="+$('#utilisateur').val()+"&passftp="+shapass,
  		    success: function(msg){
			//alert(msg);
			if(msg !='login0')
			{
			ifconnect();
			}
			else
			{
			$('#connectionerror').html('Gebruikersnaam of wachtwoord is ongeldig!');
			}

			}
			});
	
}
function logout()
{
		$.ajax({	
			async: true,
			url: "php/login/logout.php",
		    type: "POST",
			data: "action=logout",
			success: function(msg){
			//alert(msg);
			if(msg !='0')
			{
			window.location.reload();		
			}
			else
			{
			$('#connectionerror').html('Gebruikersnaam of wachtwoord is ongeldig!');
			}

			}
			});
		
	
}
     
//CHARGEMENT AU DEMARAGE || CHANGEMENT DE PAGE


$(window).load(function(){



//$.historyInit(pageload,"index.html");

//If connect	
$.ajax({
			url: "php/cat/menu.php",
			async: false,
  		    success: function(msg){
			//alert(msg);

		$("div#boutiqueMenu").html(msg);
									//Lorsqu'on clique
									$("a.remote").click(function(){
									var hash = $(this).attr('href');
									
									hash = hash.replace(/^.*#/, '');
									hash = hash.split(':')
									// moves to a new page. 
									// pageload is called at once. 
									// hash don't contain "#", "?"
									$.historyLoad(hash[1]);
									return false;
									});
		   }
		   
 });	
 
return false;
		
});

///MENU


//ROLL OVER ###################################################################
function SimpleSwap(el,which){
  el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
      
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}

