browser = {
	msie:	 /msie/i.test(navigator.userAgent),
	ie6:	/msie (5|6)/i.test(navigator.userAgent),
	opera:	 /opera/i.test(navigator.userAgent),
	safari:  /webkit/i.test(navigator.userAgent),
	mozilla: /mozilla/i.test(navigator.userAgent)
};
$(document).ready(function(){
	if(browser.ie6){
		var style = document.createElement('link');
		style.setAttribute('rel','stylesheet');
		style.setAttribute('type','text/css');
		style.setAttribute('href','css/iefix.css');
		document.getElementsByTagName('head')[0].appendChild(style)	;		
	}		
});
$(document).ready(function(){
	initSlide();
	$('#top-nav ul li a').hover(function(){$(this).addClass('hover');}, function(){$(this).removeClass('hover');});
});
function initSlide(){
	var speed = 800;
	$('#boxs-wrap .left-box .header a').each(function(){
		$(this).focus(function(){this.blur();});
		$(this).click(function(){
			showRight(speed);
			document.title = $(this).attr('title');
			return false;		
		});
	});
	$('#boxs-wrap .right-box .header a').each(function(){
		$(this).focus(function(){this.blur();});
		$(this).click(function(){
			showLeft(speed);
			document.title = $(this).attr('title');
			return false;		
		});
	});		
	
	$('#south-box .box .header a').each(function(){
		$(this).focus(function(){this.blur();});												 	
		$(this).click(function(){
			showFooter(speed);
			document.title = $(this).attr('title');
			return false;							   
		});
	});
	$('#boxs-wrap #center-box .c-header #left-header a').each(function(){
		$(this).focus(function(){this.blur();});
		$(this).click(function(){
			document.title = $(this).attr('title');				   
			$('#boxs-wrap #center-box .c-header').css({'padding-bottom': '20px'});
			showLeft(speed);
			$('#south-box .box .body').css({'padding-bottom': '0px'});
			$('#south-box .box .body').slideUp(speed, function(){
				$('#boxs-wrap #center-box .c-header').hide();
				$('#boxs-wrap #center-box .c-header').css({'padding-bottom': '0px'});	
				$('#south-box .box .body').css({'padding-bottom': '20px'});	
				$('#south-box .box .header').show();
				
			});	
			$('#boxs-wrap #center-box .c-body').slideDown(speed);
			return false;
		});
	});
	$('#boxs-wrap #center-box .c-header #right-header a').each(function(){
		$(this).focus(function(){this.blur();});
		$(this).click(function(){
			document.title = $(this).attr('title');							   
			$('#boxs-wrap #center-box .c-header').css({'padding-bottom': '20px'});
			showRight(speed);
			
			$('#south-box .box .body').css({'padding-bottom': '0px'});
			$('#south-box .box .body').slideUp(speed, function(){
				$('#boxs-wrap #center-box .c-header').hide();
				$('#boxs-wrap #center-box .c-header').css({'padding-bottom': '0px'});	
				$('#south-box .box .body').css({'padding-bottom': '20px'});	
				$('#south-box .box .header').show();
				
			});	
			$('#boxs-wrap #center-box .c-body').slideDown(speed);
			return false;
		});
	});	
	var hash = window.location.hash;
	if(hash != ''){
		hash = hash.replace('#', '');
		if(hash == 'inteligencia-estrategica'){
			$('#boxs-wrap #center-box .c-body .c-body-ct').css({'left': '-928px'});
			showLeft(speed);
			document.title = 'Inteligencia estratégica: qué es y qué beneficios ofrece | BW2 Chile: Inteligencia Estratégica y Marketing Digital';
		}
		if(hash == 'marketing-digital'){
			showRight(speed);
			document.title = 'Marketing digital : testeo y optimización, adaptación, medición, planificación y desarrollo| BW2 Chile';
		}
		if(hash == 'programa-inteligencia-estrategica-y-marketing-digital'){
			showFooter(speed);
			document.title = '¿Por qué implementar un programa de inteligencia estratégica y marketing digital?| BW2 Chile';
		}
	}
	
	$('#boxs-wrap #center-box .left-box .header, #boxs-wrap #center-box .right-box .header, #south-box .box .header').hover(function(){
		$(this).addClass('hover');																  
	}, function(){
		$(this).removeClass('hover');	
	});
	
	$('#boxs-wrap #center-box .c-header .top-left-header').hover(function(){
		$(this).addClass('top-left-header-hover');																  
	}, function(){
		$(this).removeClass('top-left-header-hover');	
	});	
	
	$('#boxs-wrap #center-box .c-header .top-right-header').hover(function(){
		$(this).addClass('top-right-header-hover');																  
	}, function(){
		$(this).removeClass('top-right-header-hover');	
	});		
	/*
	$('#boxs-wrap #center-box .left-box .body, #boxs-wrap #center-box .right-box .body, #south-box .box .body ').hover(function(){
		$(this).addClass('body-hover');																										
	}, function(){
		$(this).removeClass('body-hover');	
	});
	*/
}
function showLeft(speed){
	var left = $('#boxs-wrap #center-box .c-body .c-body-ct').css('left');
	if(left != '0px'){
		$('#boxs-wrap #center-box .c-body').css({'border-left': '#3a383a 1px solid'});
	}
	$('#boxs-wrap #center-box .c-body .c-body-ct').animate({left:'0px'}, speed, 'swing', function(){	
		if(left != '0px'){																								  
			$('#boxs-wrap #center-box .c-body').css({'border-left': '0px'});
		}
	});	
	window.location.hash = '#inteligencia-estrategica';
}
function showRight(speed){
	var left = $('#boxs-wrap #center-box .c-body .c-body-ct').css('left');
	if(left == '0px'){
		$('#boxs-wrap #center-box .c-body').css({'border-left': '#3a383a 1px solid'});
		$('#boxs-wrap #center-box .left-box .body').css({'border-left': '0px'});	
	}
	$('#boxs-wrap #center-box .c-body .c-body-ct').animate({left:'-928px'}, speed, 'swing', function(){
		if(left == '0px'){																									 
			$('#boxs-wrap #center-box .c-body').css({'border-left': '0px'});	
			$('#boxs-wrap #center-box .left-box .body').css({'border-left': '#3a383a 1px solid'});
	 	}
	});	
	window.location.hash = '#marketing-digital';
}
function showFooter(speed){
			$('#boxs-wrap #center-box .c-body').slideUp(speed, function(){
				$('#boxs-wrap #center-box .c-header').show();
				$('#south-box .box .header').hide();
			});
			$('#south-box .box .body').slideDown(speed);	
			window.location.hash = '#programa-inteligencia-estrategica-y-marketing-digital';
}
function initHome(){
	$('#container .leftcx .colpadding, #container .rightcx .colpadding, #container .footercx .colpadding ').hover(function(){
		$(this).addClass('hover');
	}, function(){
		$(this).removeClass('hover');
	});	
	$('#container .leftcx .colpadding, #container .rightcx .colpadding, #container .footercx .colpadding').click(function(){
		var url = $(this).find('a').attr('href');
		window.location = url;
		return false;
	});
}