
/*
	Author: BDQWorks/BDQThemes/Jason Saeho Lee
	Version: 1.0.1
	Updated: May 20th, 2011
*/

	
	$(window).scroll(function() {
/*	  if ($(this).scrollTop() > 951) {
		$('.float-me').css('top', "951px").css('position', "absolute");  
	  } else */ if ($(this).scrollTop() > 178) {
		$('.float-me').css('top', '0').css('position', "fixed");
	  } else {
		$('.float-me').css('top', "178px").css('position', "absolute");
	  } 
	  
	  if($(this).scrollTop() > $('#float-check').offset().top-38) {
		$('.float-me-table').fadeIn();
	  } else {
		$('.float-me-table').fadeOut();
	  }
	});
	
	$(document).ready(function() {

	  comments=setInterval("comments_rotate()", 6000);
	  sparks=setInterval("sparkle()", 10000);
		
	  $('.disappear-me').hover(function() {
		$('.disappear-me .disappear').hide();
	  }, function(){
		$('.disappear-me .disappear').show();
	  });
	  
	  $('#shop-pane').hover(function() {
		
	  }, function(){
		$(this).stop().animate({top: '-124px'}, 250);
	  }); 
	  
	  $('#connect-pane').hover(function() {
		
	  }, function(){
		$(this).stop().animate({top: '-124px'}, 250);
	  });
	  
	  $('#catalog-pane').hover(function() {
		
	  }, function(){
		$(this).stop().animate({top: '-124px'}, 250);
	  });
	  
	  $('#dealers-pane').hover(function() {
		
	  }, function(){
		$(this).stop().animate({top: '-124px'}, 250);
	  });
	
	});
	
	function sparkle(){	
		$('#sparkle1').delay(485).fadeIn(80).fadeOut(1300);
		$('#sparkle2').delay(515).fadeIn(80).fadeOut(1300);
		$('#sparkle3').delay(1585).fadeIn(80).fadeOut(1300);
		$('#sparkle4').delay(1615).fadeIn(80).fadeOut(1300);
		$('#sparkle5').delay(2685).fadeIn(80).fadeOut(1300);
		$('#sparkle6').delay(2715).fadeIn(80).fadeOut(1300);
	};

   function comments_rotate() {
    if (!$(this).parent().children().is(':animated')) {
	  var top = parseInt($('#comments-scroll').css('margin-top').replace("px", ""));
	  var target = parseInt($('#comments-scroll').attr('name'));
	  
	  if(top>target) {
	  	$('#comments-scroll').stop().animate({
          marginTop: '-=290px'
        }, 1500);
	  } else {
		$('#last-comments').html('');
		$('.first-comments').clone().prependTo('#last-comments');  
		$('#comments-scroll').stop().animate({
    	  marginTop: '-=290px'
          }, 1500, function() {
			$('#comments-scroll').css('marginTop', '0px');
		  });
	  };
	};
  };
  
  function cc_show() {
	if ($("input:radio[name=eshop_payment]:checked").val()=='authorizenet')
	  $('#cc-info').slideDown();
	else
	  $('#cc-info').slideUp();
  }


	  $('.navigation-scroll').live('click', function (event) {
	    event.preventDefault();
		var id = $(this).attr('href');
		if (id=='#a')
		  $('html,body').animate({scrollTop: $(id).offset().top+0},'slow');
		else if (id=='#top')
		  $('html,body').animate({scrollTop: 0},'slow');
		else
		  $('html,body').animate({scrollTop: $(id).offset().top-85},'slow');
      });
	  
	  $('.navigation-scroll-short').live('click', function (event) {
	    event.preventDefault();
		var id = $(this).attr('href');
		if (id=='#a')
		  $('html,body').animate({scrollTop: $(id).offset().top+0},'slow');
		else if (id=='#top')
		  $('html,body').animate({scrollTop: 0},'slow');
		else
		  $('html,body').animate({scrollTop: $(id).offset().top-62},'slow');
      });
	  
	  $('.navigation-scroll-direct').live('click', function (event) {
	    event.preventDefault();
		var id = $(this).attr('href');
		if (id=='#a')
		  $('html,body').animate({scrollTop: $(id).offset().top+0},'slow');
		else if (id=='#top')
		  $('html,body').animate({scrollTop: 0},'slow');
		else
		  $('html,body').animate({scrollTop: $(id).offset().top},'slow');
      });
	  
	  $('a.disable').live('click', function (e) {
	    e.preventDefault();
  	  });
  
	  $('#shop').live('click', function () {
	    if (!$(this).parent().children().is(':animated')) {
		  $('#connect-pane').stop().animate({top: '-124px'}, 250);
	  	  $('#shop-pane').stop().animate({top: 0}, {duration: 500});
		  
	    }
	  });
	  
	  $('#connect').live('click', function () {
	    if (!$(this).parent().children().is(':animated')) {
		  $('#shop-pane').stop().animate({top: '-124px'}, 250);
	  	  $('#connect-pane').stop().animate({top: 0}, {duration: 500});
	    }
	  });
	  
	  $('#catalog').live('click', function () {
	    if (!$(this).parent().children().is(':animated')) {
	  	  $('#catalog-pane').stop().animate({top: 0}, {duration: 500});
	    }
	  });
	  
	  $('#dealers').live('click', function () {
	    if (!$(this).parent().children().is(':animated')) {
	  	  $('#dealers-pane').stop().animate({top: 0}, {duration: 500});
	    }
	  });
