var animation = false,
	contentShow = false,
	href;
	//oScrollbar5 = [];
window.onload = function(){
	$('#cargador').hide();
	$('#container').show();
	init();
}	
/*
$(function(){
	 $('#container').ajaxSuccess(preload(this));
});
	
*/
function init(){	
	$('#cajaPoxipolHome').animate({left:'200px', width: '460px'}, 1500,function(){
		$('#luzContainer').fadeIn(2000);
		$('.sloganHomeSe').animate({top:'0px'}, 500, function(){
			$('.sloganHomeArr').animate({top:'0px'}, 500,function(){
				$('.sloganHomeCon').animate({top:'0px'}, 500, function(){
					$('.sloganHomePox').animate({top:'0px'}, 500);
				});
			});
		});
	});
	
	$('.menuOp').click(function(){
		var href = $(this).attr('name');
		if(href == 'caracteristicas' || href == 'formas_de_uso' || href == 'presentaciones' || href == 'aplicaciones'){
		
			$('.menuOp').removeClass('act');
			$('.qsPox').removeClass('act');
			$('.qsPox').addClass('act');
		}else{
			$('.menuOp').removeClass('act');
			$('.qsPox').removeClass('act');
			$(this).addClass('act');
		}
		
		if(href == 'aplicaciones'){
			$("#accordion_uno").accordion("destroy");
			$("#accordion_uno").accordion({ header: "h3", autoHeight:false, "collapsible": true, "active": false, change: function( ) {
				$('.aplicacionesScroll').tinyscrollbar_update('relative');
			}
			});
		}else if(href== 'preguntas_frecuentes'){
			$("#accordion_dos").accordion("destroy");
			$("#accordion_dos").accordion({ header: "h3", autoHeight:false, "collapsible": true, "active": false, change:function(){
				$('.frecuentesScroll').tinyscrollbar_update('relative');
			}
			});
		}
		
		if(contentShow == false){
			$('#cajaPoxipolHome').animate({left:'220px', width: '480px'}, 800,function(){
				$('#luzContainer').fadeOut(1500);
				$(this).animate({width: '60px'}, 500, function(){
					$(this).animate({opacity:'0',});
					$('#sloganhome').animate({opacity:'0'},function(){
						$('#headerHome').hide();
						$('#headerAnim').animate({height: '100px'}, 1500,function(){
							$('#main').show();
							$('#menu').animate({left:'0'}, 1500);
							$('#headerSec').show();
							$('article').hide();
								
							$('#'+href).fadeIn( function(){
								
								if(href == 'formas_de_uso'){
									$('#formasDeUsoScroll').tinyscrollbar();
									$('#recomendacionesScroll').tinyscrollbar();
									
								} else if(href == 'aplicaciones'){
									$('.aplicacionesScroll').tinyscrollbar();
								}else if(href == 'preguntas_frecuentes'){
									$('.frecuentesScroll').tinyscrollbar();
								}else if(href== 'presentaciones'){
									$('#cajasPresentaciones').fadeIn();
								}
							});
							$('#logoPoxipolSec').animate({left:'0'}, 800,function(){
								$('.sloganSecSe').animate({top:'0px'}, 800, function(){
									$('.sloganSecArr').animate({top:'0px'}, 800,function(){
										$('.sloganSecCon').animate({top:'0px'}, 800, function(){
											$('.sloganSecPox').animate({top:'0px'}, 800);
										});
									});
								});
							});
						});
					});
				});
			});
			contentShow = true;
		}else{
			$('article').hide();
			$('#'+href).fadeIn(function(){
				if(href == 'formas_de_uso'){
					$('#wrapperFormasDeUso').css('left', 0);
					$('#wrapperRecomendaciones').css('left', '850px');
					$('#wrapperPrecauciones').css('left', '850px');
					$('#formasDeUsoScroll').tinyscrollbar();
					$('#recomendacionesScroll').tinyscrollbar();
				}else if(href == 'aplicaciones'){
					$('.aplicacionesScroll').tinyscrollbar();
				}else if(href == 'preguntas_frecuentes'){
					$('.frecuentesScroll').tinyscrollbar();
				}else if(href== 'presentaciones'){
					$('#cajasPresentaciones').fadeIn();
				}else if(href== 'caracteristicas'){					
					$('.otras_caracteristicas').css('left', '860px');
					$('.caracteristicas').css('left', '0');
				}
			});
		}
		
	});
	
	$('#precaucionesBtn').click(function(){
		$('#wrapperFormasDeUso').animate({left:'-860px'}, 500);
		$('#wrapperPrecauciones').animate({left:'0px'}, 500);
		
	});
	$('#volverFormasDeUsoP').click(function(){
		$('#wrapperFormasDeUso').animate({left:'0px'}, 500);
		$('#wrapperPrecauciones').animate({left:'860px'}, 500);
		
	});
	$('#recomendacionesBtn').click(function(){
		$('#wrapperFormasDeUso').animate({left:'-860px'}, 500);
		$('#wrapperRecomendaciones').animate({left:'0px'}, 500);
		
	});
	$('#volverFormasDeUsoR').click(function(){
		$('#wrapperFormasDeUso').animate({left:'0px'}, 500);
		$('#wrapperRecomendaciones').animate({left:'860px'}, 500);
		
	});
	$('#otrasCaracteristicasBtn').click(function(){
		$('.caracteristicas').animate({left:'-860px'}, 500);
		$('.otras_caracteristicas').animate({left:'0px'}, 500);
		
	});
	$('#CaracteristicasBtn').click(function(){
		$('.caracteristicas').animate({left:'0px'}, 500);
		$('.otras_caracteristicas').animate({left:'860px'}, 500);
		
	});
	$('#advertenciasBtn').click(function(){
		$('#advertencia').fadeIn(500);
		$('#aplicaciones').hide();
		
	});
	$('#vovlerAplicacionesBtn').click(function(){
		$('#advertencia').hide();
		$('#aplicaciones').fadeIn(500);
		
	});
	$('#contactoBorrarBtn').click(function(){
		$('#comentArea').val('');		
	});
	var valInit,
		elem = $('.col-left input[type="text"]');
	
	elem.focus(function(){
		valInit = $(this).val();
		$(this).val('');
	}).blur(function(){
		if($(this).val() === ''){
			$(this).val(valInit);
		}
	});
	
	
}
