function writediv(message) {
	document.getElementById("message").innerHTML = message;
	document.getElementById("message").style.visibility = "visible";
	document.location="#message"; 
}

function supprimer (type, nom) {
		switch (type){
			case 'categorie' : 
				if(confirm("voulez vous réellement supprimer la categorie "+ nom)) {
					message = "La categorie "+nom+" a bien été supprimée";
					writediv(message);
					alert ("oui")
					return true;
				}
				
				break;
			default : break;
		}
	return false;
}

function file(fichier){
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);		
	xhr_object.open("GET", fichier, true);
	xhr_object.send(null);
	if(xhr_object.readyState == 4)
	return(xhr_object.responseText);
	else return(false);
}


function majVote(texte, vote_moyenne, video) {
	document.getElementById("infos_vote_" + video).innerHTML = texte;
	document.getElementById("taille_vote_" + video).style.width = (16*vote_moyenne) + "px";
}

function voter (video, note) {
	if (note != "") {
		texte = file("/inc/vote_ajax.php?key="+escape(video)+"&note="+escape(note));
		if (texte != "") {
			tab = texte.split("|");
			vote_moyenne = tab[0];
			vote_nb = tab[1];
			deja_vote = tab[2];
			affiche = "Note " + vote_moyenne + "/5 : ";
			if (deja_vote == "oui") { affiche = "<font color='red'>D&eacute;j&agrave; vot&eacute; : </font>"; }
			majVote(affiche, vote_moyenne, video);
		}
	}
}

function CookieExist(CookieName) {
	cookieinfo = document.cookie;
	if (cookieinfo.indexOf(CookieName) == -1) {
		return false;
	} else {
		return true;
	}
}

function SetCookie(CookieName,CookieArgs,CookieExpire) {
	document.cookie = CookieName + "=" + CookieArgs + ";" + "expires=" + CookieExpire;
}

function GetCookie(CookieName) {
	if ( CookieExist(CookieName) ) {
		d = cookieinfo.indexOf(CookieName) + CookieName.length + 1;
		f = cookieinfo.indexOf(";",d);
		if ( f == -1) {
			f = cookieinfo.length;
		}
		return (cookieinfo.substring(d,f));
	} else {
		return ("0");
	}
}

function stats ( id_out, aff_pub) {
	url_in = "/sexe-hard/inc/stats/clic.php";
	url_out = "/sexe-hard/inc/stats/out.php";
	if (id_out != "") {
		error_out = file(url_out+"?ids="+escape(id_out));
	}
	error_in = file(url_in);
	
	if (aff_pub == "1") {	
		if (GetCookie("_popup250x250") != 1) {
			window.open('/promo/popup_250x250.html','PUBLICITE','width=250,height=250');
			SetCookie("_popup250x250", 1, "");
		}
	}
}

function stats_page_in (id_page_in, aff_pub) {
	error_in = file("/inc/stats/clic.php?id_page_in="+escape(id_page_in));
	
	if (aff_pub == "1") {	
		if (GetCookie("_popup250x250") != 1) {
			window.open('/promo/popup_250x250.html','PUBLICITE','width=250,height=250');
			SetCookie("_popup250x250", 1, "");
		}
	}
}

function afficheBloc(id_du_div) {
	var oDiv = document.getElementById(id_du_div);
	if (oDiv.style.display == "none") {
		oDiv.style.display="";
	} else {
		oDiv.style.display="none";
	}	
}

function compterCaracteres (champ_textarea,nbcar) {
	var nb = champ_textarea.value.length;
	document.getElementById(nbcar).value = nb;
}

function ouvrir_popup (url) {
	winwidth = screen.availWidth - 10;
	winheight = screen.availHeight - 30;
	window.open(url, '_blank', 'scrollbars=yes, width=' + winwidth + ', height=' + winheight + ', top=0, left=0, resizable');
} 

/* Disclaimer */
function disclaimer_verif_cookie(variable) {
	cook=document.cookie;
	variable+="=";
	place=cook.indexOf(variable,0);
	if (place<=-1) { 
		return("0");
	} else {
		end=cook.indexOf(";",place)
		if(end<=-1) return(unescape(cook.substring(place+variable.length,cook.length)));
		else return(unescape(cook.substring(place+variable.length,end)));
	}
}


function disclaimer_pose_cookie() {
	document.cookie="disclaimerok=oui;path=/;";
}

function disclaimer_entrer() {
	disclaimer_pose_cookie();
	if(document.getElementById) { document.getElementById("disclaimer").style.display='none' };
}

function disclaimer() {
	if (disclaimer_verif_cookie("disclaimerok")==0) {
		document.write("<div id=disclaimer><div id=disclaimer-fond></div><div id=disclaimer-conteneur>");
		document.write("<div id=disclaimer-cadre>");
		document.write("<b>ATTENTION: CONTENU STRICTEMENT RESERVE AUX ADULTES</b>");
		document.write("<br /><br />Le contenu de ce site ne conviens pas à un public mineur. Les photos, vidéos, et textes pornographiques disponibles ici peuvent choquer certaines sensibilités. En entrant, vous déclarez prendre vos responsabilités vis-à-vis de ce contenu.");
		document.write("<br /><br />Pour entrer sur ce site CLIQUEZ SUR ENTRER");
		document.write("<br><br>SI VOUS ETES MINEUR (- 18 ans), cliquez sur Sortir pour quitter ce site.");
		document.write("<br /><br />");
		document.write("<a href='#' onclick='disclaimer_entrer(); return(false)'>ENTRER</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href='http://www.google.com/'>Sortir</a>");
		document.write("</div>");
		document.write("</div></div>");
	}
}
