$(document).ready(function() {
 });

 function iniciar(){
	$('.img_novedad_portada').each(function(){
		//alert ($(this).width());
		if ($(this).width() == 160){
			$(this).siblings('#texto_novedades').each(function(){
				$(this).css('width', '240px');
			});

		}else if ($(this).width() < 160 && $(this).width() > 100){
			$(this).siblings('#texto_novedades').each(function(){
				$(this).css('width', '275px');
			});
		}else if ($(this).width() < 100){
			$(this).siblings('#texto_novedades').each(function(){
				$(this).css('width', '305px');
			});
		}
	});

	$('.casos_izq').each(function(){
		//alert ($(this).width());
		var hermano = $(this).siblings();
		var item = hermano.attr('id');
		//hermano.css('height', '80px');
		$('#'+item+' .texto_largo').hide();
		$('#'+item+' #btn_menos').hide();

		if ($(this).width() >= 160){
			hermano.css('width', '680px');
		}else{
			hermano.css('width', '720px');
		}
	});
}


function caso_desplegado(div_derecha){
	var ancho = $('.prueba').width();

	if (ancho == '140')
		document.getElementById(div_derecha).style.width = '680px';
	else
		document.getElementById(div_derecha).style.width = '600px';
}

function desplegar(elem, btn, thumb, img, div_derecha){
	var ancho = $('#'+img).width();
	$('#'+btn).hide();
	$('#'+thumb).hide();
	$('#'+elem+' .texto_corto').hide();
	$('#'+img).show();
	$('#'+elem+' .texto_largo').show();
	$('#'+elem+' #btn_menos').show();

	if (ancho == '140')
		$('#'+elem+' .casos_dch').css('width', '680px');
	else
		$('#'+elem+' .casos_dch').css('width', '600px');
}

function plegar(elem, btn, thumb, img, div_derecha){
	var ancho = $('#'+img).width();
	$('#'+btn).show();
	$('#'+thumb).show();
	$('#'+elem+' .texto_corto').show();
	$('#'+img).hide();
	$('#'+elem+' .texto_largo').hide();
	$('#'+elem+' #btn_menos').hide();

	if (ancho == '140')
		$('#'+elem+' .casos_dch').css('width', '750px');
	else
		$('#'+elem+' .casos_dch').css('width', '680px');
}

function MarcarChecksNewsletter(limite, elemento){
	cont = 0;
	for (i=0;i<document.form_noticias_news.elements.length;i++){
		 if(document.form_noticias_news.elements[i].type == "checkbox" && document.form_noticias_news[i].checked){
			cont++;
		 }
	}

	if (cont > limite){
		alert ('Ha seleccionado más de '+limite+' noticias, no se corresponde con el formato seleccionado.');
		document.getElementById(elemento).checked=false;
	}
}

function mostrarCapa(cual){
	if (cual == 'listadoNoticiasNewsletter'){
		document.getElementById(cual).style.display = 'inline';
		document.getElementById('crearNoticia').style.display = 'none';
	}else
	{
		document.getElementById(cual).style.display = 'inline';
		document.getElementById('listadoNoticiasNewsletter').style.display = 'none';
	}

}

function ocultarCapa(cual){
	document.getElementById(cual).style.display = 'none';
	}

/*function mostrarCasosExp(){
	$('.contenido_proyectos_experiencia_mas').removeClass('oculto');
	$('#content_btn_vermasExperiencia').html('<div id="botonMasExperiencia" onclick="cerrarCasosExp();">Ocultar casos</div>');
}

function cerrarCasosExp(){
	$('.contenido_proyectos_experiencia_mas').addClass('oculto');
	$('#content_btn_vermasExperiencia').html('<div id="botonMasExperiencia" onclick="mostrarCasosExp();">Ver más casos</div>');
}*/

function muestra(que){
	var todoshermanos = $(que).siblings();
	var hermanos_ocultos = todoshermanos.filter('div.preoculto');
	hermanos_ocultos.each(function(){
		if ($(this).hasClass('oculto')) {
			$(que).removeClass('btnMas').addClass('btnMenos');
			$(this).slideDown('slow', function(){
				$(this).removeClass('oculto');
			});
		}
		else {
			$(this).slideUp('slow', function(){
				$(this).addClass('oculto');
				$(que).removeClass('btnMenos').addClass('btnMas');
			});

		}
	});
}

function buscarExp(idioma){
	var area = $('#buscador_area').val();
	if (area == 'Seleccione área'){
		alert ('Debe seleccionar un área');
	}else{
		window.location.href=base_url+idioma+'/experiencia/'+area;
	}
}

