$(document).ready(function() {
	/*STANDS::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
	$(window).load(function() {
		$('.people').hide();
		
		$('#CargadorStand').fadeOut(500, function() {
			$(this).hide();
			$('.people').fadeIn(1500);
		});
	});			
	
	$('ul#listaVotos li a.btnVotar').click(function () {		
		$(this).css({backgroundPosition: "0 -64px"});					
	}); 
	
	/*QUIENES SOMOS*/
	//$('p.InfoEmpresa').load("texto-mini-qs.htm p");
	//$('.ContenedorFilete .cargadorLogo').load("texto-mini-qs.htm img");
	$('.ContenedorFilete .cargadorLogo img').addClass('logoEmpresa');
	
	/*QUIENES SOMOS PLANTILLA*/
	$('#logoQuienesSomos img').addClass('logoEmpresa');	
	
	/*COMENTARIOS*/	
	/*....................................................................................*/
	$('a.btnPrev').click(function () {		
		$('#itemsComentarios').animate({marginTop:"+=100px"}, "slow");						
	}); 
	
	$('a.btnNext').click(function () {		
		$('#itemsComentarios').animate({marginTop:"-=100px"}, "slow");						
	});
	
	$('#EnviarComentarios').click(function(){
		$.ajax({
			url: '/ajax/agregarComentario.php',
			type: "POST",
			data: ({
					empresa : $('#idEmpresa').val(),
					comentario : $('#Comentarios').val()
					}),
			success: function(data){
				$('#Comentarios').val('');
				$.colorbox({html:"<div id=\"comentarioEnviado\"><h1>Comentario enviado</h1>Tu comentario fue enviado! La empresa lo responder&aacute; lo antes posible</div>", close: "cerrar"});
			}
		});
	});
	
	/*VOTACIONES*/
	$('.btnVotar').each(function(){
		$(this).click(function(){
			if($(this).hasClass('activo')){
			$.ajax({
				url: '/ajax/votarEmpresa.php',
				type: "POST",
				data: ({
						empresa : $('#idEmpresa').val()
						}),
				success: function(cantidadVotaciones){
					actualizarVotaciones(cantidadVotaciones);
				}
			});
			}
			$(this).removeClass('activo');
		});
	});
	
	function actualizarVotaciones(cantidad){
		$('.cantVotaciones').each(function(){
			$(this).html(cantidad);
		});
	}
			
	/*OCULTAR EL TEXTO EN INPUT AL HACAER CLICK*/	
	var texto ="Escriba su comentario aqui";
	var vacio ="";	
	$('textarea#Comentarios').val(texto);
	$('textarea#Comentarios').focus(function () {
		 $(this).val(vacio);
	});

//Examples of how to assign the ColorBox event to elements
if($(".btnEnviarCv").length > 0){
$(".btnEnviarCv").colorbox({
					iframe:true,
					height:"346px",
					width:"314px", 
					scrolling:false,
                                        close: "cerrar"
				}); 
$(".btnAvisos").colorbox({
					iframe:true,
					height:"346px",
					width:"314px", 
					scrolling:false,
                                        close: "cerrar"
				});

$(".pds-box").css("width","270px");
}
function aplicarCV (idempresa,idposting) {
        $.colorbox({
                                href:"aplicar.ngmf?idpost="+idposting+"&idemp="+idempresa+"&deStand=1",
                                iframe:true,
                                height:"346px",
                                width:"314px",
                                scrolling:false,
                close: "cerrar"
                        });
}

});
