$(function(){
	if($.cookie('amazontan_persistent') == 'y'){
		$('#persistent').attr({checked:'checked'});
		$('#amazonid').val($.cookie('amazontan_id'));
		$('#amazonwidth').val($.cookie('amazontan_width'));
		$('#amazonheight').val($.cookie('amazontan_height'));
	}else{
		$('#amazonid').val('akaandmore-22');
		$('#amazonwidth').val('280');
		$('#amazonheight').val('280');
	}
	set();
	$(".set").change(set);
	function set(){
		if($('#amazonid').val() != '' && $('#amazonurl').val() != ''){
			var id = $('#amazonid').val();
			var url = $('#amazonurl').val();
			var width = $('#amazonwidth').val();
			var height = $('#amazonheight').val();
			
			$('#done').append('LOADING...');
			
			if($('#persistent').attr('checked') == true) {
				$.cookie('amazontan_persistent', 'y', { expires: 365 });
				$.cookie('amazontan_id', id, { expires: 365 });
				$.cookie('amazontan_width', width, { expires: 365 });
				$.cookie('amazontan_height', height, { expires: 365 });
			} else {
				$.cookie('amazontan_persistent', '', { expires: -1 });
				$.cookie('amazontan_id', '', { expires: -1 });
				$.cookie('amazontan_width', width, { expires: -1 });
				$.cookie('amazontan_height', height, { expires: -1 });
			}
			$p = 'amazonlink.php?id='+id+'&width='+width+'&height='+height+'&url='+url;
			$('#done').load($p, null,function() {
				$("input[type=text]").focus(function(){ $(this).select();}).click(function(){ $(this).select(); return false;});
			});
		};		
	};
});
