//jQuery(document).load(onload);
//jQuery(document).ready(onready);


/*function onready() {
  if(navigator.appName=='Netscape')
    jQuery("#container").hide();
}

function aonload() {
  if(navigator.appName=='Netscape')
    jQuery("#container").fadeIn('slow');
}
function onunload() {
  jQuery("#container").fadeOut('slow');
}
*/
/*function cloakImagesInShadow() {
  $("img.s").each(cloakImageInShadow);
}
 

function cloakImageInShadow() {

  // Skip over images we don't want cloaked; try to be smart about this.
  
  if ($(this).is(".noshadow")) return;
  if ($(this).parent().parent().is("p.portfolio")) return;
  
  // Okay, this is clever. If the image has been loaded when this function runs,
  // wrap it in a properly sized shadow div. If not, then set an onload handler
  // on the image. That way, when it's loaded, this function will run. There will
  // be a flicker, but the image will still get shadowed correctly.
    
  if ($(this).width() == 0 || $(this).height() == 0) {
    $(this).load(cloakImageInShadow);
    return;
  }

  var shadowDiv = $('<div class="shadow"><div class="topleft"></div><div class="topright"></div><div class="bottomleft"></div><div class="bottomright"></div></div>');
  if ($(this).attr("class")) shadowDiv.addClass($(this).attr("class"));
  $(shadowDiv).width($(this).width() + 10);
  $(shadowDiv).height($(this).height() + 14);
  if ($(this).parent().is("p")) {
    var containingParagraph = $(this).parent();
    containingParagraph.before(shadowDiv);
    containingParagraph.remove();
  } else {
    $(this).parent().append(shadowDiv);
  }
  $(shadowDiv).append(this);

  if ($(shadowDiv).next().is(".caption")) {
    $(shadowDiv).next().width($(shadowDiv).width());
    $(shadowDiv).next().addClass($(shadowDiv).attr("class"));
    $(shadowDiv).next().show();
  }
      
  $(this).removeAttr("class");
  

}

*/

var gradientshadow={}
gradientshadow.depth=6 //Depth of shadow in pixels
gradientshadow.containers=[]

gradientshadow.create=function(){
var sDiv = 0;
var parent = 0;

var a = document.all ? document.all : document.getElementsByTagName('*')
for (var i = 0;i < a.length;i++) {
	if (a[i].className == "shadow") {
    //sDiv = $('<div class="s"></div>');
    //parent = $(a[i]).parent();
    //$(a[i]).appendTo(sDiv);
    //sDiv.appendTo(parent);
    
		for (var x=0; x<gradientshadow.depth; x++){
			var newSd = document.createElement("DIV")
			newSd.className = "shadow_inner"
			newSd.id="shadow"+gradientshadow.containers.length+"_"+x //Each shadow DIV has an id of "shadowL_X" (L=index of target element, X=index of shadow (depth) 
			if (a[i].getAttribute("rel"))
				newSd.style.background = a[i].getAttribute("rel")
			else
				newSd.style.background = "#666666" //default shadow color if none specified
			document.body.appendChild(newSd)
		}
	gradientshadow.containers[gradientshadow.containers.length]=a[i]
	}
}
gradientshadow.position()
window.onresize=function(){
	gradientshadow.position()
}
}

gradientshadow.position=function(){
if (gradientshadow.containers.length>0){
	for (var i=0; i<gradientshadow.containers.length; i++){
		for (var x=0; x<gradientshadow.depth; x++){
  		var shadowdiv=document.getElementById("shadow"+i+"_"+x)
			shadowdiv.style.width = gradientshadow.containers[i].offsetWidth + "px"
			shadowdiv.style.height = gradientshadow.containers[i].offsetHeight + "px"
			shadowdiv.style.left = gradientshadow.containers[i].offsetLeft + x + "px"
			shadowdiv.style.top = gradientshadow.containers[i].offsetTop + x + "px"
		}
	}
}
}

/*gradientshadow.other=function{
gradient.shadow.create();
aonload();
}*/

if (window.addEventListener)
window.addEventListener("load", gradientshadow.create, false)
else if (window.attachEvent)
window.attachEvent("onload", gradientshadow.create)
else if (document.getElementById)
window.onload=gradientshadow.create;
