$.ajaxSetup({
cache: false
});


$("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;
									});

$(document).ready( function () {


//FORMULAIRE DE RECHERCHE
//produits

	
	

	

	
});

    
//CHARGEMENT AU DEMARAGE || CHANGEMENT DE PAGE


$(window).load(function(){


//IFCONNECT
$.ajax({
		   type: "POST",
		   url: "php/login/ifconnect.php",
		   data: "action=ifconnect",
		   success: function(msg){
		//	alert(msg);
				if(msg!=0) // si la connexion en php a fonctionnée
				{	
				
								$("div#containerg").html(msg);

					//$("div#body").html("oki");
					
					// on désactive l'affichage du formulaire et on affiche un message de bienvenue à la place
				}
				else // si la connexion en php n'a pas fonctionnée
				{				
				
				}
		   }
		});
return false;

 								

									
					
								
$.historyInit(pageload, "jquery_history.html");	

			$("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 "#", "?"
									if(!hash[1]){
									listblog();	
									}else{
									$.historyLoad(hash[1]);
									}
									
									return false;
									});

return false;
		
});
 
///MENU


function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}







//##################################################################
//RECHERCHE


function ouvre_popup(id_pic) {
alert("--");
 }
 
function pageload(hash) {

								//le nom de la page qui load le script
								var nom = window.location.pathname;
								nom = nom.split("/");
								nom = nom[nom.length - 1];
								//nom = nom.substr(0, nom.lastIndexOf("."));
								nom = nom.replace(new RegExp("(%20)", "g"), "");
								if(nom.indexOf('#')!=-1){var sentinelle = 1}
								nom = nom.replace("#", "");
								//On initialise l'historique du menu 
								
								
		if(hash && hash.indexOf("(") != -1) {
			// restore ajax loaded state
			if($.browser.msie) {
				// jquery's $.load() ne prend pas les caractères trop spéciaux ex: ë
				hash = encodeURIComponent(hash);
			}
			hash = "<script type='text\/javascript'>"+hash+"<\/script>";
			hash = unescape(hash);
			
			$("div#colRightBlog").html(hash);
			
		}
		else{
			// start page
			nom = nom+'#'+hash;
			window.location.replace(nom);
		}
	}
	
//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);
  }
}


//NOUVELLES #########################################################################

function list_t(total){
//alert(total);
$.ajax({
		   type: "POST",
		   url: "php/nouvelles/list-t.php",
		   data: "nb="+total,
		   success: function(msg){
		   	$("div#nouvelles").html(msg);
			 }
		});
}
function list_s(){

$.ajax({ 
		   type: "POST",
		   url: "php/nouvelles/list-s.php",
		   success: function(msg){
		  // alert(msg);
		   	$("div#nouvellesBig").html(msg);
			//alert(window.location.href.indexOf('#'));
			if(window.location.href.indexOf('#') != -1)
				{
				
					var ancre = window.location.href.split('#');
					var ancre = ancre[1];
					ancre = document.getElementById(ancre).offsetTop;
					scrollTo(0,ancre);
					
				}
				
			 }
		});
}

function list_l(){
if(window.location.href.indexOf('?') != -1)
				{
				//alert('ok');
					var ask = window.location.href.split('?');
					var ask = ask[1];
					$.ajax({ 
						   type: "POST",
						   url: "php/nouvelles/list-l.php",
						   data: "id="+ask,
						   success: function(msg){
						   //alert(msg);
								$("div#nouvellesBig").html(msg);
							}
					});
					
				}else{
				//alert('KO');

				window.location.href="nouvelles.html";
				}

}
