		//* FormCheck
		//* Used to check required field in a Form
		//* Boolean, returns false when a required field is not filled
				
		function FormCheck(formobj){
			// Enter name of mandatory fields
			var fieldRequired = Array("fmContactNombre", "fmContactEmail", "fmContactComentario", "fmChatNombre", "fmChatComentario", "fmInvitarAmigoNombre", "fmInvitarAmigoEmail", "fmInvitarTuNombre", "fmInvitarTuEmail", "fmComentarioNombre", "fmComentarioTexto", "fm_email", "fm_file", "fm_Nombre", "fmFotoCategoria", "fm_Descripcion", "fmTitulo", "fmFechaInicio", "fmFechaFinal", "fmTipoPublicacion", "textarea1", "nombre", "nombre_usuario", "newpassword", "c_newpassword", "fmKey");
			// Enter field description to appear in the dialog box
			var fieldDescription = Array("Nombre", "Email", "Comentario", "Nombre", "Mensaje", "Nombre de tu amig@", "Email de tu Amig@", "Tu nombre", "Tu email", "Nombre", "Comentario", "Email", "Seleccione fotografia", "Nombre de la fotografia", "Categoria de la Fotografia", "Descripcion de la Fotografia", "Titulo", "Fecha Inicio", "Fecha Final", "Tipo Publicacion", "Texto", "Nombre", "Email(Nombre de Usuario)", "Clave", "Confirmacion de Clave", "Codigo de Seguridad");
			// dialog message
			var alertMsg = "Por favor complete los siguientes campos:\n";

			var l_Msg = alertMsg.length;
			for (var i = 0; i < fieldRequired.length; i++){
				var obj = formobj.elements[fieldRequired[i]];
				if (obj){
					switch( obj.type ){
						case "select-one":
							if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" || obj.options[obj.selectedIndex].text == "NONE"){
								alertMsg += " - " + fieldDescription[i] + "\n";
							}
							break;
						case "select-multiple":
							if (obj.selectedIndex == -1){
								alertMsg += " - " + fieldDescription[i] + "\n";
							}
							break;
						case "text":
							if ( (obj.value == "" || obj.value == null) && obj.disabled == false ) {
								alertMsg += " - " + fieldDescription[i] + "\n";
							}
							break;
						case "hidden":
							if (obj.value == "" || obj.value == null){
								alertMsg += " - " + fieldDescription[i] + "\n";
							}
							break;
						case "textarea":
							if (obj.value == "" || obj.value == null){
								alertMsg += " - " + fieldDescription[i] + "\n";
							}
							break;
						default:
					}
					if (obj.type == undefined){
						var blnchecked = false;
						for (var j = 0; j < obj.length; j++){
							if (obj[j].checked){
								blnchecked = true;
							}
						}
						if (!blnchecked){
							alertMsg += " - " + fieldDescription[i] + "\n";
						}
					}
				}
			}

			if (alertMsg.length == l_Msg){
				return true;
			}else{
				alert(alertMsg);
				return false;
			}
		}

		function validateEmailAddress ( email )
		{
			var str = email
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

			if ( filter.test(str) )
			{
				return true;
			}
			else
			{
				if ( email != '' ) { alert("Por favor increse una direccion de correo valida!") }
				return false;
			}
		}

		function GetXmlHttpObject1()
		{ 
			var objXMLHttp=null
			if (window.XMLHttpRequest)
			{
				objXMLHttp=new XMLHttpRequest();
				//objXMLHttp.overrideMimeType('text/xml');
				//objXMLHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			}
			else if (window.ActiveXObject)
			{
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
			}
			return objXMLHttp
		}

		function insertCommentAjax( nombre, comentario )
		{ 
			var myvar;
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
			//return false;
			var url="insertarChat.php";
			url=url+"?nombre="+nombre+"&comentario="+comentario;
			url=url+"&sid="+Math.random();

			xmlHttp.open("GET",url,false);
			xmlHttp.send(null);
		}
		
		function insertEncuesta( encuesta_id, label, voto )
		{ 
			var myvar;
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
			//return false;
			var url="insertarEncuesta.php";
			url=url+"?label="+label+"&encuesta_id="+encuesta_id+"&voto="+voto;
			url=url+"&sid="+Math.random()

			xmlHttp.open("GET",url,false);
			xmlHttp.send(null);
			
			//document.write(xmlHttp.responseText);
			
			if ( xmlHttp.responseText == 0 )
			{
				alert('Muchas gracias por compartir con nosotros su sentir. \n Si desea ver los resultados, favor haga click en `Ver resultados`');
			}
			else
			{
				alert('Este voto no sera tomado en cuenta, porque ya habia votado por esta encuesta, \nmantengase informado de los resultados, haciendo click en `Ver resultados`');
			}
		}
		
		
		function refrescarFoto ( nombre, ruta, objeto, orientacion, id )
		{
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
			//return false;
			var url="refrescarFoto.php";
			url=url+"?nombre="+nombre+"&ruta="+ruta+"&orientacion="+orientacion+"&id="+id;
			url=url+"&sid="+Math.random()

			xmlHttp.open( "GET", url, false );
			xmlHttp.send(null);
			//alert(xmlHttp.responseText)
			document.getElementById(objeto).innerHTML = null
			document.getElementById(objeto).innerHTML = xmlHttp.responseText;
		}
		
		function validarCaracteres(e) {
			tecla=(document.all) ? e.keyCode : e.which;
			if(tecla<30 || tecla>122)
			if(tecla!=8)// BackSpace
			if(tecla!=0)// DEL
			return false;
		}
		
		function validarCaracteresEnter(e) {
			tecla=(document.all) ? e.keyCode : e.which;
			if(tecla<30 || tecla>122)
			if(tecla!=8)// BackSpace
			if(tecla!=13)// Enter
			if(tecla!=0)// DEL
			return false;
		}

		//hiddeshowinfo
		function hiddeshowinfo( list, label, strhidde, strshow ) {
			var hidde = "<label onmouseover=\"this.style.cursor='pointer';\"><img src = 'images/collapse.gif'>&nbsp;";
			var show = "<label onmouseover=\"this.style.cursor='pointer';\"><img src = 'images/expand.gif'>&nbsp;";

			if ( strhidde == "A" ) { hidde += "<a href = '#comentarios'>Ocultar Comentarios</a>"; }
			if ( strhidde == "C" ) { hidde += "<a href = '#foto'>Ocultar Busqueda de Fotografias</a>"; }
			if ( strhidde == "E" ) { hidde += "<a href = '#foto'>Ocultar detalles de la Foto</a>"; }
			if ( strhidde == "G" ) { hidde += "<a href = '#foto'>Ocultar Comentarios</a>"; }

			hidde += "</label>";

			if ( strshow == "B" ) { show += "<a href = '#comentarios'>Mostrar Comentarios</a>"; }
			if ( strshow == "D" ) { show += "<a href = '#foto'>Buscar Fotografias</a>"; }
			if ( strshow == "F" ) { show += "<a href = '#foto'>Ver detalles de la Foto</a>"; }
			if ( strshow == "H" ) { show += "<a href = '#foto'>Ver Comentarios</a>"; }
			show += "</label>";

			    if (document.getElementById(list).style.display == 'none') {
				document.getElementById(label).innerHTML = hidde;
				document.getElementById(list).style.display='';
				document.getElementById(label).style.color = '#FF0000';
			    } else {
				document.getElementById(label).innerHTML = show;
				document.getElementById(list).style.display='none';
				document.getElementById(label).style.color = '#000000';
			    }
		}
		
	function populateArrays( )
		{

			ids = typeof(ids) != 'undefined' ? ids : ids = new Array();
			values = typeof(values) != 'undefined' ? values : values = new Array();

			// assign the default values to the items in the values array
			for ( var i = 0; i < ids.length; i++ )
			{
				var elem = document.getElementById(ids[i]);

				if (elem)
					if (elem.type == 'checkbox' || elem.type == 'radio')
					values[i] = elem.checked;
					else
					values[i] = elem.value;
			}

		}
		 
		  function confirmExit()
		  {
			var alertMsg = "";

			ids = typeof(ids) != 'undefined' ? ids : ids = new Array();
			values = typeof(values) != 'undefined' ? values : values = new Array();

			if ( needToConfirm )
			{
				// check to see if any changes to the data entry fields have been made
				for (var i = 0; i < values.length; i++)
				{
						var elem = document.getElementById(ids[i]);
						if (elem)
						{
						if ((elem.type == 'checkbox' || elem.type == 'radio') && values[i] != elem.checked)
						{
							alertMsg += "\n       * " + labels[i];
						}
						else if (!(elem.type == 'checkbox' || elem.type == 'radio') && elem.value != values[i])
						{
							//document.getElementById(ids[i]).style.backgroundColor="#FBFFA9";
							alertMsg += "\n       * " + labels[i];
						}
						}
				}

				if (alertMsg.length > 0)
				{
					return "ALERTA: Has realizado cambios que aun no has grabado!!!\n" + alertMsg;
				}
				// no changes - return nothing
			}
		  }

		function ajax_query_exec ( query, redirect )
		{
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 

			redirect = typeof(redirect) != 'undefined' ? redirect : false;

			if ( query != "" && query != null )
			{
				var url="/includes/ajax_query_exec.php?query=" + query;
				xmlHttp.open("GET",url,false)
				xmlHttp.send(null)

				//if ( xmlHttp.responseText != "" ) alert(xmlHttp.responseText);
				if ( redirect != false )  window.location.href = redirect;
			}
		}

		function ajax_query_select ( query )
		{
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 

			if ( query != "" && query != null )
			{
				var url="/includes/ajax_query_select.php?query=" + query;
				xmlHttp.open("GET",url,false)
				xmlHttp.send(null)

				return xmlHttp.responseText;
			}
		}
		
		function checkdaterange ( dateObj, validDays, futureDays, cleanField, msg )
		{
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			}

			futureDays = typeof(futureDays) != 'undefined' ? futureDays : false;
			cleanField = typeof(cleanField) != 'undefined' ? cleanField : true;
			msg = typeof(msg) != 'undefined' ? msg : '';

			var date = document.getElementById(dateObj).value;
			var days = 0;

			if ( date.length > 0 && date.length < 10 )
			{
				alert("Incorrect Date Format mm/dd/yyyy");
				document.getElementById(dateObj).value = null;
				return false;
			}

			if ( date != "" )
			{
				var url="../includes/validateDate.php?date=" + date;
				xmlHttp.open("GET",url,false)
				xmlHttp.send(null)
				
				validDays = parseInt( validDays, 10 );
				days = xmlHttp.responseText;

				//if ( xmlHttp.responseText == '' || xmlHttp.responseText < 0 || ( xmlHttp.responseText > validDays )  )
				if ( futureDays == false )
				{
					if ( days == '' || days <= 0 || days > validDays )
					{
						if ( msg != '' ) alert(msg);
						else alert("Invalid Date");

						if ( cleanField == true ) document.getElementById(dateObj).value = '';
					}
				}
				else
				{
					days = (days * -1);
					if ( validDays < 0 ) validDays = ( validDays * - 1 );

					if ( ( days < 0 && (days > validDays) ) || ( days == '' || days <= 0 ) )
					{
						if ( msg != '' ) alert(msg);
						else alert("Invalid Date");

						if ( cleanField == true ) document.getElementById(dateObj).value = '';
					}
				}
			}
		}
		
		function countDays ( dateObj )
		{
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			}

			var date = document.getElementById(dateObj).value;

			if ( date != "" )
			{
				var url="../includes/validateDate.php?date=" + date;
				xmlHttp.open("GET",url,false)
				xmlHttp.send(null)
				return xmlHttp.responseText;
			}else
			{
				return 0;
			}
		}

