function SWFobjHANDLER_class() {

    this.AR_SWFOBJ = Array(); // array of swf object
    this.count_swf_obj = 0 ;

         
    this.get_next_free_id =  function () {
        return this.count_swf_obj;
    }

    // create a object and return the free id 
    this.crate_swf_obj =  function () {
        var SWF_ID = this.get_next_free_id();
        this.AR_SWFOBJ[SWF_ID] = new SWFobj_class();
        this.AR_SWFOBJ[SWF_ID].nmod = SWF_ID;
        this.count_swf_obj++;
        return SWF_ID;
    }

}
G_SWF_HANDLER = new SWFobjHANDLER_class();
/* var swfid = G_SWF_HANDLER.crate_swf_obj();
 * G_SWF_HANDLER.AR_SWFOBJ[swfid].SET_SMALLCIRCLE();
 * G_SWF_HANDLER.AR_SWFOBJ[swfid].nome_DIV_CONTAINER ='';
 * G_SWF_HANDLER.AR_SWFOBJ[swfid].STR_EVAL_CALLBACK();
 * G_SWF_HANDLER.AR_SWFOBJ[swfid].CICLE_ADDVALUE('google',90);
 * G_SWF_HANDLER.AR_SWFOBJ[swfid].LOAD_FOB();
 *
 */
function SWFlink(idswf,value) {
    //alert(idswf+','+value);
    if(!G_SWF_HANDLER.AR_SWFOBJ[idswf]) return ;
    var OBJ_SWF = G_SWF_HANDLER.AR_SWFOBJ[idswf];
    if(OBJ_SWF.swfclickfunct !=''){
        var funct_GOTO = OBJ_SWF.swfclickfunct.split('--value--').join(value);
        setTimeout(funct_GOTO,20);
    }
}


// callback of all swf functions 
function SWFcallback(idswf,value) {
    //if(!G_SWF_HANDLER) return ;
    //if(!G_SWF_HANDLER.AR_SWFOBJ[idswf]) return ;

    //setTimeout('alert (\''+idswf + ' , ' + value+ " callback = " + (G_SWF_HANDLER.AR_SWFOBJ[idswf].STR_EVAL_CALLBACK + idswf + ',' +  value + ');') + '\' );',200);
    
    //alert(G_SWF_HANDLER.AR_SWFOBJ[idswf].STR_EVAL_CALLBACK);
    if(value=='var_ER') G_SWF_HANDLER.AR_SWFOBJ[idswf].AR_RETURN_DATA['rldData'] = '0';
    if(G_SWF_HANDLER.AR_SWFOBJ[idswf].callback_type =='string'){
        if(G_SWF_HANDLER.AR_SWFOBJ[idswf].STR_EVAL_CALLBACK.length > 0 ){
            eval(G_SWF_HANDLER.AR_SWFOBJ[idswf].STR_EVAL_CALLBACK + idswf + ',\'' +  value + '\');'); // functNAME(idswf,'value');
        }
    }
    if(G_SWF_HANDLER.AR_SWFOBJ[idswf].callback_type =='funct'){
        return G_SWF_HANDLER.AR_SWFOBJ[idswf].FUNCT_callback(idswf,value);
    }
    if(G_SWF_HANDLER.AR_SWFOBJ[idswf].callback_type =='data'){
        if(!G_SWF_HANDLER.AR_SWFOBJ[idswf].AR_RETURN_DATA[value]) return "";
        return G_SWF_HANDLER.AR_SWFOBJ[idswf].AR_RETURN_DATA[value];
    }
}




/* 
 * classe di 1 grafico flash swf
 */
