// DEFINES
var TEXT_SMOOTH_ROLLOVER_TIME       = 250 ;            
var TEXT_SMOOTH_ROLLOVER_COLOR      = '#000000' ;      
var IMAGE_SMOOTH_ROLLOVER_TIME      = 0 ;         
var SIMPLE_TIP_SHOWTIME             = 300 ;          
var IMAGE_SMOOTH_ROLLOVER           = IMAGE_SMOOTH_ROLLOVER_TIME > 0 ? true : false ;
var TEXT_SMOOTH_ROLLOVER            = TEXT_SMOOTH_ROLLOVER_TIME  > 0 ? true : false ;
var OVER_KEYWORD                    = '_over';
var OVER_LINK_ACTION                = true ;
var OVER_LINK_ROLLOVER              = true ;
    OVER_LINK_ROLLOVER              = OVER_LINK_ROLLOVER &&  OVER_LINK_ROLLOVER ? true : false ;

// set page menu
var PAGEMENU = [
					{ id : 'home' , url : 'includes/ajax/home.html' , fstImage : 'img/bkg_gradient_home.png'  , sndImage : 'img/tubos_home.png' , trdImage : 'img/logo_my3dlab_home.png'  , active : 1 } ,
					{ id : 'interior' , url : 'includes/ajax/interior.html' , fstImage : 'img/bkg_gradient_interior.png'  , sndImage : 'img/tubos_interior.png' , trdImage : 'img/logo_my3dlab_interior.png'} ,
					{ id : 'exterior' , url : 'includes/ajax/exterior.html' , fstImage : 'img/bkg_gradient_exterior.png'  , sndImage : 'img/tubos_exterior.png' , trdImage : 'img/logo_my3dlab_exterior.png'} ,
					{ id : 'stands' , url : 'includes/ajax/stands.html' , fstImage : 'img/bkg_gradient_stands.png'  , sndImage : 'img/tubos_stands.png' , trdImage : 'img/logo_my3dlab_stands.png'} ,
					{ id : 'animations' , url : 'includes/ajax/animations.html' , fstImage : 'img/bkg_gradient_animations.png'  , sndImage : 'img/tubos_animations.png' , trdImage : 'img/logo_my3dlab_animations.png'} ,
					{ id : 'interactivity' , url : 'includes/ajax/interactivity.html' , fstImage : 'img/bkg_gradient_interactivity.png'  , sndImage : 'img/tubos_interactivity.png' , trdImage : 'img/logo_my3dlab_interactivity.png'} ,
					{ id : 'art' , url : 'includes/ajax/art.html' , fstImage : 'img/bkg_gradient_art.png'  , sndImage : 'img/tubos_art.png' , trdImage : 'img/logo_my3dlab_art.png'} ,
					{ id : 'media' , url : 'includes/ajax/media.html' , fstImage : 'img/bkg_gradient_media.png'  , sndImage : 'img/tubos_media.png' , trdImage : 'img/logo_my3dlab_media.png'} ,
					{ id : 'conceptual' , url : 'includes/ajax/conceptual.html'  , fstImage : 'img/bkg_gradient_conceptual.png'  , sndImage : 'img/tubos_conceptual.png' , trdImage : 'img/logo_my3dlab_conceptual.png'} ,
					{ id : 'clients' , url : 'includes/ajax/clients.html'  , fstImage : 'img/bkg_gradient_clients.png'  , sndImage : 'img/tubos_clients.png' , trdImage : 'img/logo_my3dlab_clients.png'} ,
					{ id : 'contact' , url : 'includes/ajax/contact.html' , fstImage : 'img/bkg_gradient_contact.png'  , sndImage : 'img/tubos_contact.png' , trdImage : 'img/logo_my3dlab_contact.png'}
				] ;

// functions
function SetMenuActive ( active ) {
	PAGEMENU.each( function ( val ) {
			e = IMAGE_SMOOTH_ROLLOVER ? $(val.id).getLast('div').getLast('img') : $(val.id).getLast('img');
		    e.removeClass('active');
   			imageDoRollOver(e  , false ) ;
	});
	
	toggleImageActive(active); 
}

//includes
include("js/vendors/slimbox/js/slimbox.js"); 
include("js/vendors/slimbox/js/videobox.js"); 
include("js/vendors/slimbox/css/videobox.css");
include("js/vendors/slimbox/css/slimbox.css");
include("js/vendors/slimbox/js/swfobject.js");


 
// DOM READY
window.addEvent("domready", function() {
 
	//Slimbox.scanPage(); // scan page for lightbox.
	//Videobox.init.bind(Videobox);
	// rollOver images
	$$('.rollOver').each (function(e){ imgRollOver (e) });
	
	// Init page menu 
	PAGEMENU.each( function ( val ) {
		if ( $( val.id ) ) {
			$(val.id).store('url' , val.url ) ;
			$(val.id).store('body.background.image' , val.fstImage ) ;
			$(val.id).store('bkgFull.background.image' , val.sndImage ) ;
			$(val.id).store('logo.image.image' , val.trdImage ) ;
			$( val.id ).addEvent('click' , function() { 
				
				SetMenuActive ( ( IMAGE_SMOOTH_ROLLOVER ? this.getLast('div').getLast('img') : this.getLast('img') )) ;
				$$('body').setStyle('background-image' , 'url(' + this.retrieve('body.background.image') + ')') ;
				$('bkgFull').setStyle('background-image' , 'url(' + this.retrieve('bkgFull.background.image') + ')') ;
				fixT();
				$('siteLogo').src = this.retrieve('logo.image.image')  ;
				$('solapas').load( this.retrieve('url') ,  {evalScripts: true , noCache : true} ); 
			});
		}  
		if ( val.active ) {
			SetMenuActive (  (IMAGE_SMOOTH_ROLLOVER ? $(val.id).getLast('div').getLast('img') : $(val.id).getLast('img') ) )
			$('solapas').load(val.url);
		} 
	});
	
	 
	setInterval( fixT, 100 );

	
	// Links font color fade
	$$('a').each(function(e){ overTween(e) });
	
});

function fixT() {
	w  =  window.size().height ; 
	w = w >= 410 ? w : 410 ;
	$('bkgFull').setStyle('width' , '100%') ;
	$('bkgFull').setStyle('height' , w + 'px') ;
	var top = parseInt( $('fullCtr').getStyle('height') ) - w ;
	top = top >= 0 ? top + 'px' : '0px' ;
	$('bkgFull').setStyle('top' , top ) ;
	$('bkgFull').setStyle('left' , '0px' ) ;
}
