/* Funciones JQuery para sitio www.talentmanagement.cl
 * Author: Boris Fernandois M.
 * version 0.1
 */
var Random ={
	Adn : function(){
		var rndO = parseInt(Math.random()*3+1);
		if($.id('#Adn')){
			if (rndO==1) $('#Adn').html('Ayudamos a nuestros clientes a tomar la mejor <strong>decisi&oacute;n de negocios</strong><br /> en relaci&oacute;n a la administraci&oacute;n de su talento ejecutivo.');
			if (rndO==2) $('#Adn').html('Actuamos como <strong>socios estrat&eacute;gicos</strong> de nuestros clientes<br /> apoy&aacute;ndolos en la gesti&oacute;n de sus equipos gerenciales.');
			if (rndO==3) $('#Adn').html('Entregamos asesor&iacute;as de alto valor que impactan<br />  directamente sus <strong>resultados de negocio.</strong>');
		}
	},
	AdnEn : function(){
		var rndO = parseInt(Math.random()*3+1);
		if($.id('#Adn')){
			if (rndO==1) $('#Adn').html('We help our clients to make the best <strong>business decision</strong><br />regarding their executive talent management.');
			if (rndO==2) $('#Adn').html('We act as <strong>strategic partners</strong> for our clients, supporting them<br />in the arrangement of their management teams.');
			if (rndO==3) $('#Adn').html('We give high value advisories that<br />directly impact their <strong>business results.</strong>');
		}
	},
	DestBlock : function(){
		var rndO = parseInt(Math.random()*2+1);
		if (rndO==1) {$('#Group2').remove(); $('#Group1').show();};
		if (rndO==2) {$('#Group1').remove(); $('#Group2').show();};
	}
}
var Func = {
	Current : function(){		
		if ($.id('#Home')) {
			Random.Adn();
			Random.DestBlock();	
			Func.Banner();
			Func.LoadFunc();
		}else if ($.id('#HomeEn')) {
			Random.AdnEn();
			Random.DestBlock();
			Func.Banner();
			Func.LoadFunc();
		}else if ($.id('#Slide')) {
			Func.Slide();
			Func.Lnks();
			Func.LoadFunc();
		}else if ($.id('#NuesValo')) {
			Func.Tips();
			Func.LoadFunc();
		}else {
			Func.LoadFunc();
		}
	},
	Banner: function(){ 
		$('#Bann').innerfade({
			animationtype:'fade',
            speed: 1000,
            timeout: 6000,
            type: 'random_start'
        });
		$('#Thumb li').bind("click",function(e){
			Func.BannerStop(e);
			$('#Thumb li').removeClass("acti"); 
			$(this).addClass("acti"); 
			return false; 
		});
	},
	BannerStop : function(e){
		clearTimeout(time);
		imag = e.target.id.split('_');
		$('#Bann li').fadeOut(500)
		$('#Bann li#Bann_'+imag[1]).fadeIn(500);
	},
	Tips: function(){
		$('a.Block span').css({opacity:.95, bottom: '60px'});
		$('a.Block').hover(function(){
			$(this).find('span').stop(true, true).animate({opacity: 'show', bottom: '40px'}, 'normal');
		},function(){
			$(this).find('span').stop(true, true).animate({opacity: 'hide', bottom: '60px'}, 'fast'); 
		});
		$('a.Block span').hover(function(){
			$(this).hide();
		},function(){
			$(this).hide();
		});
	},
	Slide: function(){
		var SlideSize = $('dl.index dd').size();
		var SlideActi = parseInt(Math.random()*SlideSize+0);
		
		$('dl.index dt').addClass('SlideOff');
		$('dl.index dt').eq(SlideActi).addClass('SlideOn');
		$('dl.index dd').hide();
		$('dl.index dd').eq(SlideActi).show();
		$('dl.index dt').bind('click', function(){
			$(this).next('dd').slideToggle('slow').siblings('dd:visible').slideUp('slow');
			$(this).toggleClass('SlideOn');
			$(this).siblings('dt').removeClass('SlideOn');			
		});
	},
	Lnks : function(){
		var Lnk = (location.hash.split('#'))[1];
		if(location.hash.match(/#/)){
			$('dl.index dt#'+Lnk).addClass('SlideOn');
			$('dl.index dt#'+Lnk).siblings('dt').removeClass('SlideOn');
			$('dl.index dt#'+Lnk).next('dd').show().siblings('dd:visible').hide();
		}
    },
	BackToTop : function(){
		$('a#LnkSubi').click(function(e){
			e.preventDefault();
			$('html,body').animate({scrollTop:0}, 500);
		});
	},
	LnkBlock: function(){
		$('.LnkBlock').click(function(){
			window.location=$(this).find('a').attr('href'); return false;
		});
		$('.LnkBlock').hover(function(){
			$(this).find('a').css({'border-bottom':'1px solid #F06C1A'});
		},function(){
			$(this).find('a').css({'border-bottom':'1px solid #514422'});
		});
	},
	LoadFunc : function(){		
		Func.BackToTop();
		Func.LnkBlock();
		
		if ($('#Main').height()<420 && $('#LnkSubi')){ $('#LnkSubi').hide();}
	}
}
$(function() {
	$('.remove').remove();
	$('.hide').hide();
	$('.show').show();
	
	Func.Current();

});
jQuery.extend({
	id : function(id) {
		var id = id.split('#');
		return document.getElementById(id[1])?true:false;
	}
});
