﻿var xhr = null;

function getXhr(){
	var xhr = null; 
	if(window.XMLHttpRequest) // Firefox et autres
	   xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject){ // Internet Explorer 
		try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} 
		catch(e){
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
	}
	else if(window.ActiveXObject){
    	xhr = new ActiveXObject("Msxml2.XMLHTTP.4.0");//internet explorer version 7
	}	
	else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xhr = false;
	} 
	return xhr;
}


/* Fonction trim, pour enlever les espaces au debut et a la fin du variable */
function trim(s){ 
    s=removebeforechar(s); 
    s=removeafterchar(s); 
    return s; 
} 

function removebeforechar(t){ 
	if(t.charCodeAt(0)==32 || t.charCodeAt(0)==12288) 
	{ 
		t=t.slice(1,t.length); 
		return   removebeforechar(t); 
	} 
	else 
	{ 
		return t; 
	} 
}

function removeafterchar(t){ 
	if(t.charCodeAt(t.length-1)==32 || t.charCodeAt(t.length-1)==12288) 
	{ 
		t=t.slice(0,t.length-1); 
		return   removeafterchar(t); 
	} 
	else 
	{ 
		return t; 
	 } 
}

function movePhoto(nomimg,imgurl) {
	document[nomimg].src=imgurl;
}

/* ======================== Fonction trim ==================================*/



 /**ajax connexion sur les page dynamique asp
  * postBody : transferer les donnees, si choisissez poster en post, il faut utiliser $("#form_id").serialize() pour realier les variables
  * asoft_asp_file : URL de asp
  * gf_method : type de transfer get ou post
  * Element_ID : element id de retour
  * is_async : 
  */
function Load_getUEUPData(postBody,asoft_asp_file,gf_method,Element_ID,is_async){
	var return_temp;
	$.ajax({
		async: is_async,
		url: asoft_asp_file,
		type: gf_method,
		data:postBody,
		cache:false,
		success: function(data){
			if(Element_ID=="alert"){alert(data);}
			if(Element_ID!=""){$("#"+Element_ID).attr("innerHTML",data);}
			return_temp=data;
		}
	});
	return return_temp;
}



function jsleft(lefts,leftn){
	var sl=lefts;
	sl = sl.substring(0,leftn);
	return sl;
}

/* =====================================================================================================*/

$(document).ready(function() {
    $('a[href=#maincontainer]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });
});


$(function(){
	$("#accordion").accordion({autoHeight: false});
});


$(function(){
	$("#galerie").accordion({autoHeight: false});
});


$(function() {
	$(".newsticker-jcarousellite").jCarouselLite({
		vertical: true,
		hoverPause:true,
		btnNext: ".next",
        btnPrev: ".prev",
		visible: 1,
		auto:4000,
		speed:500
	});
});


$(document).ready(function(){
	$("#breadCrumb3").jBreadCrumb();
});


function changer_langue(langue){
	//alert(langue);
	var Then = new Date();
	Then.setTime(Then.getTime()+365*24*60*60*1000);
	document.cookie="strLangue=" + langue + ";expires=" + Then.toGMTString();
	//window.history.go(0);
	document.location.reload();
};


$().ready(function() {
       $('#coda-slider-1').codaSlider({
           dynamicArrows: false,
           dynamicTabs: false
       });
   });


/* =============================== Highslide galerie ============================================= 
hs.graphicsDir = 'highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.numberPosition = 'caption';
hs.dimmingOpacity = 0.75;

// Add the controlbar
hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: .75,
		position: 'bottom center',
		hideOnMouseOut: true
	}
});*/

	hs.graphicsDir = 'highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.fadeInOut = true;
	hs.outlineType = 'rounded-white';
	hs.preserveContent = false; // always use this with flash, else the movie will be stopped on close
	hs.wrapperClassName = 'draggable-header no-footer';
	hs.dimmingOpacity = 0.8;

	// Add the slideshow providing the controlbar and the thumbstrip
	if (hs.addSlideshow) hs.addSlideshow({
		slideshowGroup: 'group1',
		//thumbnailId: 'thumb1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			position: 'bottom center',
			opacity: .75,
			hideOnMouseOut: true
		},
		thumbstrip: {
		slideshowGroup: 'group1',
		position: 'above',
		mode: 'horizontal',
		relativeTo: 'expander'
	}

	});
	

// create a shorthand function so we don't need to put all this in the opener's onclick
function openYouTube(opener) {
	var returnValue;
	
	// Safari Mobile doesn't have Flash, so we just let the device use the built-in 
	// YouTube viewer.		
	if (/(iPhone|iPod|iPad)/.test(navigator.userAgent)) {
		opener.href = opener.href.replace('/v/', '/watch?v=');
		returnValue = true;		
	}

	else returnValue = hs.htmlExpand(opener, { 
		objectType: 'swf', 
		objectWidth: 640, 
		objectHeight: 390, 
		width: 640, 
		swfOptions: { 
			params: { 
				allowfullscreen: 'true' 
			}
		}, 
		maincontentText: 'You need to upgrade your Flash player' 
	});
	
	return returnValue;
}  

/* =============================== Fin Highslide galerie ========================================= */


/* ================================ Photo Diaporama================================================ */
$(document).ready(function () {
	$('.highslide-gallery').cycle({
		fx: 'fade', speed: 300,timeout: 7000
	}); 
});

/* ================================ Photo Diaporama================================================ */

