// JavaScript Document

jQuery.fn.wms_addShadows = function(options) {
	
	return this.each(function(count){
		jQuery(this)
			.addClass('transformed')
			.append('<span class="shadowSide top">&nbsp;</span>')
			.append('<span class="shadowSide right">&nbsp;</span>')
			.append('<span class="shadowSide bottom">&nbsp;</span>')
			.append('<span class="shadowSide left">&nbsp;</span>')
			.append('<span class="shadowCorner topLeft">&nbsp;</span>')
			.append('<span class="shadowCorner topRight">&nbsp;</span>')
			.append('<span class="shadowCorner bottomRight">&nbsp;</span>')
			.append('<span class="shadowCorner bottomLeft">&nbsp;</span>')
			;
	});

};


$(window).load(function(){
	// load images marked as 'loading'	
	jQuery('img.loading').__loadImage()
});
	
jQuery.fn.__loadImage = function(){
	
	this.each(function(){
		//	console.log(jQuery(this).attr('src')+' : '+jQuery(this).__imageOK());		
		jQuery(this).attr('src',jQuery(this).attr('src').replace(/(.*)?i=/,'')).delay(200).load(function(){
			jQuery(this).removeClass('loading').removeClass('portrait');

			if(jQuery(this).width()>jQuery(this).height()){
				jQuery(this).addClass('landscape');
				//console.info('LS: '+jQuery(this).attr('src'));
			}else{
				jQuery(this).addClass('portrait');
				//console.info('PT: '+jQuery(this).attr('src'));				
			}
		});
	});
	
}

