var gender_icons = new Array();
gender_icons["M"] = "http://62.105.135.100/images/default/default/ico_m.gif";
gender_icons["F"] = "http://62.105.135.100/images/default/default/ico_f.gif";


var PhotoLine  =
{
   
   init: function ()
   {
      this.initBaloon();
      this.initBox();
      this.initSwf();
   },

   
   initBox: function ()
   {
      $('#FlashLineBox').hover(
           function (){ try { PhotoLine.$Baloon.show(); $('#mymovie1')[0].SetVariable('_root.photoline.JS_mouseOver', 1); } catch (e) { }; }
         , function (){ try { PhotoLine.$Baloon.hide(); $('#mymovie1')[0].SetVariable('_root.photoline.JS_mouseOut', 1); } catch (e)  { }; }
      );
   },
   
   
   initSwf: function ()
   {
      window.PhotoLineSetMessage = function (){ PhotoLine.setMessage.apply(PhotoLine, arguments); };
//      var so = new SWFObject("http://62.105.135.100/images/default/default/photoplacement/photoline.swf?r=1", "mymovie1", "500", "66", "8", "#000000");      

      var so = new SWFObject("http://www.allpersons.ru/i/photo_line_banner_gnuman.swf", "mymovie1", "500", "66", "8", "#000000");
      so.addParam("wmode", "transparent");
      so.addParam("AllowScriptAccess", "always");

	  so.addVariable("server_uri", "rtmp://194.67.27.119:80");

      so.addVariable("base_url", "http://www.znakomania.ru/");

//      so.addVariable("region_id", "6");

      so.addVariable("JS_Notify", 'PhotoLineSetMessage');
      so.addVariable( 'is_opera',  /Opera/.test(navigator.userAgent) ? "1" : "0" );
      so.write("flashcontent1");
   },
   
   
   initBaloon: function ()
   {
        this.$Baloon    = jQuery('#lb_photoline_info').css('zIndex', 100);
        
        this.$Greeting  = this.$Baloon.find('.mm_greeting');
        this.$Url       = this.$Baloon.find('.url');
        this.$Age       = this.$Baloon.find('.age');
        this.$Gender    = this.$Baloon.find('.gender');
        this.$City      = this.$Baloon.find('.city');
        
        this.$Baloon[0].style.marginTop = -2;
   },
   
   
   setMessage: function (greeting, name, age, gender, city, metro, anketa_url, type, offset_x)
   {
    this.$Greeting[0].innerHTML = decodeURIComponent( (greeting && (greeting != 'null') && greeting.length > 0) ? greeting : '&nbsp;' );
    this.$Url[0].href                   = decodeURIComponent( anketa_url );
    this.$Url[0].innerHTML          = decodeURIComponent( name );
    this.$Age[0].innerHTML          = decodeURIComponent( age );
    this.$Gender[0].src             = gender_icons[decodeURIComponent( gender )];   // FIXEME: Registry àÍàÀàÊá?àÎá?àÍá?àÊ
    this.$City[0].innerHTML         = decodeURIComponent( city + (metro && (metro != 'null') && metro.length > 0 ? ', àÌ.' + metro : '') );
    
    this.$Baloon[0].style.marginLeft    = (offset_x*1) + (
                                                    (offset_x >= (500 - this.$Baloon[0].offsetWidth))
                                                    ? -this.$Baloon[0].offsetWidth + 60
                                                    : -8
                                               );
   }

};
