// JavaScript Document for Tissot 14-02-2006
function VerifEntier(){
	//alert(event.keyCode);
		if (event.keyCode < 46 || event.keyCode > 57)
		{
				//alert("false");
				event.returnValue = false;
		}
	}
function popImage(imageURL,imageTitle){
	PositionX = 10;
PositionY = 10;
defaultWidth  = 600;
defaultHeight = 400;

//kinda important
var AutoClose = true;
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
		(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
		'<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
		(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

function setBull(numImg,source){
		document.images[numImg].src = source;
}
// Détéction des browsers
var NS4=(document.layers)?1:0;
var IE=(document.all)?1:0; 
var NS6=(!document.all && document.getElementById)?1:0;

// detection OS
var MacOS=(navigator.appVersion.indexOf("Mac")!=-1)?1:0;

var timer1=setTimeout("",0);
var list=new Array('menuPrincipal_div1','menuPrincipal_div2','menuPrincipal_div3'); 
var isNewmenu = true;
var posYMenu;
var posXMenu;

function init(){
	clearTimeout(timer1);
	for(i in list){
		this.css=est.dom?document.getElementById(list[i]).style:est.ie?document.all[list[i]].style:est.ns?document.layers[list[i]]:0;
		if(!NS6){
			if(IE){
				//document.all[list[i]].filters[0].Apply() ;
				this.css.visibility='hidden';
				//document.all[list[i]].filters[0].Play() ;
			}else{
				this.css.visibility='hidden';	
			}
		}else{
			this.css.visibility='hidden';
		}
	}
}

function ia(){
	timer1=setTimeout('init();',100);
}

function ct(){
	clearTimeout(timer1);
}

function sh(div,state,imgRef,dX,dY){
	clearTimeout(timer1);
	this.css=est.dom?document.getElementById(div).style:est.ie?document.all[div].style:est.ns?document.layers[div]:0;
	this.css.left = moveXbySlicePos(imgRef) + dX;
	this.css.top = moveYbySlicePos(imgRef) + dY;
	if(!NS6){
		if(IE){
			//document.all[div].filters[0].Apply() ;
			this.css.visibility=state;
			//document.all[div].filters[0].Play() ;
		}else{
			this.css.visibility=state;
		}
	}else{
		this.css.visibility=state;
	}
	/*this.css=est.dom?document.getElementById("tri"+div).style:est.ie?document.all["tri"+div].style:est.ns?document.layers["tri"+div]:0;
	this.css.visibility=state;
	this.css.top = posYMenu; */	
}

function Browser(){
	b=navigator.appName;
	if(b=="Netscape"){
		this.b="ns"; 
	}else{
		if(b=="Microsoft Internet Explorer"){
			this.b="ie";
		}else{
			this.b=b;
		}
	}
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns"&&this.v>=4);
	this.ie=(this.b=="ie"&&this.v>=4);
	this.dom=((document.createRange&&(document.createRange().createContextualFragment))?true:false);
}

est=new Browser();

function getExplorerVersion() {
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;
	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) {
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}

//---- determination de la position de y ------------//
function moveYbySlicePos (ImgName) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = document.images[ImgName];
		var lastOffset = 0;
		var y = 0 ;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (par.y >= 0) y += par.y;
	return y;
}
//---- determination de la position de x ------------//
function moveXbySlicePos (ImgName) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = document.images[ImgName];
		var lastOffset = 0;
		var x = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (par.x) x += par.x;
	return x;
}

function newMenu(isnew) {
	isNewmenu = true;	
}
function MM_openBrWindow(theURL,winName,features,position) { //v2.0	
   	var pop = window.open(theURL,winName,features);
	var windowX = screen.width - position;
	pop.moveTo(windowX,0);
	pop.focus();
}
function MM_openBrWindow2(theURL,winName,features,position) { //v2.0	
   	var pop = window.open(theURL,winName,features);
	var windowX = (screen.width - position)/2;
	pop.moveTo(windowX,0);
	pop.focus();
}

var dontshwfield;
function montreChamp(fieldName) {
	dontshwfield = document.getElementById(fieldName).style.visibility = "visible" ;
}
function cacheChamp(fieldName) {
	document.getElementById(fieldName).style.visibility = "hidden" ;
}

//----------- cache champs -------------//
var timeOutID ;
function showHiddenDiv(state){
	clearTimeout(timeOutID) ;
	var message="";
	var idDiv;
	var list = document.body.getElementsByTagName("DIV");
	for(i=0; i<list.length; i++){
		idDiv = list[i].id ;
		if (idDiv.substr(0,3) == "div"){
			divObj = eval(document.all[idDiv].style) ;
			/*if(state=='visible')
				timeOutID = setTimeout("divObj.visibility = 'visible';",100);
			else*/ 
				document.all[idDiv].style.visibility = state;
		}
	}
}

function opacityHandler(transparent, menu){
	if(transparent){
		document.getElementById(menu).className='pasdopacity';
	}else{
		document.getElementById(menu).className='';
	}
	return true;
}