function changePage(url) {
	var data="";
	changePage(url,data);

}

function grosSucces() {

	new $('patience').hide();
	SortableTable.load();

}

var corpsCourant="";
var urlPrededente="";
var dataPrecedente="";
function changePage(url,data) {
	$('patience').show();
	var urlfinale = "http://www.stades-spectateurs.com/" + url;
	if (urlfinale.indexOf("www.stades-spectateurs.com") != -1) {
			urlfinale=url;
	}
	
	
	
	//var urlfinale = url;
	//alert(urlfinale);
	window.status=urlfinale;
	corpsCourant = $('corps').innerHTML;
	//urlPrededente = url;
	//dataPrecedente = data;
	//alert(corpsCourant);
	var method ="post";
	if (urlfinale.indexOf("html") != -1) {
		method = "GET";
	}
	
	
	new Ajax.Updater('corps',urlfinale,
	{
		evalScripts:true,
		insertion:undefined,
		onComplete:grosSucces,
		method:method,
		encoding:'iso-8859-1',
		postBody:data

	});
	//alert("salut");

}


function majContent(nomDiv, url, data) {
	//var urlfinale = "http://www.stades-spectateurs.com/" + url;
	var urlfinale = url;
	//alert(urlfinale);
	
	var method ="post";
	if (urlfinale.indexOf("html") != -1) {
		method = "GET";
	}


	new Ajax.Updater(nomDiv,urlfinale,
	{
		evalScripts:false,
		insertion:undefined,
		method:method,
		encoding:'iso-8859-1',
		postBody:data

	});
}


function clickLink(event) {
	var elt = Event.element(event);
	//alert(elt);
	//alert(elt);
	//alert(elt.innerHTML);
	//alert(elt.type);
	if (elt.innerHTML == "Retour") {
		
		$('corps').innerHTML=dataPrecedente;
		new $('patience').hide();
		Event.stop(event);
		return false;
	}
	
	if (elt.href != null) {
		if (elt.href.indexOf("javascript:") != -1) {
			// on ne fait rien

		} else if (elt.href.indexOf(".gif") != -1) {
			// on ne fait rien

		} else if (elt.href.indexOf("mailto") != -1) {
			// on ne fait rien

		} else if (elt.href.indexOf("saison-bilan") != -1) {
			// on ne fait rien

		} else if (elt.href.indexOf("http://") != -1 && elt.href.indexOf("http://www.stades-spectateurs.com") == -1) {
			// on ne fait rien

		} else if (elt.height != null) {
			// on ne fait rien

		}else {
			var index = elt.href.lastIndexOf("/");
			var url = elt.href.substring(index+1,elt.href.length);
			Event.stop(event);
			changePage(url);
			return false;
		}
	} else if (elt.type != null && elt.type == "submit") {
		
		Event.stop(event);
		//alert(elt.form.action);
		//alert(Form.serialize(elt.form));
		
		changePage(elt.form.action,Form.serialize(elt.form));
		return false;

	} else if (elt.type != null && elt.type == "select-one") {
		//alert(elt.onchange);
		//Event.stop(event);
		//changePage(elt.form.action,Form.serialize(elt.form));

		//return false;
	} else {
		//alert("salut");

	}
	
	//window.status = "fin click link";


}


//Event.observe(document,'click', clickLink);


function enlarge(url){
	var contenu = '<img src="'+url+'">';
	openPopupContenu(contenu,"dwindow");

}

function enlargeHistorique(contenu){
	$('dwindow').style.width='';
	openPopupContenu(contenu,"dwindow");

}


function enlargeURL(url,width,height){

	openPopup(url,'dwindow');
}

function enlargeResume(contenu){
	$('dwindow').style.width=300;
	openPopupContenu(contenu,"dwindow");
}


function SuccesArriveePopup() {



}

function openPopupContenu(contenu, idDiv) {
	$(idDiv).style.left= document.body.scrollLeft+300;
	$(idDiv).style.top= document.body.scrollTop +100;
	
	$(idDiv).innerHTML='<div align="right" style="background-color:navy;cursor:hand"><b onClick="closepreview()" style="cursor: hand"><img src="close.gif"></b></div>';
	$(idDiv).innerHTML+=contenu;
	new Effect.Appear(idDiv);

}

function openPopup(url, idDiv) {
$(idDiv).style.width='';
	$(idDiv).style.left= document.body.scrollLeft+300;
	$(idDiv).style.top= document.body.scrollTop +100;
	
	$(idDiv).innerHTML='<div align="right" style="background-color:navy;cursor:hand"><b onClick="closepreview()" style="cursor: hand"><img src="close.gif"></b></div>';
	
	//var urlfinale = "http://rernes.free.fr/" + url;
	var urlfinale = url;
	new Ajax.Updater(idDiv,urlfinale,
	{
		evalScripts:false,
		insertion:Insertion.Bottom,
		onComplete:SuccesArriveePopup,
		encoding:'iso-8859-1',
		postBody:''
	
	});
	new Effect.Appear(idDiv);

}

function closepreview() {

	if ($('showimage')) {
		new Effect.SwitchOff('showimage');
	}
	if ($('dwindow')) {
		$('dwindow').hide();;
	}
	if ($('resume')) {
		$('resume').hide();;
	}
	if ($('historique')) {
		$('historique').hide();;
	}
	

}

function initDraggables() {
	if ($('showimage')) {
		new Draggable('showimage');
	}
	if ($('dwindow')) {
		new Draggable('dwindow');
	}
	
	
	
}

Event.observe(window, 'load', initDraggables, false);