	 function funcion_global (idioma, modelo){
		
		/* FORMULARIO EMAIL*/
		$.get("./mailer/token.php", function(txt){
		  $("#form-correo").append('<input type="hidden" id="ts" name="ts" value="'+txt+'" />');
		});
		
		
		$('#captcha')
		  .bind('loaded.simpleCaptcha', function() {
			// do something when loaded
		  })
		  .simpleCaptcha({
  				numImages: 7,
				idioma: idioma
			});

		
		$.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
		  while(x<c.length){var m=r.exec(c.substr(x));
			if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
			}else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
			o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;},
		URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;
		  while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){b=parseInt(m[1].substr(1),16);
		  t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;}
		});

		 /* Inicializar cuadro de diálogo */
		var nombre = $("#nombre"),
		email_1 = $("#email_1"),
		email_2 = $("#email_2"),
		allFields = $([]).add(nombre).add(email_1).add(email_2),
		tips = $(".validateTips"),
		_mensaje_1, _cadena_nombre, _cadena_email_1, _cadena_email_2, _error_email, _error_nombre;
		
		if ( idioma == 'en' )
		{
			_mensaje_1 = "You have not indicated ";
			_mensaje_2 = "\n(It must have at least 5 characters)";
			_cadena_nombre = "your name";
			_cadena_email_1 = "your email";
			_cadena_email_2 = "receiver email";
			_error_nombre = "Your name may consist of letters, spaces and underscores, begin with a letter.";
			_error_email = "Write a valid email address. Eg. example@email.com";
		}
		else
		{
			_mensaje_1 = "No ha indicado ";
			_mensaje_2 = "\n(Debe tener al menos 5 caracteres)"
 			_cadena_nombre = "su nombre";
			_cadena_email_1 = "su email";
			_cadena_email_2 = "el email del destinatario";
			_error_nombre = "Su nombre debe consistir en letras y espacios.";
			_error_email = "Escriba un email válido. Ej. ejemplo@email.com";
		}

		function updateTips(t) {
			tips
				.text(t)
				.addClass('ui-state-highlight');
			setTimeout(function() {
				tips.removeClass('ui-state-highlight', 1500);
			}, 500);
		}

		function checkLength(o,n,min,max) {

			if (o.val().length == 0 ) {
				o.addClass('ui-state-error');
				//updateTips("Length of " + n + " must be between "+min+" and "+max+".");
				updateTips(_mensaje_1 + n );
				return false;
			} else if ( o.val().length > max || o.val().length < min ) {
				o.addClass('ui-state-error');
				//updateTips("Length of " + n + " must be between "+min+" and "+max+".");
				updateTips(_mensaje_1 + n + _mensaje_2);
				return false;
			} else {
				return true;
			}

		}

		function checkRegexp(o,regexp,n) {

			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass('ui-state-error');
				updateTips(n);
				return false;
			} else {
				return true;
			}

		}
		
		$("#dialog-form").dialog({
			autoOpen: false,
			height: 460,
			width: 370,
			modal: true,
			resizable: false,
			buttons: {
				'Cancelar': function() {
					$(this).dialog('close');
				},
				'Enviar': function() {
					var bValid = true;
					allFields.removeClass('ui-state-error');
					
					bValid = bValid && checkLength(nombre, _cadena_nombre, 5, 100);
					bValid = bValid && checkLength(email_1, _cadena_email_1, 1);
					bValid = bValid && checkLength(email_2, _cadena_email_2, 1);
					//bValid = bValid && checkLength(password,"password",5,16);

					bValid = bValid && checkRegexp(nombre,/^[a-zAz ]([0-9a-zAz_ ])*$/i, _error_nombre);
					// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
					bValid = bValid && checkRegexp(email_1,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, _error_email);
					bValid = bValid && checkRegexp(email_2,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, _error_email);
					//bValid = bValid && checkRegexp(password,/^([0-9a-zA-Z])+$/,"Password field only allow : a-z 0-9");
					
					if (bValid) {
						enviar_correo(idioma);
						//$(this).dialog('close');
					}
				}
			},
			close: function() {
				allFields.val('').removeClass('ui-state-error');
			}
		});
		
		
		
		$('#opener')
			.click(function() {
				$('#dialog-form').dialog('open');
			});

	 
	 
		function enviar_correo(idioma)
		{
			$('#formulario').hide();
			$('#mensaje-retorno').html('<div style="margin: 0; padding: 110px 0 0 150px;"><img src="images/loading.gif"></div>');
			$('#mensaje-retorno').show();
			
			$.ajax({
				type: "POST",
				url: './mailer/envio-ajax.php',
				//data: 'email_1='+$.URLEncode($('#email_1').val())+'&email_2='+$.URLEncode($('#email_2').val())+'&idioma=es',
				data: ({nombre : $('#nombre').val(), email_1: $('#email_1').val(), email_2: $('#email_2').val(), idioma: idioma, modelo: modelo, ts: $('#ts').val(), captchaSelection: $('#simpleCaptcha_0').val() }), 
				cache: false,
				success: function(data) {
					//console.log(data);
					//alert('Load was performed.'+data);
					if ( data == 'EXITO' )
					{
						//console.log('2 '+data);
						
						if ( idioma == 'en' )
							var mensaje = '<div style="padding: 40px 20px 20px 10px; color: #ECB50F;">The email has been sent.<br /><br />Thank you.</div>';
						else
							var mensaje = '<div style="padding: 40px 20px 20px 10px; color: #ECB50F;">Mensaje enviado correctamente.<br /><br />Gracias.</div>';
							
						$('#mensaje-retorno').html(mensaje);
						setTimeout(function() {
							$('#dialog-form').dialog('close');
							
							$('#mensaje-retorno').hide();
							$('#formulario').show();
						}, 3500);
					}
					else if ( data == 'DATOS' )
					{
						//console.log('3 '+data);
						
						if ( idioma == 'en' )
							var mensaje = '<div style="padding: 40px 20px 20px 10px; color: red;">You have entered bad data.<br /><br />Please, check the data.</div>';
						else
							var mensaje = '<div style="padding: 40px 20px 20px 10px; color: red;">Ha introducido datos err&oacute;neos.<br /><br />Por favor, compruebe los datos.</div>';
							
						$('#mensaje-retorno').html(mensaje);
						setTimeout(function() {
							$('#mensaje-retorno').hide();
							$('#formulario').show();
						}, 3500);
					}
					else if ( data == 'ERROR_3' )
					{
						//console.log('4 '+data);
						
						if ( idioma == 'en' )
							var mensaje = '<div style="padding: 40px 20px 20px 10px; color: red;">The email could not be delivered.<br /><br />Please, check you click in the image, Thank you.</div>';
						else
							var mensaje = '<div style="padding: 40px 20px 20px 10px; color: red;">No se ha podido enviar el correo.<br /><br />Por favor, no olvide hacer click en la imagen que se le indique, gracias.</div>';
						
						$('#mensaje-retorno').html(mensaje);
						setTimeout(function() {
							//$('#dialog-form').dialog('close');
							
							$('#mensaje-retorno').hide();
							$('#formulario').show();
						}, 4500);
					}
					else
					{
						//console.log('5 '+data);
						
						if ( idioma == 'en' )
							var mensaje = '<div style="padding: 40px 20px 20px 10px; color: red;">The email could not be delivered.<br /><br />Please, try later, Thank you.</div>';
						else
							var mensaje = '<div style="padding: 40px 20px 20px 10px; color: red;">No se ha podido enviar el correo.<br /><br />Vuelva a intentarlo m&aacute;s tarde, gracias.</div>';
						
						$('#mensaje-retorno').html(mensaje);
						setTimeout(function() {
							$('#dialog-form').dialog('close');
							
							$('#mensaje-retorno').hide();
							$('#formulario').show();
						}, 3500);
					}
					
					
				},
				error: function(data)
				{
					//console.log('6 '+data);
					
					if ( idioma == 'en' )
						var mensaje = '<div style="padding: 40px 20px 20px 10px; color: red;">The email could not be delivered.<br />Please, try later, Thank you.</div>';
					else
						var mensaje = '<div style="padding: 40px 20px 20px 10px; color: red;">No se ha podido enviar el correo.<br />Por favor, vuelva a intentarlo m&aacute;s tarde, gracias.</div>';
						
					$('#mensaje-retorno').html(mensaje);
					setTimeout(function() {
						$('#dialog-form').dialog('close');
						
						$('#mensaje-retorno').hide();
						$('#formulario').show();
					}, 3500);
				}
			});
		}
		/* fin FORMULARIO EMAIL*/
	 
	 
	 
		
	
	/* ESQUINAS REDONDEADAS */
	$("#box1").corner();
	
	
	/* TOOLTIPS */
	$(".ttip").tooltip({showURL: false, showBody: " - "});
	 
	 
	 
	 /* STEP CARROUSEL */	 
	stepcarousel.setup({
		galleryid: 'mygallery', //id of carousel DIV
		beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
		panelclass: 'panel', //class of panel DIVs each holding content
		autostep: {enable:false, moveby:1, pause:3000},
		panelbehavior: {speed:500, wraparound:false, persist:true},
		defaultbuttons: {enable: true, moveby: 1, leftnav: ['js/images/prev.gif', -5, 80], rightnav: ['js/images/next.gif', -20, 80]},
		statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
		contenttype: ['inline'], //content setting ['inline'] or ['ajax', 'path_to_external_file']
		idioma: idioma
	})
	
}

function cambiar_imagen(elemento)
 {
	var temporal = elemento.src;
	elemento.src = elemento.getAttribute("otro");
	elemento.otro = temporal;
 }
 function devolver_imagen(elemento)
 {
	var temporal = elemento.src;
	elemento.src = elemento.otro;
	elemento.otro = temporal;
 }
