var cur_this;

function MappyFlashComponent(divId,_width,_height,bg_color,sessionId,server,embPath,flashOK,initMode)
{
	var uid = new Date().getTime();
	this.loadFlag = flashOK;
	cur_this = this;

	var fo = new FlashObject(server+"/swf/i/static/BtoB/flashcomponent/bin/"+embPath+"?w="+_width+";h="+_height, divId, _width, _height, 7, "#efefef");
	fo.addParam("swLiveConnect", "true");
	fo.addParam("quality", "high");
	fo.addParam("menu", "false");
	fo.addParam("loop", "false");
	fo.addParam("scale", "noScale");
	fo.addParam("salign", "tl");
	fo.addParam("allowScriptAccess","always");
	fo.addParam("wmode", "transparent");

	fo.addVariable("lcId", uid);
	fo.addVariable("mappy_server", server);
	fo.addVariable("mappy_session", sessionId);
	fo.addVariable("stage_width", _width);
	fo.addVariable("stage_height", _height);
	fo.addVariable("fullscreen","0");
	fo.addVariable("bgcolor","0x"+bg_color);
	fo.addVariable("fpx", server+"/"+sessionId+"/Z?out=2;xsl=fpx");
	fo.addVariable("iti", server+"/"+sessionId+"/Z?out=2;xsl=iti");
	fo.addVariable("movie", server+"/x/i/static/BtoB/flashcomponent/bin/mappy-flashcomponent.swf?vs=1.01");
	fo.addVariable("initMode", initMode);

	fo.write("swfmap"); // attention : le divId passé en paramètre est trompeur : ce n'est pas un id de div c'est l'identifiant du flash ds les balise object et embed

	if (navigator.appName.indexOf( "Microsoft") != -1) 
	{ 
		this.flash = window[divId];
		//this.flash = window["myFlash"];
	}
	else
	{
		this.flash = document[divId];
		//this.flash = document["myFlash"];
	}
	//alert(this.flash);
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.moveMapPix = function(x,y) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.moveMapPix(x,y);
	} 
	else 
	{
		setTimeout("cur_this.flash.moveMapPix("+x+","+y+");", 500);
	}
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.moveMapGeo = function(coord_sys,x,y) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.moveMapGeo(coord_sys,x,y);
	} 
	else 
	{
		setTimeout("cur_this.flash.moveMapGeo("+coord_sys+","+x+","+y+");", 500);
	}
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.setMapMode = function(mode) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.setMapMode(mode);
	}
	else 
	{
		setTimeout("cur_this.flash.setMapMode("+mode+");", 500);
	}
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.setZoom = function(zoom_level) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.setZoom(zoom_level);
	} 
	else 
	{
		setTimeout("cur_this.flash.setZoom("+zoom_level+");", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.zoomPlus = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.zoomPlus();
	} 
	else 
	{
		setTimeout("cur_this.flash.zoomPlus();", 500);
	}
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.zoomMoins = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.zoomMoins();
	}
	else 
	{
		setTimeout("cur_this.flash.zoomMoins();", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.stopZoom = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.stopZoom();
	}
	else 
	{
		setTimeout("cur_this.flash.stopZoom();", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
var monparam=0;
MappyFlashComponent.prototype.addSimplePoi = function(id,coord_sys,x,y,type,number,txt) 
{
	//document.getElementById("debug").innerHTML += id + " " + eval(this.loadFlag) +  " " + (eval(this.loadFlag)==true) + "<br>";
	if (eval(this.loadFlag)) 
	{
		//monalert("ok");
		//alert("sqfdqsdf");
		this.flash.addSimplePoi(id,coord_sys,x,y,type,number,txt);
	} 
	else 
	{
	//	alert('t out '+id+" "+coord_sys+" "+x+" "+y+" "+type+" "+number+" "+txt);
	//document.getElementById("debug").innerHTML += "cur_this.flash.addSimplePoi('"+id+"',"+coord_sys+","+x+","+y+",'"+type+"',"+number+",'"+txt+"');" + "<br>";
		setTimeout("cur_this.flash.addSimplePoi('"+id+"',"+coord_sys+","+x+","+y+",'"+type+"',"+number+",'"+txt+"');", 900);
		//setTimeout("monalert('"+monparam+"');", 1000);
		//monparam += 1;
	}
	//document.getElementById("debug").innerHTML += id + " " + eval(this.loadFlag) +  " " + (eval(this.loadFlag)==true) + "<br>";
}
function monalert(monparam)
{
	//document.getElementById("debug").innerHTML += monparam;
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.addHTMLPoi = function(id,coord_sys,x,y,type,number,html,width, height, poi_bgcolor) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.addHTMLPoi(id,coord_sys,x,y,type,number,html,width, height, poi_bgcolor);
	} 
	else 
	{
		setTimeout("cur_this.flash.addHTMLPoi('"+id+"',"+coord_sys+","+x+","+y+",'"+type+"',"+number+",'"+html+"',"+width+","+height+","+poi_bgcolor+");", 500);
	}
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.addXMLPoi = function(id,coord_sys,x,y,type,number,xmlText) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.addXMLPoi(id,coord_sys,x,y,type,number,xmlText);
	} 
	else 
	{
		setTimeout("cur_this.flash.addXMLPoi('"+id+"',"+coord_sys+","+x+","+y+",'"+type+"',"+number+",'"+xmlText+"');", 1900);
	}
}


//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.selectAndZoom = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.selectAndZoom();
	} 
	else 
	{
		setTimeout("cur_this.flash.selectAndZoom();", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.modeDeplacement = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.modeDeplacement();
	} 
	else 
	{
		setTimeout("cur_this.flash.modeDeplacement();", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.modeZoom = function(zoomType) 
{
	if (eval(this.loadFlag))
	{
		this.flash.modeZoom(zoomType);
	}
	else 
	{
		setTimeout("cur_this.flash.modeZoom('"+zoomType+"');", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.modeZoomPlus = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.modeZoomPlus();
	} 
	else 
	{
		setTimeout("cur_this.flash.modeZoomPlus();", 500);
	}
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.modeZoomMoins = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.modeZoomMoins();
	} 
	else 
	{
		setTimeout("cur_this.flash.modeZoomMoins();", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.setMapMode = function(mode) 
{
	if (eval(this.loadFlag))
	{
		this.flash.setMapMode(mode);
	}
	else 
	{
		setTimeout("cur_this.flash.setMapMode('"+mode+"');", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.reloadMap = function() 
{
	if (eval(this.loadFlag))
	{
		this.flash.reloadMap();
	}
	else 
	{
		setTimeout("cur_this.flash.reloadMap();", 500);
	}
}
//----------------------------------------------------------
//
//
//
//

MappyFlashComponent.prototype.calculItiPoiToAdr = function(poiID,wn,tn,pc,cc,pimode) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.calculItiPoiToAdr(poiID,wn,tn,pc,cc,pimode);
	} 
	else 
	{
		setTimeout("cur_this.flash.calculItiPoiToAdr('"+poiID+"','"+wn+"','"+tn+"',"+pc+","+cc+","+pimode+");", 500);
	}	
}

//----------------------------------------------------------
//
//
//
//

MappyFlashComponent.prototype.calculItiAdrToPoi = function(poiID,wn,tn,pc,cc,pimode) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.calculItiAdrToPoi(poiID,wn,tn,pc,cc,pimode);
	} 
	else 
	{
		setTimeout("cur_this.flash.calculItiAdrToPoi('"+poiID+"','"+wn+"','"+tn+"',"+pc+","+cc+","+pimode+");", 500);
	}	
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.calculItiAdrToAdr = function(wn1,tn1,pc1,cc1,wn2,tn2,pc2,cc2,pimode) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.calculItiAdrToAdr(wn1,tn1,pc1,cc1,wn2,tn2,pc2,cc2,pimode);
	} 
	else 
	{
		setTimeout("cur_this.flash.calculItiAdrToAdr('"+wn1+"','"+tn1+"',"+pc1+","+cc1+",'"+wn2+"','"+tn2+"',"+pc2+","+cc2+","+pimode+");", 500);
	}	
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.getRoadMapURL = function(callBackFunction) 
{
	/*
	var temp = setTimeout("cur_this.flash.getRoadMapURL();", 500);
	alert("js : "+this.flash.getRoadMapURL());
	*/
	
	if (eval(this.loadFlag)) 
	{
		this.flash.getRoadMapURL(callBackFunction);
	} 
	else 
	{
		setTimeout("cur_this.flash.getRoadMapURL('"+callBackFunction+"');", 500);
	}
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.getVisibleAreaCoordinates = function(callBackFunction,out_cs) 
{	
	if (eval(this.loadFlag)) 
	{
		this.flash.getVisibleAreaCoordinates(callBackFunction,out_cs);
	} 
	else 
	{
		setTimeout("cur_this.flash.getVisibleAreaCoordinates('"+callBackFunction+"',"+out_cs+");", 500);
	}
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.removePOI = function(poiID) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.removePOI(poiID);
	} 
	else 
	{
		setTimeout("cur_this.flash.removePOI("+poiID+");", 500);
	}	
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.drawEllipse = function(p_x, p_y, xRadius, yRadius, lineWidth, lineColor, fillAlpha, fillColor)
{
	if (eval(this.loadFlag)) 
	{
		this.flash.drawEllipse(p_x, p_y, xRadius, yRadius, lineWidth, lineColor, fillAlpha, fillColor);
	} 
	else 
	{
		setTimeout("cur_this.flash.drawEllipse("+p_x+", "+p_y+", "+xRadius+", "+yRadius+", "+lineWidth+", "+lineColor+", "+fillAlpha+", "+fillColor+", );", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.drawRectangle = function(x, y, w, h, cornerRadius, lineWidth, lineColor, fillAlpha, fillColor) 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.drawRectangle(x, y, w, h, cornerRadius, lineWidth, lineColor, fillAlpha, fillColor);
	} 
	else
	{
		setTimeout("cur_this.flash.drawRectangle("+x+", "+y+", "+w+", "+h+", "+cornerRadius+", "+lineWidth+", "+lineColor+", "+fillAlpha+", "+fillColor+");", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.drawLine = function(startx, starty, endx, endy, thickNess, lineColor, len, gap) 
{
	//alert('drawLine JS');
	//Line(startx:Number, starty:Number, endx:Number, endy:Number, thickNess:Number, dashedLineColor:Number, len:Number, gap:Number, mcToDrawIn:MovieClip)
	
	if (eval(this.loadFlag)) 
	{
		this.flash.drawLine(startx, starty, endx, endy, thickNess, lineColor, len, gap);
	}
	else 
	{
		setTimeout("cur_this.flash.drawLine("+startx+","+starty+","+endx+","+endy+","+thickNess+","+lineColor+","+len+","+gap+");", 500);
	}
	
}
//----------------------------------------------------------
//
//
//
//

MappyFlashComponent.prototype.displayPOIrollOver = function(poiID) 
{
	//alert('drawLine JS');
	//Line(startx:Number, starty:Number, endx:Number, endy:Number, thickNess:Number, dashedLineColor:Number, len:Number, gap:Number, mcToDrawIn:MovieClip)
	if (eval(this.loadFlag)) 
	{
		this.flash.displayPOIrollOver(poiID);
	}
	else 
	{
		setTimeout("cur_this.flash.displayPOIrollOver("+poiID+");", 500);
	}
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.removePOIrollOver = function(poiID) 
{
	//alert('drawLine JS');
	//Line(startx:Number, starty:Number, endx:Number, endy:Number, thickNess:Number, dashedLineColor:Number, len:Number, gap:Number, mcToDrawIn:MovieClip)
	
	if (eval(this.loadFlag)) 
	{
		this.flash.removePOIrollOver(poiID);
	}
	else 
	{
		setTimeout("cur_this.flash.removePOIrollOver("+poiID+");", 500);
	}
	
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.getPixelCoordoOfPoi = function(poiID, callBackFunction) 
{
	//alert('drawLine JS');
	//Line(startx:Number, starty:Number, endx:Number, endy:Number, thickNess:Number, dashedLineColor:Number, len:Number, gap:Number, mcToDrawIn:MovieClip)
	
	if (eval(this.loadFlag)) 
	{
		this.flash.getPixelCoordoOfPoi(poiID, callBackFunction);
	}
	else 
	{
		setTimeout("cur_this.flash.getPixelCoordoOfPoi("+poiID+",'"+callBackFunction+"');", 500);
	}
	
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.masqueFlechesNav = function() 
{
	//alert('drawLine JS');
	//Line(startx:Number, starty:Number, endx:Number, endy:Number, thickNess:Number, dashedLineColor:Number, len:Number, gap:Number, mcToDrawIn:MovieClip)
	
	if (eval(this.loadFlag)) 
	{
		this.flash.masqueFlechesNav();
	}
	else 
	{
		setTimeout("cur_this.flash.masqueFlechesNav();", 500);
	}
	
}
//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.afficheFlechesNav = function() 
{
	//alert('drawLine JS');
	//Line(startx:Number, starty:Number, endx:Number, endy:Number, thickNess:Number, dashedLineColor:Number, len:Number, gap:Number, mcToDrawIn:MovieClip)
	
	if (eval(this.loadFlag)) 
	{
		this.flash.afficheFlechesNav();
	}
	else 
	{
		setTimeout("cur_this.flash.afficheFlechesNav();", 500);
	}
	
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.sendMail = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.sendMail();
	}
	else 
	{
		setTimeout("cur_this.flash.sendMail();", 500);
	}
	
}

//----------------------------------------------------------
//
//
//
//
MappyFlashComponent.prototype.printMap = function() 
{
	if (eval(this.loadFlag)) 
	{
		this.flash.printMap();
	}
	else 
	{
		setTimeout("cur_this.flash.printMap();", 500);
	}
	
}
