/* $('#menu_main a').mouseover(function() {
	if(!$(this).parent().hasClass('active') && !$(this).parent().hasClass('not_active'))
	{
		this_src = $(this).find('img').attr('src');
		//m_01.gif->m_over_01.gif
		this_src = this_src.replace("/m_", "/m_over_");
		$(this).find('img').attr('src', this_src);
	}
})


$('#menu_main a').mouseout(function() {
	if(!$(this).parent().hasClass('active') && !$(this).parent().hasClass('not_active'))
	{
		this_src = $(this).find('img').attr('src');
		//m_over_01.gif->m_01.gif
		this_src = this_src.replace("/m_over_", "/m_");
		$(this).find('img').attr('src', this_src);
	}
})
*/


$('#block_vip_part_cont img').mouseover(function() {
		this_src = $(this).attr('over');
		$(this).attr('src', this_src);
})


$('#block_vip_part_cont img').mouseout(function() {
		this_src = $(this).attr('out');
		$(this).attr('src', this_src);
})






var _Today = new Date();

function getDaysLeft(_DeadLineDate, _Today){
  return _DeadLineDate > _Today ? Math.ceil((_DeadLineDate - _Today) / (1000 * 60 * 60 * 24)) : null;
}

function writeDaysLeft(sDeadLineDate, sDeadLineText){
  var sTime = sDeadLineDate + " " + _Today.getHours() + ":" + _Today.getMinutes() + ":" + _Today.getSeconds();
  var _DeadLineDate = new Date(sTime);
  var _DaysLeft = getDaysLeft(_DeadLineDate, _Today);
  if (_DaysLeft){
    var sDaysLeft = String(_DaysLeft);
    var sDaysText = "днів";
    var _DaysLeftLength = sDaysLeft.length;
    if (sDaysLeft.charAt(_DaysLeftLength - 2) != "1"){
      if (sDaysLeft.charAt(_DaysLeftLength - 1) == "2" || sDaysLeft.charAt(_DaysLeftLength - 1) == "3" || sDaysLeft.charAt(_DaysLeftLength - 1) == "4") sDaysText = "дня";
      else if (sDaysLeft.charAt(_DaysLeftLength - 1) == "1") sDaysText = "день";
    }
    var sLeftText = sDaysText == "день" ? "залишився" : "залишилось";
	$('#about_i_ven .hover').html(sDeadLineText + " " + sLeftText + " <strong>" + _DaysLeft + "</strong> " + sDaysText + "&nbsp; &nbsp;");
  }
}

writeDaysLeft("March 24, 2012", "До Урочистої церемонії «Людина року - 2011» ");


/*
#about_i_ven:hover .not_hover{ display:none;}
#about_i_ven:hover .hover{ display:block; }
*/
function show_hover(){

			$("#about_i_ven .hover").css('opacity','0');
			$("#about_i_ven .hover").css('display','block');

			$("#about_i_ven .hover").animate({
			opacity: 1,
			filter: ''
		 	}, 1000,
				function() {
					timer_i_ven = setInterval(function(){ close_hover(); clearInterval(timer_i_ven); }, 2000);
				 }
			 );

}

function close_hover(){

			$("#about_i_ven .hover").animate({
			opacity: 0,
			filter: ''
		 	}, 1000,
				function() {
					$("#about_i_ven .hover").css('display','none');
					show_not_hover();
				 }
			 );

}

function close_not_hover(){

			$("#about_i_ven .not_hover").animate({
			opacity: 0,
			filter: ''
		 	}, 1000,
				function() {
					$("#about_i_ven .not_hover").css('display','none');
					show_hover();
				 }
			 );

}

function show_not_hover(){

			$("#about_i_ven .not_hover").css('opacity','0');
			$("#about_i_ven .not_hover").css('display','block');

			$("#about_i_ven .not_hover").animate({
			opacity: 1,
			filter: ''
		 	}, 1000,
				function() {
					timer_i_ven = setInterval(function(){ close_not_hover(); clearInterval(timer_i_ven); }, 2000);
				 }
			 );

}




timer_i_ven = setInterval(function(){ close_not_hover(); clearInterval(timer_i_ven); }, 2000);






	var kids = $('#i_slideShow').children();
	var currentImage = 0;
	var timer;
	var timer_over;
	var timeout_over;
	var is_videoPlay=false;

	$('#slideShow_select li').hover(
		function() {
			clearInterval(timer);
			newImage = parseInt($(this).attr('value'));
			clearTimeout(timeout_over);
			timeout_over = setTimeout( function(){  sliderShow(newImage); }, 100);
			clearInterval(timer_over);
			clearInterval(timer);
			timer_over = setInterval(function(){ timer_over_func(); }, 6000);
		},
		function() {
			clearTimeout(timeout_over);
			clearInterval(timer_over);
			clearInterval(timer);
			//sliderNew(currentImage);
			timer_set();
		}
	);

	function timer_over_func(){ timer_set(); clearInterval(timer_over); }

	function timer_set(){ timer = setInterval(function(){ sliderNew(currentImage); }, 4000); }
	timer_set();

	function sliderNew(currentImage){
		newImage = currentImage + 1;
		if(newImage>=kids.length){newImage=0;}
		sliderShow(newImage);
	}

	function sliderShow(newImage){
		if(is_videoPlay){
				$('#i_slideShow').css( 'display', 'block' );
				$('#i_slideShow img').css( 'display', 'block' );
				$('#i_slideShow_play').css( 'display', 'block' );
				$('#i_slideShow_video').css( 'display', 'none' );
				$('#i_slideShow').css('background','#540800');
				$('#i_slideShow_video').html( "" );
		}
		else {
      $('#i_slideShow').css('background','#540800 url('+kids[currentImage].src+') 3px 3px no-repeat');
      //alert(kids[currentImage].src);  
    }
		for(var i = 0; i < kids.length; i++){
			$(kids[i]).css('display','none');
		}
		$('#slideShow_select #a'+currentImage).removeClass('active');
		$(kids[newImage]).fadeIn(1000);
		$('#slideShow_select #a'+newImage).addClass('active');
		currentImage=newImage;
		is_videoPlay=false;
	}

