var interv;
function patientez(){
	setTimeout("fin_patientez()",800);
	document.getElementById('patientez').style.display='block';
}
function fin_patientez() {
	document.getElementById('patientez').style.display='none';
}


function setData(idFlash, st1, st2){
	if(flashDisponible){
		st1 = st1.replace(/#/gim, "0x");
		thisMovie(idFlash).setData(st1, st2);
	}
}
function setColor(idFlash, st1){
	if(flashDisponible){
		st1 = st1.replace(/#/gim, "0x");
		thisMovie(idFlash).setColor(st1);
	}
}

function setDesign(idFlash, st1){
	if(flashDisponible){
		thisMovie(idFlash).setDesign(st1);
	}
}




function changeTissu(image){
	if(flashDisponible){
		callExternalTissu(image);
	}
}

function changeTissu2(image){
	if(flashDisponible){
		callExternalTissu2(image);
	}
}


function changerPiece(piece, type){
	if(flashDisponible){
		callExtChangerPiece(piece,type);
	}
}


// 3 valeurs possibles : "col", "face", "dos"
function changerVue(laVue){
	if(flashDisponible){
		ext_cgView(laVue);
	}
}
function colorFormat(color){
return color.replace("#", "0x");
}

//une couleur au format #aaaaaa
function cgColorBoutons(color){
	if(flashDisponible){
	color = colorFormat(color);
		thisMovie("application").cgColorBoutons(color);
	}
}


//une couleur au format #aaaaaa
function cgColorCoutures(color){
	if(flashDisponible){
		if(color && color.match(/^#(?:\d|[a-f]){6}$/gi)){
			color = colorFormat(color);
			thisMovie("application").cgColorCoutures(color);
		}else{
			thisMovie("application").cgColorCoutures();
		}
	}
}
//une couleur au format #aaaaaa
function cgColorBoutonieres(color){
	if(flashDisponible){
		if(color && color.match(/^#(?:\d|[a-f]){6}$/gi)){
			color = colorFormat(color);
			thisMovie("application").cgColorBoutonieres(color);
		}else{
			thisMovie("application").cgColorBoutonieres();
		}
	}
}
//une couleur au format #aaaaaa
function cgColorCoutEtBout(color){
	if(flashDisponible){
		if(color && !color.match(/Ton\ssur\sTon/gi)){
			color = colorFormat(color);
			thisMovie("application").cgColorCoutEtBout(color);
		}else{
			thisMovie("application").cgColorCoutEtBout();
		}
	}
}
/*
//col blanc (et vice versa) 
function ext_col_color(){
	thisMovie("application").col_color();
}

//poignet blanc (et vice versa) 
function ext_poignet_color(){
	thisMovie("application").poignet_color();
}
*/


function recupData(){
	if(flashDisponible){
		thisMovie("application").recupData();
	}
}

function sendData(myObject){
	document.getElementById("targetField").value = myObject;
}

var flashDisponible = false;
function flashDispo(){
//appelée lorsque le fla est disponible
flashDisponible = true;
}
function flashIndispo(){
//appelée lorsque le fla est Indisponible
flashDisponible = false;
}

function tissusCol(aa){
	if(flashDisponible){
		thisMovie("application").tissusCol(aa);
	}else{
		patientez();
	}
}
function tissusPoignet(aa){
	if(flashDisponible){
		thisMovie("application").tissusPoignet(aa);
	}else{
		patientez();
	}
}

function ext_cgView(newView){
	thisMovie("application").cgView(newView);
}

/*
function callExtManches_courtes(){
	thisMovie("application").manches_courtes();	
}*/

function callExtChangerPiece(a,b) {
	thisMovie("application").changer(a,b);
}
function callExternalTissu(numTissu){
	thisMovie("application").changer_tissu(numTissu);
}

function callExternalTissu2(numTissu){
	thisMovie("application").changer_tissu2(numTissu);
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
	  return window[movieName]
	}
	else {
		if(document[movieName] != undefined){
			return document[movieName];
		}else{
			return document.getElementById(movieName);
		}
	}
}

