function agregar(addURL, titulo)

{

	var navAg1 = navigator.userAgent;

	var navAg =navAg1.indexOf('Safari');

	if (navAg > 0){

	alert('Por favor, presione CTRL + D');

	return ;

	}



	//Para internet explorer

	if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) 

	{

		window.external.AddFavorite(addURL,titulo);

	}

	//Para Netscape y Firefox

	else 

	{

		if(navigator.appName == "Netscape")

			window.sidebar.addPanel(titulo, addURL,'');  //Puedes personalizar este mensaje

	}

}



function mostrar(nombreCapa){

	document.getElementById(nombreCapa).style.display="inline";

}



function ocultar(nombreCapa){

	document.getElementById(nombreCapa).style.display="none";

}



$(document).ready(function() {




	$('#enviarProducto').click(function () {		

		//Get the data from all the fields

		var email_de = $('input[name=mail_de]');

		var email_para = $('input[name=mail_para]');

		var mensaje = $('textarea[name=mensaje]');

		var lnk = $('input[name=link]');
		
		var titulo_producto =  $('input[name=titulo_producto]');

		var foto = $('input[name=foto]');
		
		var descripcion =  $('input[name=descripcion]');


		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_de.val()))

		{

			email_de.removeClass('errorMail');

		}else

		{

			email_de.addClass('errorMail');

			return false;

		}

		

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_para.val()))

		{

			email_para.removeClass('errorMail');

		}else

		{

			email_para.addClass('errorMail');

			return false;

		}

		

		if (mensaje.val()=='') {

			mensaje.addClass('errorMail');

			return false;

		} else mensaje.removeClass('errorMail');

		//organize the data properly

		var data = 'titulo_producto=' + titulo_producto.val() + '&foto=http://www.busymindstudio.com/clientes/22dg/munchis/site/admin/uploads/' + foto.val() +'&descripcion=' + descripcion.val() +'&email_de=' + email_de.val() + '&email_para=' + email_para.val() + '&link=' + encodeURIComponent(lnk.val()) + '&mensaje='  + mensaje.val();

