
// Log to Firebug's console using:
// console.log(string)

$(document).ready(function() {
						   
	// Feedback Scroller
	setInterval('feedback()', 5000);
						   
	/* Homepage Shirt Thumbnails
	   Overcomes IE's lack of nth-child CSS support. */
	$('li:nth-child(2n+3)', $('#home-shirts #shirts')).addClass('right');
	
	/* City / State view thumbnails. */
	$('li:nth-child(4n)', $('#images')).addClass('right');
	
	/* Checkout Login Page */
	$('#login-email').focus();

	/* Checkout Login & Checkout Address */
	$(':radio', $('#radio-onoff')).click(function() {
		
		if ($(this).val() == '0')
		{
			$('#hidden-option').hide();
		}
		else if ($(this).val() == '1')
		{
			$('#hidden-option').show();
		}
		
	});
	
	/* Homepage button, prevent action if state val is empty. */
	$('#home-go').click(function() {
		
		if ( $('#home-state').val() == '')
		{
			return false;
		}
	
	});
	
	/* Disable submit button and show thinking div. */
	$('#thinking').hide();
	
	$('#disable-submit').click(function() {
		
		$('#thinking').show();
		$(this).val('Processing...');
		
	});
	
	/* Feedback Form */
	$('#open-feedback').click(function() { $('#share-feedback').toggle(); });

});

function load_cities(val,dest)
{
	$(dest).attr('disabled', 'disabled').html('<option value="0">Loading...</option>');
	
	$.get('/ladyliberty/ajax_states/get_cities.php?state=' + val,null,function(html,callback){
		$(dest).removeAttr('disabled').html(html);
	},'html');
	
	return false;
}

function verify(method, value)
{
	var data = 'method='+method+'&value='+value;
	var response;
	
	$.ajax({
		   async: false,
		   global: false,
		   url: '/system/ajax/ajaxverify.php', 
		   data: data, 
		   dataType: 'text',
		   success: function(result) { response = (result == 'false') ? false : true; }
		   });
	
	return response;
}

function feedback()
{
	var $active = $('.active', $('#fback'));
	
	if ($active.length == 0) { $active = $('li:last', $('#fback')); }
	
	var $next = $active.next().length ? $active.next() : $('li:first', $('#fback'));
	
	$active.addClass('last-active');
	
	$next.css({ opacity: 0.0 })
		.addClass('active')
		.animate({ opacity: 1.0 }, 1000, function() {
			$active.removeClass('active last-active');
		});
}
