jQuery.noConflict();
jQuery(document).ready(function($){

function delayTimer(delay){
     var timer;
     return function(fn){
          timer=clearTimeout(timer);
          if(fn)
               timer=setTimeout(function(){
               fn();
               },delay);
          return timer;
     }
}


// Scrolling Timer for homepage	
var switchDelay = 10000;
var fadeOutDelay = 1000;
var fadeInDelay = 2000;

jQuery.fn.SlideOne = function() {
	$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo').css('z-index','1');
		$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo').animate({opacity: '0'}, {duration: fadeOutDelay, complete: function(){
			$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo.two').animate({opacity: '1', duration: fadeInDelay});
			$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo.two').css('z-index','200');
		}});
};
jQuery.fn.SlideTwo = function() {
	$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo').css('z-index','1');
		$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo').animate({opacity: '0'}, {duration: fadeOutDelay, complete: function(){
			$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo.three').animate({opacity: '1', duration: fadeInDelay});
			$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo.three').css('z-index','200');
		}});
};
jQuery.fn.SlideThree = function() {
	$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo').css('z-index','1');
		$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo').animate({opacity: '0'}, {duration: fadeOutDelay, complete: function(){
			$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo.one').animate({opacity: '1', duration: fadeInDelay});
			$('div#ImageWrapper #ImageBlock #ImageBlock_Box.one.community div.promo.one').css('z-index','200');
		}});
};

var timerDelay=delayTimer(switchDelay);
jQuery.fn.TimerRun = function() {
	timerDelay(function(){
		$(this).SlideOne(timerDelay(function(){
			$(this).SlideTwo(timerDelay(function(){
				$(this).SlideThree($(this).TimerRun());
			}));
		}));
	});
//Timer Run
};

$(this).TimerRun();


$('div.pgk_fullrunner').css({opacity:'0'});
$('div#default_runner, div#default_masthead').css({opacity:'1', zIndex:'50'});
$('div.remove_mastheads').hide();
$('div#matchbox_masthead, div#beginner_masthead, div#standard_masthead, div#pro_masthead').css({opacity: '0'});
var AllMastheads = $('div#default_masthead, div#matchbox_masthead, div#beginner_masthead, div#standard_masthead, div#pro_masthead');

function ShowIt(this_collective_id, this_runner, this_price_block, this_price_price, this_price_buy){
	AllMastheads.animate({opacity: '0'},{queue: false, duration:300});
	$('span.price_block_title:not(' + this_price_block + '), span.price_block_price:not(' + this_price_price + '), span.price_block_buy:not(' + this_price_buy + ')').animate({opacity: '0.4'},{queue: false, duration:200});
	$('div.pgk_fullrunner').animate({opacity: '0'},{queue: false, duration:300, complete:function(){
		$(this_collective_id).animate({opacity: '1'},{queue: false, duration:200});
		$(this_runner).css({zIndex: '51'});
		$('div.remove_mastheads').show();
		$(this_price_block).animate({opacity: '1'},{queue: false, duration:300}).css({zIndex: '100'});
		$(this_price_price).animate({opacity: '1'},{queue: false, duration:300}).css({zIndex: '100'});
		$(this_price_buy).animate({opacity: '1'},{queue: false, duration:300}).css({zIndex: '100'});
	}}).css({zIndex:'49'});
}

$('div.package_trigger').click(function(){
		if ($(this).hasClass('pgk_matchbox_trigger')) {ShowIt('div#matchbox_masthead, div#matchbox_runner', 'div#matchbox_runner', "span#price_block_matchbox_title", "span#price_block_matchbox_price", "span#price_block_matchbox_buy");}
		else if ($(this).hasClass('pgk_beginner_trigger')) {ShowIt('div#beginner_masthead, div#beginner_runner', 'div#beginner_runner', "span#price_block_beginner_title", "span#price_block_beginner_price", "span#price_block_beginner_buy");}
		else if ($(this).hasClass('pgk_standard_trigger')) {ShowIt('div#standard_masthead, div#standard_runner', 'div#standard_runner', "span#price_block_standard_title", "span#price_block_standard_price", "span#price_block_standard_buy");}
		else if ($(this).hasClass('pgk_pro_trigger')) {ShowIt('div#pro_masthead, div#pro_runner', 'div#pro_runner', "span#price_block_pro_title", "span#price_block_pro_price", "span#price_block_pro_buy");}
});

function ResetMasthead(){
	$('div#matchbox_runner, div#beginner_runner, div#standard_runner, div#pro_runner, div#matchbox_masthead, div#beginner_masthead, div#standard_masthead, div#pro_masthead').animate({opacity: '0'}, {duration: 300, complete:function(){
		$('div.remove_mastheads').hide();
		$('div#default_runner').animate({opacity: '1'}, {queue: false, duration: 300, complete: function(){
		}}).css({zIndex: '55'});
		$('span.price_block_title, span.price_block_price, span.price_block_buy').animate({opacity: '1'},{queue: false, duration:200});
	}});
}
function Nowdosomething(){$.stop();}

$('div.remove_mastheads, div.homepagecopy').hoverIntent({
	sensitivity: 3,
    interval: 100,  
    over: ResetMasthead,
    timeout: 200,
    out: Nowdosomething
});




$('.default_button').mouseover(function(){
	$(this).addClass('hover_over');
}).mouseout(function(){
	$(this).removeClass('hover_over');
	$(this).removeClass('click_it');
});

$('.default_button').mousedown(function(){
	$(this).addClass('click_it');
}).mouseup(function(){
	$(this).removeClass('click_it');	
});


$('div.homepage_feature_video_link').mouseover(function(){
	$(this).css({backgroundPosition: 'left -136px'});
}).mouseout(function(){
	$(this).css({backgroundPosition: '0px 0px'});
});;


// /DOM
});