// JavaScript Document
$(document).ready(function() {
		$("a[rel=img_group]").fancybox({
				'opacity'		: true,
				'overlayShow'	: true,
				'overlayOpacity' :0.8,
				'overlayColor' : '#000',
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
	});
	
document.write("<div id=overlay style=\"position:absolute;z-index:9;background-color:#000000;display:block;top:0px;left:0px\" class=\"trans80\" ></div>");
document.write("<div id=\"popup\" style=\"position:absolute;top:0px;left:0;z-index:10;\" ></div>");
var lightbox1_width=640;
var lightbox1_height=640;
function showImg(html_mil) 
{ 
	var arrayPageSize = getPageSize();
    document.getElementById('overlay').style.width = (arrayPageSize[0] + 'px');
	document.getElementById('overlay').style.height = (arrayPageSize[1] + 'px');
	//document.getElementById('popup').style.left = ( ( ( arrayPageSize[0] / 2 ) - ( lightbox1_width / 2 ) ) + 'px');
	document.getElementById('popup').style.top = ( ( getPageScroll() + (( haut / 2 ) - ( lightbox1_height / 2 ) )) + 'px');
	document.getElementById('popup').style.display='block';
	document.getElementById('popup').style.width = '100%';  
	document.getElementById('popup').style.height = haut+'px'; 
    document.getElementById('overlay').style.display='block';
	document.getElementById('popup').innerHTML = html_mil;	
} 
larg = alertSize('width'); 
haut = alertSize('height'); 

function alertSize(taille) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(taille=='width') { return myWidth;}
  if(taille=='height') {return myHeight;}
}
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+'&dt='+ new Date().getTime(), false); 
	xhr_object.setRequestHeader("Cache-Control","no-cache");
	xhr_object.send(null); 
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
}
function closeIt(id)
{
	document.getElementById(id).style.display='none';
	document.getElementById('overlay').style.display='none';
	document.getElementById('popup').style.display='none';
}
function writediv(idP,idG,w,h)
{

	texte=file('viewphoto.php?idP='+idP);
	showImg(texte);
}
function abus(lg)
{
	texte=file('abus.php?lg='+lg);
	showImg(texte);
}
function sendabus(lg)
{
	var email=document.getElementById('mail').value;
	var msg=document.getElementById('message').value;
	var page=document.getElementById('page').value;

	var url = "sendabus.php";
	var params = 'lg='+lg+'&mail='+escape(email)+'&msg='+escape(msg)+'&page='+escape(page);
	
	var http = new XMLHttpRequest();
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			showImg(http.responseText);
		}
	}
	http.send(params);
}

function mentions(lg)
{
	texte=file('mentions.php?lg='+lg);
	showImg(texte);
}
function disclaimer()
{
	if (document.cookie.indexOf('foto-200911')<=-1)
	{
		document.cookie='test_cook=oui;path=/';
		if (document.cookie.indexOf('test_cook')<=-1)
		{
			window.location.replace(escape(window.location));
		}
		else 
		{
			ouinon=confirm("ATTENTION : PAGE INTERDIT AUX MINEURS ! !\n"+"\n"+"Le contenu de cette page ainsi que les contenus vers lesquels pointent les liens de ce site sont interdits aux enfants. Ils peuvent choquer certaines sensibilit\351s\n"+"\n"+"Pour acc\351der \340 ce site cliquez sur OK\n"+"\n"+"SI VOUS ETES MINEUR, CLIQUEZ SUR ANNULER.");
		}
		if (ouinon==false)
		{
			if (history.length>1) 
			{
				history.go(-1); 
			}
			else 
			{ 
				window.location.href = 'index.php?act=2'; 
			}
		}
		else 
		{
			document.cookie='foto-200911=ok;';
		}
	}
}
function getPageScroll()
{
	var theTop = 0;
	var old = 0;

	if (window.innerHeight) {
		pos = window.pageYOffset
	} else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop
	} else if (document.body) {
		pos = document.body.scrollTop
	}
	return pos;
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

var theTop = 0;
var old = 0;
function movelayer() {
	var pos;
	if (window.innerHeight) {
		  pos = window.pageYOffset
	} else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop
	} else if (document.body) {
		  pos = document.body.scrollTop
	}
	
	if (pos < theTop)
		pos = theTop
	else
		pos += 30
	if (pos == old)
		document.getElementById("popup").style.top = pos + "px"
	old = pos
	setTimeout("movelayer()",20);
}
function montre(id)
{
	var strdisplay=document.getElementById(String(id)).style.display;
	if(strdisplay=='none')
	{
		document.getElementById(String(id)).style.display='block';
		document.getElementById('commentform').innerHTML='Masquer le formulaire <img src="images/moins.png" width="10" height="10" border="0" align="absmiddle">';
	}
	else 
	{
		document.getElementById(String(id)).style.display='none';
		document.getElementById('commentform').innerHTML='Afficher le formulaire <img src="images/plus.png" width="10" height="10" border="0" align="absmiddle">';
	}
}

movelayer();
