
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// Tout autres qu'Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

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){ // Tous sauf Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...marchera également avec Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// tous 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) { // autres qu'Explorer
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


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


function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){ hideLightbox(); }
}

// listenKey()

function listenKey () {	document.onkeypress = getKey; }

function hideLightbox()
{
	// get objects
	objOverlay = document.getElementById('overlay');
	objBox = document.getElementById('box');

	
	objOverlay.style.display = 'none';
	objBox.style.display = 'none';
	
	document.onkeypress = '';
}

function str_replace(a, b, str) {
    return str_replace2(str, a, b);
}
function str_replace2(SRs, SRt, SRu) {
  /*
  **  Replace a token in a string
  **    s  string to be processed
  **    t  token to be found and removed
  **    u  token to be inserted
  **  returns new String
  */
  SRRi = SRs.indexOf(SRt);
  SRRr = '';
  if (SRRi == -1) return SRs;
  SRRr += SRs.substring(0,SRRi) + SRu;
  if ( SRRi + SRt.length < SRs.length)
    SRRr += str_replace2(SRs.substring(SRRi + SRt.length, SRs.length), SRt, SRu);
  return SRRr;
}

$(document).ready(function(){
	$("img").click(function(){
	var mytitle = $(this).attr('alt');
	if(mytitle!='Godage'){
	var preid = $(this).attr('src');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var closeButton = 'http://www.godage.fr/images/close.gif';
	var regunit=new RegExp("[\./]+", "g");
	var secid=preid.split(regunit);
	var id=secid[5];

	//var mytitle = str_replace('plan cul ', '', mytitle);



	//if (!document.getElementsByTagName){ return; }

	var objBody = document.getElementsByTagName("body").item(0);

		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
        objOverlay.style.left="0px";
        objOverlay.style.top="0px";
		objOverlay.style.position = 'absolute';
        objOverlay.style.width="100%";
		objOverlay.style.height=(arrayPageSize[1]+70) + 'px';
		objOverlay.style.zIndex="90";
		objBody.insertBefore(objOverlay, objBody.firstChild);

	var boxTop = arrayPageScroll[1] + (arrayPageSize[3] - 460);
	var boxLeft = ((arrayPageSize[0]/100)*1);

	var objBox = document.createElement("div");
	objBox.setAttribute('id','box');
	objBox.style.top = (boxTop-50) + "px";
	objBox.style.left = boxLeft + "px";
	//objBox.style.display = 'block';
	objBox.style.position = 'absolute';
	objBox.style.zIndex = '100';
	objBox.style.padding="0px";
	objBox.style.width="98%";
	objBox.style.height=(arrayPageSize[3]-40) + "px";
	objBox.style.background="#FFFFFF";
	//bjBox.style.border="1px solid #FF01FD";
	objBox.innerHTML = '&nbsp;';

	objBody.insertBefore(objBox, objBody.firstChild);


	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.setAttribute('title','Cliquez pour fermez');
	objLink.onclick = function () {hideLightbox(); window.clearInterval(force); return false;}
	objBox.appendChild(objLink);

var imgPreloadCloseButton = new Image();
	imgPreloadCloseButton.onload=function(){

		var objCloseButton = document.createElement("img");
		objCloseButton.src = closeButton;
		objCloseButton.setAttribute('id','closeButton');
		objCloseButton.style.border = '0px';
		objCloseButton.style.zIndex = '200';
		objLink.appendChild(objCloseButton);

		return false;
	}

	imgPreloadCloseButton.src = closeButton;




var objIframe = document.createElement("iframe");
	objIframe.setAttribute('src','http://www.godage.fr/pdv.php?id='+id);
	objIframe.setAttribute('id','myiframe');
	objIframe.setAttribute('FRAMEBORDER','0');
	objIframe.setAttribute('scrolling','no');
	objIframe.style.width = '97%';
	objIframe.style.height = (arrayPageSize[3]-75) + 'px';
	objIframe.style.margin = '20px 0px 0px 0px';



	objBox.appendChild(objIframe);
	//objBody.appendChild(objBox);
 force=window.setInterval("window.scrollTo(0,"+(boxTop-60)+")", 1);
 }
		});
	}); 

// Disclaimer DHTML
// Copyright SexyTools.be 2008

function ScanCookie(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 Entrer()
{
 document.cookie="disclaimerok=oui;path=/;";
 if(document.getElementById) document.getElementById("disclaimer").style.display='none'
 top.location.href=location.href;
}

if(ScanCookie("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 convient 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='Entrer(); return(false)'>ENTRER</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href='http://www.plancul.net'>Sortir</a>");
 document.write("</div>");
 document.write("</div></div>");
 document.write('<style>embed,object,select,iframe { display:none; visibility:hidden }</style>');
 force=window.setInterval("window.scrollTo(0,0)", 1);
}
