/*
 * ----------------------------------------------------
 * Mootools extensions
 * ----------------------------------------------------
 * by Limarc /Alexander Lobashev/
 * (c) 2007-2008 by Limarc, Lim-on Media
 * Web: http://www.lobashev.org
 *      http://www.limon-media.org
 * ----------------------------------------------------
 * Index: mootools-ext.js
 * ----------------------------------------------------
 */


 window.addEvent('domready', function()
 {
     var Menu = new DropMenu('navmenu-h');
 });
 
 /*
  * > Show-services
  * > by limarc 
  * > v1.0.1
  **/
 /* > 
 ----------------------------------------------- */ 
 var Showservices = new Class
 ({

	 /* > constructor class
         ----------------------------------------------- */	
	 initialize: function()
	 {
                 
                 $$('body').addEvent('click',  function (event)
                 {
                         $$('.service-content').each(function(al)
			 {
				 if (al.getStyle('opacity') == '1' && event.target.getStyle('opacity') == '1')
				 {
                                         al.fade('out');
				 }
			 }, this);

                 });		 
                 
                 $$('.service-content').each(function(cl)
		 {
			 cl.setStyle('opacity', 0);
                         /*cl.morph({'opacity': 0});*/
			 
		 }, this);
                 
                 //
		 // event click element
                 //		
		 $$('.service-title').each(function(ael)
		 {
                         ael.addEvent('click', this._showServices.pass(ael, this));
		 }, this);
	 },
	
	 /* > show services
         ----------------------------------------------- */	
         _showServices: function(ael)
	 {

		 /* > get id, size and count...
                 ----------------------------------------------- */		 
		 var id = ael.get('id');
		 
                 //alert($('cont' + id).getStyle('opacity'));
                 
                 $$('.service-content').each(function(cl)
		 {
                         cl.fade('out');
			 
		 }, this);
                 
		 if ($('cont' + id).getStyle('opacity') == '1')
		 {
			 $('cont' + id).fade('out');
                         /*$('cont' + id).morph({'visibility': 'visible'});*/
			 //$('cont' + id).setStyle('display', 'none');
			 //$('cont' + id).fade('out');
		 }
		 else
		 {
			 $('cont' + id).fade('in');
			 /*$('cont' + id).morph({'visibility': 'visible'});*/
                         //$('cont' + id).setStyle('display', 'block');
			 //$('cont' + id).fade('in');
		 }
         },	
	

	 Implements : [Events]
 });                 
	
        

 /*
  * > Tabs
  * > by limarc 
  * > v1.1.0
  *
  */
 var Mtabs = new Class
 ({
	
	 options:
         {
		 activateClass: 	'active',
                 //activateClassOther: 	'active-other',
		 activateOnLoad:	'description'
         },
	
	 initialize: function(element, options)
	 {
		 //
                 // Set option...
                 //			
		 if (options)
                 {
                         this.setOptions(options);
                 }
                 
		 this.el = $(element);
		 this.contid = element;                 
                 
                 this.titles = $$('#' + this.contid + ' ul.mtabs-title li');
                 this.panels = $$('#' + this.contid + ' .mtabs-block');
                 
		 this.titles.each(function(item)
                 {

                         if (item.getProperty('class') != 'none')
			 {
                                 $$('#show-' + item.getProperty('id')).fade('out');
                                 $$('#show-' + item.getProperty('id')).setStyle('display', 'none');
                                 
                                 //
                                 // Clicked...
                                 //
                                 item.addEvent('click', function()
                                 {
                                         if (item != this.activeTitle)
                                         {
                                                 item.removeClass(this.options.activateClass);
                                                 this.activate(item);
                                         }
                                         
                                 }.bind(this));
                                
                                 //
                                 // Mouse over...
                                 //                        
                                 item.addEvent('mouseover', function()
                                 {
                                         if (item != this.activeTitle)
                                         {
                                                 item.addClass(this.options.activateClass);
                                         }
                                 }.bind(this));
                                
                                 //
                                 // Mouse out...
                                 //                                
                                 item.addEvent('mouseout', function()
                                 {
                                         if (item != this.activeTitle)
                                         {
                                                 item.removeClass(this.options.activateClass);
                                         }
                                 }.bind(this));
                         }
                         
                 }.bind(this));
                 
                 if (document.location.hash.indexOf("#tab-") != -1)
                 {
                         var selectedTab = document.location.hash.substr(5,document.location.hash.length);
                         var activeTab = $(selectedTab);
                         
                         if (activeTab)
                         {
                                 this.activate(activeTab);
                         }
                 }
                 else if (this.options.activateOnLoad != 'none')
		 {
			 var activeTab = $(this.options.activateOnLoad);
                         
                         this.activate(activeTab);
		 }                 
	 },
	
	 activate: function(tab)
         {
                 /*if ($type(tab) == 'string') 
		 {
			 tab = $$('#' + this.contid + ' ul li').filter('[title=' + tab + ']')[0];
		 }*/
		
		 if($type(tab) == 'element')
		 {
			 var newTab = tab.getProperty('id');
                         var newTabBlock = $$('#show-' + newTab);
                         var myFx = new Fx.Tween(newTabBlock);
                         
			 //
                         // De-activated last tab...
                         //
                         if (this.activeTitle)
                         {
                                 //alert(this.activeTitle.getProperty('id'));
                                 this.activeTitle.removeClass(this.options.activateClass);
                                 
                                 $$('#show-' + this.activeTitle.getProperty('id')).fade('out');
                                 $$('#show-' + this.activeTitle.getProperty('id')).setStyle('display', 'none');
                                 //myFx.start('display', 'none', 'block');
                         }

			 //
                         // Activated new tab...
                         //                         
                         tab.addClass('active');
                         
			 //
                         // Show block new tab...
                         //

                         //Immediately sets the background color of the element to red:
                         //myFx.start('display', 'none', 'block');
                         //myFx.set('display', 'block');
                         
                         newTabBlock.fade('in');
                         newTabBlock.setStyle('display', 'block');
                         
			 //
                         // Save new tab...
                         //                           
                         this.activeTitle = tab;
		 }
	 },        
        
	 Implements : [Events]
 });
 
 
