﻿/* Bilboost.com */
/* bilboostcore.js */
/* Created Oct, 2009 */
/* Modified Oct, 2009
--------------------------------------- */

var bilboostCore = {};

bilboostCore.bilboost = new Class({
        Implements: [Options, Events],
		
		ie : (navigator.userAgent).indexOf('MSIE'),
		ie6 : ( (navigator.appVersion).indexOf('6.0') > 0 && (navigator.userAgent).indexOf('MSIE') > 0 ),
		ie7 : ( (navigator.appVersion).indexOf('7.0') > 0 && (navigator.userAgent).indexOf('MSIE') > 0 ),
		
		initialize: function(options){
			
        }
		
    });
	
bilboostCore.appCore = new Class({
        Extends: bilboostCore.bilboost,
		
		headerUtils : null,
		
		initialize: function(options){
			this.headerUtils = new bilboostCore.headerUtils();
		},
		
		setContenidoOnCenter :function(){
			var tClass = this;
			var contenido = $("central");
			
			if(contenido == null)
				return;
			
			var altoVentana = document.documentElement.clientHeight;
			var posTop = contenido.offsetTop;
			var paddingTopCapa = contenido.getStyle("padding-top").split("px")[0];
			var altoCapa = contenido.offsetHeight - paddingTopCapa;			
			
			var margen = Math.round( ((altoVentana - posTop) - altoCapa) / 2);
			
			contenido.setStyle("padding-top",margen + "px");
		},
		
		replaceFonts : function(){
			Cufon.set('fontFamily', 'clarendonbt').replace($$(".menuItems"),{hover: true});
			Cufon.set('fontFamily', 'clarendonbt').replace($$("form p"),{hover: true});
			Cufon.set('fontFamily', 'neutratitling').replace($$("h1"),{hover: true});
			Cufon.set('fontFamily', 'neutratitling').replace($$("h2"),{hover: true});
			Cufon.set('fontFamily', 'neutratitling').replace($$("h3"),{hover: true});
			Cufon.set('fontFamily', 'neutratitling').replace($$("h4"),{hover: true});
			Cufon.set('fontFamily', 'clarendonbt').replace($$("h5"),{hover: true});
			if($("pageNavigator") != null)
				Cufon.set('fontFamily', 'neutratitling').replace($("pageNavigator"),{hover: true});
		}
		
});
	
bilboostCore.headerUtils = new Class({
	Extends: bilboostCore.bilboost,
	
	element : null,
	initTop : null,
	fx1 : null,
	fx2 : null,
	out : false,
	
	initialize: function(options){
	},
	
	showLoginLayer:function(){
		if(this.element == null){
			this.element = $("loginLayer");
			this.element.setStyle("visibility","visible");
			this.initTop = this.element.getStyle("top").split("px")[0];
			this.fx1 = new Fx.Tween(this.element, {duration: 600, transition: Fx.Transitions.Sine.easeOut});
			this.fx2 = new Fx.Tween(this.element, {duration: 600, transition: Fx.Transitions.Sine.easeOut});
			
			if(this.ie > -1){
				var marginLeft = this.element.getStyle("margin-left").split("px")[0];
				this.element.setStyle("margin-left",String(Number(marginLeft)+20) + "px");
			}
		}
				
		if(this.out == true)
			return;
		else
			this.out = true;
		
		this.fx1.start('opacity', '0', '1');		
		this.fx2.start('top', String(Number(this.initTop) + 20) + "px", String(this.initTop) + "px");
	},
	
	hideLoginLayer:function(){
		this.out = false;
		
		this.fx1.start('opacity', '1', '0');		
		this.fx2.start('top', String(this.initTop) + "px", String(Number(this.initTop) + 20) + "px");
	}
	
});