
Shadowbox.init({
	language: 'es',
	players:  ['img', 'html', 'qt', 'wmp', 'swf', 'flv']
});






function urlencode(str) { 
  return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40'); 
}



function info(id){

	$("#loading-"+id).show();

	$.ajax({
	  type: "POST",
	  url: "/archivo/info.php",
	  cache: false,
	  data: "pos="+id+"&modo=1",
	  success: function(msg){

		$("#thumb_info").hide();

	  	$("#loading-"+id).hide();

		$("#thumb_info").html(msg);

		$("#thumb_info").css({top: $(window).scrollTop() });

		$("#thumb_info").show("fast");		

		if(document.getElementById('captcha'))
			document.getElementById('captcha').src = '/incs/securimage/securimage_show.php?' + Math.random();

	  }

	});

}


function info_close(id){

  	$("#thumb_info").hide("fast");
    $("#thumb_info").empty();

	$(".loading").hide();	
	
}


function send_post(btn_envio){
	var salida=true;

	$("#email_form").hide();
	$("#captcha_form").hide();
	$("#texto_span").hide();
	
	
    if( document.getElementById("FCKeditor1").value.length < 10 ){
        $("#texto_span").show();
        salida = false;
    }


      if( document.getElementById("alerta").checked==1 ){
              var email = document.getElementById("email")
              var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
              if (!filter.test(email.value)) {
                      $("#email_form").show();
                      email.focus()
                      salida = false;
              }
      }

	if(document.getElementById("captcha_code")){
		if( document.getElementById("captcha_code").value.length < 4 ){
			   $("#captcha_form").show();
			   document.getElementById("captcha_code").focus()
			   salida = false;
		}
	}


	//envio el formulario via ajax
	if(salida){

		var email =		urlencode(document.getElementById("email").value);
		var nombre =	urlencode(document.getElementById("name").value);

		var captcha_code = "";
		if(document.getElementById('captcha_code')){
			captcha_code = document.getElementById("captcha_code").value;
		}


		var id = document.getElementById("id").value;
		var title =  urlencode(document.getElementById("title").value);
		

		$.ajax({
		  type: "POST",
		  url: "/archivo/send_post.php",
		  cache: false,
		  data: "name="+nombre+"&email="+email+"&captcha_code="+captcha_code+"&id="+id+"&title="+title+"&FCKeditor1="+urlencode(document.getElementById("FCKeditor1").value),
		  success: function(msg){
			
			switch(msg){
			
				case "0":
					alert("El codigo antispam es incorrecto! Por favor, vuelve a escribirlo y pulsa 'Enviar comentario'");
				break;
				
				case "1":
					btn_envio.disabled=1;

					$.ajax({
					  type: "POST",
					  url: "/archivo/info.php",
					  cache: false,
					  data: "pos="+id+"&modo=1",
					  success: function(msg){
						
						$("#thumb_info").html(msg);
						
						if(document.getElementById('captcha'))
							document.getElementById('captcha').src = '/incs/securimage/securimage_show.php?' + Math.random();
				
					  }
				
					});

				break;
			
			}
				
			
		  }
	
		});

	}
	
}


function toggle_pipe_obras(id){
	$("#pipe_obras_"+id).toggle(110);
}

