
function ocultar_enlace(correo,dominio,extension)  { 
	document.write('<a href="mailto:' + correo + "@" + dominio + "." + extension + '" class="gris">' + correo + "@" + dominio + "." + extension + '</a>');
}

$(document).ready(function() {

	/*
	$('ul.sf-menu').superfish({	
		delay:       300,
		animation:   {opacity:'show',height:'show'},
		speed:       'fast',
		autoArrows:  false,
		dropShadows: false
	});
	*/

	if(archivoactual=="index.php") {
		$('#coin-slider-index').coinslider({
			width: 669, // width of slider panel
			height: 541, // height of slider panel
			spw: 9, // squares per width
			sph: 7, // squares per height
			delay: 8000, // delay between images in ms
			sDelay: 10, // delay beetwen squares in ms
			opacity: 1, // opacity of title and navigation
			titleSpeed: 3000, // speed of title appereance in ms
			effect: 'rain', // random, swirl, rain, straight
			navigation: true, // prev next and buttons
			links : false, // show images as links 
			hoverPause: false // pause on hover	
		});
	} else {
		$('#coin-slider').coinslider({
			width: 960, // width of slider panel
			height: 412, // height of slider panel
			spw: 9, // squares per width
			sph: 7, // squares per height
			delay: 8000, // delay between images in ms
			sDelay: 10, // delay beetwen squares in ms
			opacity: 1, // opacity of title and navigation
			titleSpeed: 3000, // speed of title appereance in ms
			effect: 'rain', // random, swirl, rain, straight
			navigation: true, // prev next and buttons
			links : false, // show images as links 
			hoverPause: false // pause on hover	
		});
	}
	
	$(".fancybox").fancybox({
		'titleShow'     : false
	});
	
	/* ----------------------------------------------------------------------- */
	
	$('.seccion_equipo_equipo').css("cursor","pointer");
	if($('.seccion_equipo').length) {
		$(".seccion_equipo ul").click(function() {
			name_div_click = $(this).attr("name");
			$(".seccion_equipo_equipo").each(function() {
				if($(this).find(".curriculum").is(':visible')) {
					name_div_click_each = $(this).attr("name");
					if(name_div_click==name_div_click_each) {
						
					} else {
						$(this).find(".curriculum").stop(true,true).slideUp();
					}
				}
			});
			$(this).find(".curriculum").stop(true,true).slideDown();
		});
	}
	
	/* ----------------------------------------------------------------------- */
	
	if($('.seccion_servicios').length) {

		$(".derecho_administrativo").fancybox({
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'width'				: 700,
			'height'			: 340,
			'type'				: 'iframe'
		});
		
		$(".derecho_urbanistico").fancybox({
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'width'				: 700,
			'height'			: 260,
			'type'				: 'iframe'
		});
		
		$(".derecho_inmobiliario").fancybox({
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'width'				: 700,
			'height'			: 380,
			'type'				: 'iframe'
		});
		
		$(".derecho_empresa").fancybox({
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'width'				: 700,
			'height'			: 330,
			'type'				: 'iframe'
		});
		
		$(".derecho_penal").fancybox({
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'width'				: 700,
			'height'			: 400,
			'type'				: 'iframe'
		});

		$(".derecho_internacional").fancybox({
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'width'				: 700,
			'height'			: 400,
			'type'				: 'iframe'
		});
	
	}

	/* ----------------------------------------------------------------------- */
	
	if($('.seccion_contacto').length) {
		
		var markersArray = [];
		
		var oficina_alicante = new google.maps.LatLng(38.3432084,-0.4921927);
		var oficina_sanvicente = new google.maps.LatLng(38.3949709,-0.5205099);
		var oficina_montesinos = new google.maps.LatLng(38.027984170933685,-0.7432347536087036);

		var myOptions = {
			zoom: 14,
			center: oficina_alicante,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		}

		var map = new google.maps.Map(document.getElementById("mapa_gmaps"), myOptions);
		
		function addMarker(location) {
			marker = new google.maps.Marker({
				position: location,
				map: map
			});
			markersArray.push(marker);
		}

		function clearOverlays() {
			if (markersArray) {
				for (i in markersArray) {
					markersArray[i].setMap(null);
				}
			}
		}
		
		addMarker(oficina_alicante);
		
		$(".seccion_contacto ul li.cab").css("cursor","pointer");
		
		$(".seccion_contacto ul li.cab").mouseenter(function() {
			$(this).css("text-decoration","underline");
		});
		
		$(".seccion_contacto ul li.cab").mouseleave(function() {
			$(this).css("text-decoration","none");
		});
		
		$(".seccion_contacto ul").click(function() {
												 
			name_div_click = $(this).attr("name");
			
			clearOverlays();
			
			if(name_div_click=="seccion_contacto_contacto_1") {
				addMarker(oficina_alicante);
				map.setCenter(oficina_alicante)
			} else if(name_div_click=="seccion_contacto_contacto_2") {
				addMarker(oficina_sanvicente);
				map.setCenter(oficina_sanvicente)
			} else if(name_div_click=="seccion_contacto_contacto_3") {
				addMarker(oficina_montesinos);
				map.setCenter(oficina_montesinos)
			}
			
			$(".seccion_contacto_contacto").each(function() {
				if($(this).find(".texto").is(':visible')) {
					name_div_click_each = $(this).attr("name");
					if(name_div_click==name_div_click_each) {
						
					} else {
						if($.browser.msie && parseInt($.browser.version.substr(0, 1)) < 8) {
							$(this).find(".texto").css("display","none");
						} else {
							$(this).find(".texto").stop(true,true).slideUp();
						}
					}
				}
			});
			
			if($.browser.msie && parseInt($.browser.version.substr(0, 1)) < 8) {
				$(this).find(".texto").css("display","block");
			} else {
				$(this).find(".texto").stop(true,true).slideDown();
			}
			
		});
	
	}

	/* ----------------------------------------------------------------------- */

	if($('.seccion_trabaja').length) {
		
		var queueSize = 0;
		
		$('#fileUploadname').uploadify({
			'uploader'       : rutaweb+'/js/uploadify/uploadify.swf',
			'cancelImg'      : rutaweb+'/js/uploadify/cancel.png',
			'buttonImg'		 : rutaweb+'/images/boton_browse_es.gif',
			'script'         : rutaweb+'/trabaja_enviar.php',
			'width'			 : 167,
			'height'		 : 24,
			'rollover'		 : true,
			'folder'         : '/db/imgs/',
			'multi'          : false,
			'fileExt'        : '*.pdf',
			'fileDesc'       : 'Archivos PDF (.pdf)',
			'queueID'        : 'custom-queue',
			'queueSizeLimit' : 1,
			'simUploadLimit' : 1,
			'removeCompleted': true,
			'scriptData' 	 : { 'tabla':'a' },
			'onOpen':function(event,data) {
				$("<div></div>").addClass("ui-widget-overlay").appendTo(document.body).css("width",$(document).width()).css("height",$(document).height()).css("color","#FFF").css("textAlign","center");
			},
			'onSelectOnce':function(event,data) {
				queueSize = queueSize+1;
				$('#custom-queue').css("border","1px solid #d7d7d7").css("background","#FFF");
			},
			'onAllComplete':function(event,data) {
				$(".ui-widget-overlay").remove();
				$('#custom-queue').remove();
				$('#fileUploadname').remove();
				$('#fileUploadnameUploader').remove();
				setTimeout(function() {
					$('.seccion_trabaja_cen form').slideUp(500);
					$('.seccion_trabaja_cen_txt_inicio').css("display","none");
					$('.seccion_trabaja_cen_txt_inicio').slideUp(500);
					setTimeout(function() {
						$('.seccion_trabaja_cen_txt_final').slideDown(500);
					}, 500);
				}, 250);
			}
		});
		
		var $mensaje_nombre_error = $("#formulario .nombre_error_obligatorio").dialog({ autoOpen:false, height:100, modal:true });
		var $mensaje_email_error_obligatorio = $("#formulario .email_error_obligatorio").dialog({ autoOpen:false, height:100, modal:true });
		var $mensaje_email_error_incorrecto = $("#formulario .email_error_incorrecto").dialog({ autoOpen:false, height:100, modal:true });
		var $mensaje_observaciones_error_obligatorio = $("#formulario .comentarios_error_obligatorio").dialog({ autoOpen:false, height:100, modal:true });
		var $mensaje_curriculum_error_obligatorio = $("#formulario .curriculum_error_obligatorio").dialog({ autoOpen:false, height:100, modal:true });
		
		$("#formulario").submit(function () {

			if($("#formulario .nombre").val().length < 2) {
				$mensaje_nombre_error.dialog('open');
				return false;
			}
			
			if($("#formulario .email").val().length < 2) {
				$mensaje_email_error_obligatorio.dialog('open');
				return false;
			}
			
			if($("#formulario .email").val().indexOf('@', 0) == -1) {
				$mensaje_email_error_incorrecto.dialog('open');
				return false;
			}
			
			if($("#formulario .observaciones").val().length < 2) {
				$mensaje_observaciones_error_obligatorio.dialog('open');
				return false;
			}
			
			$('#fileUploadname').uploadifySettings("scriptData", {
				'nombre': $("#formulario .nombre").val(), 
				'apellidos': $("#formulario .apellidos").val(), 
				'telefono': $("#formulario .telefono").val(), 
				'email': $("#formulario .email").val(), 
				'observaciones': $("#formulario .observaciones").val(), 
				'nombre': $("#formulario .nombre").val() 
			});
			
			if(queueSize==0) {
				$mensaje_curriculum_error_obligatorio.dialog('open');
				return false;
			}
			
			$('#fileUploadname').uploadifyUpload();
			
			return false;
		
		});
	
	}

	/* ----------------------------------------------------------------------- */

	if($('.seccion_boletines_der').length) {
		
		$(".seccion_boletines_der ul li a img").mouseenter(function() {
			$(this).css("border","1px solid #666");
		});
		
		$(".seccion_boletines_der ul li a img").mouseleave(function() {
			$(this).css("border","1px solid #e5e5e5");
		});

	
	}

});
