/**
 * @author VdC
 * Thibault Graindorge
 * Graindorge.Informatique
 * Tout droit réservé
 */
$(document).ready(function(){
	VdcBox.init()
});
VdcBox={
	init:function(){
		$("img[reel='VdcBox']").click(function(){
			$("#VdcBox").remove();
			$("#cacheVisio").remove();
			$("#VdcBox_close").remove();
			$('#news').fadeTo("normal", 0,(function(){}));
			VdcBox.lien=$(this).attr("src");
			VdcBox.open(VdcBox.lien);
		});
	},
	open:function(lien){
		VdcBox.lien=lien;
		$("body").append('<div id="VdcBox_close"></div><div id="VdcBox"></div><div id="cacheVisio"></div>');
		VdcBox.img=new Image();
		VdcBox.img.src=VdcBox.lien;
		VdcBox.timer=window.setInterval(VdcBox.load,100);
		$('#VdcBox_close').click(VdcBox.close);
	},
	load:function(){
		if(VdcBox.img.complete){
			window.clearInterval(VdcBox.timer);
			VdcBox.anim();
		}
	},
	anim:function(){
		$("VdcBox").show();
		$("VdcBox_close").show();
		VdcBox.largeur=VdcBox.img.width;
		VdcBox.hauteur=VdcBox.img.height;
		$("#VdcBox").animate({ width:VdcBox.largeur},500).animate({ height:VdcBox.hauteur}, 500);
		$("#VdcBox").append('<img src="'+VdcBox.lien+'">');
		$("#cacheVisio").fadeTo("normal",1,(function(){}));
	},
	close:function(){
		$('#VdcBox_close').fadeOut(500, function(){
			$('#VdcBox_close').remove();
		});
		$('#VdcBox').fadeOut(500, function(){
			$('#VdcBox').remove();
			$('#news').fadeTo("normal",1,(function(){}));
			$("#cacheVisio").fadeOut(100, function(){});
			$("#cacheVisio").remove();
		});
	}
}