// RD medias **************************************************************************************
function myPopupAlexandrie(width, height, src){
	popupLeft = screen.availWidth / 2 - width / 2;
	popupTop = screen.availHeight / 2 - height / 2;
	propertiesStr = "width=" + width + ", height=" + height + ", left=" + popupLeft + ", top=" + popupTop +",toolbar=1,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1,status=0";
	if(myPopupAlexandrie.arguments.length > 3)
		propertiesStr += ", " + myPopupAlexandrie.arguments[3];
	open(src, "Alexandrie", propertiesStr);
}
// ************************************************************************************************


function addslashes(ch) {
   ch = ch.replace(/\\/g,"\\\\") 
   ch = ch.replace(/\'/g,"\\'") 
   ch = ch.replace(/\"/g,"\\\"")
   return ch
}

// Affiche le div 'divName' a gauche ou a droite du pointeur en fonction de sa position dans la fenêtre
function showDivByClick(divName){
	div = document.getElementById(divName);
	with(div){
		style.left = (event.clientX + document.body.scrollLeft + clientWidth < document.body.offsetWidth) ? event.clientX + document.body.scrollLeft : event.clientX + document.body.scrollLeft - clientWidth;
		style.top = (event.clientY + document.body.scrollTop + clientHeight < document.body.offsetHeight) ? event.clientY + document.body.scrollTop : event.clientY + document.body.scrollTop - clientHeight;
		style.visibility = 'visible';
	}
}

// Fonction de popup
function myPopup(width, height, src){
	popupLeft = screen.availWidth / 2 - width / 2;
	popupTop = screen.availHeight / 2 - height / 2;
	propertiesStr = "width=" + width + ", height=" + height + ", left=" + popupLeft + ", top=" + popupTop;
	if(myPopup.arguments.length > 3)
		propertiesStr += ", " + myPopup.arguments[3];
	open(src, "", propertiesStr);
}



// Préload des images passées en paramètres
function simplePreload(){ 
	var args = simplePreload.arguments;
	document.imageArray = new Array(args.length);
	for(var i=0; i<args.length; i++){
		document.imageArray[i] = new Image;
		document.imageArray[i].src = args[i];
	}
}

// Fonction de click droit
function rightClick(){
	args = rightClick.arguments;
	if(event.button == 2 && args.length){
		innerHTML_ = "<table>";
		for(i = 0; i < args.length; i += 2)
			innerHTML_ += returnActionRow(args[i], args[i+1]);
		innerHTML_ += "</table>";
		document.all.actions.innerHTML = innerHTML_;
		showDivByClick("actions");
	}
}

// Fonction privée, renvoie un ligne pour le calque d'actions
function returnActionRow(actionLabel, jsFunction){
	return "<tr onMouseOver=\" this.bgColor='#0091d7'; this.style.color='white'\" onMouseOut=\"this.bgColor=''; this.style.color=''\"><td nowrap onClick=\"" + jsFunction + "\">" + actionLabel + "</td></tr>";
}

// Vérifie que la page soit appelée dans un jeu de carde,
// Sinon, redirige vers le jeu de cadre (admin_index.php);
function checkFrameset(){
	frameset = "admin_index.php";
	if(parent.frames.mainFrame == null)
		location.href = frameset;
}

// Redirige l'utilisateur vers l'URL "href + prompt" dans la cible targetFrame
function promptAndSubmit(targetFrame, href, promptStr, defaultValue){
	if(promptValue = prompt(promptStr, defaultValue))
		targetFrame.location.href = href + promptValue;
}

// Redirection après confirmation de l'utilisateur
function confirmDelete(link){
	if(confirm("Êtes-vous sûr ?"))
		parent.frames.mainFrame.location.href = link;
}
