/* 
 * Author: Derek Mattson @insivia
 */

var wrp = wrp || {};
wrp.qwy = wrp.qwy || {};
wrp.rot = wrp.rot || {};
	
jQuery(function()
{
	 wrp.qwy.init();
     wrp.rot.init();
});

wrp.qwy = 
{		
	init: function()
	{
		wrp.qwy.path_to_template = 'http://wesrespartners.com/wp-content/themes/western/';
    	wrp.qwy.number_of_posts = 5;
    	wrp.qwy.default_category = 'Business Services';
		wrp.qwy.animspeed = 'medium';
		wrp.qwy.element = '#mygallery';
		
		$('.slider-nav ul li a').bind('click',wrp.qwy.click);
	},
	click:function()
	{
		wrp.qwy.cat = $(this).attr("title");
		$('.slider-nav ul li a.active').removeClass('active');
		$(this).addClass('active');
		
		$(wrp.qwy.element).fadeOut(wrp.qwy.animspeed, function()
		{	
			wrp.qwy.load();
		});
	},
	load: function()
	{
        $('.belt').css('left','0px');
		switch(wrp.qwy.cat)
		{
		case 'Business Services':
		  wrp.qwy.cat = '45';
		  break;
		case 'Consumer':
			wrp.qwy.cat = '46';
		  break;
		case 'Healthcare':
			wrp.qwy.cat = '47';
		  break;
		case 'Industrial':
			wrp.qwy.cat = '48';
		  break;
		case 'Real Estate':
			wrp.qwy.cat = '49';
		  break;
        case 'Technology':
			wrp.qwy.cat = '50';
		  break;
		default:
		  wrp.qwy.cat = '45';
		};
		
		var query = '?showposts=' + wrp.qwy.number_of_posts + '&cat=' + wrp.qwy.cat;
        var url = wrp.qwy.path_to_template + 'querySort.php' + query;
        stepcarousel.configholder['mygallery'].contenttype[1] = url;
        stepcarousel.getremotepanels($,stepcarousel.configholder['mygallery']);
        reset = true;
        $(wrp.qwy.element).fadeIn(wrp.qwy.animspeed);
		
		return false;
	}
};

wrp.rot = 
{		
	init: function(){wrp.rot.element = '.slider';wrp.rot.timer;$(wrp.rot.element).bind('mouseenter', wrp.rot.stop);$(wrp.rot.element).bind('mouseleave', wrp.rot.start);wrp.rot.start();},
    stop:function(){clearInterval(wrp.rot.timer);},
	start:function(){wrp.rot.timer = setInterval (wrp.rot.rotate, 5000);},
    rotate:function(){stepcarousel.stepBy('mygallery', 1)}
};
