window.addEvent('domready', function() {


var changerShowFirst = true;

    var displayChanger = function() {
        if ($('changer_first') != null && $('changer_second') != null) {
            if (changerShowFirst) {

                $('changer_first').style.display = 'none';
                $('changer_second').style.display = 'block';
                changerShowFirst = false;
            }
            else {
                $('changer_second').style.display = 'none';
                $('changer_first').style.display = 'block';
                changerShowFirst = true;
            }
        }
    };
    var myTimerChanger = displayChanger.periodical(5000);



var withoutbusiness = $('withoutbusiness');
if(withoutbusiness  != null)
{	
	var business = 0;
	
	withoutbusiness.addEvent( 'click', function() 
	{
		if (business==0)
		{
			$('withoutbusiness1').style.visibility='visible';
			$('withoutbusiness1').style.display='block';
			
			if($('withbusiness_info') != null)
			{
				$('withbusiness_info').style.visibility='hidden';
				$('withbusiness_info').style.display='none';
			}
			
			if($('withbusiness_foto') != null)
			{
				$('withbusiness_foto').style.visibility='hidden';
				$('withbusiness_foto').style.display='none';
			}
			business = 1;
		}
		else
		{
			$('withoutbusiness1').style.visibility='hidden';
			$('withoutbusiness1').style.display='none';
			
			if($('withbusiness_info') != null)
			{
				$('withbusiness_info').style.visibility='visible';
				$('withbusiness_info').style.display='block';
			}
			
			if($('withbusiness_foto') != null)
			{
				$('withbusiness_foto').style.visibility='visible';
				$('withbusiness_foto').style.display='block';
			}
			business = 0;
		}
		
	} );
	
}


var list = $$('#city li');
list.each(function(element) {
 
			var firstDiv = element.getElement('div');
			var mySlide = new Fx.Slide(firstDiv, {        duration: 250,        transition: Fx.Transitions.linear, wait:true});
			mySlide.hide();
			
//			var fx = new Fx.Styles(firstDiv, {duration:200, wait:false});
		
			element.addEvent('mouseenter', 
		    function(e)
			{
				e = new Event(e);
				mySlide.slideIn();
				e.stop();
			});
 
			element.addEvent('mouseleave', 
			function(e)
			{
				
				e = new Event(e);
				mySlide.slideOut();
				e.stop();
			});
			
		
			
		});

$('city').addEvent('mouseleave', 
			function()
			{
				$$('#city div').each(function(element) {
												 var mySlide = new Fx.Slide(element);
												mySlide.hide();
												 });
			});
//*******************************************************
//   level content blocks
//*******************************************************
//var lst = $$('#qq div');
//var maxDivHeight = 300;
//lst.each(function(element) {
//		if(element.clientHeight > maxDivHeight)
//			maxDivHeight = element.clientHeight;
////		alert(element.clientHeight);
//				  });
//
//lst.each(function(element) {
//				  //element.setProperty('background-color', '#000000');	
//				 var fx = new Fx.Styles(element, {duration:500, wait:false});
// 				fx.start({	'height': maxDivHeight	});
//	
//				
//				   });

//*******************************************************
//   
//*******************************************************
var list = $$('#nav_bar li');
list.each(function(element) {
			var links =  element.getElement('ul.links');

			if(links != null)
				links.style.display = 'none';

			var fx = new Fx.Styles(element, {duration:500, wait:false});
 
			element.addEvent('mouseenter', 
		    function()
			{
				fx.start({
							'background-color': '#cec5bd',
							color: '#ff8'
						});
				if(links != null)
				{
					links.style.display = 'block';
					//ddMenu.slideIn();

				}
			});
 
			element.addEvent('mouseleave', 
			function()
			{
				fx.start({
							'background-color': '#edeceb',
							'color': '#888'
						});
				if(links != null)
				{
					links.style.display = 'none';
					//ddMenu.slideOut();
					
				}
			});
		});
	
	//*******************************************************
	//   Top toggler menu with banners
	//*******************************************************


	//var mySlide2 = new Fx.Slide('test2');
//	$('toggle2').addEvent('click', function(e){
//	e = new Event(e);
//	mySlide2.toggle();
//	e.stop();
//	});
	
	//*******************************************************
	//   Services menu
	//*******************************************************
	
	//create our Accordion instance
	//var accordion = new Accordion($('accordion'), $$('#category_list li'), $$('#service_list ul'), {
//		opacity: false,
//		onActive: function(toggler, element){
//			//toggler.setStyle('color', '#ff3300');
//		},
//	 
//		onBackground: function(toggler, element){
//			//toggler.setStyle('color', '#222');
//		}
//	});

 Accordion.implement({
	addSection: function(toggler, element, pos){
		toggler = $(toggler);
		element = $(element);
		var test = this.togglers.contains(toggler);
		var len = this.togglers.length;
		this.togglers.include(toggler);
		this.elements.include(element);
		if (len && (!test || pos)){
		pos = $pick(pos, len - 1);
		toggler.injectBefore(this.togglers[pos]);
		element.injectAfter(toggler);
		} else if (this.container && !test){
		toggler.inject(this.container);
		element.inject(this.container);
		}
		var idx = this.togglers.indexOf(toggler);
		toggler.addEvent('mouseover', this.display.bind(this, idx));
		if (this.options.height) element.setStyles({'padding-top': 0, 'border-top': 'none', 'padding-bottom': 0, 'border-bottom': 'none'});
		if (this.options.width) element.setStyles({'padding-left': 0, 'border-left': 'none', 'padding-right': 0, 'border-right': 'none'});
		element.fullOpacity = 1;
		if (this.options.fixedWidth) element.fullWidth = this.options.fixedWidth;
		if (this.options.fixedHeight) element.fullHeight = this.options.fixedHeight;
		element.setStyle('overflow', 'hidden');
		if (!test){
		for (var fx in this.effects) element.setStyle(fx, 0);
		}
		return this;
	}
});
 
 var selectedElement = -1;

 if($('services_selected_category') != null && $('services_selected_category') != "")
	var selectedElement = $('services_selected_category').value;
 
 var myAccordion = new Accordion($('accordion'), 'li.toggler', 'div.cat_element', {
		opacity: true,
		display: selectedElement,
		mode: 'horizontal',
		onActive: function(toggler, element){
			toggler.setStyle('color', '#41464D');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#528CE0');
		}
	});
	
 if($('services_selected_category') != null && $('services_selected_category') != "")
	myAccordion.display(selectedElement);
 
});




var oldMenu = null;
var oldMenuId = -1;
function showsubmenu(id)
 {
	 if(oldMenu != null) 
 		oldMenu.style.display="none";
	 else
	 {
		document.getElementById('anons'+oldMenuId).style.display="none"; 
	 }
	
/*	if(oldMenuId > 0)
	{
 		
	}
	else
	alert("adasdasdas");
*/	
	
		

	submenu = document.getElementById('anons'+id);

   submenu.style.display="block";

	oldMenu = submenu ;
	//oldMenuId = id;

}
