var allow = 1;
var tmp,a;
var url=new String(window.location);

var lang = 'ru';
 if (window.location.href.indexOf('/en/') > -1)  lang = 'en';

function validate(string) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
   return reg.test(string);
}

function setMenu(link)
    {
        
        $('.Menu a.active').removeClass('active');
       $('.Menu a[href="'+link+'"]').addClass('active');
      $('.Menu a[href="'+link+'en/"]').addClass('active');
        
        
    }
    
    




$(document).ready(function(){
    
    $("a.imgLarge").fancybox({
		'titleShow'     : true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn'      : 'easeOutBack',
		'easingOut'     : 'easeInBack',
        'showNavArrows' : true
	});
    
    $('.News .newsChange a').click(function(e){
        
       e.preventDefault();
       $('.News .newsChange a.active').removeClass('active');
       $(this).addClass('active');
       
       $('.News div.'+$(this).attr('rel')).show(0);
       $('.News div.e:not(.'+$(this).attr('rel')+')').hide(0);
        
    });
    
    $('.ArchiveSearch input[type=button]').click(function(e){
        
        if ($('.ArchiveSearch select[name=year]').val() != 0)
            {
                
                tmp = '/'+$('.ArchiveSearch').attr('id')+'/listing/'+$('.ArchiveSearch select[name=year]').val()+'/';
                if  ($('.ArchiveSearch select[name=month]').val() != 0) tmp += $('.ArchiveSearch select[name=month]').val()+'/';
                if (window.location.href.indexOf('/en/') > -1) tmp += 'en/';
                window.location.href = tmp;
            }
        
    });
      
      if(url.indexOf('/news/')>-1)  setMenu('/news/'); 
      if(url.indexOf('/about/')>-1)  setMenu('/about/'); 
      if(url.indexOf('/vacancy/')>-1)  setMenu('/about/'); 
      if(url.indexOf('/expo/')>-1)  setMenu('/expo/');
      if(url.indexOf('/services/')>-1)  setMenu('/services/');
      if(url.indexOf('/congress/')>-1)  setMenu('/congress/');
     
     
 	$(".Carousel").carousel({loop:true, effect: 'fade', pagination: true, autoSlide: true, animSpeed: "normal",autoSlideInterval: 5000})
    $('.Search input[name=query]').focus(function(){ if (($(this).val()=='Поиск по сайту')||($(this).val()=='Search...')) {$(this).val('');  } }).blur(function(){ if($(this).val()=='') {$(this).val('Поиск по сайту'); } });
   	$(".Gallery>.in>.Items>.in").carousel({ dispItems: 6, animSpeed: "slow", prevBtn:'.Arrow.L',nextBtn : '.Arrow.R'})
   
    $('select[name=year]').change(function(e){
        
        if ($(this).val() != '0') 
            {
                
                //$(this).spinner();
                $.post('/do/getMonth/',{'y':$(this).val(),'type':$(this).parents('.ArchiveSearch').attr('id')},function(data){ $('select[name=month]').html(data); },'html')
            } else { if (lang == 'ru') $('select[name=month]').html('<option value="0">Выберите месяц</option>'); else $('select[name=month]').html('<option value="0">Select month</option>'); 
              }
        
    });
  
         
});
