/*-------------------------------GLOBAL VARIABLES------------------------------------*/

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
/*-----------------------------------------------------------------------------------------------*/
//Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/
function getBrowserInfo() {
	if (checkIt('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser 	= "Safari"
	else if (checkIt('omniweb')) browser 	= "OmniWeb"
	else if (checkIt('opera')) browser 		= "Opera"
	else if (checkIt('webtv')) browser 		= "WebTV";
	else if (checkIt('icab')) browser 		= "iCab"
	else if (checkIt('msie')) browser 		= "Internet Explorer"
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux')) OS 		= "Linux";
		else if (checkIt('x11')) OS 	= "Unix";
		else if (checkIt('mac')) OS 	= "Mac"
		else if (checkIt('win')) OS 	= "Windows"
		else OS 								= "an unknown operating system";
	}
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

/*-----------------------------------------------------------------------------------------------*/
function hideSelects(visibility){
	if (browser == "Internet Explorer"){
		selects = document.getElementsByTagName('select');
		for(i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
	}
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getSize() {
  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;
  }
  return [ (myWidth), myHeight ];
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

var separateur = '///', newWidth = 0, newHeight = 0, current = '', strToReturn = '', imgPath = '';
function flipDiapo(divID1,divID2,imgPath) {
	imgPath = (imgPath == null || imgPath == '')? 'none' : imgPath;
	
	currentbody = (document.body.style.overflow == 'auto') ? 'hidden' : 'auto';
	document.body.style.overflow = currentbody;
	//on dimensionne la div dans la fenetre
	//var bordures = 24;
	var bordures = 0;
	laTaille = getSize();
	newWidth = laTaille[0] - bordures;
	newHeight = laTaille[1] - bordures;
	newWidth2 = newWidth;
	//newHeight2 = newHeight - 20;
	newHeight2 = newHeight - 0;
	document.getElementById(divID1).style.width = newWidth + "px";
	document.getElementById(divID1).style.height = newHeight + "px";
	document.getElementById(divID2).style.width = newWidth2 + "px";
	document.getElementById(divID2).style.height = newHeight2 + "px";
	//document.getElementById(divID2).style.top = "20px";
	//document.getElementById('divID2').style.width = newWidth2 + "px";
	//document.getElementById('divID2').style.height = newHeight2 + "px";
	
	//on redimensionne l'objet / embed
	thisMovie("flash2").width = newWidth2 + "px";
	thisMovie("flash2").height = newHeight2 + "px";
	
	//on replace la div dans le navigateur
	leScroll = getScrollXY();
	newposX = leScroll[0] + (bordures/2);
	newposY = leScroll[1] + (bordures/2);
	document.getElementById(divID1).style.left = newposX + "px";
	document.getElementById(divID1).style.top = newposY + "px";
	document.getElementById(divID2).style.left = newposX + "px";
	document.getElementById(divID2).style.top = newposY + "px";
	
	current = (document.getElementById(divID1).style.display == 'none') ? 'block' : 'none';
	document.getElementById(divID1).style.display = current;
	document.getElementById(divID2).style.display = current;
	//document.getElementById(divID1).style.border = "2px solid #900";
	
	
	if(current == 'none'){
		hideSelects('visible');
	}else{
		hideSelects('hidden');
	}
	
	strToReturn = newWidth2 + separateur + newHeight2 + separateur + current + "Div" + separateur+ imgPath;
}

function calledFromAS() {
	return  strToReturn;
}
function showFO(){
var str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '; 
str += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ';
str += ' width="' + screen.availWidth + '" height="' + screen.availHeight + '" align="left" id="flash2"> ';
str += '<param name="movie" value="flash/diaporama.swf"> ';
str += '<param name="quality" value="high"> ';
str += '<param name="scale" value="noscale"> ';
str += '<param name="salign" value="LT"> ';
str += '<param name="wmode" value="transparent"> ';
str += '<embed src="flash/diaporama.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ';
str += 'type="application/x-shockwave-flash" ';
str += 'width="' + screen.availWidth + '" height="' + screen.availHeight + '" ';
str += 'wmode="transparent" ';
str += 'salign="LT" scale="noscale" ';
str += 'align="left" name="flash2"></embed> ';
str += '</object>';
		document.write(str);
}


