// JavaScript Comun
/*Iniciamos las funciones*/
/*Agregar a marcadores*/

$("a.jQueryBookmark").click(function(e){
        e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
        var bookmarkUrl = this.href;
        var bookmarkTitle = this.title;
 
        if (window.sidebar) { // For Mozilla Firefox Bookmark
                window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
        } else if( window.external || document.all) { // For IE Favorite
                window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
        } else if(window.opera) { // For Opera Browsers
                $("a.jQueryBookmark").attr("href",bookmarkUrl);
                $("a.jQueryBookmark").attr("title",bookmarkTitle);
                $("a.jQueryBookmark").attr("rel","sidebar");
        } else { // for other browsers which does not support
                 alert('Your browser does not support this bookmark action');
                 return false;
        }
});



function cambioImagen(){

    $("#imagenGaleria img:visible").fadeOut("slow",function(){
        proximaImagen = $(this).next("img");
        
        if($(this).is(":last-child")){
            
            $("#imagenGaleria img:eq(0)").fadeIn("slow");//.fadeIn("slow");
        }else{
            proximaImagen.fadeIn("slow");
        }
    });
    
}
function cambioTexto(){

    $("#notas p:visible").fadeOut("slow",function(){
        proximaImagen = $(this).next("p");

        if($(this).is(":last-child")){

            $("#notas p:eq(0)").fadeIn("slow");//.fadeIn("slow");
        }else{
            proximaImagen.fadeIn("slow");
        }
    });

}
/*Formulario*/
var colorN = {
	 "background-color": "#cfa6e5",
	 "color": "#111111"
}
/*Iniciamos shadobox*/
Shadowbox.init({
 language: 'es',
 players: ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv'],
 animate: true

}); 


/*Gestion de Eventos*/
$(document).ready(function(){
    //Titulo
    $("#notas p:first").fadeIn("0.30");
    setInterval(cambioTexto,5000);
    
    /*Galeria*/
    $("#imagenGaleria img:first").show();
    setInterval(cambioImagen,5000);

    $("#formularioPresupuesto table input[type=text],.tcontacto input[type=text],.tcontacto textarea ,#formularioPresupuesto table textarea").css(colorN);
	
	/*Imagenes en miniatura*/
	$("#miniatura img").fadeTo("slow", 0.30);
        $("#miniatura img").not(".visible").hover(
        function(){
            $(this).fadeTo("slow", 1.0);
        }, function(){
            $(this).fadeTo("slow", 0.30);
    });
	/*cambio de imagen de la galeria imagen*/
        //$(".visible").fadeTo("slow", 1.0);
	$("#miniatura img").click(function(){
									   
		titulo = $(this).attr("title");
		urlImagen = $(this).attr("alt");
		
		$("#visor img").fadeOut("slow", function(){
                $("#visor").remove("img");
                $('#visor').html("<img src='/img/gAlgunosTrabajos/"+urlImagen+".jpg' /><p class='textoImagen'>" + titulo+ "</p>");
                $("#visor img").fadeIn("slow");
	});
    });

});