wmin=0;
test=0;
nbfo=0;
liens=0;
fclose=0;
$(document).ready(function(){ 
	$('.windowOpen').bind(
		'click',
		function() {
			if($('#window'+test).css('display') == 'none') {
					$(this).TransferTo(
						{
							to:'window'+test,
							className:'transferer2', 
							duration: 400,
							complete: function()
							{
								$('#window'+test).show();
							}
						}
					);
				}
			/*$(this).TransferTo({
				to:'window'+test,
				className:'transferer2', 
				duration: 400,
				complete: function(){
					$('#window'+test).show();		
				}
			});*/
			this.blur();
			return false;
		}
	);
	$('.windowClose').bind(
		'click',
		function(){
			$('#window'+test).TransferTo({
				to:'demarre',
				className:'transferer2', 
				duration: 400
			}).hide();
		}
	);
	$('.windowReduce').bind(
		'click',
		function(){
			$('#window'+test).TransferTo({
				to:'onglet'+test,
				className:'transferer2', 
				duration: 400
			}).hide();
		}
	);
	
	
	$('.windowMin').bind(
		'click',
		function(){
			wmin = 1;
			if(test==1){
				document.getElementById('window'+test).style.left='337px';
				document.getElementById('window'+test).style.top='0px';
			}
			if(test==2){
				document.getElementById('window'+test).style.left='307px';
				document.getElementById('window'+test).style.top='30px';
			}
			if(test==3){
				document.getElementById('window'+test).style.left='277px';
				document.getElementById('window'+test).style.top='60px';
			}
			if(test==4){
				document.getElementById('window'+test).style.left='247px';
				document.getElementById('window'+test).style.top='90px';
			}
			if(test==5){
				document.getElementById('window'+test).style.left='217px';
				document.getElementById('window'+test).style.top='120px';
			}
			if(test==6){
				document.getElementById('window'+test).style.left='187px';
				document.getElementById('window'+test).style.top='150px';
			}
			if(test==7){
				document.getElementById('window'+test).style.left='157px';
				document.getElementById('window'+test).style.top='180px';
			}
			if(test==8){
				document.getElementById('window'+test).style.left='0px';
				document.getElementById('window'+test).style.top='0px';
			}
			document.getElementById('window'+test).style.width='600px';
			document.getElementById('window'+test).style.height='300px';
			document.getElementById('windowContent'+test).style.height='222px';
			document.getElementById('windowContent'+test).style.width='570px';
			document.getElementById('windowBottom'+test).style.height='270px';
			document.getElementById('windowBottomContent'+test).style.height='270px';
			$('#windowMin'+test).hide();
				$('#windowResize'+test).show();
				$('#windowMax'+test).show();
		}
	);
	
	
	$('.windowMax').bind(
		'click',
		function(){
			wmin = 0;
			document.getElementById('window'+test).style.left='0px';
			document.getElementById('window'+test).style.top='0px';
			document.getElementById('window'+test).style.width='937px';
			document.getElementById('window'+test).style.height='433px';
			document.getElementById('windowContent'+test).style.height='355px';
			document.getElementById('windowContent'+test).style.width='907px';
			document.getElementById('windowBottom'+test).style.height='403px';
			document.getElementById('windowBottomContent'+test).style.height='403px';
			$('#windowMax'+test).hide();
			$('#windowMin'+test).show();
			$('#windowResize'+test).hide();
		}
	);
	
	for (test=1;test<=8;test++){
		$('#window'+test).Resizable({
			minWidth: 300,
			minHeight: 200,
			maxWidth: 937,
			maxHeight: 433,
			dragHandle: '#windowTop'+test,
			handlers: {se: '#windowResize'+test},
			/*onResize : function(size, position) {
				$('#windowBottom'+test+', #windowBottomContent'+test).css('height', size.height-30 + 'px');
				var windowContentEl = $('#windowContent'+test).css('width', size.width - 30 + 'px');
				if (!document.getElementById('window'+test).isMinimized) {
					windowContentEl.css('height', size.height - 78 + 'px');
				}
			},*/
			minTop:1,
			minLeft:1,
			maxRight:937,
			maxBottom:483
		});
	}
});
function bouge(test) {
	$('#window'+test).Resizable({
			minWidth: 300,
			minHeight: 200,
			maxWidth: 937,
			maxHeight: 433,
			dragHandle: '#windowTop'+test,
			handlers: {se: '#windowResize'+test},
			onResize : function(size, position) {
				$('#windowBottom'+test+', #windowBottomContent'+test).css('height', size.height-30 + 'px');
				var windowContentEl = $('#windowContent'+test).css('width', size.width - 30 + 'px');
				if (!document.getElementById('window'+test).isMinimized) {
					windowContentEl.css('height', size.height - 78 + 'px');
				}
			},
			minTop:1,
			minLeft:1,
			maxRight:937,
			maxBottom:483
		});
}
function up(num) {
	for (i=1;i<=8;i++) {
		$('#window'+i).css({zIndex: 2});
		$('#windowContent'+i).css('backgroundImage', 'url("css/nouveau/transparent.png")');
	}
	$('#window'+num).css({zIndex: 3});
	$('#windowContent'+num).css('backgroundImage', 'url("css/nouveau/transparent2.png")');
};
function raz() {
for (i=1;i<=8;i++) {
	document.getElementById('window'+i).style.position='absolute';
	document.getElementById('window'+i).style.width='600px';
	document.getElementById('window'+i).style.height='300px';
	document.getElementById('windowContent'+i).style.height='222px';
	document.getElementById('windowContent'+i).style.width='570px';
	document.getElementById('windowBottom'+i).style.height='270px';
	document.getElementById('windowBottomContent'+i).style.height='270px';
	document.getElementById('window'+i).style.display='none';
	document.getElementById('onglet'+i).style.display='none';
	$('#windowMax'+i).show();
	$('#windowMin'+i).hide();
}
	
	document.getElementById('window1').style.left='337px';
	document.getElementById('window1').style.top='0px';
	document.getElementById('window2').style.left='307px';
	document.getElementById('window2').style.top='30px';
	document.getElementById('window3').style.left='277px';
	document.getElementById('window3').style.top='60px';
	document.getElementById('window4').style.left='247px';
	document.getElementById('window4').style.top='90px';
	document.getElementById('window5').style.left='217px';
	document.getElementById('window5').style.top='120px';
	document.getElementById('window6').style.left='187px';
	document.getElementById('window6').style.top='150px';
	document.getElementById('window7').style.left='157px';
	document.getElementById('window7').style.top='180px';
	document.getElementById('window8').style.left='0px';
	document.getElementById('window8').style.top='0px';
		
		
		
		

		
}
