jQuery(document).ready(function(){

	jQuery('.cats').mouseover(function(){
		this.className='catsH';
	}).mouseout(function(){
		this.className='cats';
	});
	
	jQuery('#loopedSlider').loopedSlider({containerClick: false,autoStart:10000});
	
	jQuery('#mashupBottom').click(function(){
		jQuery('#mashupForm').toggle("slow");
		pageTracker._trackEvent('Mash-Ups', 'Show');
	});

	jQuery('#downloadButton').click(function(){
		pageTracker._trackEvent('Download', 'DemoFiles', jQuery(this).attr('href'));
	});
	
	jQuery('#demoButton').click(function(){
		pageTracker._trackEvent('Visit', 'Demo', jQuery(this).attr('href'));
	});
	
	
	jQuery('.previous,.next').css('opacity',0);
	
	jQuery('#loopedSlider').unbind('mousemove').mousemove(function(e){
	
		if(!this.offsetX)
		{
			this.el = jQuery(this);
			this.offsetX = this.el.offset().left;
			this.width = this.el.width();
			this.prev = this.el.find('.previous');
			this.next = this.el.find('.next');
		}
		var pos = e.pageX-this.offsetX;
		
		if(pos<300)
		{
			this.prev.css('opacity',(300-pos)/300);
			this.next.css('opacity',0);
		}
		else if(this.width-pos<300)
		{
			this.next.css('opacity',(300-(this.width-pos))/300);
			this.prev.css('opacity',0);
		}
		else
		{
			this.next.css('opacity',0);
			this.prev.css('opacity',0);
		}
	});
	
	jQuery('#loopedSlider').mouseout(function(){jQuery('.previous,.next').css('opacity',0);})


	if(jQuery('.rssSubscribe a').length)
	{
		jQuery.get('/wp-content/themes/stepinto/ajax/feed_data.php',function(d){
	
			jQuery('.rssSubscribe a').html('And join '+d+'+ happy readers!');
		
		});
	}
});

function mashupSubmit()
{
	jQuery('#mashupForm form img').show();
	
	jQuery.ajax({
		
		type:"POST",
		url:jQuery('#mashupForm form').attr('action'),
		data:jQuery('#mashupForm form').serialize(),
		success:function(msg){
			
			if(parseInt(msg)!=1)
				alert(msg);

			else
				jQuery('#mashupForm').html('<h2 style="border:0;margin:0">Thank you!</h2>');

			jQuery('#mashupForm form img').hide();
		}

	})
}

function trackP()
{
	return location.href.match(/(\d+)\/(\d+)\/([\w-]+)/i).slice(3).join('-');
}



