/*
	Global JS
*/


/*
	On load
*/
window.addEvent('domready', setActiveStyleSheet);

/*
	Gestions des sons
*/
		soundManager.flashVersion = 9;
		soundManager.url = 'js/soundmanager2/'; // directory where SM2 .SWFs live
		soundManager.debugMode = false;
		//soundManager.defaultOptions.multiShot = true;

		soundManager.onload = function() {
			init();
		}
		
		function init() {
			roll = soundManager.createSound({
				id: 'roll',
				url: 'js/soundmanager2/sound/tuck.mp3',
				volume: 15,
				multiShot: true,
				autoLoad: true,
				autoPlay: false
		  		});
			click = soundManager.createSound({
				id: 'click',
				url: 'js/soundmanager2/sound/tick.mp3',
				volume: 5,
				multiShot: true,
				autoLoad: true,
				autoPlay: false
		  		});
		}



/*
	Blur link pour firefox
*/
function blurLink(theObject){
	theObject.blur();
}
/*
	Fonction goto pour flash et div
*/
function goTo(url){
	window.location.href=url
}
/*
	Fonction de validation de la resolution
*/
function checkRes(){	
	if ( screen.width<=1024) {
		return true;
	}
}
/*
	Affichage ou non du style pour petite resolution
*/

function setActiveStyleSheet() {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") == "lowres" ) {
			a.disabled = true;
		    if ( checkRes() == true ) a.disabled = false;
		}
	}
}
/*
	Fonctions pour fiches metiers
*/

var currentBlocSelected=0;
var currentSectionSelected='';

function fc_prev6() {
	if (blocVisible(currentBlocSelected - 1, currentBlocSelected))
		currentBlocSelected -= 1;
}
function fc_next6() {
	if(blocVisible(currentBlocSelected + 1, currentBlocSelected))
		currentBlocSelected += 1;
}

function blocVisible(idVisible,idHidden) {
	if (document.getElementById('tous6_'+idVisible)) {
		document.getElementById('tous6_'+idHidden).className='unactive';
		document.getElementById('tous6_'+idVisible).className='active';
		return true;
	} else {
		return false;
	}
}

function fc_prev6_selection() {
	if (blocVisibleSelection(currentBlocSelected - 1, currentBlocSelected))
		currentBlocSelected -= 1;
}

function fc_next6_selection() {
	if (blocVisibleSelection(currentBlocSelected + 1, currentBlocSelected))
		currentBlocSelected += 1;
}

function blocVisibleSelection(idVisible,idHidden) {
	if (document.getElementById(currentSectionSelected+'_tous6_'+idVisible)) {
		if (document.getElementById(currentSectionSelected+'_tous6_'+idHidden))
			document.getElementById(currentSectionSelected+'_tous6_'+idHidden).className='unactive';
		document.getElementById(currentSectionSelected+'_tous6_'+idVisible).className='active';
		return true;
	} else {
		return false;
	}
}

function blocSelectionSelected(actual) {
	if (document.getElementById(currentSectionSelected)) {
		document.getElementById(currentSectionSelected).className='unactiveBloc';
		document.getElementById(currentSectionSelected+'_tous6_'+currentBlocSelected).className='unactive';
	}

	if (document.getElementById(actual)) {
		document.getElementById('nosRealisations').style.visibility = 'visible';
		currentSectionSelected = actual;
		currentBlocSelected = 0;
		document.getElementById(currentSectionSelected).className='activeBloc';
		document.getElementById(currentSectionSelected+'_tous6_'+currentBlocSelected).className='active';
		return true;
	} else {
		return false;
	}
}

function sendDataVignette(reloadLink, flashVignetteID) {
	//alert("Sendata..."+reloadLink+document.getElementById('myFlashVignette1').style.display);
	var obj = swfobject.getObjectById("myFlashVignette"+flashVignetteID);
	if (obj && typeof obj.reload != "undefined") {
		//alert("passé..."+reloadLink);
		obj.reload(reloadLink);
	} else {
		//var d = new Date();
		//alert("ratardé Alert JS"+ d.getSeconds() );
		setTimeout('sendData('+reloadLink+');',200);
	}
}

/*
	Fonction pour le fullscreen
*/

function showFS(showID) {
			//Gerer la taille en live du div FS 
	var todiv = document.getElementById('flash-fullscreen');
 	todiv.style.display = 'block';
 	todiv.style.height = '100%';
 	todiv.style.width = '100%';
 		
 			//Gerer le scroll du body
	var todiv = document.getElementById('body');
 	todiv.style.overflow = 'hidden';
 			
 			//myFlashMedium
	var todiv_un = document.getElementById('flash-myFlashMedium');
 	todiv_un.style.display = 'none';
	sendDataFS(showID);
}

function sendDataFS(showID) {
	var obj = swfobject.getObjectById("myFullScreenContent");
	//document.title = "Sendata... "+showID+document.getElementById('flash-fullscreen').style.display+" / "+obj;
	if (obj && typeof obj.callBackJS != "undefined") {
		//alert("passé..."+showID);
		obj.callBackJS(showID);
		//obj.SetVariable("myVar", "test");
	} else {
		//alert("Erreur, le div FS n'est pas identifie...")
		//var d = new Date();
		//document.title += " / ratarde Alert JS "+ d.getSeconds();
		setTimeout('sendDataFS('+showID+');',10);
	} 
}
function fc_removeDiv() {
	var todiv = document.getElementById('flash-fullscreen');
 	todiv.style.display = 'none';
	var todiv = document.getElementById('body');    			
 	todiv.style.overflow = 'auto';
	var todiv_un = document.getElementById('flash-myFlashMedium');
 	todiv_un.style.display = 'block';
}






/*
	Old
*/

//			addEvent(window, 'load', setActiveStyleSheet);
			/*function addEvent(obj, evType, fn){ 
				if (obj.addEventListener){ 
					obj.addEventListener(evType, fn, false); 
					return true; 
				} else if (obj.attachEvent){ 
					var r = obj.attachEvent("on"+evType, fn); 
					return r; 
				} else { 
					return false; 
				} 
			}*/
			
/*function inc(filename)
{
	var body = document.getElementsByTagName('body').item(0);
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	body.appendChild(script)
}

inc("js/soundmanager2/script/soundmanager2.js");

// several more functions that call functions in the above two files
function blah(foo)
{
	if (isBlank(foo)) return false;
}
*/
