// JavaScript Document

/**
 *
 *  Now that most js development is stable, it is probably best to statically link to js.
 *  create a 'google' object to catch any remaining google calls.
 *
 **/
// http://code.google.com/apis/ajaxlibs/documentation/
//google.load("jquery", "1.3");
//google.load("jqueryui", "1.7");
//google.load("swfobject", "2");
var google = {setOnLoadCallback:$}
var uri;

$(function(){
	uri = parseUri(document.location.href);

	// PNG Fix for IE6
	$('body').supersleight();
	
	// TABS for prod pages
	$('div.tabs a.tabContent-tab').click(function(){
		var tab = $(this);
		var tab_id = tab.attr('id');
		var content_id = tab_id.replace('tabContent-tab-','tabContent-content-');
		var content = $('#'+content_id);
		var tabLi = $(tab.parent().get(0));
		tabLi.siblings('li').removeClass('active');
		tabLi.addClass('active');
		content.siblings('.tabContent-content').hide();
		if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7 && parseInt(jQuery.browser.version) > 4) {
			content.show(1); //NOTE: giving an animation speed fixes an IE placement issue. (1ms)
		} else {
			content.show();
		}
		return false;
	});

	$('div.tabs ul').each(function(){
	    var me = $(this);
		//console.log(this);
	    var tab;
		if (!tab && uri.anchor) tab = me.find('li > a#'+uri.anchor); // chosen via anchor fragment
		if (!tab) tab = me.find('li.active:first > a.tabContent-tab:first'); 
	    if (!tab) tab = me.find('li:first > a.tabContent-tab:first');
        tab.click();
	});
	$('#prodThumbs ul li.active .thumb').each(function(){
		//console.log(this);
		$(this).fadeTo("slow", 0.33);
	});
	$('#prodThumbs ul .thumb').click(function(){
		var allThumbs = $('#prodThumbs ul .thumb').parent();
		var me = $(this);
		var prodPhoto = $('.prodPhoto img');
		var newImg;
		var currentThumb = $('#prodThumbs ul li.active .thumb');
		currentThumb.fadeTo("slow", 1);
		allThumbs.removeClass('active');
		me.parent().addClass('active');
		me.fadeTo("slow", 0.33);
		newImg = me.attr("src").replace('.gif','.jpg');
		prodPhoto.attr("src", newImg);
	});
});
