//Copyright (c) 2010 - by Kamil Tomsik - All rights reserved.
//see http://tomsik.cz/ for more info

var shadow = function ( el, baseUrl, imageName	, size )
{
	if ( !size )
		size = 10;

	var urlTpl = "url('BASE/IMAGE_NAME_NUM.png')".replace ( "BASE", baseUrl ).replace ( "IMAGE_NAME", imageName );
	var bl = $( "<div></div>" );

	var target = $( el );
	var newZ = ( target.css ( "z-index" ) == "auto" ) ?-1 :parseInt ( target.css ( "z-index" ) ) - 1;
		
	var shadow = bl.clone ().css ( { position: "absolute", width: target.outerWidth () + 2*size, zIndex: newZ } ).addClass ( "shadow" );


	var top = bl.clone ().css ( { background: urlTpl.replace ( "NUM", "01" ) + " top center no-repeat", height: size } );
	var center = bl.clone ().css ( { background: urlTpl.replace ( "NUM", "02" ) + " center center repeat-y", height: target.outerHeight () } );
	var bottom = bl.clone ().css ( { background: urlTpl.replace ( "NUM", "03" ) + " bottom center no-repeat", height: size } );
	shadow.append ( top ).append ( center ).append ( bottom );

	
	shadow.css ( { left: target.offset ().left - target.offsetParent ().offset ().left - size, top: target.offset ().top - target.offsetParent ().offset ().top - size } );
	target.after ( shadow );
	
}

