
if(typeof(advisorBookMaximized) == 'undefined') var advisorBookMaximized = 0;
if(typeof(advisorBookFixed) == 'undefined') var advisorBookFixed = 1;
if(typeof(advisorExamplesMaximized) == 'undefined') var advisorExamplesMaximized = 0;

/*
function advisorMove(){
	
	var slideEffect = new Fx.Style('ostendisAdvisor', 'margin-top', { wait:false, duration:900, transition:Fx.Transitions.circOut});   
	var top = $('ostendisAdvisor').getPosition().y - 50;
	window.addEvent('scroll', function(){ slideEffect.start.delay(300, slideEffect, Math.max(0, document.documentElement.scrollTop - top)) });
	new SmoothScroll({duration:400, transition:Fx.Transitions.circOut});
	
}
*/

function advisorBookMaximiz(){
	
	if(advisorBookMaximized == 0){
		/*
		$('abChapter').setStyles({'visibility': 'hidden', 'display': 'none'}); // hide the cahpter - selection in advisorBook
		$('abContainer').setStyle('height', ($('contentAdvisorBook').getSize().size.y + 5) + 'px'); // set new height of advisorBook container
		$('abContent').setStyles({'top': '3px', 'height': ($('contentAdvisorBook').getSize().size.y + 3) + 'px'}); // move advisorBook content up to 3px under head
		*/

		if($('contentAdvisorBook').getSize().y < ((window.getHeight() - 315) + 5)) { // the advisor text is smaller than max.value
			var advisorMaxSize = $('contentAdvisorBook').getSize().y; // show the whole content
			$('abChapter').setStyles({'visibility': 'hidden', 'display': 'none'}); // dont display the chapture selection
			$('abContainer').setStyle('height', (advisorMaxSize + 5)  + 'px'); // set new height of advisorBook container
			$('abContent').setStyles({'top': '3px', 'height': (advisorMaxSize + 3) + 'px'}); // move advisorBook content up to 3px under head
			if($('aeContainer')) $('aeContainer').setStyle('height', 0);
		
		} else {
			var advisorMaxSize = window.getHeight() - 320;
			try{ $('abChapter').setStyles({'visibility': 'visible', 'display': 'block'}); } catch(e){}
			$('abContainer').setStyle('height', (advisorMaxSize + 5)  + 'px'); // set new height of advisorBook container
			$('abContent').setStyles({'top': '25px', 'height': (advisorMaxSize - 20) + 'px', 'border-top': 0}); // move advisorBook content up to 3px under head
			
			if($('aeContainer')) $('aeContainer').setStyle('height', 0);
		
		}	
		
		advisorBookMaximized = 1;
		
	} else {
	
		try{ $('abChapter').setStyles({'visibility': 'visible', 'display': 'block'}); } catch(e){} // hide the cahpter - selection in advisorBook
		$('abContainer').setStyle('height', '240px'); // set new height of advisorBook container
		$('abContent').setStyles({'top': '25px', 'height': '215px', 'border-top': 0}); // move advisorBook content up to 3px under head
		
		if($('aeContainer')) $('aeContainer').setStyle('height', '160px');
		
		advisorBookMaximized = 0; // set global var for ad
		
	}
	
	CSBfleXcroll('abContent'); // new init of flexcroll in advisorBook

}


