soundManager.url = REAL_PATH+'scripts/';
soundManager.waitForWindowLoad = true;
soundManager.onload = function() {
  soundManager.createSound('click',REAL_PATH+'css/images/click.mp3');
};
$(document).ready(function(){

    $('a.lightbox').lightBox();

    $('div.header ul.menu li a').bind('mouseover', function(){
        $(this).parent().addClass('cur').animate({ 'background-position': '100px 0px' });
        soundManager.play('click');
    }).bind('mouseout', function(){
        $(this).parent().removeClass('cur').animate({ 'background-position': '0px 0px' });
    });

    function star_one(){
        $('div.graphic div.star.one').animate({ 'bottom': '+=10px' }, 200).animate({ 'right': '+=50px' }, 200).dequeue().animate({ 'bottom': '-=10px' }, 300).animate({ 'right': '+=30px' }, 300).animate({ 'bottom': '+=20px' }, 400).animate({ 'right': '+=30px' }, 300).animate({ 'bottom': '+=40px' }, 300).animate({ 'right': '-=20px' }, 400).animate({ 'bottom': '-=10px' }, 400).animate({ 'right': '-=20px' }, 400).animate({ 'bottom': '-=30px' }, 400).animate({ 'right': '-=30px' }, 400).animate({ 'bottom': '40px' }, 500).animate({ 'right': '200px' }, 200, function(){ star_one(); });
    }
    function star_two(){
        $('div.graphic div.star.two').animate({ 'bottom': '+=15px' }, 300).dequeue().animate({ 'bottom': '+=10px' }, 500).animate({ 'right': '+=45px' }, 400).animate({ 'bottom': '-=20px' }, 400).animate({ 'right': '+=15px' }, 200).animate({ 'bottom': '+=45px' }, 200).animate({ 'right': '+=5px' }, 200).animate({ 'bottom': '+=20px' }, 400).animate({ 'right': '-=60px' }, 400).animate({ 'bottom': '-=10px' }, 200).animate({ 'right': '-=30px' }, 400).animate({ 'bottom': '-=20px' }, 600).animate({ 'right': '-=40px' }, 400).animate({ 'bottom': '60px' }, 300).animate({ 'right': '250px' }, 400,  function(){ star_two(); });
    }
    function star_three(){
        $('div.graphic div.star.three').animate({ 'bottom': '-=15px' }, 400).animate({ 'right': '+=30px' }, 200).dequeue().animate({ 'bottom': '-=20px' }, 400).animate({ 'right': '+=40px' }, 300).animate({ 'bottom': '+=25px' }, 400).animate({ 'right': '-=20px' }, 400).animate({ 'bottom': '+=20px' }, 300).animate({ 'right': '-=16px' }, 400).animate({ 'bottom': '-=40px' }, 400).animate({ 'right': '+=10px' }, 400).animate({ 'bottom': '-=10px' }, 600).animate({ 'right': '+=10px' }, 300).animate({ 'bottom': '80px' }, 500).animate({ 'right': '210px' }, 400,  function(){ star_three(); });
    }
    function star_four(){
        $('div.graphic div.star.four').animate({ 'bottom': '+=20px' }, 300).dequeue().animate({ 'bottom': '+=30px' }, 00).animate({ 'right': '+=65px' }, 200).animate({ 'bottom': '-=40px' }, 400).animate({ 'right': '-=15px' }, 300).animate({ 'bottom': '-=25px' }, 300).animate({ 'right': '-=5px' }, 400).animate({ 'bottom': '-=40px' }, 400).animate({ 'right': '-=40px' }, 400).animate({ 'bottom': '-=20px' }, 300).animate({ 'right': '+=20px' }, 200).animate({ 'bottom': '+=30px' }, 400).animate({ 'right': '+=20px' }, 400).animate({ 'bottom': '100px' }, 500).animate({ 'right': '230px' }, 400, function(){ star_four(); });
    }
    function star_five(){
        $('div.graphic div.star.five').animate({ 'bottom': '-=30px' }, 200).animate({ 'right': '+=20px' }, 200).dequeue().animate({ 'bottom': '+=10px' }, 300).animate({ 'right': '+=10px' }, 200).animate({ 'bottom': '+=35px' }, 400).animate({ 'right': '+=10px' }, 400).animate({ 'bottom': '+=25px' }, 400).animate({ 'right': '+=20px' }, 400).animate({ 'bottom': '+=20px' }, 400).animate({ 'right': '-=10px' }, 400).animate({ 'bottom': '-=20px' }, 400).animate({ 'right': '-=10px' }, 400).animate({ 'bottom': '50px' }, 300).animate({ 'right': '270px' }, 600, function(){ star_five(); });
    }
    star_one();star_two();star_three();star_four();star_five();
	
	
	$('ul.scroll li').bind('mouseover', function(){
		$width = $(this).width();
		$tag = $(this);
		$(this).find('span').animate({ 'height': '+=5px' }, 100);
		$(this).animate({ 'background-position': '-='+$width+'px 0px' });
		$(document).everyTime(2000, function(i) {
            $($tag).animate({ 'background-position': '-='+ $width +'px 0px' });
        });
    }).bind('mouseout', function(){
		$(this).find('span').animate({ 'height': '-=5px' }, 100);
		$(this).animate({ 'background-position': '0px 0px' });
        $(document).stopTime();
    });

    
    $tstm_count = $('ul.testimonials li').size();
    $('ul.testimonials li:eq(0)').show();
    if( $tstm_count!=1 ){
    $index = 0;
    $('body').everyTime(6000, function(i) {
        $('ul.testimonials li:visible').fadeOut(300, function(){ $('ul.testimonials li:eq('+ $index +')').fadeIn(300); });

        if( $index == ($tstm_count-1) ){
            $index=0;
        } else {
            $index++;
        }
    });
    }
	
	$('ul.testimonials li a').bind('click', function(){
		$html = $(this).next('p').html();
		$('div.left *:not(h2:first)').fadeOut();
		
		$content = '<div class="pwrap round testimonial" style="display:none;"><p>'+ $html +'</p><a class="back close-testimonials" title="Inapoi"></a><br style="clear:both;" /></div>';
		
		$('div.left div.testimonial').remove();
		$('div.left').append($content).find('div.testimonial:hidden').fadeIn(500);
	});
	
	$('a.close-testimonials').live('click', function(){
		
		$('div.left div.testimonial:visible').fadeOut(500, function(){
			$('div.left *:hidden:not(div.testimonial)').fadeIn(500);
			$('div.left div.testimonial').remove();
		});
	});
	
});
