/**
 * (c) Copyright 2008 Oakley, Inc.
 *
 */
// Casper was here.
// Variables
var $J = jQuery.noConflict();
var tab_open = '';
$J(document).ready(function(){
	$J('#pd_tab_nav ul#performance_defined_nav').tabs();
	$J("#pd_tab_nav ul#performance_defined_nav").bind('tabsselect', function(event, ui) {
		// The following is because of the flash and swfaddress and......
		
		event.preventDefault();
		event.stopPropagation();

		switch(ui.tab.hash){
			case '#hdpolarized':
				window.location.hash = '#/hdpolarized';
				tab_open = 'performance_nav_btn_hdpolarized';
			break;
			case '#apparel':
				window.location.hash = '#/apparel';
				tab_open = 'performance_nav_btn_apparel';
			break;
			case '#footwear':
				window.location.hash = '#/footwear';
				tab_open = 'performance_nav_btn_footwear';
			break;
			case '#watches':
				window.location.hash = '#/watches';
				tab_open = 'performance_nav_btn_watches';
			break;
			default:
				window.location.hash = '#/eyewear';
				tab_open = 'performance_nav_btn_eyewear';
		}
		
	});
	// Settings for OCP Eyewear
	$J('div.promo_selector_eyewear').scrollable({
		items: "div.promo_images_eyewear",
		size: 1, 
		interval: 6000,
		speed: 600,
		loop: true
	});
	
	// Settings for OCP HDPolarized
	$J('div.promo_selector_hdpolarized').scrollable({
		items: "div.promo_images_hdpolarized",
		size: 1, 
		interval: 6000,
		speed: 600,
		loop: true
	});
	
	// HDO Widget
	$J('#lens_sim_widget_image_holder_withlens').resizable({
		handles: 'e',
		maxWidth: 330		
	});
});
// Flash calls this function which in-turns clicks the appropriate navigtion item
function click_nav(nav_btn_id){
	// Cause Jimmy said so.
	if(nav_btn_id != tab_open){
		$J("#" + nav_btn_id).trigger('click');
	}
}