//		var data = 'titulo_producto=' + titulo_producto.val() + '&foto=http://www.busymindstudio.com/clientes/22dg/munchis/site/admin/uploads/' + foto.val() +'&descripcion=' + descripcion.val() +'&email_de=' + email_de.val() + '&email_para=' + email_para.val() + '&link=' + encodeURIComponent(lnk.val()) + '&mensaje='  + encodeURIComponent(mensaje.val());

		//disabled all the text fields

		//$('.text').attr('disabled','true');

		

		//show the loading sign

		//$('.loading').show();

		

		//start the ajax

		$.ajax({

			//this is the php file that processes the data and send mail

			url: "async/sendMailProducto.php",	

			//GET method is used

			type: "GET",

			//pass the data			

			data: data,		

			//Do not cache the page

			cache: false,

			//success

			success: function (html) {				

				//if process.php returned 1/true (send mail success)

				if (html==1) {					

					$('#ventana_contale').fadeOut('slow');

					$('#graciasContacto').fadeIn('slow');

					$('#graciasContacto').fadeOut(4000);

				//if process.php returned 0/false (send mail failed)

				} else alert('Error, por favor intente mas tarde.');				

			}		

		});

		//cancel the submit button default behaviours

		return false;

	});



	//if submit button is clicked

	$('#submit').click(function () {		

		//Get the data from all the fields

		var email_de = $('input[name=mail_de]');

		var email_para = $('input[name=mail_para]');

		var mensaje = $('textarea[name=mensaje]');

		var titulo_producto = 'titulo generico' ;


		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_de.val()))

		{

			email_de.removeClass('errorMail');

		}else

		{

			email_de.addClass('errorMail');

			return false;

		}

		

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_para.val()))

		{

			email_para.removeClass('errorMail');

		}else

		{

			email_para.addClass('errorMail');

			return false;

		}

		

		if (mensaje.val()=='') {

			mensaje.addClass('errorMail');

			return false;

		} else mensaje.removeClass('errorMail');



		//organize the data properly

		var data = 'email_de=' + email_de.val() + '&email_para=' + email_para.val() + '&mensaje='  + encodeURIComponent(mensaje.val());

		//disabled all the text fields

		//$('.text').attr('disabled','true');

		

		//show the loading sign

		//$('.loading').show();

		//start the ajax

		$.ajax({

			//this is the php file that processes the data and send mail

			url: "async/sendMail.php",	

			//GET method is used

			type: "GET",

			//pass the data			

			data: data,		

			//Do not cache the page

			cache: false,

			//success

			success: function (html) {				

				//if process.php returned 1/true (send mail success)

				if (html==1) {					

					$('#ventana_contale').fadeOut('slow');

					$('#graciasContacto').fadeIn('slow');

					$('#graciasContacto').fadeOut(4000);

				//if process.php returned 0/false (send mail failed)

				} else alert('Error, por favor intente mas tarde.');				

			}		

		});

		

		//cancel the submit button default behaviours

		return false;

	});	



	$('#enviarHelado').click(function () {		

		//Get the data from all the fields

		var email_de = $('input[name=mail_de]');

		var email_para = $('input[name=mail_para]');

		var mensaje = $('textarea[name=mensaje]');



		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_de.val()))

		{

			email_de.removeClass('errorMail');

		}else

		{

			email_de.addClass('errorMail');

			return false;

		}

		

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_para.val()))

		{

			email_para.removeClass('errorMail');

		}else

		{

			email_para.addClass('errorMail');

			return false;

		}

		

		if (mensaje.val()=='') {

			mensaje.addClass('errorMail');

			return false;

		} else mensaje.removeClass('errorMail');

		//organize the data properly

		var data = 'email_de=' + email_de.val() + '&email_para=' + email_para.val() + '&mensaje='  + encodeURIComponent(mensaje.val());

		//disabled all the text fields

		//$('.text').attr('disabled','true');

		

		//show the loading sign

		//$('.loading').show();



		//start the ajax

		$.ajax({

			//this is the php file that processes the data and send mail

			url: "async/sendMailHelado.php",	

			//GET method is used

			type: "GET",

			//pass the data			

			data: data,		

			//Do not cache the page

			cache: false,

			//success

			success: function (html) {	

				//if process.php returned 1/true (send mail success)

				if (html==1) {					

					$('#ventana_contale').fadeOut('slow');

					$('#graciasContacto').fadeIn('slow');

					$('#graciasContacto').fadeOut(4000);

					

				//if process.php returned 0/false (send mail failed)

				} else alert();				

			}		

		});



		//cancel the submit button default behaviours

		return false;

	});

	



	$('#enviarSabor').click(function () {		

		//Get the data from all the fields

		var email_de = $('input[name=mail_de]');

		var email_para = $('input[name=mail_para]');

		var mensaje = $('textarea[name=mensaje]');

		var lnk = $('input[name=link]');
		
		var titulo_producto =  $('input[name=titulo_producto]');

		var foto = $('input[name=foto]');
		
		var descripcion =  $('input[name=descripcion]');


		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_de.val()))

		{

			email_de.removeClass('errorMail');

		}else

		{

			email_de.addClass('errorMail');

			return false;

		}

		

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_para.val()))

		{

			email_para.removeClass('errorMail');

		}else

		{

			email_para.addClass('errorMail');

			return false;

		}

		

		if (mensaje.val()=='') {

			mensaje.addClass('errorMail');

			return false;

		} else mensaje.removeClass('errorMail');

		//organize the data properly

		var data = 'titulo_producto=' + titulo_producto.val() + '&foto=http://www.busymindstudio.com/clientes/22dg/munchis/site/admin/uploads/' + foto.val() +'&descripcion=' + descripcion.val() +'&email_de=' + email_de.val() + '&email_para=' + email_para.val() + '&link=' + encodeURIComponent(lnk.val()) + '&mensaje='  + encodeURIComponent(mensaje.val());


	// var data = 'titulo_producto=ttt' + '&email_de=' + email_de.val() + '&email_para=' + email_para.val() + '&link=' + encodeURIComponent(lnk.val()) + '&mensaje='  + encodeURIComponent(mensaje.val());


		//disabled all the text fields

		//$('.text').attr('disabled','true');

		

		//show the loading sign

		//$('.loading').show();

		

		//start the ajax

		$.ajax({

			//this is the php file that processes the data and send mail

			url: "async/sendMailSabor.php",	

			//GET method is used

			type: "GET",

			//pass the data			

			data: data,		

			//Do not cache the page

			cache: false,

			//success

			success: function (html) {				

				//if process.php returned 1/true (send mail success)

				if (html==1) {					

					$('#ventana_contale').fadeOut('slow');

					$('#graciasContacto').fadeIn('slow');

					$('#graciasContacto').fadeOut(4000);

				//if process.php returned 0/false (send mail failed)

				} else alert('Error, por favor intente mas tarde.');				

			}		

		});

		//cancel the submit button default behaviours

		return false;

	});

	

	$('#enviarDelicia').click(function () {	

		//Get the data from all the fields

		var email_de = $('input[name=mail_de]');

		var email_para = $('input[name=mail_para]');

		var mensaje = $('textarea[name=mensaje]');

		var lnk = $('input[name=link]');



		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_de.val()))

		{

			email_de.removeClass('errorMail');

		}else

		{

			email_de.addClass('errorMail');

			return false;

		}

		

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_para.val()))

		{

			email_para.removeClass('errorMail');

		}else

		{

			email_para.addClass('errorMail');

			return false;

		}

		

		if (mensaje.val()=='') {

			mensaje.addClass('errorMail');

			return false;

		} else mensaje.removeClass('errorMail');

		//organize the data properly

		// var data = 'email_de=' + email_de.val() + '&email_para=' + email_para.val() + '&link=' + lnk.val() + '&mensaje='  + encodeURIComponent(mensaje.val());


		var data = 'email_de=' + email_de.val() + '&email_para=' + email_para.val() + '&link=' + encodeURIComponent(lnk.val()) + '&mensaje='  + encodeURIComponent(mensaje.val());


		//disabled all the text fields

		//$('.text').attr('disabled','true');

		

		//show the loading sign

		//$('.loading').show();

		

		//start the ajax

		$.ajax({

			//this is the php file that processes the data and send mail

			url: "async/sendMailDelicia.php",	

			//GET method is used

			type: "GET",

			//pass the data			

			data: data,		

			//Do not cache the page

			cache: false,

			//success

			success: function (html) {				

				//if process.php returned 1/true (send mail success)

				if (html==1) {					

					$('#ventana_contale').fadeOut('slow');

					$('#graciasContacto').fadeIn('slow');

					$('#graciasContacto').fadeOut(4000);

				//if process.php returned 0/false (send mail failed)

				} else alert('Error, por favor intente mas tarde.');				

			}		

		});

		//cancel the submit button default behaviours

		return false;

	});

	

	$('#enviarSucursal').click(function () {	

		//Get the data from all the fields

		var email_de = $('input[name=mail_de]');

		var email_para = $('input[name=mail_para]');

		var mensaje = $('textarea[name=mensaje]');


		var foto = $('input[name=foto]');
		var fotomapa = $('input[name=fotomapa]');
		var nombre = $('input[name=nombre]');
		var descripcion = $('input[name=descripcion]');
		var zonadelivery = $('input[name=zonadelivery]');


		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_de.val()))

		{

			email_de.removeClass('errorMail');

		}else

		{

			email_de.addClass('errorMail');

			return false;

		}

		

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_para.val()))

		{

			email_para.removeClass('errorMail');

		}else

		{

			email_para.addClass('errorMail');

			return false;

		}

		

		if (mensaje.val()=='') {

			mensaje.addClass('errorMail');

			return false;

		} else mensaje.removeClass('errorMail');

		//organize the data properly

		var data = 'email_de=' + email_de.val() + '&email_para=' + email_para.val()+ '&zonadelivery=' + zonadelivery.val()+ '&descripcion=' + descripcion.val()+ '&nombre=' + nombre.val()+ '&fotomapa=' + fotomapa.val()+ '&foto=' + foto.val() + '&mensaje='  + encodeURIComponent(mensaje.val());

		//alert(data);

		/*
		var foto = $('input[name=foto]');
		var fotomapa = $('input[name=fotomapa]');
		var nombre = $('textarea[name=nombre]');
		var descripcion = $('input[name=descripcion]');
		var zonadelivery = $('textarea[name=zonadelivery]');
		*/

		//disabled all the text fields

		//$('.text').attr('disabled','true');

		

		//show the loading sign

		//$('.loading').show();

		

		//start the ajax

		$.ajax({

			//this is the php file that processes the data and send mail

			url: "async/sendMailSucursal.php",	

			//GET method is used

			type: "GET",

			//pass the data			

			data: data,		

			//Do not cache the page

			cache: false,

			//success

			success: function (html) {				

				//if process.php returned 1/true (send mail success)

				if (html==1) {					

					$('#ventana_contale').fadeOut('slow');

					$('#graciasContacto').fadeIn('slow');

					$('#graciasContacto').fadeOut(4000);

				//if process.php returned 0/false (send mail failed)

				} else alert('Error, por favor intente mas tarde.');				

			}		

		});

		//cancel the submit button default behaviours

		return false;

	});

	

	$('#enviarContacto').click(function () {		

		//Get the data from all the fields

		var nombre = $('input[name=nombre]');

		var mail = $('input[name=mail]');

		var mensaje = $('textarea[name=mensaje]');



		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail.val()))

		{

			mail.removeClass('errorMail');

		}else

		{

			mail.addClass('errorMail');

			return false;

		}

		

		if (mensaje.val()=='') {

			mensaje.addClass('errorMail');

			return false;

		} else mensaje.removeClass('errorMail');

		//organize the data properly

		var data = 'nombre=' + nombre.val() + '&mail=' + mail.val() + '&mensaje='  + encodeURIComponent(mensaje.val());

		//disabled all the text fields

		//$('.text').attr('disabled','true');

		

		//show the loading sign

		//$('.loading').show();

		

		//start the ajax

		$.ajax({

			//this is the php file that processes the data and send mail

			url: "async/sendContacto.php",	

			//GET method is used

			type: "GET",

			//pass the data			

			data: data,		

			//Do not cache the page

			cache: false,

			//success

			success: function (html) {				

				//if process.php returned 1/true (send mail success)

				if (html==1) {					

					document.location.href = 'contacto2.php';					

				//if process.php returned 0/false (send mail failed)

				} else alert('Error, por favor intente mas tarde.');				

			}		

		});

		//cancel the submit button default behaviours

		return false;

	});

});	











