component['rcMainBannerGenerator'] = Class.create({

 THREAD_ID: null,
 EXEC_UID: null,
 intTimeout: 6,

 initialize: function(arrInstVars, arrParams, arrLang)
 {
   this.THREAD_ID    = arrInstVars.THREAD_ID;
   this.EXEC_UID     = arrInstVars.EXEC_UID;

   this._update.bind(this).delay(this.intTimeout);
   
   $$('*[name="noPhoto"]').each(function(el)
   {
	 this.createMaps.bind(this, el).defer();
   }.bind(this));   

 },

 _update: function()
 {
   new Ajax.Request('/?call_element=component.rcMainBannerGenerator',
   {
     onComplete: this._onComplete.bind(this)
   });
 },

 _onComplete: function(t)
 {
    new Effect.Opacity($$('div[_name="banner"]')[0].down('div[_name="bannerContent"]'), 
    { 
      duration: 0.6,  
      from: 1, 
      to: 0.1,
      afterFinish: function()
      {
        (function(){
        $$('div[_name="banner"]')[0].insert({after: t.responseText});
        $$('div[_name="banner"]')[0].remove();
        new Effect.Opacity($$('div[_name="banner"]')[0].down('div[_name="bannerContent"]'), { duration: 0.6, from: 0.1, to: 1, afterFinish: function(){this._update.bind(this).delay(this.intTimeout);}.bind(this)});
        }.bind(this)).defer();        
      }.bind(this) 
    });  
    
    $$('*[name="noPhoto"]').each(function(el)
    {
	  this.createMaps.bind(this, el).defer();
    }.bind(this));    
 },
 createMaps: function(el)
 {
	if(el.getAttribute('_addressQ')!='')
	{	
     if (GBrowserIsCompatible()) {
		var geocoder = new GClientGeocoder();
		var address = el.getAttribute('_addressQ');
		
		  this.pnt = {x: false, y:false};
		  geocoder.getLatLng(
			address,
			function(point) {
			  if (point) {
			    this.pnt = point;
				
				el.src="http://maps.google.com/staticmap?center="+point.y+","+point.x+"&zoom=11&size=88x63&maptype=mobile\&markers="+point.y+","+point.x+",redc\&key=ABQIAAAAmnFRCzYpgfPZjCDBjwrR-RRZV0JwcVAs3i6Xzl1ib4DSe9JwfBTYINqtoxR2JnS4MYmy-DZiAgYGSQ";
			  }
			  new Ajax.Request('/?call_element=component.rcGeoMapper', 
			  {
				  method: 'post',
				  parameters: {_x: this.pnt.x, _y: this.pnt.y, 
					contentType: el.getAttribute('_contentType'), 
					_id: el.getAttribute('_id')}
			  });			  
			}.bind(this)
		  );
     } 
	}
 } 
});
arrJsLoaded['component.rcMainBannerGenerator.js']=true;init.jsLoaded("component.rcMainBannerGenerator.js");