/* =========================================================================
Title: Product Focus Site, main.js
Version: 1.0
Description: Contains general javascript functionality
-- Minified with http://fmarcia.info/jsmin/test.html
============================================================================ */

$(function(){init();});function init(){ProductTabs();ProductsFocus();ViewCategories();Styleswitcher();ProductListStyle();};function ViewCategories(){if($('body').hasClass('productslist')){$('#viewCategories').hide();$('#viewCategories').load('products.html #categories');$('#viewAllCategories').click(function(){$('#viewCategories').slideToggle();return false;});}$('.productsList li:last').css('border-bottom','none');};function ProductsFocus(){HideProductsFocus();$('.productsFocus_tabs li a').click(function(){if($(this).hasClass('current')){}else{target=$(this).attr('href');$('.productsFocus_tabs li a').removeClass('current');$(this).addClass('current');HideProductsFocus();$(target).show();}return false;});$('.productsFocus_tabs li a:first').click();};function HideProductsFocus(){var divs=new Array();$('.productsFocus_tabs li a').each(function(){divs.push($(this).attr('href').substr(1));});$(divs).each(function(){$('#'+this).hide();});};function ProductTabs(){HideProductDivs();$('.productTabs li a').click(function(){if($(this).hasClass('current')){}else{target=$(this).attr('href');$('.productTabs li a').removeClass('current');$(this).addClass('current');HideProductDivs();$(target).show();}return false;});$('.productTabs li a:first').click();};function HideProductDivs(){var divs=new Array();$('.productTabs li a').each(function(){divs.push($(this).attr('href').substr(1));});$(divs).each(function(){$('#'+this).hide();});};function Styleswitcher(){ssHtml='Style:\n';ssHtml+='<a href="?style=style1" rel="Default" class="styleswitch"><img src="styles/01/colorswatch.png" alt="Default Styling" align="top" /></a>\n';ssHtml+='<a href="?style=style2" rel="Nighttime" class="styleswitch"><img src="styles/02/colorswatch.png" alt="Nighttime Styling" align="top" /></a>';ssHtml+=' |';$('.right_upper_nav').prepend(ssHtml);};function ProductListStyle(){$('.blockview').removeClass('hidden').hide();var c=readCookie('productliststyle');if(c)SwitchProductListStyle(c);$('.listviewButton').click(function(){SwitchProductListStyle('list');return false;});$('.blockviewButton').click(function(){SwitchProductListStyle('block');return false;});};function SwitchProductListStyle(listStyle){if(listStyle=='block'){$('.productsList').hide();$('.blockview').show();}else{$('.blockview').hide();$('.productsList').show();}createCookie('productliststyle',listStyle,365);};function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else var expires="";document.cookie=name+"="+value+expires+"; path=/";};function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}return null;};function eraseCookie(name){createCookie(name,"",-1);};