function validarFormulario()

{

	var nombre = $('input[name=nombre]');

	var apellido = $('input[name=apellido]');

	var email = $('input[name=email]');

	

	if (nombre.val()=='') {

			nombre.addClass('errorMail');

			return false;

		} else nombre.removeClass('errorMail');



	if (apellido.val()=='') {

			apellido.addClass('errorMail');

			return false;

	} else apellido.removeClass('errorMail');



	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.val()))

	{

		email.removeClass('errorMail');

	}else

	{

		email.addClass('errorMail');

		return false;

	}

	

	var data = 'email=' + email.val();

	

	$.ajax({

		//this is the php file that processes the data and send mail

		url: "async/valEmail.php",	

		//GET method is used

		type: "POST",

		//pass the data			

		data: data,		

		//Do not cache the page

		cache: false,

		//success

		success: function (html) {				

			//if process.php returned 1/true (send mail success)

			if (html==1) {					

				$('#xform').submit();

			//if process.php returned 0/false (send mail failed)

			} else alert('La direccion de Email ya esta registrada.');				

		}		

	});

}





function validarFormularioPaso2()

{

	var nombre = $('input[name=nombre]');

	var apellido = $('input[name=apellido]');

	var email = $('input[name=email]');

	var nombreUsuario = $('input[name=nombreUsuario]');

	var passUsuario = $('input[name=passUsuario]');

	

	if (nombreUsuario.val()=='') {

			nombreUsuario.addClass('errorMail');

			return false;

		} else nombreUsuario.removeClass('errorMail');



	if (passUsuario.val()=='') {

			passUsuario.addClass('errorMail');

			return false;

	} else passUsuario.removeClass('errorMail');

	

	var data = 'user=' + nombreUsuario.val();

	

	$.ajax({

		//this is the php file that processes the data and send mail

		url: "async/valUser.php",	

		//GET method is used

		type: "POST",

		//pass the data			

		data: data,		

		//Do not cache the page

		cache: false,

		//success

		success: function (html) {				

			//if process.php returned 1/true (send mail success)

			if (html==1) {					

				$('#xform2').submit();

			//if process.php returned 0/false (send mail failed)

			} else alert('El Nombre de Usuario ya esta registrado.');				

		}		

	});

}







