function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

function add_selected(sec){
	$("#menu_servicios").addClass("selected");
}
function rem_selected(sec){
	$("#menu_servicios").removeClass("selected");
}
function menu_select(obj){
	$(obj).addClass("selected");
}

function slide_switch(){
    var $active = $('#last_slideshow img.active');

    if ( $active.length == 0 ) $active = $('#last_slideshow img:last');

    var $next =  $active.next().length ? $active.next()
        : $('#last_slideshow img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
function slide_init(){
	setInterval( "slide_switch()", 4000 );
}


function validar(t)
{
	var html = $("html", t).text();	
	$("#trabajo_foto").html(html).addClass("accesibility");
}

function ajaxError()
{
	alert('Error en el servidor.');
}





// SIRF
function tipografia(server)
{
	$.sifr({
		path: server + "/swf/",
		save: true
	});
	$("h2").sifr({ font: 'Gillsansmtbold' });
	$("h4").sifr({ font: 'Gillsansmtbold' });
	$(".eventos_realizados_titulo").sifr({ font: 'Gillsansmtbold' });
	$(".proyectos_realizados_titulo").sifr({ font: 'Gillsansmtbold' });
	$("#trabajo_nombre p").sifr({ font: 'Gillsansmtbold' });


}


// Easing para slideshows
function easing()
{
	jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	};
}


// Segunda mano
function segunda_mano(num)
{
	
	$('#productos_slideshow ul').css("width", num + "px");
	$('#productos_slideshow').serialScroll({
		items:'li',
		prev:'#productos_galeria a.prev',
		next:'#productos_galeria a.next',		
		offset:0, //when scrolling to photo, stop -x before reaching it (from the left)
		start:0, //as we are centering it, start at the 0
		force:true,
		stop:true,
		lock:false,
		cycle:false, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false //click on the images to scroll to them
	});
}


// Proyectos
function proyectos(num)
{
	
	$('#proyectos_listado_galeria ul').css("width", num + "px");
	$('#proyectos_listado_galeria').serialScroll({
		items:'li',
		prev:'#proyectos_navigation a.prev',
		next:'#proyectos_navigation a.next',		
		offset:0, //when scrolling to photo, stop -x before reaching it (from the left)
		start:0, //as we are centering it, start at the 0
		force:true,
		stop:true,
		lock:false,
		cycle:false, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false //click on the images to scroll to them
	});	
}

// Proyectos Galeria
function proyectos_video(server, id)
{
	var param = "id=" + id + "&server=" + server;
	$.ajax({
		async:true,
		type: "post",
		dataType: "xml",
		contentType: "application/x-www-form-urlencoded",
		url: server + "/sc-video.php",
		data:param,
		success:validar,
		timeout:10000,
		error:ajaxError
	});
}
function proyectos_foto(param)
{
	$("#trabajo_foto").css({display:"none"});
	$("#trabajo_foto").html('<img src="' + param + '" />');
	$("#trabajo_foto").fadeIn("slow").toggleClass("accesibility");	
}

// Contacto -> Google Maps
function google(server)
{
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("contacto_info_mapa"));		
		map.setCenter(new GLatLng(39.138908, -0.170288), 8);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());		
		map.setMapType(G_HYBRID_MAP);	
		var iconoMarca = new GIcon(G_DEFAULT_ICON);
		iconoMarca.image = server + "/img/icon_logo.png";
		iconoMarca.iconSize =  new GSize(162,70);
		iconoMarca.iconAnchor = new GPoint(162,70);
		var marker1 = new GMarker(new GLatLng(38.598086,-0.135446), iconoMarca);
		map.addOverlay(marker1);
		var marker2 = new GMarker(new GLatLng(39.417969,-0.375338), iconoMarca);
		map.addOverlay(marker2);
	}
}