/*----------------------------------------------------------------
 TELEMAX - Job Script File.
 ----------------------------------------------------
 designed by  :: 3W Ideas :: digital agency
 ----------------------------------------------------
 www.3w.com.uy
 Jan 1st, 2010,  Montevideo. Uruguay.
 ----------------------------------------------------------------*/
jQuery(function(){
	
	
	jQuery("#btnEnviarEmpleo").click(function(){
		var enviar = true;
		
		jQuery(".filefieldEmpleo, .textfieldEmpleo").each(function(){
		
			if(jQuery(this).attr("title") == jQuery(this).val() || jQuery(this).val().trim() == ""){
					jQuery(this).css("border","1px solid red");
					enviar = false;
			}else{
				jQuery(this).css("border","1px solid #5a7723");
			}
			
		});
	
		
		if(enviar){
			jQuery("#frmEmpleo").submit();
		}else{
			alert("Rellene todos los campos requeridos.")
			return false;
		}
	});

	// File Handler Subir Cv (DOC, PDF)
	new AjaxUpload('btnSubirCv', {		  
		  action: './ajax/file_handler.php?type=cv_job',
		  name: 'fileCv',
		  autoSubmit: true,
		  responseType: false,
		  onChange: function(file, extension){},
		  onSubmit: function(file, extension) {
		  	if(extension == "doc" || extension =="pdf"){
				jQuery("#txtCv").val(file);		
			}else{
				alert("Extension de archivos no soportada, solo utilice .pdf o .doc");	
				jQuery("#txtCv").val(jQuery("#txtCv").attr("title"));
				return false;
			}			
		  },
		  onComplete: function(file, response) {
					
		  }	  
	});
	
	// File Handler Subir Foto Carnet (JPG ONLY)
	new AjaxUpload('btnFotoCarnet', {
		  action: './ajax/file_handler.php?type=photo_job',
		  name: 'filePhoto',
		  autoSubmit: true,
		  responseType: false,
		  onChange: function(file, extension){},
		  onSubmit: function(file, extension) {
		  	if(extension == "jpg" || extension == "jpeg"){
				jQuery("#txtFotoCarnet").val(file);		
			}else{
				alert("Extension de archivos no soportada, solo utilice .jpg");	
				jQuery("#txtFotoCarnet").val(jQuery("#txtFotoCarnet").attr("title"));
				return false;
			}	
		  },
		  onComplete: function(file, response) {
					
		  }	  
	});
	
});