function ajax_query_exec ( query )
		{
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 

			if ( query != "" && query != null )
			{
				var url="/includes/ajax_query_exec.php?query=" + query;
				url=url+"&sid="+Math.random();
				xmlHttp.open("GET",url,false)
				xmlHttp.send(null)

				//if ( xmlHttp.responseText != "" ) alert(xmlHttp.responseText);
			}
		}

		function ajax_query_select ( query )
		{
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 

			if ( query != "" && query != null )
			{
				var url="/includes/ajax_query_select.php?query=" + query;
				url=url+"&sid="+Math.random();
				xmlHttp.open("GET",url,false)
				xmlHttp.send(null)

				//if ( xmlHttp.responseText != "" ) alert(xmlHttp.responseText);
				return xmlHttp.responseText;
			}
		}

		function resetpassword ( username )
		{
		
			xmlHttp=GetXmlHttpObject1()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			}

			var sql = "SELECT COUNT(*) FROM usuarios WHERE activa = 1 AND nombre_usuario = `" +  username + "`";
			var exists = ajax_query_select ( sql );
			
			if ( exists >= 1 )
			{
					var url="/includes/reset_password.php?username=" + username;
					url=url+"&sid="+Math.random();
					xmlHttp.open("GET",url,false)
					xmlHttp.send(null)	
					
					return true;
			}
			else return false;
		}