function advisorExamplesMaximiz(){
	
	if(advisorExamplesMaximized == 0){
	
		/*
		$('aeChapter').setStyles({'visibility': 'hidden', 'display': 'none'}); // hide the cahpter - selection in advisorBook
		$('aeContainer').setStyle('height', ($('contentAdvisorExamples').getSize().size.y + 5) + 'px'); // set new height of advisorBook container
		$('aeContent').setStyles({'top': '3px', 'height': ($('contentAdvisorExamples').getSize().size.y + 3) + 'px'}); // move advisorBook content up to 3px under head
		*/
		
		if($('contentAdvisorExamples').getSize().y < ((window.getHeight() - 180) + 5)) { // the advisor text is smaller than max.value
			var advisorMaxSize = $('contentAdvisorExamples').getSize().y; // show the whole content
			$('aeChapter').setStyles({'visibility': 'hidden', 'display': 'none'}); // dont display the chapture selection
			$('aeContainer').setStyle('height', (advisorMaxSize + 5)  + 'px'); // set new height of advisorBook container
			$('aeContent').setStyles({'top': '3px', 'height': (advisorMaxSize + 3) + 'px'}); // move advisorBook content up to 3px under head
			
			$('abContainer').setStyle('height', 0);
		
		} else {
			var advisorMaxSize = window.getHeight() - 180;
			$('aeChapter').setStyles({'visibility': 'visible', 'display': 'block'});
			$('aeContainer').setStyle('height', (advisorMaxSize + 5)  + 'px'); // set new height of advisorBook container
			$('aeContent').setStyles({'top': '25px', 'height': (advisorMaxSize - 20) + 'px', 'border-top': 0}); // move advisorBook content up to 3px under head
			
			$('abContainer').setStyle('height', 0);
		
		}	

		
		advisorExamplesMaximized = 1; // set global var for ad
		
	} else {
	
		$('aeChapter').setStyles({'visibility': 'visible', 'display': 'block'}); // hide the cahpter - selection in advisorBook
		$('aeContainer').setStyle('height', '160px'); // set new height of advisorBook container
		$('aeContent').setStyles({'top': '25px', 'height': '135px', 'border-top': 0}); // move advisorBook content up to 3px under head
		$('abContainer').setStyle('height', '240px');

		advisorExamplesMaximized = 0; // set global var for ad

	}
	
	CSBfleXcroll('aeContent'); // new init of flexcroll in advisorBook
}


function jumpAnchor(targetContainer, targetAnchor){ // navigate trough the advisorBook & advisorExamples
	var addFromTop = (navigator.appName == 'Microsoft Internet Explorer') ? -3 : 18;
	if(navigator.appName != 'Microsoft Internet Explorer' && $(targetAnchor).offsetTop < 5) addFromTop = 0;
	if($(targetContainer).contentScroll) $(targetContainer).contentScroll($(targetAnchor).offsetLeft, ($(targetAnchor).offsetTop + addFromTop));
}


function showAdvisorChapture(advisorType){

	var advisorTypePrefix = (advisorType == 'advisorBook' ? 'ab' : 'ae');
	var chapterExpandHight = $(advisorTypePrefix + 'ChapterContent').getSize().y + $(advisorTypePrefix + 'ChapterLink').getSize().y;

	$(advisorTypePrefix + 'ChapterLink').firstChild.className = ($(advisorTypePrefix + 'ChapterLink').firstChild.className == 'showChapters' ? 'showChaptersActive' :'showChapters');
	$(advisorTypePrefix + 'ChapterContent').setOpacity(1.0);
	
	if($(advisorTypePrefix + 'ChapterLink').firstChild.className == 'showChaptersActive') {
		
		var twFx = new Fx.Tween($(advisorTypePrefix + 'Chapter'));

		twFx.start('height', 21, chapterExpandHight);
	
	} else {
		
		var twFx = new Fx.Tween($(advisorTypePrefix + 'Chapter'));
		twFx.start('height', chapterExpandHight, 21);

	}

}


function changeAdvisorIcon(referId, iconType){
	
	var iconName = $(referId).src.split('/');
	var iconBasePath = 'elements/images/advisor/';
	
	switch(iconType){
	
		case 'minimize': // mouse effect for minimize icon
			$(referId).src = (iconName[iconName.length-1] == 'ico_advisor_minimize.gif' ? iconBasePath + 'ico_advisor_minimize_active.gif' : iconBasePath + 'ico_advisor_minimize.gif');
			break;
		
		case 'scale': // mouse effect for scale icon
			$(referId).src = (iconName[iconName.length-1] == 'ico_advisor_scale.gif' ? iconBasePath + 'ico_advisor_scale_active.gif' : iconBasePath + 'ico_advisor_scale.gif');			
			break;
			
		case 'maximize': // mouse effect for maximize icon
			if(advisorBookMaximized == 1 || advisorExamplesMaximized == 1) $(referId).src = (iconName[iconName.length-1] == 'ico_advisor_maximize_hover.gif' ? iconBasePath + 'ico_advisor_maximize_hover.gif' : iconBasePath + 'ico_advisor_maximize.gif');
			else $(referId).src = (iconName[iconName.length-1] == 'ico_advisor_maximize.gif' ? iconBasePath + 'ico_advisor_maximize_hover.gif' : iconBasePath + 'ico_advisor_maximize.gif');			
			break;
	}

}
