
function showHideTaxOption(stid)
{
	if(stid == 36)
	{
		Element.show('tax_exempt_p');
	}
	else
	{
		Element.hide('tax_exempt_p');
		$('tax_exempt').checked = false;
	}
}

function toggle_size_chart()
{	
	if ($('size_chart').style.display == 'none') {
		Effect.BlindDown('size_chart', {duration: 0.2});
	}
	else {
		Effect.BlindUp('size_chart', {duration: 0.2});
	}
}

function toggle_email_page()
{
	if ($('email_page_form').style.display == 'none') {
		Effect.BlindDown('email_page_form', {duration: 0.2});
	}
	else {
		Effect.BlindUp('email_page_form', {duration: 0.2});
	}
}

function reset_email_page_form()
{
	$('your_name').value = "";
	$('your_email').value = "";
	$('friend_name').value = "";
	$('friend_email').value = "";
	$('message').value = "";
}

function toggle_cart_details()
{	
	if ($('cart_details').style.display == 'none') {
		if (png_browser() == 'alpha') {
			$('cart_summary_trigger').style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/_bg/cart_summary_close.png')";
		}
		else {
			$('cart_summary_trigger').src = '/images/_bg/cart_summary_close.png';							
		}
		Effect.BlindDown('cart_details', {duration: 0.2});
	}
	else {
		Effect.BlindUp('cart_details', {duration: 0.2});
		if (png_browser() == 'alpha') {
			$('cart_summary_trigger').style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/_bg/cart_summary_footer.png')";
		}
		else {
			$('cart_summary_trigger').src = '/images/_bg/cart_summary_footer.png';					
		}
	}
}

function show_sizes(id)
{

	// Close the main color list
	$('prod_colors').style.display = 'none';
	
	// Show the appropriate size options
	$('size_chooser_' + id).style.display = '';
}

function show_all_colors(divToHide)
{
	$(divToHide).style.display = 'none';
	$('prod_colors').style.display = '';
}

function hide_sizes(id)
{
	if ($('sizes_'+id).style.display != 'none') {
		Effect.BlindUp('sizes_'+id, {duration: 0.2});
	}
}

function updateJSON(request, json)
{
	var responses = json;
	if (!json){
	  //if you don't use the json tips then evaluate the renderedText instead
	  var responses = eval('(' + request.responseText + ')');
	}
	
	var resSize = responses.length;
	for (var i = 0; i < resSize; i++) {
	   Element.update(responses[i][0], responses[i][1]);
	}
}

