// JavaScript Document

//#################################################################
//First load Code
$(document).ready(function() {
  // Handler for .ready() called.

  
});

//les etats du menu admin (devrait etre maintenus dans le module adminMenu lui meme)
var adminMenuState = 'closed';
var selectedMenu = 'admin';


//#################################################################
//Interfaces

//***** adminMenu *******//
function activateAdminMenuItem(menu){
	
// Gerer le passage de l'un des menus a l'autre (close - reopen).	
	if(adminMenuState == 'closed'){
		adminMenuState = 'open';
		
		$('#adminMenu').animate({"height" : "120px"}, 150,'linear', function(){}); 
    		// Animation complete.
	}else{ 
	
		adminMenuState = 'closed';
		
		$('#adminMenu').animate({"height" : "40px"}, 150,'linear', function(){}); 
    		// Animation complete.
	}
}

function mainMenuPushed(itemId){
//One of the main menu buttons as been pressed
	
	if(itemId == 'home_button'){
		modalShow('http://www.tarkans.com/WIZZARDS/Login/login.html',200,300);
	}else if(itemId == 'cloud_button'){
	
		contentShow('http://www.tarkans.com/MODULES/WFlowBuilder/WflowMain.html',700,500);
	
	}else{
		modalHide();
	}	
	
}

//#################################################################
//Local DATAs


//----------------------------------
//Local Functions

function modalShow(src,width,height){
	
	$('#modalIFrame').attr('src',src);
	
	$('#modalMask').css('z-index','110');
	$('#modalIFrame').css('z-index','120');
	
	
			
	$('#modalIFrame').animate({
  				"opacity": "1"
			}, 10 , "linear",function(){} );
			
	$('#modalMask').animate({
  				"opacity": "1"
			}, 300 , "linear",function(){} );
			
			
}

function modalHide(){
	
	
	$('#modalMask').animate({
  				"opacity": "0"
			}, 10 , "linear",function(){} );
			
	$('#modalIFrame').animate({
  				"opacity": "0"
			}, 300 , "linear",function(){} );
			
	$('#modalIFrame').attr('src','');
	
	$('#modalMask').css('z-index','0');
	$('#modalIFrame').css('z-index','0');
	
	
}

function contentShow(src,width,height){
	
	$('#contentFrame').css('width',width+'px');
	$('#contentFrame').css('height',height+'px');
	$('#contentFrame').attr('src',src);
	
			
}
