jQuery.noConflict();

// Document Ready Event
jQuery(document).ready(function(){
// Around the site tab links
jQuery(".wpn_around-tabs a").each(function(i) {
	jQuery(this).click(function(e){
		e.preventDefault();
						
		jQuery(".wpn_around-tabs a").removeClass('wpn_active');
		jQuery(this).addClass('wpn_active');
		
		jQuery('div.wpn_around div').removeClass('wpn_active');
		jQuery(jQuery(this).attr('href')).addClass('wpn_active');
	});
});

// Add dropdown class to links that have dropdowns
jQuery('.wpn_menu > li > ul, .wpn_submenu > li > ul').each(function(i,li) {
	jQuery(li).parent('li').addClass('wpn_dropdown');
});

// Drop down menus - level 2
jQuery(".wpn_menu > li,.wpn_submenu > li").hover(
function(){
	var menu = jQuery(this).children(':parent > ul');
	var offset = jQuery(this).offset();
	var bodywidth = jQuery('body').width();
	
	// Check to make sure the dropdown won't go off screen
	if(offset.left + 200 > bodywidth) {
		menu.css({
			left: 'auto',
			right: '0px'
		});
	}
	
	menu.css({visibility: "visible",display: "none"}).slideDown(268);
	// menu.slideDown(268);
},
function() {
	var menu = jQuery(this).children(':parent > ul');
	menu.css({visibility: "hidden"});
});

// Drop down menus - level 3
jQuery(".wpn_menu > li > ul > li, .wpn_submenu > li > ul > li").hover(
function(){
	var menu = jQuery(this).children(':parent > ul');
	var offset = jQuery(this).offset();
	var bodywidth = jQuery('body').width();
	
	// Check to make sure the dropdown won't go off screen
	if(offset.left + 400 > bodywidth) {
		menu.css({
			left: '-200px'
		});
	}
	
	// menu.slideDown(268);
	menu.css({visibility: "visible",display: "none"}).slideDown(268)
},
function() {
	var menu = jQuery(this).children(':parent > ul');
	menu.css({visibility: "hidden"});
});


// Featured Slide Thing

var items = jQuery('.wpn_featured li');
var item_width = 594;
var max_margin = items.length * item_width - item_width;
var animstatus = false;
var user_click = false;
var animation_speed = 1000;
var auto_speed = 7500;

jQuery('.wpn_featured-arrowl').click(function(e) {
	e.preventDefault();
	user_click = true;
	moveFeature('back')
});

jQuery('.wpn_featured-arrowr').click(function(e) {
	e.preventDefault();
	user_click = true;
	moveFeature('next')
});

jQuery('.wpn_featured .wpn_fthumbs span a').each(function(i,link) {
	var index = i+1;
	jQuery(link).click(function(e) {
		e.preventDefault();
		user_click = true;
		
		moveFeature(index);
	});
});

function moveFeature(location) {
	if(animstatus == false) {
		animstatus = true;
		var feature = jQuery('.wpn_featured ul');
		var pos = parseInt(jQuery(feature).css('left'));
		
		feature.animate({opacity: 0},animation_speed,"swing",function() {
			if(location) {
				if(location=='next') {
					if(pos == -max_margin){
						left = 0;
					}
					else {
						left = pos-item_width;
					}
				}
				else if(location=='back') {
					if(pos == 0){
						left = -max_margin;
					}
					else {
						left = pos+item_width;
					}
				}							
				else {
					left = -(item_width*location)+item_width;
				}
				
				var item = Math.abs(left/item_width);
				jQuery('.wpn_featured .wpn_fthumbs span a img').removeClass('wpn_active');
				jQuery('.wpn_featured .wpn_fthumbs span a:eq('+item+') img').addClass('wpn_active');
				
				feature.css('left',left);
				
				feature.animate({opacity: 1},animation_speed,"swing",function() {
					animstatus = false;
				});
			}
		});
	}
}

function feature_automove() {
	if(user_click == true) {
		user_click = false;
	}
	else {
		moveFeature('next');
	}
}
var feature_auto = setInterval(feature_automove, auto_speed);
});