// JavaScript Document
//$('select_color') = dropdown div
//$('pink_icon')
//$('black_icon')
//$('white_icon')
//$('product_shot_white')
//$('product_shot_black')
//$('product_shot_pink')
//$('cur_selected_color')

var prodshots = $$('div.prod_shot');
var icons = $$('img.icons');

function switchProduct(which,item_num,sold_out){
		//switch the large image
		prodshots.each(function(item){
				item.setStyle({display:'none'});
		});
		$('product_shot_'+which).setStyle({display:'block'});
			
		//switch the icon images
		if($('white_icon')) { $('white_icon').src = '/images/products/white_icon_unsel.gif'; }
		if($('pink_icon')) { $('pink_icon').src = '/images/products/pink_icon_unsel.gif'; }
		if($('black_icon')) { $('black_icon').src = '/images/products/black_icon_unsel.gif'; }
		$(which+'_icon').src = '/images/products/'+which+'_icon_sel.gif';
		
		//switch the selected color box
		$('cur_selected_color').src = '/images/products/'+which+'_sel.png'; 
		$('select_color').hide();
		
		//update the form element
		$('ss_frm_item_num').value = item_num;
		
		//switch amazon universal wishlist details
		if($('AUWLBkTitle.CooshHeadphones')) { $('AUWLBkTitle.CooshHeadphones').innerHTML = 'Coosh Headphones ('+which.charAt(0).toUpperCase()+''+which.slice(1).toLowerCase()+') for iPod and MP3 Players'; }
		if($('AUWLBkImage.CooshHeadphones')) { $('AUWLBkImage.CooshHeadphones').innerHTML = 'http://coosh.com/images/amazon/amazon'+which.charAt(0).toUpperCase()+'Y.jpg'; }
		if($('AUWLBkTitle.CooshiPhone')) { $('AUWLBkTitle.CooshiPhone').innerHTML = 'Coosh Headset ('+which.charAt(0).toUpperCase()+''+which.slice(1).toLowerCase()+') for iPhone and Blackberry'; }
		if($('AUWLBkImage.CooshiPhone')) { $('AUWLBkImage.CooshiPhone').innerHTML = 'http://coosh.com/images/amazon/amazon'+which.charAt(0).toUpperCase()+'R.jpg'; }
		if($('AUWLBkTitle.CooshOtherPhone')) { $('AUWLBkTitle.CooshOtherPhone').innerHTML = 'Coosh Headset ('+which.charAt(0).toUpperCase()+''+which.slice(1).toLowerCase()+') for Other Music Phones'; }
		if($('AUWLBkImage.CooshOtherPhone')) { $('AUWLBkImage.CooshOtherPhone').innerHTML = 'http://coosh.com/images/amazon/amazon'+which.charAt(0).toUpperCase()+'R.jpg'; }
				
		//change the add to cart button to sold out when appropriate
		if(sold_out < 1){
				$('sold_out_image').hide();
				$('add_to_cart_sbt').show();
		} else {
				$('sold_out_image').show();
				$('add_to_cart_sbt').hide();
		}
		return false;
}
function switchProduct_fr(which,item_num,sold_out){
		//switch the large image
		prodshots.each(function(item){
				item.setStyle({display:'none'});
		});
		$('product_shot_'+which+'_fr').setStyle({display:'block'});
		
		//switch the icon images
		if($('white_icon')) { $('white_icon').src = '/images/products/white_icon_unsel.gif'; }
		if($('pink_icon')) { $('pink_icon').src = '/images/products/pink_icon_unsel.gif'; }
		if($('black_icon')) { $('black_icon').src = '/images/products/black_icon_unsel.gif'; }
		$(which+'_icon').src = '/images/products/'+which+'_icon_sel.gif';
		
		//switch the selected color box
		$('cur_selected_color').src = '/images/products/'+which+'_sel_fr.png'; 
		$('select_color').hide();
		
		//update the form element
		$('ss_frm_item_num').value = item_num;
		
		//change the add to cart button to sold out when appropriate
		if(sold_out < 1){
				$('sold_out_image').hide();
				$('add_to_cart_sbt_fr').show();
		} else {
				$('sold_out_image').show();
				$('add_to_cart_sbt_fr').hide();
		}
		return false;
}
function switchProduct_fr2(which,item_num,sold_out){
		//switch the large image
		prodshots.each(function(item){
				item.setStyle({display:'none'});
		});
		$('product_shot_'+which+'_fr2').setStyle({display:'block'});
		
		//switch the icon images
		if($('white_icon')) { $('white_icon').src = '/images/products/white_icon_unsel.gif'; }
		if($('pink_icon')) { $('pink_icon').src = '/images/products/pink_icon_unsel.gif'; }
		if($('black_icon')) { $('black_icon').src = '/images/products/black_icon_unsel.gif'; }
		$(which+'_icon').src = '/images/products/'+which+'_icon_sel.gif';
		
		//switch the selected color box
		$('cur_selected_color').src = '/images/products/'+which+'_sel_fr.png'; 
		$('select_color').hide();
		
		//update the form element
		$('ss_frm_item_num').value = item_num;
		
		//change the add to cart button to sold out when appropriate
		if(sold_out < 1){
				$('sold_out_image').hide();
				$('add_to_cart_sbt_fr').show();
		} else {
				$('sold_out_image').show();
				$('add_to_cart_sbt_fr').hide();
		}
		return false;
}

function showSelect(){
	$('select_color').show();
	return false;
}

function switchQty(num){
		//switch the selected color box
		$('cur_selected_qty').src = '/images/quantity/qty_'+num+'_sel.png';
		$('select_qty').hide();

		//update the form element
		$('ss_frm_qty').value = num;
		return false;
}
function switchQty_fr(num){
		//switch the selected color box
		$('cur_selected_qty').src = '/images/quantity/qty_'+num+'_sel_fr.png';
		$('select_qty').hide();

		//update the form element
		$('ss_frm_qty').value = num;
		return false;
}

function showQty(){
	$('select_qty').show();
	return false;
}



//how to wear scripts
var prod_info_layers = $$('div.product_info_layers');
var prod_info_triggers = $$('a.trigger');

function switchLayer(which){
		//switch the large image
		prod_info_layers.each(function(item){
				item.hide();
		});
		showOverlayInstant(); //this function is in video_effects.js
		$(which+'_target').show();
		
		return false;
}


function infoLayersOff(){
		prod_info_layers.each(function(item){
				var info_children = item.select('div.nokeep');
				info_children.each(function(nokeepchild){
						nokeepchild.hide();
				});
				var keep_children = item.select('div.keep');
				keep_children.each(function(keeper){
						keeper.show();
				});
				item.hide();				

		});
		hideOverlayInstant();
		return false;
}