$(document).ready(function(){	
	$('#formContactSend').click(sendContactForm);
	
	
	// Increase Font Size
		$(".options .increase").click(function(){
		var currentFontSize = $('#bd .clear').css('font-size');		
		if (currentFontSize < "16px") {
				var currentFontSizeNum = parseFloat(currentFontSize, 10);			
				var newFontSize = currentFontSizeNum + 1;
				$('#bd .clear').css('font-size', newFontSize);
				//initScroll();
				return false;
			}
		});
		// Decrease Font Size
		$(".options .decrease").click(function(){
		var currentFontSize = $('#bd .clear').css('font-size');
		if (currentFontSize > "13px") {			
				var currentFontSizeNum = parseFloat(currentFontSize, 10);
				var newFontSize = currentFontSizeNum - 1;			
				$('#bd .clear').css('font-size', newFontSize);
				//initScroll();
				return false;			
			}
		});


            $('#slider').nivoSlider({
                    effect: 'sliceUpDownLeft',
                    animSpeed:1000,
                    pauseTime:6000,
                    controlNav:false,
                    directionNavHide:false,
                    captionOpacity:0.95
            });
	
});


function setMenuActive() {
    $('#liActive').css('class', "active");
}

/**
 * valida el formulario de contacto
 */
function sendContactForm(){
       
	if (inputIsEmpty('userName')) {
		$('#msg_error').html(MSG_COMPLETAR_NOMBRE);
		$('#userName').focus();
	}else if (inputIsEmpty('surname')) {
		$('#msg_error').html(MSG_COMPLETAR_APELLIDO);
		$('#surname').focus();
	}else if (inputIsEmpty('email')) {
		$('#msg_error').html(MSG_COMPLETAR_EMAIL);
		$('#email').focus();
	}else if (!is_email($('#email').val())) {
		$('#msg_error').html(MSG_EMAIL_INCORRECTO);
		$('#email').focus();
	}else if (inputIsEmpty('comment')) {
		$('#msg_error').html(MSG_COMPLETAR_COMMENT);
		$('#comment').focus();
	}else{
		$('#msg_error').html('');
                $('#msg_success').html('');
		$.ajax({
			type:"POST",
			dataType: "json",
			url: WEB_PATH + "app/ajax/contact.php",
			data:$('#formContact').serialize(),
			success: function(response){
				if(response.error == 0 ){
					$('#msg_error').html('<span class="success">'+response.message+'</span>');
                                        $('#formContact')[0].reset();
                                       
				}else{
					$('#msg_error').html(response.message);
                                       
                                       
				}
			}
		});
              
                    
	}

        

}

function setLenguage (lang, page) {
	document.location = WEB_PATH+lang+'/'+page+'/';
	
}
