jQuery(document).ready(function($) {
	// initialize scrollable
    $("div.scrollable").scrollable({
        speed: 900,
        size: 1,
        items: '#thumbs',
        hoverClass: 'hover'
    });
	
	$('img.thumbnail').click(function(){
		
		/*show notification*/
		$('div#notificationWrapper').show();
		
		var id = $(this).attr('id');
		//var templateDirectory = $('input#templateDirectory').attr('value');
		
		//alert(id);
		//$.ajaxError(function(event, request, settings){
		//					alert(settings.url);
							
		//});
		
		$.ajax({
			url: "http://www.petcamp.com/camper-cameos-blog/wp-content/ajax.getImagePreview.php",
			data:"postid=" + id,
			cache: false,
			contentType: "text/html",
			success: function(res) {
				//alert(res);
				$('<img />').attr('src',res).load(function(){
        			$('div#preview').html( $(this) );
					
					/*hide notification*/
					$('div#notificationWrapper').hide();
			
        		});
			},
			error: function(xhr,err){
                       alert("There was an Ajax error.");
					 alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
						alert("responseText: "+xhr.responseText);


			}
		
		});
		
	});
	
	//preLoad();
});

/*preload images here*/
function preLoad() {
	var dateposted;
	
	dateposted = $('input#dposted').attr('value');
	
	$.ajax({
		url: "http://www.petcamp.com/camper-cameos-blog/wp-content/ajax.preloadImagePreview.php",
		//url: "http://www.wordpress.local/petcamp/wp-content/ajax.preloadImagePreview.php",
		contentType: "text/html",
		data: "dposted=" + dateposted,
		dataType: "json",
		success: function(msg) {
			
			var jSON = eval("(" + msg + ")");
			
			$.each(jSON.result, function(key,value) {
				
				$('<img />').attr('src',value).load(function(){
					$('div#preload').append( $(this) );
				});
			});
			
		}
	});
}
	
