// <THIS FIlE RUN ONLY ONCE
if(window.jsfiles_aristflash==null){
window.jsfiles_aristflash=true;
// THIS FIlE RUN ONLY ONCE>

var getAristFlashBlocks=function(){
	var blocks=new Object();
	var shem=null;
	this.setShem=function(_shemid,_blocks){
		shem=document.getElementById(_shemid);
		myEvents.addto(window,this.init,'onscroll');
		
		
		//var s='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"  id="lines" width="100%" height="100%" ><param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent"/><param name="scale" value="noscale" /><param name="salign" value="lt" /> <param name="swliveconnect" value="true"/><param name="movie" value="/lines.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#cccccc" /><embed src="/lines.swf" scale="noscale" salign="lt" quality="high" wmode="transparent" bgcolor="#cccccc" width="100%" height="100%" swLiveConnect=true id="lines_embed" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
		
		//var div=document.createElement('div');
		//div.innerHTML=s;
		//shem.parentNode.insertBefore(div,shem);
		if(_blocks instanceof Object) blocks=_blocks;
	}
	
	var getFlashObj=function(){
		var el;
		if(
			(el=document.getElementById('lines_embed'))==null && 
			(el=document.getElementById('lines'))==null
		) return null;
		return el;
	}
	
	this.getCoordinats=function(){
		var flash=getFlashObj();
		if(flash==null) return;

		var s='';
		for(var i in blocks){
			
			var el=document.getElementById(i);
			var up_el=document.getElementById(blocks[i]);
			//alert(i+','+blocks[i]+';'+el+','+up_el);
			var pos_el=getElementPosition(el);
			var pos_up_el=getElementPosition(up_el);
			var pos_flash=getElementPosition(flash);
			if(s!='') s=s+';';
			s=s + 
				(pos_el.left-pos_flash.left) + ',' + (pos_el.top-pos_flash.top) + ',' + el.offsetWidth + ',' + el.offsetHeight + ',' + 
				(pos_up_el.left-pos_flash.left) + ',' + (pos_up_el.top-pos_flash.top) + ',' + up_el.offsetWidth + ',' + up_el.offsetHeight;
		}
		flash.SetVariable('coordinates',s);
	}
	
	this.getBlocks=function(){
		var flash=getFlashObj();
		if(flash==null) return;

		var s='';
		for(var i in blocks){
			if(s!='') s=s+';';
			s=s + i + ',' + blocks[i];
		}
		flash.SetVariable('blocks',s);
	}
	this.init=function(){
		flash=document.getElementById('lines');
		if(flash==null) return;

		flash.style.position='absolute';

		if(shem==null) {
			//flash.style.display='none';
			return;
		}
		var pos=getElementPosition(shem);
		flash.style.zIndex='2';
		flash.style.left=pos.left+'px';
		flash.style.top=pos.top+'px';
		flash.style.width=shem.offsetWidth+'px';
		flash.style.height=shem.offsetHeight+'px';
		
		shem.style.position='relative';
		shem.style.zIndex='20';
		shem.style.left='0px';
		shem.style.top='0px';
	}
	/*this.insert=function(){
		myEvents.addto(
			window,
			function(){
				var body=document.getElementById('body');
				alert(body.)
			},
			'onload'
		);
	}*/
	
	return this;
}

//myEvents.addto(window,function(){alert(1);},'onresize');
var AristFlashBlocks=new getAristFlashBlocks();
//AristFlashBlocks.setBlocks({'zzzz2':'zzzz1'});

var getAristFlashControls=function(){
	
	/*var flash;
	var content;
	var resize = this.resize = function(){
		if(flash==null || content==null) return;

		

		var pos=getElementPosition(content);
		
		flash.style.left=pos.left+'px';
		flash.style.top=pos.top+'px';
		flash.style.width=content.offsetWidth+'px';
		flash.style.height=content.offsetHeight+'px';
		//status=;
	}*/

	var lastZIndex=200;

	this.init=function(flashid,contentid){
		
				var flash=document.getElementById(flashid);
				var content=document.getElementById(contentid);
				
				if(flash==null || content==null) return false;
				flash.style.position='absolute';
				content.style.position='relative';
				content.style.left='0px';
				content.style.top='0px';
				content.style.zIndex=lastZIndex--;
				flash.style.zIndex=lastZIndex--;
				
				
				var	resize=function(){
					var pos=getElementPosition(content);
					
					flash.style.left=pos.left+'px';
					flash.style.top=pos.top+'px';
					flash.style.width=content.offsetWidth+'px';
					flash.style.height=content.offsetHeight+'px';

				}
				//resize();
				myEvents.addto(window,resize,'onresize');
				myEvents.addto(window,resize,'onload');
	}
	
	var controls = {'uncnown':new Array()};
	this.regControlById=function(id){
		var el=document.getElementById(id);
		if(el!=null)
			controls.uncnown[controls.uncnown.length]=el;
	}
	this.regControlsByClass=function(className){
		var els=document.getElementsByClass(className);
		if(els.length>0){
			for(var i=0; i<els.length; i++){
				if(!els[i].id.length) els[i].id='rendomelement'+getUniqueIndex();
			}
			controls[className]=els;
		}
	}
	
	
	var createFlashFunc=function(flash,el,action){
		return function(){
			var pos=getElementPosition(el);
			
			flash.SetVariable(action, pos.left + ',' + pos.top + ',' + el.offsetWidth + ',' + el.offsetHeight + ',' + el.flashid);
		};
	}

	var getFlashObj=this.getFlashObj=function(id){
		var el;
		/*if(
			(el=document.getElementById(id+'_embed'))==null && 
			(el=document.getElementById(id))==null
		) return null;*/
		if(window[id]) el=window.document[id];
		if(document[id]) el=document[id];
		
		return el;
	}

	
	this.delFlashProp=function(id,prop){
		var el=document.getElementById(id);
		el[prop]=null;
	}
	
	this.regFlashForClass=function(flashid,className){
		var flash=getFlashObj(flashid);
		var els=document.getElementsByClass(className);
		var active_el=null;
		for(var i=0; i< els.length; i++){
			var el=els[i];
			if(el.flashid==null){
				el.flashid=getUniqueIndex();
			}
			//alert((' '+el.className).indexOf(' active'));
			if((' '+el.className).indexOf(' active')!=-1) {
				active_el=el;
		/*myEvents.addto(
			document.getElementById(flashid),
			createFlashFunc(flash,active_el,'setactive_'+className),
			'setactive_'+className
		);*/
				//var pos=getElementPosition(el);
				//flash.SetVariable('setactive_'+className, pos.left + ',' + pos.top + ',' + el.offsetWidth + ',' + el.offsetHeight);
				//var f=createFlashFunc(flash,el,'setactive_'+className);
				//f();
				

			}
			myEvents.addto(el,createFlashFunc(flash,el,'mouseover_'+className),'onmouseover');
			myEvents.addto(el,createFlashFunc(flash,el,'mouseout_'+className),'onmouseout');
		}
		
		var mflash=document.getElementById(flashid);
		if(active_el!=null){
			mflash['setactive_'+className]=createFlashFunc(flash,active_el,'setactive_'+className);
			var f2=function(){
				if(mflash['setactive_'+className]!=null){
					mflash['setactive_'+className]();
					setTimeout(f2,500);
				}
			}
			setTimeout(f2,500);
		}
		//myEvents.addto(window,function(){flash.SetVariable('runinit', '1');},'onload');
	}
	
	
	
	this.runfunc=function(flashid,funcname){
		
		eval('if(document.getElementById("' + flashid + '").' + funcname + '!=null) document.getElementById("' + flashid + '").' + funcname + '();');
	}
	
	
	var initfuncs=new Array();
	//var initfuncs_i=0;
	this.runInitFunc=function(flashid,func){
		var flash=getFlashObj(flashid);
		var func_i=getUniqueIndex();
		flash['flashfunc'.func_i]=function(){
			if(flash['flashfunc'.func_i]!=null) {
				func(flash);
				flash.SetVariable('delfunction',func_i);
				if(flash['flashfunc'.func_i]!=null)
					setTimeout(flash['flashfunc'.func_i],500);
			}
		}
		setTimeout(flash['flashfunc'.func_i],500);
	}
	this.delFlashFunc=function(flashid,func_i){
		var flash=getFlashObj(flashid);
		flash['flashfunc'.func_i]=null;
	}
	
	return this;
}
var AristFlashControls=new getAristFlashControls();


}