function validarFormularioPaso3()

{

	var nombre = $('input[name=nombre]');

	var apellido = $('input[name=apellido]');

	var email = $('input[name=email]');

	var nombreUsuario = $('input[name=nombreUsuario]');

	var passUsuario = $('input[name=passUsuario]');

	var masculino = $('input[name=sexoM]');

	var femenino = $('input[name=sexoF]');

	var dia = $('select[name=formDia]');

	var mes = $('select[name=formMes]');

	var anio = $('select[name=formAnio]');

	var terminos = $('input[name=acepto]');



	if(!terminos.attr("checked"))

	{

		alert('Acepte los terminos y condiciones');

		return false;

	}

	

	if(masculino.val() == 'undefined')

	{

		sexo = 'F';

	}else

	{

		sexo = 'M';

	}

	

	var data = 'nombre=' + nombre.val() + '&apellido=' + apellido.val() + '&email='  + email.val() + '&nombreUsuario='  + nombreUsuario.val() + '&passUsuario='  + passUsuario.val() + '&sexo='  + sexo  + '&dia='  + dia.val()  + '&mes='  + mes.val()  + '&anio='  + anio.val();

	

	$.ajax({

		//this is the php file that processes the data and send mail

		url: "async/sendRegistro.php",	

		

		//GET method is used

		type: "POST",



		//pass the data			

		data: data,		

		

		//Do not cache the page

		cache: false,

		

		//success

		success: function (html) {				



			//if process.php returned 1/true (send mail success)

			if (html==1) {					

				//hide the form

				//$('.form').fadeOut('slow');					

				//document.getElementById('ventana_contale').style.display="none";

				//show the success message

				//$('.done').fadeIn('slow');

				alert('Gracias por registrarte. En unos instantes recibiras un mail para completar el proceso.');

				document.location.href = 'index.php';

			//if process.php returned 0/false (send mail failed)

			} else alert('Error, por favor intente mas tarde.');				

		}		

	});

}
