/* When the user clicks on the button, 
toggle between hiding and showing the dropdown content */
function Menu(men) {
  document.getElementById(men).classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
  if (!event.target.matches('.dropbtn')) {
    var dropdowns = document.getElementsByClassName("dropdown-content");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('show')) {
        openDropdown.classList.remove('show');
      }
    }
  }
}
// Responsive resize
function myFunction() {
  var x = document.getElementById("myTopnav");
  if (x.className === "topnav") {
    x.className += " responsive";
  } else {
    x.className = "topnav";
  }
}
function upload_file(){
				var inputFileImage = document.getElementById("datafile");
				var file = inputFileImage.files[0];
				if( (typeof file === "object") && (file !== null) )
				{
					var data = new FormData();
					data.append('datafile',file);
					$.ajax({
					url: "cvguardar.php",        // Url to which the request is send
						type: "POST",             // Type of request to be send, called as method
						data: data,			  // Data sent to server, a set of key/value pairs (i.e. form fields and values)
						contentType: false,       // The content type used when sending data to the server.
						cache: false,             // To unable request pages to be cached
						processData:false,        // To send DOMDocument or non processed data file it is set to false
						            xhr: function () {
                var xhr =  new XMLHttpRequest();
                xhr.upload.addEventListener("progress", function (evt) {
                    if (evt.lengthComputable) {
                        var percentComplete = evt.loaded / evt.total;
                        percentComplete = parseInt(percentComplete * 100);
                        //console.log(percentComplete);
                        $('progress').val(percentComplete);  
                    }
                }, false);
                return xhr;
            },
						success: function(data)   // A function to be called if request succeeds
						{
							$("#archivopdf").html(data);
						}
					});	
				}
			}