//-----------------------------
function thisMovie(movieName) {
//-----------------------------	
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}

//-----------------------------
function fixSizeRightPane() {
//-----------------------------	
	//var iHeight = $('Content').getSize().size.y;
	//$('Contact').setStyle('height', iHeight);
	$('Contact').setStyle('height', '100%');
}

//------------------------------------
function handleMenuAction(sAction) {//alert(sAction)
//------------------------------------	

	if(window.ie) _oReq = new Ajax();
	
	var sUrl, sUpdate, sUrchinPath;
	var oTarget = document.getElementById('Content'); 
	var bEvalScripts = false;

	switch(sAction) {
		case 'm1' : sUrl = 'static/home.xml'; sUpdate='Content'; bEvalScripts=true; sUrchinPath='home'; break;
		case 'm2' : sUrl = 'static/visie.xml'; sUpdate='Content'; bEvalScripts=true; sUrchinPath='visie';  break;
		case 'm3' : sUrl = 'static/training.xml'; sUpdate='Content'; bEvalScripts=true; sUrchinPath='training';  break;
		case 'm4' : sUrl = 'static/leren.xml'; sUpdate='Content'; bEvalScripts=true; sUrchinPath='leren';  break;
		case 'm5' : sUrl = 'static/workshops.xml'; sUpdate='Content'; bEvalScripts=true; sUrchinPath='workshop';  break;
		case 'm6' : sUrl = 'dynamic/master.php'; sUpdate='Content'; bEvalScripts=true; sUrchinPath='master';  break;
		case 'm7' : sUrl = 'dynamic/actueel.php'; sUpdate='Content'; bEvalScripts=true; sUrchinPath='actueel';  break;
		case 'm8' : sUrl = 'static/inschrijven.xml'; sUpdate='Content'; bEvalScripts=true; sUrchinPath='inschrijven';  break;
		case 'm9' : sUrl = 'static/route.xml'; sUpdate='Content'; bEvalScripts=true; sUrchinPath = 'route'; break;
	}
	
	_oReq.url = sUrl;
	
	_oReq.options.update = $(sUpdate);
	
	_oReq.options.method = 'get';
	
	_oReq.options.onRequest = handleLoadingMessage('start');
	
	_oReq.options.onComplete = handleLoadingMessage('succes');
	
	_oReq.options.evalScripts = bEvalScripts;
	
	_oReq.request();
	
	urchinTracker(sUrchinPath); 
	
	if(window.ie) fixSizeRightPane();
	
	//always hide form when clicking menu items
	//hideForm();
	
}

//---------------------------------------
function handleLoadingMessage(sState) {//console.info(sState)
//---------------------------------------
	switch(sState) {
		case 'start'  : _oEloader.style.display=''; break;
		case 'succes' : _oEloader.style.display='none'; break;
	}
}

//-----------------------
function deepLink(sUrl) {
//-----------------------	
	
	if(window.ie) _oReq = new Ajax(); 
	
	_oReq.url = sUrl;
	
	_oReq.options.method = 'get';
	
	_oReq.options.update = $('Content');
	
	_oReq.options.onRequest = handleLoadingMessage('start');
	
	_oReq.options.onComplete = handleLoadingMessage('succes');
	
	_oReq.options.evalScripts = true;

	//_oReq.options.evalResponse = true;

	_oReq.request();	
}

//-------------------------------------
function loadContent(sUrl, sUpdate) {
//-------------------------------------	
	
	if(window.ie) _oReq = new Ajax(); 
	
	_oReq.url = sUrl;
	
	_oReq.options.method = 'get';
	
	_oReq.options.update = $(sUpdate);
	
	_oReq.options.onRequest = handleLoadingMessage('start');
	
	_oReq.options.onComplete = handleLoadingMessage('succes');
	
	_oReq.options.evalScripts = true;

	//_oReq.options.evalResponse = true;

	_oReq.request();
	
	//always hide form when clicking menu items
	//hideForm();	
	
}

//----------------------------------
function handleTrainingMenu(sId) {//console.info($(sId).getLast())
//----------------------------------	
	var sUrl, sUrchinPath;
	switch(sId) {
		case 'itilFoundation': sUrl = 'static/itilFoundation.xml'; sUrchinPath='ITIL Foundation'; break;
		case 'servicemanagementISO': sUrl = 'dynamic/servicemanagementISO.php'; sUrchinPath='IT-servicemanagement based on ISO/IEC 20000 Foundation'; break;
		case 'itilFoundation-v2-v3': sUrl = 'dynamic/itilFoundation_v2_v3.php'; sUrchinPath='ITIL V2-V3 Foundation Bridge Course'; break;	
		case 'itilPractioner': sUrl = 'static/itilPractioner.xml'; sUrchinPath='ITIL Practioner'; break;
		case 'itilM-Bridge': sUrl = 'dynamic/itilManagerBridge_v2_v3.php'; sUrchinPath='ITIL V2-V3 Managers Bridge Course'; break;
		case 'itilSM': sUrl = 'static/itilSM.xml'; sUrchinPath='ITIL Service Management'; break;
		case 'lifecycle': sUrl = 'static/LifecycleModules.xml'; sUrchinPath='Lifecycle modules'; break;
		case 'capability': sUrl = 'static/CapabilityModules.xml'; sUrchinPath='Capability modules'; break;
		case 'itilExpertProgram': sUrl = 'dynamic/itilExpertProgram.php'; sUrchinPath='ITIL Expert program'; break;		
		case 'prince2': sUrl = 'static/prince2.xml'; sUrchinPath='Prince 2'; break;
		case 'itGame': sUrl = 'dynamic/itGame.php'; sUrchinPath='IT-Game'; break;
		case 'softSkills': sUrl = 'dynamic/bewustzijn.php'; sUrchinPath='Bewustzijn'; break;
		case 'ikAlsSSM': sUrl = 'dynamic/ikAlsSSM.php'; sUrchinPath='Ik als strategisch servicemanager'; break;
		case 'ASL2Foundation': sUrl = 'dynamic/ASL2Foundation.php'; sUrchinPath='ASL2 Foundation'; break;
		case 'BiSLFoundation': sUrl = 'dynamic/BiSLFoundation.php'; sUrchinPath='BiSL Foundation'; break;				
	}
	if(_sOpenedTrainingItem!=null) { 
		$(_sOpenedTrainingItem).getLast().setStyle('display', 'none'); 
		$(_sOpenedTrainingItem).getFirst().removeClass('Selected');
		}
	_sOpenedTrainingItem = sId;
	loadContent(sUrl, $(_sOpenedTrainingItem).getLast());
	$(_sOpenedTrainingItem).getFirst().addClass('Selected');
	$(_sOpenedTrainingItem).getLast().setStyle('display', 'block');
	
	urchinTracker(sUrchinPath);
	
}

