
// google analytic
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1258141-5']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


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;}
}
larg = alertSize('width'); 
haut = alertSize('height'); 
document.write("<div id=overpopup style=\"position:absolute;z-index:9;background-color:#000000;display:none;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=600;
var lightbox1_height=haut;
function showImg(html_mil) 
{ 
	var arrayPageSize = getPageSize();
    document.getElementById('overpopup').style.width = (arrayPageSize[0] + 'px');
	document.getElementById('overpopup').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('overpopup').style.display='block';
	document.getElementById('popup').innerHTML = html_mil;	
} 

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 signin()
{
	texte=file('signin.php?act=');
	showImg(texte);
}
function access()
{
	texte=file('access.php?act=');
	showImg(texte);
}
function forgetaccess()
{
	texte=file('access.php?act=lost');
	showImg(texte);
}
function sendlost(email)
{
	texte=file('access.php?act=sendlost&email='+email);
	showImg(texte);
}
function sendaccess(email,pass)
{
	texte=file('access.php?act=send&email='+escape(email)+'&pass='+escape(pass));
	//alert(email+'\n'+pass);
	showImg(texte);
}
Object.size = function(arr) {    var size = 0;    for (var key in arr)     {        if (arr.hasOwnProperty(key)) size++;    }    return size;};
function sendsignin()
{
	//var s = Object.size(document.form1.secteur.value);
	var str='&secteur=';
	for ( n=0;n<document.form1.elements.length;n++)
	{
		if(document.form1.elements[n].type=='checkbox' && document.form1.elements[n].checked)
		{
			str+=document.form1.elements[n].value+',';
		}
	}
	for ( n=0;n<document.form1.elements.length;n++)
	{
		if(document.form1.elements[n].type!='checkbox' && document.form1.elements[n].type!='button')
		{
			str+='&'+document.form1.elements[n].name+'='+escape(document.form1.elements[n].value);
		}
	}
	alert(str);
	texte=file('signin.php?act=send'+str);
	showImg(texte);
	
}
function closeIt(id)
{
	document.getElementById(id).style.display='none';
	document.getElementById('overpopup').style.display='none';
	document.getElementById('popup').style.display='none';
}
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 focusinput(id)
{
	document.getElementById(id).style.color='#333';
	document.getElementById(id).style.background='#CCC';
}
function outinput(id)
{
	document.getElementById(id).style.color='#666';
	document.getElementById(id).style.background='transparent';
}
function voirpass()
{
	var val =document.form1.pass.value;
	
	document.getElementById('pass_user').innerHTML='<input name="pass" type="text" class="accesschamp" id="pass" value="'+val+'" onfocus="focusinput(\'pass\');" onblur="outinput(\'pass\');" onmouseover="focusinput(\'pass\');" onmouseout="outinput(\'pass\');" style="width:auto;" />\n&nbsp;&nbsp;<a href="#none" onclick="maskpass();" >Masquer</a>';
}
function maskpass()
{
	var val =document.form1.pass.value;
	document.getElementById('pass_user').innerHTML='<input name="pass" type="password" class="accesschamp" id="pass" value="'+val+'" onfocus="focusinput(\'pass\');" onblur="outinput(\'pass\');" onmouseover="focusinput(\'pass\');" onmouseout="outinput(\'pass\');" style="width:auto;" />\n&nbsp;&nbsp;<a href="#none" onclick="voirpass();" >Rendre lisible</a>';
}
function montre(id)
{
	document.getElementById(id).style.display='block';
}
var http=createRequestObject();
var uploader="";
var uploadDir="";
var dirname="";
var filename="";
var timeInterval="";
var uploaderId="";
var idname="";
var type="";
function createRequestObject() {
    var obj;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
    	return new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
    	return new XMLHttpRequest();
    }   
}
function traceUpload() {
   http.onreadystatechange = handleResponse;
   http.open("GET", 'imageupload.php?uploadDir='+uploadDir+'&dirname='+dirname+'&filename='+filename+'&uploader='+uploader+'&uploaderId='+uploaderId+'&type='+type); 
   http.send(null);   
}
function handleResponse() {
	if(http.readyState == 4){
		var response=http.responseText; 
		if(response.indexOf("Actualiser la page") != -1){
			clearInterval(timeInterval);
			//document.getElementById('loading'+idname).innerHTML="";
		}
        document.getElementById(uploaderId).innerHTML=response;
    }
    else {
    	document.getElementById(uploaderId).innerHTML="<img src='../images/loading.gif' alt='Chargement en cours...' align='absmiddle' />&nbsp;Chargement en cours";
    }
}
function uploadFile(obj, dname, dest) {
	uploadDir=obj.value;
	idname=obj.name;
	dirname=dname;
	filename=uploadDir.substr(uploadDir.lastIndexOf('\\')+1);
	//document.getElementById('loading'+idname).innerHTML="<img src='loading.gif' alt='loading...' />";
	uploaderId = dest;
	uploader = obj.name;
	document.getElementById('form'+dest).submit();
	type=document.forms['form'+dest].type.value;
	timeInterval=setInterval("traceUpload()", 1500);
}
function sendcontact()
{
	var nom=document.formcontact.nomc.value;
	var mail=document.formcontact.mailc.value;
	var message=document.formcontact.message.value;
	var code=document.formcontact.code.value;
	var tel=document.formcontact.telc.value;
	var idp=document.formcontact.idP.value;
	texte=file('contact-photographe.php?nom='+escape(nom)+'&mail='+escape(mail)+'&message='+escape(message)+'&code='+escape(code)+'&tel='+escape(tel)+'&idP='+idp);
	eval(texte);
}
	
movelayer();
