jQuery.noConflict(); 
jQuery(document).ready(function(){
	jQuery('#fbanner').flash(
        { src: '/i/nasos.swf',
          width: 178,
          height: 178,
	      wmode: 'transparent' }, { version: 9 });
});
jQuery(document).ready(function(){
	jQuery('.slog').flash(
        { src: '/i/dostavka.swf',
          width: 550,
          height: 55,
	      wmode: 'transparent' }, { version: 9 });
});
jQuery(document).ready(function() {
	jQuery("#callback").fancybox({
		'width'				: '40%',
		'height'			: '34%',
        'autoScale'     	: false,
        'titleShow'         : false,
        'overlayOpacity'    : 0.4,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
});
jQuery(document).ready(function() {
    jQuery("#callback").simpletip({ content: 'Укажите свой номер телефона и мы Вам перезвоним!', position: top }); 
});
/*
jQuery(document).ready(function() {
		var offset = jQuery(".incart2").offset();
		var topPadding = 5;
		jQuery(window).scroll(function() {
			if (jQuery(window).scrollTop() > offset.top) {
				jQuery(".incart2").stop().animate({marginTop: jQuery(window).scrollTop() - offset.top + topPadding});
			}
			else {jQuery(".incart2").stop().animate({marginTop: -62});};});
});*/
function updateClock ( )
    {
    var currentTime = new Date ( );
    var currentHours = currentTime.getHours ( );
    var currentMinutes = currentTime.getMinutes ( );
    var currentSeconds = currentTime.getSeconds ( );
    currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
    currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
    currentHours = ( currentHours > 24 ) ? currentHours - 24 : currentHours;
    currentHours = ( currentHours == 0 ) ? 24 : currentHours;
    var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;
    jQuery("#clock").html(currentTimeString);
 
 }
 
jQuery(document).ready(function()
{
   setInterval('updateClock()', 1000);
}); 
jQuery(document).ready(function() {
	var loader=jQuery('#loader');
	var pollcontainer=jQuery('#pollcontainer');
	loader.fadeIn();
	jQuery.get('/poll.php', '', function(data, status){
		pollcontainer.html(data);
		animateResults(pollcontainer);
		pollcontainer.find('#viewresult').click(function(){
			loader.fadeIn();
			jQuery.get('/poll.php', 'result=1', function(data,status){
				pollcontainer.fadeOut(1000, function(){
					jQuery(this).html(data);
					animateResults(this);
				});
				loader.fadeOut();
			});
			return false;
		}).end()
		.find('#pollform').submit(function(){
			var selected_val=jQuery(this).find('input[name=poll]:checked').val();
			if(selected_val!=''){
				loader.fadeIn();
				jQuery.post('/poll.php', jQuery(this).serialize(), function(data, status){
					jQuery('#formcontainer').fadeOut(100, function(){
						jQuery(this).html(data);
						animateResults(this);
						loader.fadeOut();
					});
				});
			}
			return false;
		});
		loader.fadeOut();
	});
	
	function animateResults(data){
		jQuery(data).find('.bar').show().end().fadeIn('slow', function(){
							jQuery(this).find('.bar').each(function(){
								var bar_width=jQuery(this).css('width');
								jQuery(this).css('width', '0').animate({ width: bar_width }, 1000);
							});
						});
	}
	
});
