
	

function Flash() {

  var t=this
  var args="";
  var commandsQueue = new Array()


//////////////////////////////////////////////////////////////
t.init = function(_id,_width,_height,_src,_bgColor,_transparent,_parentObjectId) {
	t.id=_id
	t.width=_width
	t.height=_height
	t.src=_src
	t.bgColor=_bgColor
	t.transparent=_transparent
	t.version = "6,0,0,0"
	t.parentObjectId=_parentObjectId // We need the parent object id, if want to hide the mouse cursor whenever the mouse rool out from the div that "wrap" the flash object.
}
//////////////////////////////////////////////////////////////
t.getHtmlFlashTag = function() {
  if (t.transparent) t.transparent="transparent"
	 else t.transparent=""
   if (t.bgColor==null) t.bgColor = "FFFFFF"
 //t.transparent=""
   
   if (t.parentObjectId!=null) {
		onMouseOutEventString='onmouseout=flashListener.triggerEvent("'+t.parentObjectId+'","'+Flash.EVENT_FLASH_MOUSE_OUT+'","")'
   } else onMouseOutEventString = ''
   // xxonmousewheel=alert("asd") onmouseover=document.window."'+t.id+'".focus()

   var flashHtml = ""

   var divWidth  = t.width.replace("%25","%")    
   var divHeight = t.height.replace("%25","%")

   if (divWidth.indexOf("%")==-1) divWidth   +="px"
   if (divHeight.indexOf("%")==-1) divHeight +="px"

   flashHtml += '<div id="Div'+t.id+'" '+onMouseOutEventString+' xonmouseover="document.focus();" style="position:relative; overflow-x:hidden;overflow-y:hidden;width:'+divWidth+';height:'+divHeight+';background-color:#'+t.bgColor+'">'
   flashHtml += '<O';flashHtml +='BJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
   flashHtml += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+t.version+'"';
   flashHtml += ' WIDTH="'+t.width+'" HEIGHT="'+t.height+'" id="'+t.id+'" ALIGN="">';
   flashHtml += ' <PARAM NAME=movie VALUE=';flashHtml +='"'+t.src+'"> <PARAM NAME=menu VALUE=false> <PARAM NAME=FlashVars VALUE="'+args+'"> <PARAM NAME=bgcolor VALUE="#'+t.bgColor+'"> <PARAM NAME=quality VALUE=high> <PARAM name="allowScriptAccess" value="always"> <PARAM NAME=wmode VALUE="'+t.transparent+'"> ';
   flashHtml += '<E';flashHtml +='MBED src="'+t.src+'" quality=high wmode="'+t.transparent+'" allowScriptAccess="always" FlashVars="'+args+'" bgcolor="#'+t.bgColor+'" Menu=false WIDTH="'+t.width+'" HEIGHT="'+t.height+'" NAME="'+t.id+'" ALIGN=""';
   flashHtml += ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></E';flashHtml +='MBED>';
   flashHtml += '</O';flashHtml +='BJECT>';
   flashHtml += '</div>'
//<div style="position:absolute;top:0px;left:0px">ssssssssssssssssssssssssssssssssssss</div>
   //MozillaOnMouseOver = '<script language="javascript">document.getElementById("Div'+t.id+'").addEventListener("mouseover", alert, false)</script>'
   
   var IEflashFsCommand='<script event=FSCommand(command,args) for='+t.id+'>Flash_DoFSCommand(document.'+t.id+',command, args);</script>'
   var MozillaflashFsCommand='<script type="text/javascript">function '+t.id+'_DoFSCommand(command,args) {Flash_DoFSCommand(document.'+t.id+',command, args);}</script>';
   
   //flashHtml += MozillaOnMouseOver+IEflashFsCommand+MozillaflashFsCommand

   flashHtml += IEflashFsCommand+MozillaflashFsCommand

   ///////////////////////////////////////////////////////////////////  
   // Create global fsCommand to all flash maps

   // Explorer
	 /*  flashHtml +='<script type="text/vbscript">'
	   flashHtml +='Sub '+t.id+'_FSCommand(ByVal command, ByVal args)'
	   flashHtml +='call Flash_DoFSCommand(document.'+t.id+',command, args)'
	   flashHtml +='end sub'
	   flashHtml +='</script>'
   
   
   // Mozila, Netscape
	   flashHtml +='<script type="text/javascript">'
	   flashHtml +='function '+t.id+'_DoFSCommand(command,args) {'
	   flashHtml +='msgBox("ddd")'
	   //flashHtml +='Flash_DoFSCommand(document.'+t.id+',command, args)'
	   flashHtml +='}'
	   flashHtml +='</script>'*/
	

   /////////////////////////////////////////////////////////////////// 
   return flashHtml
}
//////////////////////////////////////////////////////////////
t.writeFlash = function() {
   var d=document
   d.write(t.getHtmlFlashTag())
   t.object = eval("d."+t.id)
   
   if (t.parentObjectId!=null) {
	   if (window.addEventListener) {
		  t.object.addEventListener('DOMMouseScroll', t.onMouseWheel, false);
	   } else {
		  t.object.attachEvent("onmousewheel",t.onMouseWheel);
	   }
   }
}
//////////////////////////////////////////////////////////////
t.onMouseWheel = function(evt) {
   var delta;
   if (document.all) {
		delta = event.wheelDelta
		event.returnValue = false;
      } else {
		delta = -1 * evt.detail
		if (evt.preventDefault) evt.preventDefault();
   }
   flashListener.triggerEvent(t.parentObjectId,Flash.EVENT_FLASH_MOUSE_WHEEL,new Array("" + delta))
}
//////////////////////////////////////////////////////////////
t.getContainer = function(name,value) {
	return document.getElementById("Div"+t.id)
}
//////////////////////////////////////////////////////////////
t.addArg = function(name,value) {
	args+=name+"="+value+"&"
}
//////////////////////////////////////////////////////////////
t.runFunction = function() {
  try {
	 var i;
	 if (arguments.length>1) {
		 t.object.SetVariable("JSArg0",arguments[1]);
		 if (arguments.length>2) {
			 for (i=1; i<arguments.length-1; i++) {
				 t.object.SetVariable("JSArg"+i,arguments[i+1]);
			 } 
		 }
		 t.object.SetVariable("JSArguments",arguments.length-2);
		 if (arguments[0]=="") arguments[0]="/"
		 t.object.TCallLabel(arguments[0],"runFunction");
	 }
   } catch (ex) {
	 addCommandToQueue(arguments[0],t.runFunction,arguments)
   }
}
//////////////////////////////////////////////////////////////
t.getVariable = function(arg) {
  try {
	   return t.object.GetVariable(arg);
   } catch (ex) {
	   addCommandToQueue(t.getVariable,arguments)
       return null
   }
}
//////////////////////////////////////////////////////////////
t.setVariable = function(arg,value) {
  try {
	 t.object.SetVariable("/:"+arg,value);
   } catch (ex) {
	   addCommandToQueue(t.setVariable,arguments)
   }
}
//////////////////////////////////////////////////////////////
var addCommandToQueue = function(level,fun,arg) {
   if (commandsQueue[level]==null) commandsQueue[level] = new Array();
   var arr = commandsQueue[level]
   arr.push(fun)
   arr.push(arg)
}
//////////////////////////////////////////////////////////////
t.doCommandsQueue = function(level) {
   var i;
   if (commandsQueue[level]==null) commandsQueue[level] = new Array();
   var arr = commandsQueue[level]
   for (i=0; i<arr.length; i=i+2) {
	   //arg = commandsQueue.pop()
	   //fun = commandsQueue.pop()
	   fun = arr[i]
	   arg = arr[i+1]
	   fun.apply(this,arg)
   }
   commandsQueue[level]==null
}
//////////////////////////////////////////////////////////////

}

//////////////////////////////////////////////////////////////
// This function called whenever one of the flash maps on the page fires an event.
// flash  - indicates the html flash object that fire the event.
// id_evt - id^evt , evt indicates the event type.
//					 id indicates the objectId the evt attributed to.
//                   
// args   - arguments
function Flash_DoFSCommand(flash, id_evt, args) {
  var splitId_Evt = id_evt.split("^")
  objectId = splitId_Evt[0]
  evt = splitId_Evt[1]
  var i;
 	
  flashListener.triggerEvent(objectId,evt,args)
}
//////////////////////////////////////////////////////////////


/// Flash Events ////////////////////////////////////
  Flash.EVENT_FLASH_INITIALIZE = "onflashinitialize"
  Flash.EVENT_FLASH_MOUSE_OUT    = "onflashmouseout"  // We need this event to hide the mouse cursor
  Flash.EVENT_FLASH_MOUSE_WHEEL  = "onflashmousewheel"  // We use this event to detect the mouse wheel event