var videoObject= Drupal.settings.videoObject;
//var videoObject='<object width="546" height="309"><param name="movie" value="http://www.youtube.com/v/xdlBcOA4BuE?version=3&amp;hl=ru_RU&amp;rel=0&amp;autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/xdlBcOA4BuE?version=3&amp;hl=ru_RU&amp;rel=0&amp;autoplay=1" type="application/x-shockwave-flash" width="546" height="309" allowscriptaccess="always" allowfullscreen="true"></embed></object>';


$('#i_slideShow img').click(function() {
	$('#i_slideShow').css( 'display', 'none' );
	$('#i_slideShow img').css( 'display', 'none' );
	//$('#slideShow_select').css( 'display', 'none' );
	$('#i_slideShow_play').css( 'display', 'none' );
	$('#i_slideShow_video').html( videoObject );
	$('#i_slideShow_video').css( 'display', 'block' );
	clearInterval(timer);
});


$('#i_slideShow_play').click(function() {
	is_videoPlay=true;
	$('#i_slideShow img').click();
});


    
  var currentGallery = 0;  
  var fotos_line_ul='';
  
  
  function show_fotos()
  {    
    fotos_line_ul='';
    for (var i = 0; i < fotos_line_arr[currentGallery].length; i++) { 
      fotos_line_ul+= '<a rel="foto_group" href="' + fotos_line_arr[currentGallery][i].src_b +'" title="' + fotos_line_arr[currentGallery][i].about +'"  value="' + i +'"><img src="' + fotos_line_arr[currentGallery][i].src +'" alt=""  /></a>';
    }      
    $("#fotos_inframe").empty();    
    $("#fotos_inframe").append(fotos_line_ul);    
    $('#fotos_inframe').css('width', fotos_line_arr[currentGallery].length*191+'px' ); 
    sost_foto=0;
    //$("#fotos_inframe").css( 'left', '0px' );
    set_fotos_n();
    fancybox_start();
  }
  
  show_fotos()

  sost_foto=0;
  set_fotos_n();
  
  function set_fotos_n()
  {      
      
     if((sost_foto+1)*5>=(fotos_line_arr[currentGallery].length) || (fotos_line_arr[currentGallery].length)<5 )
     {
      $('#fotogal_r').css( 'display', 'none' );
     }
     else{
        $('#fotogal_r').css( 'display', 'block' );
       }
     
     if(sost_foto==0)
     {
      $('#fotogal_l').css( 'display', 'none' );
     }
     else
     {
        $('#fotogal_l').css( 'display', 'block' );
      }
      
      $("#fotos_inframe").animate({
          left:-sost_foto*5*191+'px'
          }, 1000, 
          function() {   }
           );
    
  }
  
  function next_foto()
  {
    

     if( (fotos_line_arr[currentGallery].length - (sost_foto+1)*5)>0 )
     {
       sost_foto++;
       set_fotos_n();
     }
     
  }
  function prev_foto()
  {
    if(sost_foto>0)
    {
       sost_foto--;
       set_fotos_n();
    }
  }
  
  
$('#fotogal_l').click(function() {  
  prev_foto();
});
$('#fotogal_r').click(function() {  
  next_foto();
});

var gall_names_ul="";

  for (var i = 0; i < fotos_line_names_arr.length; i++) { 
    gall_names_ul+= '<li id="g'+i+'" value="'+i+'"><a href="#">' + fotos_line_names_arr[i] +'</a></li>';
  }  
      
  $("#gall_names").append('<ul>' + gall_names_ul + '</ul>');
  $("#gall_names ul li:nth-child(1)").addClass('active').addClass('first');
  
  
$('#gall_names a').click(function() {
    
  $('#gall_names li').removeClass('active');
  $(this).parent().addClass('active');
  currentGallery=parseInt($(this).parent().attr('value'));
  show_fotos();
  //$("#fotos_inframe").empty();
});


  function fancybox_start()
  {
      $("a[rel=foto_group]").fancybox({
        'transitionIn'    : 'none',
        'transitionOut'    : 'none',
        'titlePosition'   : 'over',
        'titleFormat'    : function(title, currentArray, currentIndex, currentOpts) {
          return '<span id="fancybox-title-over">Зображення ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
      });
  }
fancybox_start();


$('a').click(function() {
  if(  $(this).attr('href')=='#'){
      $(this).blur();
      return false;
  }  
});