//-------------------------------------
function handleSubTrainingMenu(sId) {//console.info($(sId).getLast())
//-------------------------------------	
	var sUrl, sUrchinPath;
	switch(sId) {
		case 'itilPractionerSLM': sUrl = 'dynamic/itilPractionerSLM.php'; sUrchinPath='ITIL Service Level Management'; break;	
		case 'itilPractionerSandR': sUrl = 'dynamic/itilPractionerSandR.php'; sUrchinPath='ITIL Practitioner Support and Restore'; break;
		case 'itilPractionerRandC': sUrl = 'dynamic/itilPractionerRandC.php'; sUrchinPath='Practitioner Release and Control'; break;
		case 'itilPractionerAandD': sUrl = 'dynamic/itilPractionerAandD.php'; sUrchinPath='Practitioner Agree and Define'; break;
		case 'itilPractionerPandI': sUrl = 'dynamic/itilPractionerPandI.php'; sUrchinPath='Practitioner Plan and Improve'; break;
		case 'serviceSupport': sUrl = 'dynamic/serviceSupport.php'; sUrchinPath='Service Support'; break;
		case 'serviceDelivery': sUrl = 'dynamic/serviceDelivery.php'; sUrchinPath='Service Delivery'; break;
		case 'serviceExamentraining': sUrl = 'dynamic/examenTrainingSM.php'; sUrchinPath='Service Examentraining'; break;
		case 'prince2Foundation': sUrl = 'dynamic/prince2Foundation.php'; sUrchinPath='Prince2 Foundation'; break;
		case 'prince2Practioner': sUrl = 'dynamic/prince2Practioner.php'; sUrchinPath='Prince2 Practioner'; break;
		case 'prince2Supercombo': sUrl = 'dynamic/prince2Supercombo.php'; sUrchinPath='Prince2 Supercombo'; break;
		case 'itilFoundation_v2': sUrl = 'dynamic/itilFoundation_v2.php'; sUrchinPath='ITIL FOUNDATION V2'; break;
		case 'itilFoundation_v3': sUrl = 'dynamic/itilFoundation_v3.php'; sUrchinPath='ITIL FOUNDATION V3'; break;
		case 'itilFoundation_v2_v3': sUrl = 'dynamic/itilFoundation_v2_v3.php'; sUrchinPath='ITIL FOUNDATION V2-V3 Bridge'; break;
		case 'csi': sUrl = 'dynamic/csi.php'; sUrchinPath='ITIL V3 Continual Service Improvement Lifecycle Course'; break;
		case 'ss': sUrl = 'dynamic/ss.php'; sUrchinPath='ITIL V3 Service Strategy Lifecycle Course'; break;
		case 'sd': sUrl = 'dynamic/sd.php'; sUrchinPath='ITIL V3 Service Design Lifecycle Course'; break;
		case 'st': sUrl = 'dynamic/st.php'; sUrchinPath='ITIL V3 Service Transition Lifecycle Course'; break;
		case 'so': sUrl = 'dynamic/so.php'; sUrchinPath='ITIL V3 Service Operation Lifecycle Course'; break;
		case 'osa': sUrl = 'dynamic/osa.php'; sUrchinPath='ITIL V3 Operational Support and Analysis Capability Course'; break;
		case 'ppo': sUrl = 'dynamic/ppo.php'; sUrchinPath='ITIL V3 Planning Protection and  Optimization Capability Course'; break;
		case 'rcv': sUrl = 'dynamic/ppo.php'; sUrchinPath='ITIL V3 Release,Control and Validation Capability Course'; break;
		case 'soa': sUrl = 'dynamic/soa.php'; sUrchinPath='ITIL V3 Service Offerings and Agreements Capability Course'; break;
	}
	if(_sOpenedSubTrainingItem!=null) { 
		$(_sOpenedSubTrainingItem).getLast().setStyle('display', 'none'); 
		$(_sOpenedSubTrainingItem).getFirst().removeClass('Selected');
	}
	
	_sOpenedSubTrainingItem = sId;
	
	loadContent(sUrl, $(_sOpenedSubTrainingItem).getLast());
	
	urchinTracker(sUrchinPath);
	
	$(_sOpenedSubTrainingItem).getFirst().addClass('Selected');
	$(_sOpenedSubTrainingItem).getLast().setStyle('display', 'block');	
}
