// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


function init()
{
	var smImages = $$('.img_small');
	
	for(i = 0; i < smImages.length; i++)
	{
		Event.observe(smImages[i],'click',swapImages.bindAsEventListener(smImages[i]));
	}
	
	//init the select boxes on the product details page
	Event.observe($('product_details_shirt_sex'), 'change', switchMaleFemale);
	$$('.female').invoke('hide');
}


function swapImages(e)
{	
	var temp_src = this.firstDescendant().src;
	var temp_alt = this.firstDescendant().alt;
	this.firstDescendant().src = $('img_main').firstDescendant().src;
	this.firstDescendant().alt = $('img_main').firstDescendant().alt;
	
	$('img_main').firstDescendant().src = temp_src;
	$('img_main').firstDescendant().alt = temp_alt;
}




function switchMaleFemale(event)
{
	if(event.target.value == 'Male')
	{
		$$('.female').invoke('hide');
		$$('.male').invoke('show');
	}
	else
	{
		$$('.male').invoke('hide');
		$$('.female').invoke('show');
		
	}
}


window.onload = init;
