//danceFloor by Cedric Dugas: http://position-absolute.com

$(document).ready(function(){dancingSlide.init()});

dancingSlide={
	init : function(){
		dancingSlide.isOpen="none";

		allDancer=$(".iDance").size();
		for(x=0;x<allDancer;x++){
			imgWidth=$(".iDance").eq(x).find(".open img").attr("width"); imgWidth=imgWidth+"px"
			$(".iDance").eq(x).css("width",imgWidth)
		}

		$(".iDance .open").click(function(){
			dancingSlide.needToDance=$(this)
			dancingSlide.openWidth=$(this).parent().find(".interior").css("width")

			/* this is needed for internet explorer, it will not find this attr on the spot like firefox */
			dancingSlide.callbackWidth2=$(this).find("img").attr("width")
			dancingSlide.callbackHeight2=$(this).find("img").attr("height")

			if(dancingSlide.isOpen != "none"){
				$(dancingSlide.isOpen).parent().animate({width:dancingSlide.callbackWidth});
			    $(dancingSlide.isOpen).find("img").animate({
					width:dancingSlide.callbackWidth,
					height:dancingSlide.callbackHeight},500,function(){
						$(dancingSlide.needToDance).parent().animate({width:dancingSlide.openWidth},800);
					    $(dancingSlide.needToDance).find("img").animate({width:0,height:0},700)
							dancingSlide.isOpen=dancingSlide.needToDance;
							dancingSlide.callbackWidth=dancingSlide.callbackWidth2;
							dancingSlide.callbackHeight=dancingSlide.callbackHeight2;
					})
			}else{
				dancingSlide.isOpen=$(this)

				/* this is needed for internet explorer, it will not find this attr on the spot like firefox */
				dancingSlide.callbackWidth=$(this).find("img").attr("width")
				dancingSlide.callbackHeight=$(this).find("img").attr("height")

				$(this).parent().animate({width:dancingSlide.openWidth},800); $(this).find("img").animate({width:0,height:0},700)}
			return false;
		});
	}
}