var userAgent = window.navigator.userAgent ;

function DefineObjById(id) {
	identity=document.getElementById(id);
	if(identity.style) {
		identity = identity.style ;
	}
	return identity ;
}
//
function CropBrowser(movie,zoneWidth,zoneHeight) {
	//if(movie) { // faire qqchoz ; }
	window.focus() ;		
	var DuckBrowser = false ;
	if(userAgent.search("MSIE") > 0) {
		DuckBrowser = true ;		
	}
	if(userAgent.search("Safari") > 0) {
		DuckBrowser = true ;
	}
	var grafixL = 20 ;
	var grafixR = 20 ;
	var grafixT = 43 ;
	var grafixB = 10 ;
	
	var xWidth = parseInt(zoneWidth)+parseInt(grafixL)+parseInt(grafixR) ;
	var xHeight = parseInt(zoneHeight)+parseInt(grafixT)+parseInt(grafixB) ;
	
	var MoveX = ( window.screen.availWidth - parseInt(xWidth) )/2;
	var MoveY = ( window.screen.availHeight - parseInt(xHeight) )/3;
	window.moveTo(parseInt(MoveX),parseInt(MoveY));

	var DeltaW = 0 ;
	var DeltaH = 0 ;
	
	if(userAgent.search("Safari") > 0) {
		DeltaW = 0 ;
		DeltaH = 112 ;
	}
	if(userAgent.search("Camino") > 0) {
		DeltaW = 0 ;
		DeltaH = 116 ;
	}
	if(userAgent.search("MSIE") > 0) {
		if(userAgent.search("Mac") > 0) {
			DeltaW = 37 ;
			DeltaH = 124 ;
		} else {
			DeltaW = 29 ;
			DeltaH = 147 ;
		}
	}
	var totalWidth = parseInt(xWidth)+parseInt(DeltaW) ;
	var totalHeight = parseInt(xHeight)+parseInt(DeltaH) ;
	
	if ( DuckBrowser ){
		if (window.screen.availHeight > xHeight || window.screen.availWidth > xWidth){
			window.resizeTo(totalWidth,totalHeight);
		} else {
			window.resizeTo(window.screen.availWidth,window.screen.availHeight);
		} 
	} else {
		if (window.screen.availHeight > xHeight || window.screen.availWidth > xWidth){
			window.innerWidth = xWidth;
			window.innerHeight = xHeight ;
		} else {
			window.outerWidth = window.screen.availWidth;
			window.outerHeight = window.screen.availHeight;
		}
		window.menubar.visible = false;
		window.statusbar.visible =false;
		window.toolbar.visible = true;
		window.locationbar.visible = false;
		window.personalbar.visible = false;
		window.scrollbars.visible = true;
	}	
}
//
function WindowValues(coordXorY) {
	var posvalue ;
	if(userAgent.search("MSIE") > 0) {		
		if(coordXorY == 'onX') {
			posvalue = document.body.clientWidth - document.body.scrollLeft ;
		} else {
			posvalue = document.body.clientHeight - document.body.scrollTop ;
		}
	} else {    
		if(coordXorY == 'onX') {
			posvalue = window.innerWidth ;
		} else {
			posvalue = window.innerHeight ;
		}
	}	
	return posvalue ;
}
//
function changeclass(id, newClass) {
	identity=document.getElementById(id);	
	identity.className=newClass;
}
//
function multichangesubmit(position,fix,classic) {
	if (version >= 3) {
		changeimage(position,'left'+fix,'submit_left');
		changeimage(position,'right'+fix,'submit_right');
		changeclass(fix, classic+' roll'+position+'submit');
	}
}
// change tout type dimages qqsoit le dossier
function changedimage(path,name,img) {
	document.images[name].src = path + repertoire + img ;
} 
// change les images en gif
function changeimage(position,name,img) {
	document.images[name].src = chemin + position + repertoire + img + extension ;
}
// Determine la version du navigateur
var version;
	 if (parseInt(navigator.appVersion) >=4)
         version=4;
else if (navigator.appName=="Netscape" && parseInt(navigator.appVersion) >=3)
         version=3;
         else
         version=2;
//
function openWin(theUrl) {
	var deltaW = 60 ;
	var deltaH = hmore+40 ;
	var	W_enlarge = Wenlarge+deltaW ;
	var H_enlarge = Henlarge+deltaH ;
	var	W_extra = Wextra+deltaW ;
	var H_extra = Hextra+deltaH ;
	var	W_friend = Wfriend+deltaW ;
	var H_friend = Hfriend+deltaH ;
	var	W_sendfr = Wsendfr+deltaW ;
	var H_sendfr = Hsendfr+deltaH ;	
			
	var test_script_enlarge = script_enlarge.substr(0,4);
	var test_script_extras  = script_extras.substr(0,4);
	var test_script_friend  = script_friend.substr(0,4);
	var test_script_sendfr  = script_sendfr.substr(0,4);
	
	var features = "resizable=yes,scrollbars=yes,toolbar=no,copyhistory=no,channelmode=no,directories=no,titlebar=no" ;
	if(theUrl.substr(0,4) == test_script_enlarge ){
		features+= ",width="+W_enlarge+",height="+H_enlarge ;
		
	} else if(theUrl.substr(0,4) == test_script_extras){
		features = "width="+W_extra+",height="+H_extra ;
		
	} else if(theUrl.substr(0,4) == test_script_friend){
		features+= ",width="+W_friend+",height="+H_friend ;
		
	} else if(theUrl.substr(0,4) == test_script_sendfr){
		// titre de la page de reference		
		searchOE = /Œ/  ; var replaceOE = "OE" ;
		search_oe = /œ/ ; var replace_oe = "oe" ;
		mytitle = mytitle.replace(searchOE,replaceOE);
		mytitle = mytitle.replace(search_oe,replace_oe);
		theUrl+= "&theme="+themnam+"&reftitre="+escape(mytitle) ;
		features+= ",width="+W_sendfr+",height="+H_sendfr ;
		
	} else if(theUrl.substr(0,8) == "musicbox"){
		features = "width=100,height=100" ;
	} else {
		features+= ",width="+W_friend+",height="+H_friend ;
	}
	
	if (version >= 3){
		win = window.open(theUrl,winName,features);
		win.focus();
	} else {
		window.open(theUrl,winName,features);
	}
}