function updateCartJsonNew(request, json)
{
	var responses = json;

	if (!json){
	  var responses = eval('(' + request.responseText + ')');
	}

	/* Elements to Update */
	if(responses['update'] != undefined)
	{
		for (x in responses['update'])
		{
			Element.update(x, responses['update'][x]);
		}
	}
	
	/* Error Framework */
	if(responses['errors'] != undefined)
	{
		for(x in responses['errors'])
		{
			$(x + '_warnings').innerHTML = '';
			
			if(responses['errors'][x] != "")
			{
				ul = document.createElement('ul');
				for(y in responses['errors'][x])
				{
					li = document.createElement('li');
					li.className = responses['errors'][x][y]['type'];
					li.innerHTML = responses['errors'][x][y]['message'];
					ul.appendChild(li);			
				}
				$(x + '_warnings').appendChild(ul);
			}
		}
	}
}
function png_browser() 
{	
	var browser = new BrowserDetectLite();
	
	// if IE5.5+ on Win32, then display PNGs with AlphaImageLoader
	if ((browser.isIE55 || browser.isIE6up) && browser.isWin32) {
		var png = 'alpha';
		// else, if the browser can display PNGs normally, then do that
	} 
	else if (
						(browser.isGecko) || (browser.isIE5up && browser.isMac) || 
						(browser.isOpera && browser.isWin && browser.versionMajor >= 6) || 
						(browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || 
						(browser.isOpera && browser.isMac && browser.versionMajor >= 5) || 
						(browser.isOmniweb && browser.versionMinor >= 3.1) || 
						(browser.isIcab && browser.versionMinor >= 1.9) || 
						(browser.isWebtv) || (browser.isDreamcast)) {
							var png = 'normal';
	}
	return png;
}

function toggle_payment_type(select)
{
  if (select.value == 'cc') {
		Element.show('cc_area');
		Element.hide('billme_area');
  }
  else {
		Element.hide('cc_area');
		Element.show('billme_area');
  }
}

function check_school_cats(value, school_cats)
{

		if (school_cats.split(',').indexOf(value) >= 0) {
			$('school_category').value = 1;
			if ($('school_fields').style.display == 'none') {			
				Effect.BlindDown('school_fields', {duration: 0.2});
				Effect.BlindUp('other_fields', {duration: 0.2});
			}
			if($('other_fields').style.display == 'block' || $('other_fields').style.display == '')
			{
				$('other_fields').style.display = 'none';
			}
		}
		else {
			$('school_category').value = 0;
			if ($('school_fields').style.display == 'block' || $('school_fields').style.display == '') {			
				Effect.BlindUp('school_fields', {duration: 0.2});
				Effect.BlindDown('other_fields', {duration: 0.2});
			}
		}

}

var Color= new Array();
Color[1] = "ff";
Color[2] = "ee";
Color[3] = "dd";
Color[4] = "cc";
Color[5] = "bb";
Color[6] = "aa";
Color[7] = "99";

function waittofade() {
	if (document.getElementById('flash_fade')) {
    setTimeout("fadeIn(7)", 500);
	 }
}

function fadeIn(where) {
    if (where >= 1) {
        document.getElementById('flash_fade').style.backgroundColor = "#ffff" + Color[where];
		  if (where > 1) {
			  where -= 1;
			  setTimeout("fadeIn("+where+")", 200);
			} else {
			  where -= 1;
			  setTimeout("fadeIn("+where+")", 200);
			  document.getElementById('flash_fade').style.backgroundColor = "transparent";
			}
    }
}

function pop(url,width,height)
{
	popup = window.open(url, 'popup', 'width=' + width + ',height=' + height + ',scrollbars=no');
	popup.focus();
	return;
}

function toggle_div(divFrom, divTo)
{
	if($(divFrom).style.display == 'none')
	{
		Effect.BlindUp(divTo, {duration: 0.2});
		Effect.BlindDown(divFrom, {duration: 0.4});
	}
	else
	{
		Effect.BlindUp(divFrom, {duration: 0.2});
		Effect.BlindDown(divTo, {duration: 0.4});
	}
}

function activate_tab(tab)
{	
	if(tab != 'names') { Element.hide('nn_names'); }
	if(tab != 'numbers') { Element.hide('nn_numbers'); }
	if(tab != 'info') { Element.hide('nn_info'); }
	
	Element.show('nn_' + tab);
	
	$('nn_tab_names').style.backgroundImage   = tab == 'names' ? "url('/images/nn_tab_names_on.gif')" : "url('/images/nn_tab_names_off.gif')";
	$('nn_tab_numbers').style.backgroundImage = tab == 'numbers' ? "url('/images/nn_tab_numbers_on.gif')" : "url('/images/nn_tab_numbers_off.gif')";
	$('nn_tab_info').style.backgroundImage    = tab == 'info' ? "url('/images/nn_tab_info_on.gif')" : "url('/images/nn_tab_info_off.gif')";
}

function showColorOpts(toEnable, toDisable)
{
	Element.show(toEnable);
	Element.hide(toDisable);
}

function sameAsShipping()
{
  /* Nothing remarkable..just copy fields over */

	  $('bill_address_1').value 		= $('ship_address_1').value;
	  $('bill_city').value 					= $('ship_city').value;
	  $('bill_state').selectedIndex = $('ship_state').selectedIndex;
	  $('bill_zip').value 					= $('ship_zip').value;
	  $('bill_name').value 					= $('ship_name').value + ' ' + $('ship_last_name').value;
  
}

function toggle_design_box()
{
	if ($('design_listings').style.display == 'none') {
		Effect.SlideRightIntoView('hide_show_box');
	}
	else {
		Effect.SlideRightOutOfView('hide_show_box');		
	}
}

function open_design_box()
{
	Element.hide('design_drawer_trigger');
	Element.show('design_listings');			
}

function close_design_box()
{
	Element.hide('design_listings');			
	Element.show('design_drawer_trigger');
}

function checkoutProductDetail(linky)
{
	if($('product_' + linky.rel + '_designs').style.display == 'none')
	{
		Effect.BlindDown('product_' + linky.rel + '_designs', {duration:0.3});
		linky.innerHTML = 'less detail';
	}
	else
	{
		Effect.BlindUp('product_' + linky.rel + '_designs', {duration:0.3});
		linky.innerHTML = 'more detail';
	}
}