/* Menu Tabs */
$(document).ready(function(){
  $("#left ul").idTabs()
  $("#bar a").idTabs()
});

/* Boton show-hide div */
function fade(div_id, button) {
	divn = document.getElementById("nosotros").title;
	if(divn == 'Ocultar') {
		$('#'+div_id).fadeOut('slow');
		document.getElementById("nosotros").title = 'Mostrar';
	}
	else {
		$('#'+div_id).fadeIn('slow');
		document.getElementById("nosotros").title = 'Ocultar';
	}
}
// Escape Key
$(document).keyup(function(e) {
	if (e.keyCode == 27){
		$('#portfolio-box').fadeOut('slow')
	}
});

/* Validar Form */
$(document).ready(function ajaxform(){
  $('#form').ajaxForm({
	 target: '#right',
	 clearForm: true,
	 beforeSubmit: validate,
});
});
function validate(formData, jqForm, options) { 
    var nombre = $('input[name=nombre]').fieldValue(); 
    var email = $('input[name=email]').fieldValue(); 
    var mensaje = $('textarea[name=mensaje]').fieldValue(); 
 
    if (!nombre[0] || !email[0] || !mensaje[0]) {
		cleanform();
		if (!nombre[0]) { document.getElementById("nombre").style.borderBottom = "2px solid #F00";} 
		if (!email[0]) { document.getElementById("email").style.borderBottom = "2px solid #F00";} 
		if (!mensaje[0]) { document.getElementById("mensaje").style.border = "2px solid #F00";} 
        return false; 
    }
	cleanvalidate101art();
}
function cleanform(){
	document.getElementById("nombre").style.border = "";
	document.getElementById("email").style.border = ""; 
	document.getElementById("mensaje").style.border = ""; 
}
$(window).load(function() {
    $('#portfolio-slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:5000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:true, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:true, // Use image rel for thumbs
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
    });
});

