window.addEvent('domready', function(){

	// run markup hacks
	new Exm();


	// print links
	try {
		$$('a[rel="print"]').addEvent('click', function(){
			Document.print('body');
			return false;
		});
	} catch(e){}


	// releases menu on home page
	try {
		$$('div#left_menu ul a.text-shadow').addEvent('click', function(){
			$$('div#left_menu ul a').removeClass('open');
			$$('div#left_menu ul div').removeClass('open');
			$$('div.arrow_l_menu').removeClass('open');
			this.getElements('div').addClass('open');
			
			this.addClass('open').getNext('div').addClass('open');
		});
	} catch(e) {}


	// releases accordeon
	try {
		$$('dl.accordion dt').addEvent('click', function(){
			this.getNext('dd').toggleClass('this');
			return false;
		});
	} catch(e) {}

jQuery('.proposition').hover(
  function() {

  jQuery(this).find('img:first').stop().animate({
    marginLeft: '85'
  }, 150, function() {
    // Animation complete.
  }
  )
  },
  function() {

  jQuery(this).find('img:first').stop().animate({
    marginLeft: '80'
  }, 150, function() {
    // Animation complete.
  }
    
  );
});

var today = new Date();


if(jQuery('#left_menu a.selected').text()){
jQuery('#left_menu a.selected').parent().parent().attr('class', 'open').parent().find('a:first').attr('class', 'text-shadow children open').find('div:first').attr('class', 'arrow_l_menu open');
}
else
{
   jQuery('#left_menu').find('ul:last').find('a:first').attr('class', 'text-shadow children open').find('div:first').attr('class', 'arrow_l_menu open');
   jQuery('#left_menu').find('ul:last').find('div:last').attr('class', 'open')
   
}

jQuery('.curr_box').each(function(){
  jQuery(this).find('span:first').attr('style', 'font-weight: 500;');
})




  var con ='';
  jQuery('div#contacts-holder p').last().attr('style', 'background-color:transparent;padding-bottom:0px;');
  jQuery('div#contacts-holder').each(function(i){
      jQuery(this).hide();
      var ad = str_replace('Телефон:', '',jQuery(this).html());
      ad = str_replace('Адрес:', '',ad);
      ad = str_replace('е-mail:', '',ad);
      
      ad = str_replace('т.:', '',ad);
      ad = str_replace('e-mail:', '',ad);
      ad = str_replace('тел.: .', '',ad);
      ad = str_replace('тел.:', '',ad);
      
      con +=ad;
      
    
  })
  
  if(con !== ''){
  
  jQuery('.contacts').html(con);
  
  
}
else{
    jQuery('.contacts').attr('class', 'contacts_fix').html('');
}

//alert(jQuery('#right_coll').height());
//alert(jQuery('#content').height());
if(jQuery.browser.opera && jQuery.browser.version > 9.5){
  if(document.getElementById("right_coll")){
   var h = document.getElementById("right_coll").clientHeight
  }
  else
  {
   var h = ''; 
  }
 }
 else{
   if(document.getElementById("right_coll")){
    var h =jQuery('#right_coll').height();
   }
  else
  {
    var h = ''; 
  }
 }

  if(jQuery('#content').attr('style') == 'undefine'){

jQuery('#content').attr('style', 'min-height:'+(h-70)+'px;');
}
else
{
jQuery('#content').attr('style', jQuery('#content').attr('style')+';min-height:'+(h-70)+'px;');

}

jQuery('#header_menu ul li:first').attr('class', 'hover2');
//jQuery('#header_menu ul li ul').find('li:first').remoteC('class');
jQuery('#header_menu ul li:first').find('a:first').attr('style', 'margin-left:7px;padding-left:3px;');
jQuery('#header_menu ul li:first').hover(function(){
  jQuery(this).attr('class', 'hover1');
  
}, function(){
  jQuery(this).attr('class', 'hover2');
})

jQuery('#header_menu ul li').hover(function(){
  jQuery(this).find('ul:first').attr('style','display:block;');
}, function(){
  jQuery(this).find('ul:first').attr('style','display:none;');
})

});

function str_replace ( search, replace, subject ) {	// Replace all occurrences of the search string with the replacement string
	// 
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Gabriel Paderni

	if(!(replace instanceof Array)){
		replace=new Array(replace);
		if(search instanceof Array){//If search	is an array and replace	is a string, then this replacement string is used for every value of search
			while(search.length>replace.length){
				replace[replace.length]=replace[0];
			}
		}
	}

	if(!(search instanceof Array))search=new Array(search);
	while(search.length>replace.length){//If replace	has fewer values than search , then an empty string is used for the rest of replacement values
		replace[replace.length]='';
	}

	if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
		for(k in subject){
			subject[k]=str_replace(search,replace,subject[k]);
		}
		return subject;
	}

	for(var k=0; k<search.length; k++){
		var i = subject.indexOf(search[k]);
		while(i>-1){
			subject = subject.replace(search[k], replace[k]);
			i = subject.indexOf(search[k],i);
		}
	}

	return subject;

}

