// JavaScript Document	
$(window).load(function() {
	
	
	
});
$(document).ready(function(){
	
	
	$("#cuerpo .menu ul li ul li.active2").parent().prev("a").addClass("active").next("ul").show();
	$("#cuerpo .menu ul li a.active").parent().prev("li").addClass("no_bg");
	
	$("#cuerpo .menu>ul>li>a").hover(
		function(){
			$(this).parent().removeClass("no_bg");
			$(this).addClass("hover").parent().prev("li").addClass("no_bg");
		},
		function(){
			$(this).removeClass("hover").parent().prev("li").removeClass("no_bg");
			$("#cuerpo .menu ul li a.active").parent().prev("li").addClass("no_bg");
		}
	);
	$("#cuerpo .menu>ul>li>a[href='javascript:;']").toggle(function(){ $(this).next("ul").slideDown("slow"); }, function(){ $(this).next("ul").slideUp("slow"); });
	
	$("#cuerpo .menu>ul>li>ul>li>a").hover(
		function(){
			$(this).css("fontWeight","bold");
			$(this).parent().parent().prev("a").parent().removeClass("no_bg");
			$(this).parent().parent().prev("a").addClass("hover").parent().prev("li").addClass("no_bg");
		},
		function(){
			if($(this).parent().attr("class") != "active2"){
				$(this).css("fontWeight","normal");
				$(this).parent().parent().prev("a").removeClass("hover").parent().prev("li").removeClass("no_bg");
				$("#cuerpo .menu ul li a.active").parent().prev("li").addClass("no_bg");
			}
		}
	);
	$(".bg_photo_detalle a span").css("opacity",0.6);
	
	$('.clearField').clearField({
		blurClass: 'myBlurredClass',
		activeClass: 'myActiveClass'
	});
	
	$.get("operations.php",{param:'servicios',id:$("#posS").val()},function(data){ $("#load").html(data);});
	$(".servicios-left a").click(function(){
		$("#load").hide();
		$(".servicios-left a").removeClass("active-servicios");
		$(this).addClass("active-servicios");
																	 
		$.get("operations.php",{param:'servicios',id:$(this).attr("name").split("-")[1]},function(data){ 
			$("#load").html(data).fadeIn("slow");						   
		}); 
	});	
	
	$('.view_map').click(function(){
		$.get("operations.php?param=map",{id:''}, function(data){
				$(".close").show();
				$(".mapa").html(data).fadeIn("slow");
		});
	});
	
	
	$("input.file_1").filestyle({ 
          image: "aplication/webroot/imgs/choose-file.jpg",
          imageheight : 23,
          imagewidth : 85,
          width : 159
      });


});

function viewObras(val){
	location.replace("obras.php?idd="+val+"&status=2");			
}
function viewObras2(val){
	location.replace("obras.php?idd="+val+"&status=1");			
}
function viewDetail(val){
	$(".box").attr("href","proyectos-detalle.php?id="+val);
	$(".box").trigger("click");
}

function viewMap(){
	$(".listar_obras li a").removeClass("activeo");
	$(".loading_pos").show();
	$.get("operations.php",{param:'map'},function(data){ 
		$(".loading_pos").fadeOut("slow", function(){
			$("#load-detail").html(data);						   
		});																					  
	}); 				
}

function validnum(e) { 
	tecla = (document.all) ? e.keyCode : e.which; 
	//alert(tecla)
    if (tecla==8 || tecla==46) return true; //Tecla de retroceso (para poder borrar) 
    // dejar la línea de patron que se necesite y borrar el resto 
    //patron =/[A-Za-z]/; // Solo acepta letras 
    patron = /\d/; // Solo acepta números
    //patron = /\w/; // Acepta números y letras 
    //patron = /\D/; // No acepta números 
    //patron = /[\d.-]/; numeros el punto y el signo -
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
	// uso  onKeyPress="return validnum(event)"
}

function buscar(url,texto){
	document.f2.action=url+'&q='+ texto.value;
	document.f2.submit();
}
 	
	
var testresults
function checkemail(value){
	var str = value
	var filter=/^.+@.+\..{2,3}$/
		if (filter.test(str))
		testresults=true
	else{
		alert("Por favor ingrese un e-mail valido...");
		testresults=false
	}
	return (testresults)
}	

