$(document).ready(function() {
    
    $("body.home div#slideshowHome ul").fuFade({speed: 700,timeout: 6000});
    $("div#slideshow ul").fuFade({speed: 700,timeout: 6000});
	
	$.nyroModalSettings({debug:false,type:'iframe',width:735,height:506,resizable:false,autoSizable:false});
	
	/*$("a.readMore").bind('click', preventDefault).click(function(){
    	var id = ($(this).attr('id')).replace('readA-','');
    	$('#post-'+id+' .entryShort').removeClass('displayBlock').addClass('displayNone');
    	$('#post-'+id+' .entryFull').removeClass('displayNone').addClass('displayBlock');
	});
	
	$("a.readLess").bind('click', preventDefault).click(function(){
    	var id = ($(this).attr('id')).replace('readL-','');
    	$('#post-'+id+' .entryFull').removeClass('displayBlock').addClass('displayNone');
    	$('#post-'+id+' .entryShort').removeClass('displayNone').addClass('displayBlock');
	});*/
	
	$("a.customGiftMore").bind('click', preventDefault).click(function(){
    	var id = ($(this).attr('id')).replace('customGiftMore-','');
    	//alert( $('.customGiftTable-'+id).length );
    	var isOk = false;
    	$('.customGiftTable-'+id).each(function(index) {
    		if($(this).is(".displayNone") && !isOk) {
    			$(this).removeClass('displayNone');
    			isOk = true;
    			var idx = ($(this).attr('id')).replace('customGiftTable-'+id+'-','');
    			if(idx==10) { $('#customGiftTable-'+id+'-More').remove(); }
				//alert(index + ': ' + $(this).text());
			}
  		});
	});
	
	$("a.customGiftMore").bind('click', preventDefault).click(function(){
		$("input[name='shipping[billing][FirstName]']").val(billingData['FirstName']);
    	$("input[name='shipping[billing][LastName]']").val(billingData['LastName']);
		$("input[name='shipping[billing][Address1]']").val(billingData['Address1']);
		$("input[name='shipping[billing][Address2]']").val(billingData['Address2']);
		$("input[name='shipping[billing][City]']").val(billingData['City']);
		$("input[name='shipping[billing][Email]']").val(billingData['Email']);
		$("input[name='shipping[billing][Zip]']").val(billingData['Zip']);
		
		$("select[name='shipping[billing][State]'] option:selected").attr('selected','');
		$("select[name='shipping[billing][State]'] option[value="+billingData['State']+"]").attr('selected','selected');
		
		$("select[name='shipping[billing][Country]'] option:selected").attr('selected','');
		$("select[name='shipping[billing][Country]'] option[value="+billingData['Country']+"]").attr('selected','selected');
	});
	
	$('.customGift-birthday').datepicker({
		dateFormat: 'mm/dd/yy',
		minDate: '-70Y',
		maxDate: 0,
		changeYear: true
		//,onSelect: function(dateText, inst) {applyDatepicker(dateText);}
	});
	
	$('.inDate').datepicker({
		//inline: true,
		prevText: '<',
		nextText: '>',
		dateFormat: 'mm-dd-yy'
	});

});

function preventDefault(evt){if(evt.preventDefault){evt.preventDefault();}return false;}
