$(document).ready(function() {
	// CLEAR INPUT FIELDS
	$('.textfield').clearOnFocus();
	
	// MODAL WINDOWS
	var triggers = $(".modalopen, #interview-images img[rel], img.tee-image[rel]").overlay({
		mask: {
			color: '#000',
			loadSpeed: 200,
			opacity: .5
		},
		
		effect: 'apple',
		fixed: false,

		closeOnClick: true
	});
	
	
	// IMAGE MOVER
	var $images = $('#interview-images > img');

	$('#interview > p:nth-child(4n)').each(function (i) {
		$(this).after($images.get(i));
	});
	
	
	// MEMBER PROFILE TABS
	$("ul.tabs").tabs("div.panes > div");
	$("ul.tabs li").css('border', '1px solid red;');
	
	
	// SHOW/HIDE COMMENTS
	$('#hideme').css('display', 'none');
	$('#show-comments').click(function() {
		$('#hideme').css('display', 'block');
		$(this).css('display', 'none');
		//alert('...');
	});
	
	
	
	// RATING FANCINESS
	$('#submission-rating > span').addClass('remove-input');
	$('#submission-rating .submit').css('display', 'none');
	$('#submission-rating > span').click(function(e) {
		e.preventDefault();
		
		var selected_grade = $(this).attr('id');
		
		// make the radio selected
		$('#'+selected_grade+'> input').attr('checked', true);
		
		// remove all instances of chosen class
		$('#submission-rating > span').removeClass('chosen');
		
		// add chosen class to the clicked span
		$(this).addClass('chosen');
		
		// submit form
		$('#submission-rating').submit();
	});

	
	// COPY BILLING TO SHIPPING
	$('input#copyinfo').click(function() {
	
	     // If checked
	     if ($(this).is(":checked")) {
	
	         //for each input field
	         $('#shipinfo input', ':visible', document.body).each(function(i) {
	
	             //copy the values from the billing inputs
	             //to the equiv inputs on the shipping inputs
	             $(this).val($("#billinfo input").eq(i).val());
	         });
	
	         //won't work on drop downs, so get those values
	         var billingState = $("select#state").val();
	         var shippingCountry = $("select#country_code").val();
	
	         // special for the select
	         $('select#shipping_state option[value=' + billingState + ']').attr('selected', 'selected');
	         $('select#shipping_country_code option[value=' + shippingCountry + ']').attr('selected', 'selected');
	
	     }
	     else {
	
	         //for each input field
	         $('#shipinfo input', ':visible', document.body).each(function(i) {
	
	             // put default values back
	             $(this).val($(this)[0].defaultValue);
	         });
	
	         // special for the select
	         $('select#shipping_state option[value=""]').attr('selected', 'selected');
	         $('select#shipping_country_code option[value=""]').attr('selected', 'selected');
	
	     } // end if else
	
	 }); // end copy bill to ship function

	
}); // end ready



