//JS script for Joomla template
var siteurl = '';


function exif_command(e)
{
alert(EXIF.pretty(e));
return false;
}

function cacheroption() {
setTimeout("$('KIDE_opciones').setStyle('visibility','visible')",500);
setTimeout("$('p-tiempo').setStyle('visibility','visible')",650);
}

function addSliders(cat_id) {	
	var status = {
		'false': 'open',
		'true': 'close'
	};
	//-vertical
	var slide = new Fx.Slide('pp_'+cat_id, {duration: 500});
/*	if(getCookie( 'pp_'+cat_id) == 'close' ){
		slide.toggle();
				if($('ratrap')){
				$('ratrap').setStyle('marginBottom','-3px');
				}

	}
	*/
			if(cat_id == "chatx") KIDE_desactivChat();
		if(getCookie('pp_'+cat_id)=='close') {
		slide.slideOut();
		$('img_up_'+cat_id).setStyle('display','none');
		$('img_down_'+cat_id).setStyle('display','inline');
		if(cat_id == "chatx") KIDE_desactivChat();		
		} else {
		//slide.slideIn();
		$('img_up_'+cat_id).setStyle('display','inline');
		$('img_down_'+cat_id).setStyle('display','none');
		if(cat_id == "chatx") KIDE_activChat();		
		}
	if($('togglechaty')) {
	$('togglechaty').addEvent('click', function(e){
	e = new Event(e);
			if (slide.open) {
			monSlideOpen("chatx",slide);
				e.stop();
				setCookie('pp_'+cat_id,status[slide.open],"");
				} else {
				e.stop();
				}
				KIDE_open_popup();
	})};

	$('toggle'+cat_id ).addEvent('click', function(e){

			e = new Event(e);
			if (slide.open) {	
				monSlideOpen(cat_id,slide);			
			} else {
				slide.slideIn();		
				$('img_up_'+cat_id).setStyle('display','inline');
				$('img_down_'+cat_id).setStyle('display','none');
				if(cat_id == 'chatx'){

				 KIDE_activChat() ;
				}
				if($('ratrap') && cat_id == '0'){
					$('ratrap').setStyle('marginBottom','5px');
				}
			//	cacheroption();
				//initJavaScript(true);
			}
			e.stop();
			setCookie('pp_'+cat_id,status[slide.open],"");
		});

	
}

function monSlideOpen(cat_id,slide) {
			slide.slideOut();
			$('img_up_'+cat_id).setStyle('display','none');
			$('img_down_'+cat_id).setStyle('display','inline');
			if(cat_id == 'chatx'){
				$('p-tiempo').setStyle('visibility','hidden');
				$('KIDE_opciones').setStyle('visibility','hidden');				
				KIDE_desactivChat();
			}

			if($('ratrap') && cat_id == '0'){
				$('ratrap').setStyle('marginBottom','-3px');
			}
		//	cacheroption ();
			//initJavaScript(false);
}


function inserer_captcha() {
var nommation = $('contact_captcha');
if(	nommation != undefined){
nommation.id = "contact_captcha2";
nommation.setAttribute("name", "captcha" );
}
//document.forms["emailForm"].elements["captcha"].value = "Brassai";
} 


function arrondir(value) {
if (value < 100) { 
var out =  Math.round(value) /1000;
}else if (value < 1000 ) {
var out =  Math.round(hyperFocal /10) /100;
} else if (value < 10000 ) {
var out =  Math.round(value /100 )/10;
}else if (value < 100000 ) {
var out =  Math.round(value/1000);
} else {
var out =  Math.round(value /10000) *10 ;	
}
return out;
}

function dofield(dof) {
var infini= 0;
distance = (dof.distance.value)*1000;
CoC = (dof.format.options[dof.format.selectedIndex].value);
aperture = (dof.aperture.options[dof.aperture.selectedIndex].value);
focal = (dof.focal.options[dof.focal.selectedIndex].value);
if (distance == "" )  {
infini= 1;
hyperFocal = (focal * focal) / (aperture * CoC);
/*dof.distance.value= Math.round(hyperFocal) / 1000;*/
distance = hyperFocal;
}
hyperFocal = (focal * focal) / (aperture * CoC);
/*dof.hyperFocal.value  = Math.round(hyperFocal) / 1000 + " m";*/
dof.hyperFocal.value  = arrondir(hyperFocal)+ " m";
dofNear = (hyperFocal * distance) / (hyperFocal + (distance - focal));
/* dof.dofNear.value = Math.round(dofNear) / 1000 + " m"; */
dof.dofNear.value = arrondir(dofNear)+ " m";
dofFar = (hyperFocal * distance) / (hyperFocal - (distance - focal));
if (dofFar < 0 || infini == 1) {
dof.dofFar.value  = "Infini.";
}
else {
 /* dof.dofFar.value  = Math.round(dofFar)/1000+" m";*/
 dof.dofFar.value  = arrondir(dofFar)+" m";
}
dofTotal = Math.round(dofFar - dofNear);
if (dofTotal < 0 || infini == 1) {
dof.dofTotal.value  = "";
}
else {
if (dofTotal >= 0 && dofTotal < 0.001) {
dof.dofTotal.value  = ">1 mm ";
}
else {

dof.dofTotal.value = arrondir(dofTotal) + " m";
         }
      }
}

function detect_clicdroit(e, url) {
	var rightclick ;
	if (!e) var e = window.event;
	if (e.which) rightclick = (e.which == 3);
	else if (e.button) rightclick = (e.button == 2);
	if(rightclick  ==  true)  {
		window.location= url;
		return false;
	} else {
		return false;
	}
}
function validbutton(e) {
	var rightclick ;
	if (!e) var e = window.event;
	if (e.which) rightclick = (e.which == 3);
	else if (e.button) rightclick = (e.button == 2);
	if(rightclick  ==  true)  {	
		var nommation = $('contact_captcha2');
		if(nommation != undefined) {
			nommation.value = "Brassai";
			$('avertis').style.display = "none";
			$('btns').style.visibility = "visible";
		} else {
			alert('Merci de remplir les champs du formulaire');
		}
	}		
return false;
}
