$(document).ready(function() { 	 
		
          $("#uploadfile").change( function() {	
              //Check to see if it's a PDF
			  var file = $(this).val();
			  dots = file.split(".")
			  //get the part AFTER the LAST period.
			  var fileType = "." + dots[dots.length-1];
			  if (fileType !== ".pdf"){
				  $("label.errorText1").prev().css("display", "none");
				  $("label.errorText1").css("display", "block"); }
			  else { $("label.errorText1").css("display", "none"); }
			  
			  //Verify it's file size
              var size;			  
			  if (navigator.appName == 'Microsoft Internet Explorer') {
			      //console.log("Calculating size for IE");
			      var myFSO = new ActiveXObject("Scripting.FileSystemObject");
	              var filepath = $(this).val();
	              var thefile = myFSO.getFile(filepath);
	              size = thefile.size;
			  } else {
			      //console.log("Calculating size for non-IE");
			      var node = $('#uploadfile').get(0);
                  size = node.files[0].fileSize;
			  }
              console.info("File size is ", size);  
              if (size >= 41768 && fileType == ".pdf") {
			  //1048576) {
			      $("label.errorText1").prev().css("display", "none");
                  $("label.errorText2").css("display", "block");
              } else {
                  $("label.errorText2").css("display", "none");
              }						  			  
          });	  
		  
	      $("#form1").validate({ 
	        rules: {           
		      upfile: { 
	              required: true 
	          },
	        }, 	        
	      }); 
});  