function SWFobj_class() {
    try {
        this.Fob = new Object; // flash object
        this.nmod = 0 ; //id modulo swf
        this.nmod_container = -1;

        this.nome_DIV_CONTAINER = ''; // div where the flash obj will be loaded
        this.nome_flashOBJ = ''; // div where the flash obj will be loaded
        this.swf_URLvariables = ''; // ("&a=3&b=4") div where the flash obj will be loaded

        this.BOOL_fobcreated = false; // if fob has been initialized
        this.type_GRAPH = 'standard';
        this.AR_CIRCLE_VALUES = Array(); // if fob has been initialized
        this.circle_values_count =0; // if fob has been initialized

        this.STR_EVAL_CALLBACK = '' ; // function callback
        this.callback_type = 'string'; // string, funct, data , obj ( stora il path relativo della funct )
        this.FUNCT_callback = null ; // pointer or copy of callback function
        this.AR_RETURN_DATA = Array(); // array of return data for callback functions
        this.swfclickfunct = ''; // array of return data for callback functions

        // create flash object
        this.create_FOB =  function () {
            this.BOOL_fobcreated =true ;
            this.Fob.movie=GLOBALS['FOLDER_swf']+"stats_column.swf";
            this.Fob.quality="High";
            this.Fob.wmode="transparent";
            this.Fob.width=700;
            this.Fob.height=290;
            this.Fob.version="10,0,0,0";
            this.Fob.name="mainMovieLineTime";
            this.Fob.id="mainMovieLineTime";
            this.Fob.allowScriptAccess="always";
           
        }
        
        /*this.SET_LINECHART_RANGE_11 =  function () {
            if(!this.BOOL_fobcreated) this.create_FOB();
            this.Fob.movie="http://www.histats.com/swf/lineChartR_11.swf";
            this.Fob.width=440;
            this.Fob.height=80;
            this.type_GRAPH = 'line' ;
        }*/
        
        this.SET_LINECHART_RANGE =  function () {
            if(!this.BOOL_fobcreated) this.create_FOB();
            this.Fob.movie="http://www.histats.com/swf/lineChartR.swf";
            this.Fob.width=440;
            this.Fob.height=80;
            this.type_GRAPH = 'line' ;
        }

        // return flash object
        this.SET_SMALLCIRCLE =  function () {
            if(!this.BOOL_fobcreated) this.create_FOB();
            this.Fob.movie=GLOBALS['FOLDER_swf']+"piechart_as3.swf";
            this.Fob.width=130;
            this.Fob.height=130;
            this.type_GRAPH = 'circle' ;
        }

        // return flash object
        this.SET_MAP =  function () {
            if(!this.BOOL_fobcreated) this.create_FOB();
            this.Fob.movie=GLOBALS['FOLDER_swf']+"geomap.swf";
            this.Fob.width=700;
            this.Fob.height=350;
            this.type_GRAPH = 'map' ;
        }

        // return flash object
        this.SET_MAP_zoom =  function () {
            if(!this.BOOL_fobcreated) this.create_FOB();
            this.Fob.movie=GLOBALS['FOLDER_swf']+"geomapL.swf";
            this.Fob.width=700;
            this.Fob.height=350;
            this.type_GRAPH = 'map' ;
        }

        // return flash object
        this.SET_MAP_350 =  function () {
            if(!this.BOOL_fobcreated) this.create_FOB();
            this.Fob.movie=GLOBALS['FOLDER_swf']+"Wmap350.swf";
            this.Fob.width=350;
            this.Fob.height=135;
            this.type_GRAPH = 'map' ;
        }
        
        this.SET_MAP_460 =  function () {
            if(!this.BOOL_fobcreated) this.create_FOB();
            this.Fob.movie=GLOBALS['FOLDER_swf']+"geomap460.swf";
            this.Fob.width=460;
            this.Fob.height=230;
            this.type_GRAPH = 'map' ;
        }

        this.CICLE_ADDVALUE =  function (valuekey, value) {
            if(!this.AR_CIRCLE_VALUES[valuekey]){ // new
                this.circle_values_count++;
                this.AR_CIRCLE_VALUES[valuekey] = value;
            }
        }
        this.CICLE_BUILD_URL =  function () {
            var randomnumber=Math.floor(Math.random()*1001);
           
            var _CIRCLE_URL =  this.Fob['movie'] + '?clipJSID='+this.nmod+ this.swf_URLvariables; // '&a='+randomnumber + 
            if(this.circle_values_count < 1 ) return ; 
            var tmp_counter = 0 ; 
            for(k in this.AR_CIRCLE_VALUES){
                _CIRCLE_URL+= '&valvar_' + tmp_counter + '='  +this.AR_CIRCLE_VALUES[k] ;
                tmp_counter++;
            }
            _CIRCLE_URL+= '&nval=' + tmp_counter;
            return _CIRCLE_URL;
        }
        this.BUILD_URL =  function () {
            var randomnumber=Math.floor(Math.random()*1001);
            return (this.Fob['movie']+ '?clipJSID='+this.nmod+  this.swf_URLvariables); // '&a='+randomnumber +
        }
        // return flash object 
        this.RETURN_fobOBJ =  function () {
            if (window.document[this.nome_flashOBJ]) {
                return window.document[this.nome_flashOBJ];
            }
            if (navigator.appName.indexOf("Microsoft Internet")==-1) {
                if (document.embeds && document.embeds[this.nome_flashOBJ])
                    return document.embeds[this.nome_flashOBJ];
            }
            else {
                return document.getElementById(this.nome_flashOBJ);
            }
            return document.getElementById(this.nome_flashOBJ);
        }

        this.SendDataToFlashMovie =  function () {
            var flashMovie=this.RETURN_fobOBJ;
            flashMovie.SetVariable("videopath.text", param);
        }
        this.ReceiveDataFromFlashMovie =  function () {
            var flashMovie=this.RETURN_fobOBJ;
            var message=flashMovie.GetVariable("mediaVar");
            document.controller.Data.value=message;
        }





        // create flash object
        this.LOAD_FOB =  function () { // _obj, _container,variabili
            if(!this.BOOL_fobcreated) this.create_FOB();
           
       
            /*var so = new SWFObject("Main.swf", "mymovie", "700", "240", "6", "#FFFFFF");
so.addVariable("variabile1", "valore1");
so.write("flashcontent");
             */
            //alert( this.swf_URLvariables);
            this.Fob.name="mainMovieLineTime_" + this.nmod;
            this.Fob.id="mainMovieLineTime_" + this.nmod;
            var _SWF_URL = "";
            if(this.type_GRAPH == 'circle'){
                _SWF_URL = this.CICLE_BUILD_URL();
            }else if(this.type_GRAPH == 'map'){
                _SWF_URL = this.BUILD_URL();
            }else{
                _SWF_URL = this.BUILD_URL();
            }

            var so = new SWFObject((_SWF_URL),this.Fob['name'], this.Fob['width'], this.Fob['height'], this.Fob['version'], "#FFFFFF");
            so.addVariable("clipJSID", this.nmod );
            for(_cO in this.Fob){
                so.addVariable(_cO, this.Fob[_cO]);
            }
            so.write(this.nome_DIV_CONTAINER);
            return ;
            //alert('stampo flash '  +  variabili );
            _output="";
            _paramoutput="";
            _src="";
            _ver="";

            for(_cO in this.Fob){
                _output+=_cO+"=\""+this.Fob[_cO]+"\" ";
                _paramoutput+="<param name=\""+_cO+"\" value=\""+this.Fob[_cO]+"\">";
                if(_cO=="movie"){
                    // _src="src=\""+this.Fob[_cO]+ '?' + this.swf_URLvariables + "&rnd=" + randomnumber +  "\"";
                    _src="src=\""+this.Fob[_cO]+   "&rnd=" + randomnumber +  "\"";
                }
                if(_cO=="version"){
                    _ver=this.Fob[_cO];
                }
            }
            //+ '?' + variabili +
            if(_ver==""){
                _ver="10,0,0,0";
            }
            ihtm=_paramoutput+"\n";
            ihtm+="<embed "+_src +" pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash "+_output+">\n";
            ihtm+="</embed>\n";
            document.getElementById(this.nome_DIV_CONTAINER).innerHTML=ihtm	;
        //alert(ihtm);


        }



    }catch(e){
        alert("ERROR:fogli_flashgraph_class  () \n error: " + e.message   );
    }//end try

}

if(!JSCACHE) JSCACHE = [] ;
JSCACHE.push(['swfobj.class.js',1]);
