$(document).ready(function (){
							
	$("img.rolloverimagen").mouseover(function (){
			var newImage = $(this).attr('src').replace(/^(.*?)(\.(?:gif|jpg|png))$/, "$1_over$2");
			$(this).attr('src', newImage);
	});
	$("img.rolloverimagen").mouseout(function (){
			var newImage = $(this).attr('src').replace('_over', '');
			$(this).attr('src', newImage);
	});

	if (navigator.appName.toLowerCase().indexOf("explorer") != -1) { 
		Hideframe='yes'; 
	} else if (navigator.appName.toLowerCase().indexOf("netscape") != -1) {
		Hideframe='no';
	} else {
		Hideframe='yes';
	}
							
	$("#ver_guia_aplicacion").click(function (){
		$("#guia").css({ display: "inline" });
	});
	$(".cerrar_guia").click(function (){
		$("#guia").css({ display: "none" });
	});
	
	$("#b_avisos").click(function (){
		$("#avisos").css({ display: "none" });
	});
	$("#b_avisos_close").click(function (){
		$("#avisos").css({ display: "none" });
	});
	
		
	$("#link_registro").click(muestra_capa);
	
	$("#b_cerrar_registro").click(function (){
		$("#sec_registro").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_registro").css({ display: "none" });
		}
	});

	$("#link_ident").click(function (){
		$("#sec_ident").css({ display: "block" });
		if (Hideframe=='yes'){
			$("#iframe_sec_ident").css({ display: "block" });
		}
	});
	$("#link_franchise").click(function (){
				
		$("#sec_franchise").css({ display: "block" });
		if (Hideframe=='yes'){
			$("#iframe_sec_franchise").css({ display: "block" });
		}
	});
	
	
	$("#cerrar_sec_franchise").click(function (){
		$("#sec_franchise").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_franchise").css({ display: "none" });
		}
	});
	
	$("#link_work").click(function (){
				
		$("#sec_work").css({ display: "block" });
		if (Hideframe=='yes'){
			$("#iframe_sec_work").css({ display: "block" });
		}
	});
	
	
	$("#cerrar_sec_work").click(function (){
		$("#sec_work").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_work").css({ display: "none" });
		}
	});
	
	$("#cerrar_sec_ident").click(function (){
		$("#sec_ident").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_ident").css({ display: "none" });
		}
	});
	$("#cerrar_sec_ident_express").click(function (){
		$("#sec_ident_express").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_ident_express").css({ display: "none" });
		}
	});
	
	$("#link_reg_express").click(function (){				
		$("#sec_reg_express").css({ display: "block" });
		$("#sec_ident_express").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_reg_express").css({ display: "block" });
		}
	});
	
	$("#cerrar_sec_reg_express").click(function (){
		$("#sec_reg_express").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_reg_express").css({ display: "none" });
		}
	});
	
	$("#link_ident_press").click(function (){
		$("#sec_ident_press").css({ display: "block" });
		if (Hideframe=='yes'){
			$("#iframe_sec_ident_press").css({ display: "block" });
		}
	});

	$("#cerrar_sec_ident_press").click(function (){
		$("#sec_ident_press").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_ident_press").css({ display: "none" });
		}
	});
	
	$(".capa_enviar").click(function (){
		$("#sec_envio").css({ display: "block" });
		if (Hideframe=='yes'){
			$("#iframe_sec_envio").css({ display: "block" });
		}
	});
	
	$(".capa_enviar_my").click(function (){
		$("#sec_envio_my").css({ display: "block" });
		if (Hideframe=='yes'){
			$("#iframe_sec_envio_my").css({ display: "block" });
		}
	});

	$("#cerrar_sec_envio").click(function (){
		$("#sec_envio").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_envio").css({ display: "none" });
		}
	});
	
	$("#cerrar_sec_envio_b").click(function (){
		$("#sec_envio_my").css({ display: "none" });
		if (Hideframe=='yes'){
			$("#iframe_sec_envio_my").css({ display: "none" });
		}
	});
	
	$("#regknowSalonOff").click(function (){
		$("#regsalonid").css({ display: "none" });
	});	
	$("#regknowSalonOn").click(function (){
		$("#regsalonid").css({ display: "block" });
	});		
	
	$("#registro_sec_ident").click(function (){
		$("#sec_ident").css({ display: "none" });
		$("#sec_registro").css({ display: "block" });
			xt_med('C','1','REGISTER::INIT::'+xtpage);

		if (Hideframe=='yes'){
			$("#iframe_sec_ident").css({ display: "none" });
			$("#iframe_sec_registro").css({ display: "block" });
		}
	});
	
	$("#loginsubmit").click(submitformLogin);  
	$("#loginsubmitemailfranchise").click(submitformFranchise);  
	$("#loginsubmitemailwork").click(submitformWork);  
	$("#loginsubmitexpress").click(submitformLoginExpress);  
	$("#registersubmit").click(submitformRegister);
	$("#registersubmitexpress").click(submitformRegisterExpress);
	$("#viralsubmit").click(submitformViral);   
	$("#viralsubmit_me").click(submitformViralMe);   
	$("#loginsubmitpress").click(submitformPress);   
	
    $(".controlkeysubmitLogin").keypress(function(e){
        var keyCode= e.keyCode? e.keyCode: e.which;
        if(keyCode==13){
             submitformLogin();
        }
    });	
    
    $(".controlkeysubmitFranchise").keypress(function(e){
        var keyCode= e.keyCode? e.keyCode: e.which;
        if(keyCode==13){
             submitformFranchise();
        }
    });	
    
    $(".controlkeysubmitWork").keypress(function(e){
        var keyCode= e.keyCode? e.keyCode: e.which;
        if(keyCode==13){
             submitformWork();
        }
    });	
    
    $(".controlkeysubmitpress").keypress(function(e){
        var keyCode= e.keyCode? e.keyCode: e.which;
        if(keyCode==13){        	
             submitformPress();
        }
    });

    if (_showwarning) {
        $("#avisos").css({ display: "inline" });
    }
});

function reloadPage() {
    self.location = self.location.href.replace("logout=1", "").replace("#", "");
}

function showEmailForm(id){
		if (navigator.appName.toLowerCase().indexOf("explorer") != -1) { 
			Hideframe='yes'; 
		} else if (navigator.appName.toLowerCase().indexOf("netscape") != -1) {
			Hideframe='no';
		} else {
			Hideframe='yes';
		}
		$("#iddoc").val(id);
		$("#sec_franchise").css({ display: "block" });
		if (Hideframe=='yes'){
			$("#iframe_sec_franchise").css({ display: "block" });
		}
}

function showEmailFormWork(id,isauth){
		if (navigator.appName.toLowerCase().indexOf("explorer") != -1) { 
			Hideframe='yes'; 
		} else if (navigator.appName.toLowerCase().indexOf("netscape") != -1) {
			Hideframe='no';
		} else {
			Hideframe='yes';
		}
		$("#iddoc_work").val(id);
		$("#isauth_work").val(isauth);
		$("#sec_work").css({ display: "block" });
		if (Hideframe=='yes'){
			$("#iframe_sec_work").css({ display: "block" });
		}
}

function showRegister() {
	document.getElementById('sec_ident').style.display = "none";
	document.getElementById('sec_registro').style.display = "block"
	xt_med('C','1','REGISTER::INIT::'+xtpage);
}

afterLogin = '';

function showLogin() {
	document.getElementById('sec_registro').style.display = "none"
	document.getElementById('sec_ident').style.display = "block";
}

function showLoginExpress() {	
	document.getElementById('sec_registro').style.display = "none"
	document.getElementById('sec_ident_express').style.display = "block";
			
}



function submitformLogin() {		
		
        var _email = document.getElementById('loginemail').value;        
        var _passw = document.getElementById('loginpassw').value;        
        var _xtor = document.getElementById('_xtor').value;
        var _errormsg_wronguser = document.getElementById('errormsg_wronguser').value;
        var _errormsg_fillvalues = document.getElementById('errormsg_fillvalues').value;
        
        if (_email!= '' && _email!='Nick' && _passw!='' && _passw!='Password')  {
            
            $.ajax({
               url: _base_path+"auth.php",
               type: "POST",
               dataType: "text",
               data: {email: _email, passw: _passw, xtor: _xtor},
               error: function(req, err, obj) {
                alert(err);
               },
               success: function(txt) {
                if (txt == "OK") {
                    if (afterLogin == '') reloadPage();
                    else {
                        self.location = afterLogin;
                    }
                }    
                else alert(_errormsg_wronguser);
               }
            });            
        } else {
            alert(_errormsg_fillvalues);
            document.getElementById('loginemail').focus();
        }
}

function submitformFranchise() {		
		
		var _ok = wbValidateFormL(document.getElementById('frmloginfranchise'),swlang);
		if (_ok){
        var _email = document.getElementById('loginemail_fr').value;        
        var _iddoc = document.getElementById('iddoc').value;        
                        
        
            $.ajax({
               url: _base_path+"sendFranchise.php",
               type: "POST",
               dataType: "text",
               data: {email: _email, iddoc: _iddoc},
               error: function(req, err, obj) {
                alert(err);
               },
               success: function(txt) {
                if (txt == "OK") {
                	alert("You will receive an email with the requested document.");
                    $("#sec_franchise").css({ display: "none" });
					if (Hideframe=='yes'){
						$("#iframe_sec_franchise").css({ display: "none" });
					}
                    
                }    
                else {
                	alert("An error occurred while sending the email. Please try again in a few minutes");
                	$("#sec_franchise").css({ display: "none" });
					if (Hideframe=='yes'){
						$("#iframe_sec_franchise").css({ display: "none" });
					}
                }
               }
            });            
	}
	return false;
}

function submitformWork() {		
		
		var _ok = wbValidateFormL(document.getElementById('frmloginwork'),swlang);
		if (_ok){
               
        var _moreinfo = (document.getElementById('frmloginwork').moreinfowork[0].checked)?'1':'0';
        var _isauth = document.getElementById('isauth_work').value;
        
        var _iddoc = document.getElementById('iddoc_work').value;  
                
       /* if (_isauth=='1'){
         	
         		$("#sec_work").css({ display: "none" });
					if (Hideframe=='yes'){
						$("#iframe_sec_work").css({ display: "none" });
				}
               window.open(_base_path+"download.php?doc="+_iddoc+"&work=1"); 
         }else {*/
         	var _email = document.getElementById('loginemail_work').value; 
                      
        
            $.ajax({
               url: _base_path+"sendWork.php",
               type: "POST",
               dataType: "text",
               data: {email: _email, iddoc: _iddoc, moreinfo: _moreinfo},
               error: function(req, err, obj) {
                alert(err);
               },
               success: function(txt) {
                if (txt == "OK") {
                	alert("You will receive an email with the requested document.");
                    $("#sec_work").css({ display: "none" });
					if (Hideframe=='yes'){
						$("#iframe_sec_work").css({ display: "none" });
					}
                    
                }    
                else {
                	alert("An error occurred while sending the email. Please try again in a few minutes");
                	$("#sec_work").css({ display: "none" });
					if (Hideframe=='yes'){
						$("#iframe_sec_work").css({ display: "none" });
					}
                }
               }
            }); 
         //}           
	}
	return false;
}

function submitformLoginExpress() {		
		
        var _email = document.getElementById('loginemail_ex').value;
       
        var _passw = document.getElementById('loginpassw_ex').value;
       
        var _xtor = document.getElementById('_xtor').value;
        var _errormsg_wronguser = document.getElementById('errormsg_wronguser').value;
        var _errormsg_fillvalues = document.getElementById('errormsg_fillvalues').value;
        
        if (_email!= '' && _email!='Nick' && _passw!='' && _passw!='Password')  {
            
            $.ajax({
               url: _base_path+"auth.php",
               type: "POST",
               dataType: "text",
               data: {email: _email, passw: _passw, xtor: _xtor},
               error: function(req, err, obj) {
                alert(err);
               },
               success: function(txt) {
                if (txt == "OK") {
                    if (afterLogin == '') reloadPage();
                    else {
       
                        self.location = afterLogin;
                    }
                }    
                else alert(_errormsg_wronguser);
               }
            });            
        } else {
            alert(_errormsg_fillvalues);
            document.getElementById('loginemail').focus();
        }
}


function submitformViral() {
		var _ok = wbValidateFormL(document.getElementById('frmviral'),swlang);
		var f = document.getElementById('frmviral');
		
		if(_ok) {
	        var toname = f.toname.value;
	        var fromname = f.fromname.value;
	        var toemail = f.toemail.value;
	        var fromemail = f.fromemail.value;
	        var url    = f.url.value; 
	        var section    = f.viral_section.value; 
	        var comentarios    = f.comentarios.value;  
	        var viralid    = f.viral_id.value; 
	        var messagesent    = f.messagesent.value; 
	        var error_email    = f.error_messagesent.value; 
	        
	        var xtor = f._xtor.value;
	        $.ajax({
	           url: _base_path+"viral.php",
	           type: "POST",
	           dataType: "xml",
	           data: {toname: toname, fromname: fromname, toemail: toemail, url: url, section: section, viralid: viralid, comentarios:comentarios, xtor: xtor,fromemail:fromemail},
	           error: function(req, err, obj) {
	            alert(err);
	           },
				success: function(xml) {
				   var ret = $(xml).find("ret").text();
				   if(ret == 'OK') {
				       alert(messagesent);
	                   document.location.href = url;
				   } else {
				       alert(error_email + ": " + ret + " - " + $(xml).find("code").text() );
				   }
				}
	        }); 	        
		}		
		
		
}

function submitformViralMe() {
		var _ok = wbValidateFormL(document.getElementById('frmviral_me'),swlang);
		var f = document.getElementById('frmviral_me');
		
		if(_ok) {
	        var toemail = f.toemail.value;
	        var url    = f.url.value; 
	        var section    = f.viral_section.value; 
	        var comentarios    = f.comentarios.value;  
	        var viralid    = f.viral_id.value; 
	        var messagesent    = f.messagesent.value; 
	        var error_email    = f.error_messagesent.value; 
	        
	        var xtor = f._xtor.value;
	        $.ajax({
	           url: _base_path+"viral.php",
	           type: "POST",
	           dataType: "xml",
	           data: {toemail: toemail, url: url, section: section, viralid: viralid, comentarios:comentarios, xtor: xtor},
	           error: function(req, err, obj) {
	            alert(err);
	           },
				success: function(xml) {
				   var ret = $(xml).find("ret").text();
				   if(ret == 'OK') {
				       alert(messagesent);
	                   document.location.href = url;
				   } else {
				       alert(error_email + ": " + ret + " - " + $(xml).find("code").text() );
				   }
				}
	        }); 	        
		}		
		
		
}
function muestra_capa (){
	$("#sec_registro").css({ display: "block" });
	xt_med('C','1','REGISTER::INIT::'+xtpage);

	if (Hideframe=='yes'){
		$("#iframe_sec_registro").css({ display: "block" });
	}
}

function submitformRegister() {
	
	var _ok = wbValidateFormL(document.getElementById('frmregister'),swlang);
	if(_ok) {
		
		var f = document.getElementById('frmregister');
		var _gender = (f.reggender[0].checked)?'F':'M';
        var _username = f.regusername.value;
        var _usersn = f.regusersn.value;
        var _email = f.regemail.value;
        var _mobile = f.regmobile.value;
        var _password = f.regpassword.value;
        var _password2 = f.regpassword2.value;
        var _postal_code = f.regpostal_code.value;
        var _birthdate_day = f.regbirthdate_dia.value;
        var _birthdate_month = f.regbirthdate_mes.value;
        var _birthdate_year = f.regbirthdate_anno.value;
        var _knowSalon = (f.regknowSalon[0].checked)?'1':'0';
        //var _salonid = f.regsalonid.options[f.regsalonid.selectedIndex].value;
        var _emailfriend = f.regemailfriend.value;
        var _nomoreinformation = (f.regnomoreinformation.checked)?'1':'0';
        var _conditions = (f.regconditions.checked)?'1':'0';
        var _xtor = f._xtor.value;
        var _msg_error_registerserviceproblem = f.error_registerserviceproblem.value;
        var _msg_error_registermandatoryfields = f.error_registermandatoryfields.value;
        var _msg_error_registeruserexists = f.error_registeruserexists.value;
        var _msg_thxforregistering = f.msg_thxforregistering.value;
        
        //if(_knowSalon!='1') _salonid='';
        $.ajax({
           url: _base_path+"register.php",
           type: "POST",
           dataType: "text",
           data: {gender: _gender, username: _username, usersn: _usersn, email: _email, mobile:_mobile, password: _password, password2: _password2, postal_code: _postal_code, birthdate_day: _birthdate_day, birthdate_month: _birthdate_month, birthdate_year: _birthdate_year, /*salonid: _salonid, */emailfriend: _emailfriend, nomoreinformation: _nomoreinformation, conditions: _conditions, xtor: _xtor},
           error: function(req, err, obj) {
            alert(err);
           },
           success: function(txt) {
            if (txt == "OK") {
                alert (_msg_thxforregistering);
				$("#sec_registro").css({ display: "none" });
                reloadPage();
            } else {
            	if (txt == "00") alert(_msg_error_registerserviceproblem);
            	else if (txt == "01") alert(_msg_error_registermandatoryfields);
            	else if (txt == "02") alert(_msg_error_registeruserexists);
            	else  alert(txt);
            }
           }
        });            
        
	}
	return(false);
}

function submitformRegisterExpress() {
	
	var _ok = wbValidateFormL(document.getElementById('frmregisterexpress'),swlang);
	if(_ok) {
		
		var f = document.getElementById('frmregisterexpress');				
        var _email = f.regemail.value;        
        var _password = f.regpassword.value;
        var _password2 = f.regpassword2.value;
        var _xtor = f._xtor.value;
        var _nomoreinformation = (f.regnomoreinformation.checked)?'1':'0';
        
        var _msg_error_registerserviceproblem = f.error_registerserviceproblem.value;
        var _msg_error_registermandatoryfields = f.error_registermandatoryfields.value;
        var _msg_error_registeruserexists = f.error_registeruserexists.value;
        var _msg_thxforregistering = f.msg_thxforregistering.value;
        
        $.ajax({
           url: _base_path+"register.php?type=express",
           type: "POST",
           dataType: "text",
           data: {email: _email, password: _password, password2: _password2, xtor: _xtor},
           error: function(req, err, obj) {
            alert(err);
           },
           success: function(txt) {
            if (txt == "OK") {            	
                alert (_msg_thxforregistering);
				$("#sec_registro_express").css({ display: "none" });									
                self.location = _base_path+"ShoppingBasket.html";
                
            } else {
            	if (txt == "00") alert(_msg_error_registerserviceproblem);
            	else if (txt == "01") alert(_msg_error_registermandatoryfields);
            	else if (txt == "02") alert(_msg_error_registeruserexists);
            	else  alert(txt);
            }
           }
        });

               
        
        
	}
	return(false);
}



function submitformPress(){
	
        var _passw = document.getElementById('loginpasswpress').value;
        var _error = document.getElementById('errormsg_wronguser').value;
        $.ajax({
     	
           url: _base_path+"loginpress.php",
           type: "POST",
           dataType: "text",
           data: {password: _passw },
           error: function(req, err, obj) {
            alert(err+":Password not valid");
           },
           success: function(txt) {
            if (txt == "OK") {
                self.location = "11Press.html";
            } else {
            	alert(txt);
            }
           }
        });  
    
	
}

function addEmploymentHist() {

	var field_area = document.getElementById('seccion1');
	
	
	//Contamos cuantos elementos tenemos de cada tipo
	var n_rows = $("#num_educa").val();
	var n_rows_plus = (n_rows * 1)+ 1 ;
	
	
	
	
	//Incrementamos el número de ternas de tres
	$("#num_educa").val(n_rows_plus);
	
	//Para los 8 campos
		
		
		var tr = document.createElement("tr");		
		tr.setAttribute('id', 'tr_educa_'+n_rows_plus); 				
						
		field_area.appendChild(tr);	
		
		var td1 = document.createElement("td");		
		td1.setAttribute('id', 'td_1_'+n_rows_plus); 				
		tr.appendChild(td1);
		
		var input1=document.createElement("input");		
		input1.className='input_mini'; 				
		input1.setAttribute('id', 'day_'+n_rows_plus); 				
		input1.setAttribute('maxlength', '2'); 				
		input1.setAttribute('type', 'text'); 				
		td1.appendChild(input1);
		
		var text1=document.createElement("label");	
		text1.setAttribute('id', 'label_1_'+n_rows_plus);	
		td1.appendChild(text1);
		$('#label_1_'+n_rows_plus).text('/');
		
		var input2=document.createElement("input");		
		input2.className='input_mini'; 				
		input2.setAttribute('id', 'month_'+n_rows_plus); 				
		input2.setAttribute('maxlength', '2'); 				
		input2.setAttribute('type', 'text'); 				
		td1.appendChild(input2);
		
		var text2=document.createElement("label");	
		text2.setAttribute('id', 'label_2_'+n_rows_plus);		
		td1.appendChild(text2);
		$('#label_2_'+n_rows_plus).text('/');
		
		var input3=document.createElement("input");		
		input3.className='input_mini_b'; 				
		input3.setAttribute('id', 'year_'+n_rows_plus);
		input3.setAttribute('maxlength', '4'); 				 				
		input3.setAttribute('type', 'text'); 				
		td1.appendChild(input3);
		
		
		var td2 = document.createElement("td");		
		td2.setAttribute('id', 'td_2_'+n_rows_plus); 				
		tr.appendChild(td2);
		
		var input4=document.createElement("input");		
		input4.className='input_mini'; 				
		input4.setAttribute('id', 'day_b_'+n_rows_plus); 
		input4.setAttribute('maxlength', '2'); 								
		input4.setAttribute('type', 'text'); 				
		td2.appendChild(input4);
		
		var text3=document.createElement("label");	
		text3.setAttribute('id', 'label_3_'+n_rows_plus);			
		td2.appendChild(text3);
		$('#label_3_'+n_rows_plus).text('/');
		
		var input5=document.createElement("input");		
		input5.className='input_mini'; 				
		input5.setAttribute('id', 'month_b_'+n_rows_plus); 				
		input5.setAttribute('maxlength', '2'); 				
		input5.setAttribute('type', 'text'); 				
		td2.appendChild(input5);
		
		var text4=document.createElement("label");		
		text4.setAttribute('id', 'label_4_'+n_rows_plus);			
		td2.appendChild(text4);
		$('#label_4_'+n_rows_plus).text('/');
		
		
		var input6=document.createElement("input");		
		input6.className='input_mini_b'; 				
		input6.setAttribute('id', 'year_b_'+n_rows_plus); 				
		input6.setAttribute('maxlength', '4'); 				
		input6.setAttribute('type', 'text'); 				
		td2.appendChild(input6);
		
		var td3 = document.createElement("td");		
		td3.setAttribute('id', 'td_3_'+n_rows_plus); 				
		tr.appendChild(td3);
		
		var input7=document.createElement("input");		
		input7.setAttribute('id', 'school_'+n_rows_plus); 				
		input7.setAttribute('type', 'text'); 				
		td3.appendChild(input7);
		
		var td4 = document.createElement("td");		
		td4.setAttribute('id', 'td_4_'+n_rows_plus); 				
		tr.appendChild(td4);
		
		var input8=document.createElement("input");		
		input8.setAttribute('id', 'subject_'+n_rows_plus); 				
		input8.setAttribute('type', 'text'); 				
		td4.appendChild(input8);
		
		var td5 = document.createElement("td");		
		td5.setAttribute('id', 'td_5_'+n_rows_plus); 				
		tr.appendChild(td5);
		
		var input9=document.createElement("input");		
		input9.setAttribute('id', 'qualification_'+n_rows_plus); 				
		input9.setAttribute('type', 'text'); 				
		td5.appendChild(input9);
		
		
		
		
		
		
		
	
	
	//Añadimos los campos extra para el validateforms
	var extra_hidden_area = document.getElementById('extra_hidden');
	
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_day_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_day_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
		
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_day_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_day_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_day_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_day_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date from (day)'); 				
	extra_hidden_area.appendChild(input);	
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_month_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_month_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_month_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_month_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_month_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_month_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date from (month)'); 				
	extra_hidden_area.appendChild(input);	
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_year_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_year_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_year_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_year_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_year_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_year_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date from (year)'); 				
	extra_hidden_area.appendChild(input);	
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_day_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_day_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_day_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_day_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_day_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_day_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date to (day)'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_month_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_month_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_month_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_month_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_month_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_month_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date to (month)'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_year_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_year_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_year_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_year_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_year_b_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_year_b_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date to (year)'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_school_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_school_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_school_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_school_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Name school / college / university'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_subject_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_subject_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_subject_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_subject_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Subjects studied'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_qualification_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_qualification_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_qualification_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_qualification_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Qualifications obtained'); 				
	extra_hidden_area.appendChild(input);
	

	
}

function removeEmploymentHist(){
	
	//Contamos cuantos elementos tenemos de cada tipo
	var n_rows = $("#num_educa").val();
	var n_rows_minus = (n_rows * 1)- 1 ;
	
	//Tiene que haber como mínimo 1 
	if(n_rows >=2){
	
	    
		var campo_empl = document.getElementById('tr_educa_'+n_rows);
		
		campo_empl.parentNode.removeChild(campo_empl);
		
				
		$("#num_educa").val(n_rows_minus);
		
		//Borramos los campos hidden
		var campo_hidden = document.getElementById('wbRequired_day_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_day_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_month_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_month_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_year_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_year_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_day_b_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_day_b_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_month_b_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_month_b_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_year_b_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_year_b_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_school_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_subject_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_qualification_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		

	}else{
		alert("You must fill at least one 'Education' row");	
	}	
	
}


function addWorkHist() {

	var field_area = document.getElementById('seccion2');
	
	
	//Contamos cuantos elementos tenemos de cada tipo
	var n_rows = $("#num_work").val();
	var n_rows_plus = (n_rows * 1)+ 1 ;
	
	
	
	
	//Incrementamos el número de ternas de tres
	$("#num_work").val(n_rows_plus);
	
	//Para los 9 campos
		
		
		var tr = document.createElement("tr");		
		tr.setAttribute('id', 'tr_work_'+n_rows_plus); 				
						
		field_area.appendChild(tr);	
		
		var td1 = document.createElement("td");		
		td1.setAttribute('id', 'td_6_'+n_rows_plus); 				
		tr.appendChild(td1);
		
		var input1=document.createElement("input");		
		input1.setAttribute('id', 'employer_'+n_rows_plus); 				
		input1.setAttribute('type', 'text'); 				
		td1.appendChild(input1);
		
		var td2 = document.createElement("td");		
		td2.setAttribute('id', 'td_7_'+n_rows_plus); 				
		tr.appendChild(td2);
		
		var input2=document.createElement("input");		
		input2.className='input_mini'; 				
		input2.setAttribute('id', 'day_c_'+n_rows_plus); 				
		input2.setAttribute('maxlength', '2'); 				
		input2.setAttribute('type', 'text'); 				
		td2.appendChild(input2);
		
		var text1=document.createElement("label");	
		text1.setAttribute('id', 'label_5_'+n_rows_plus);	
		td2.appendChild(text1);
		$('#label_5_'+n_rows_plus).text('/');
		
		var input3=document.createElement("input");		
		input3.className='input_mini'; 				
		input3.setAttribute('id', 'month_c_'+n_rows_plus); 				
		input3.setAttribute('maxlength', '2'); 				
		input3.setAttribute('type', 'text'); 				
		td2.appendChild(input3);
		
		var text2=document.createElement("label");	
		text2.setAttribute('id', 'label_6_'+n_rows_plus);		
		td2.appendChild(text2);
		$('#label_6_'+n_rows_plus).text('/');
		
		var input4=document.createElement("input");		
		input4.className='input_mini_b'; 				
		input4.setAttribute('id', 'year_c_'+n_rows_plus);
		input4.setAttribute('maxlength', '4'); 				 				
		input4.setAttribute('type', 'text'); 				
		td2.appendChild(input4);
		
		
		var td3 = document.createElement("td");		
		td3.setAttribute('id', 'td_8_'+n_rows_plus); 				
		tr.appendChild(td3);
		
		var input5=document.createElement("input");		
		input5.className='input_mini'; 				
		input5.setAttribute('id', 'day_d_'+n_rows_plus); 
		input5.setAttribute('maxlength', '2'); 								
		input5.setAttribute('type', 'text'); 				
		td3.appendChild(input5);
		
		var text3=document.createElement("label");	
		text3.setAttribute('id', 'label_7_'+n_rows_plus);			
		td3.appendChild(text3);
		$('#label_7_'+n_rows_plus).text('/');
		
		var input6=document.createElement("input");		
		input6.className='input_mini'; 				
		input6.setAttribute('id', 'month_d_'+n_rows_plus); 				
		input6.setAttribute('maxlength', '2'); 				
		input6.setAttribute('type', 'text'); 				
		td3.appendChild(input6);
		
		var text4=document.createElement("label");		
		text4.setAttribute('id', 'label_8_'+n_rows_plus);			
		td3.appendChild(text4);
		$('#label_8_'+n_rows_plus).text('/');
		
		
		var input7=document.createElement("input");		
		input7.className='input_mini_b'; 				
		input7.setAttribute('id', 'year_d_'+n_rows_plus); 				
		input7.setAttribute('maxlength', '4'); 				
		input7.setAttribute('type', 'text'); 				
		td3.appendChild(input7);
		
		
		
		var td4 = document.createElement("td");		
		td4.setAttribute('id', 'td_9_'+n_rows_plus); 				
		tr.appendChild(td4);
		
		var input8=document.createElement("input");		
		input8.setAttribute('id', 'job_'+n_rows_plus); 				
		input8.setAttribute('type', 'text'); 				
		td4.appendChild(input8);
		
		var td5 = document.createElement("td");		
		td5.setAttribute('id', 'td_10_'+n_rows_plus); 				
		tr.appendChild(td5);
		
		var input9=document.createElement("input");		
		input9.setAttribute('id', 'reason_'+n_rows_plus); 				
		input9.setAttribute('type', 'text'); 				
		td5.appendChild(input9);
		
		
		
		
		
		
		
	
	
	//Añadimos los campos extra para el validateforms
	var extra_hidden_area = document.getElementById('extra_hidden2');
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_employer_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_employer_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_employer_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_employer_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Employers name & address'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_day_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_day_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_day_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_day_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_day_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_day_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date from (day)'); 				
	extra_hidden_area.appendChild(input);	
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_month_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_month_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_month_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_month_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_month_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_month_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date from (month)'); 				
	extra_hidden_area.appendChild(input);	
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_year_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_year_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_year_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_year_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);		
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_year_c_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_year_c_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date from (year)'); 				
	extra_hidden_area.appendChild(input);	
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_day_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_day_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_day_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_day_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_day_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_day_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date to (day)'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_month_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_month_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_month_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_month_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_month_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_month_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date to (month)'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_year_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_year_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbType_year_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbType_year_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'numeric'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_year_d_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_year_d_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Date to (year)'); 				
	extra_hidden_area.appendChild(input);
	
		
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_job_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_job_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_job_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_job_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Job title'); 				
	extra_hidden_area.appendChild(input);
	
	var input = document.createElement("input");
	input.setAttribute('id', 'wbRequired_reason_'+n_rows_plus); 				
	input.setAttribute('name', 'wbRequired_reason_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'true'); 				
	extra_hidden_area.appendChild(input);
	var input = document.createElement("input");
	input.setAttribute('id', 'wbLabel_reason_'+n_rows_plus); 				
	input.setAttribute('name', 'wbLabel_reason_'+n_rows_plus); 				
	input.setAttribute('type', 'hidden'); 				
	input.setAttribute('value', 'Reason for leaving'); 				
	extra_hidden_area.appendChild(input);

	
}

function removeWorkHist(){
	
	//Contamos cuantos elementos tenemos de cada tipo
	var n_rows = $("#num_work").val();
	var n_rows_minus = (n_rows * 1)- 1 ;
	
	//Tiene que haber como mínimo 1 
	if(n_rows >=1){
	
	    
		var campo_work = document.getElementById('tr_work_'+n_rows);
		
		campo_work.parentNode.removeChild(campo_work);
		
				
		$("#num_work").val(n_rows_minus);
		
		var campo_hidden = document.getElementById('wbRequired_employer_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		//Borramos los campos hidden
		var campo_hidden = document.getElementById('wbRequired_day_c_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_day_c_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_month_c_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_month_c_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_year_c_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_year_c_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_day_d_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_day_d_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_month_d_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_month_d_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_year_d_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		var campo_hidden = document.getElementById('wbType_year_d_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
				
		var campo_hidden = document.getElementById('wbRequired_job_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		
		var campo_hidden = document.getElementById('wbRequired_reason_'+n_rows);
		campo_hidden.parentNode.removeChild(campo_hidden);
		

	}else{
		alert("You must fill at least one 'Employment History' row");	
	}	
	
}

function addHours() {
	var hours = $("#c_type option:selected").val(); 
	
	var elSel = document.getElementById('c_hours');
	var i;
	for (i = elSel.length - 1; i>=0; i--) 
      elSel.remove(i);


		  
	if (hours=='0'){
		$("#c_hours").append('<option value="0" id="h1" checked >0h</option>');
		$("#c_hours").append('<option value="1" id="h2">8h</option>');
		$("#c_hours").append('<option value="2" id="h3">16h</option>');
	}else if (hours=='1'){
		
		$("#c_hours").append('<option value="3" id="h4" checked >24h</option>');
		$("#c_hours").append('<option value="4" id="h5">32h</option>');
		$("#c_hours").append('<option value="5" id="h6">40h</option>');
	}else
		return false;
	
}

function addBackground() {
	var ethnic = $("#ethnic option:selected").val(); 
	
	var elSel = document.getElementById('background');
	var i;
	for (i = elSel.length - 1; i>=0; i--) 
      elSel.remove(i);


		  
	if (ethnic=='0'){
		$("#background").append('<option value="0" id="h1" checked >British</option>');
		$("#background").append('<option value="1" id="h2">Irish</option>');
		$("#background").append('<option value="other" id="h3">Other</option>');
	}else if (ethnic=='1'){
		
		$("#background").append('<option value="2" id="h3" checked >White and Black Caribbean</option>');
		$("#background").append('<option value="3" id="h4">White and Black African</option>');
		$("#background").append('<option value="4" id="h5">White and Asian</option>');
		$("#background").append('<option value="other" id="h3">Other</option>');
		
	}else if (ethnic=='2'){
		
		$("#background").append('<option value="5" id="h6" checked >Caribbean</option>');
		$("#background").append('<option value="6" id="h7">African</option>');
		$("#background").append('<option value="other" id="h3">Other</option>');
		
	}else if (ethnic=='3'){
		
		$("#background").append('<option value="7" id="h8" checked >Indian</option>');
		$("#background").append('<option value="8" id="h9">Pakistani</option>');
		$("#background").append('<option value="9" id="h10">Bangladeshi</option>');
		$("#background").append('<option value="other" id="h3">Other</option>');
		
	}else if (ethnic=='4'){
		
		$("#background").append('<option value="10" id="h11" checked >Chinese</option>');
	
	}else
		return false;
	
}
/*
$(document).ready(function (){
	
	$("#cvSubmit").click(submitCV);  
		
}
);
*/

function submitCV(_part) {
	
    var _ok = wbValidateFormL(document.getElementById('sendcv'+_part),'en');
		
	var f = document.getElementById('sendcv'+_part);
	
	var _id = f.id.value;
	
	var minYear=1900;
	var maxYear=2100;
	var daysInMonth = DaysArray(12);
	
	if (_ok && _part==1){
		
		var _cat = f.cat.value;
		var _title = f.title.value;
		var _name = f.name.value;
		var _surname = f.surname.value;
		var _address = f.address.value;
		var _postcode = f.postcode.value;
		var _email = f.email.value;
		var _telephone = f.telephone.value;
		
		var _employer_1 = f.employer_1.value;
		
		
		var _job_1 = f.job_1.value;
		var _reason_1 = f.employer_1.value;
		var _worked = $("#worked option:selected").val();
		
		var _day_c_1 = f.day_c_1.value;
		var _month_c_1 = f.month_c_1.value;
		var _year_c_1 = f.year_c_1.value;
		var _day_d_1 = f.day_d_1.value;
		var _month_d_1 = f.month_d_1.value;
		var _year_d_1 = f.year_d_1.value;
		
		if ((_ok)&&(_worked=='1')&&((!_employer_1.length>0)
		||(!_day_c_1.length>0)||(!_month_c_1.length>0)||(!_year_c_1.length>0)
		||(!_day_d_1.length>0)||(!_month_d_1.length>0)||(!_year_d_1.length>0)
		||(!_job_1.length>0)||(!_reason_1.length>0))){
		
			alert("If you select 'YES' in 'Have you previously worked for our Company?' you must insert at least one information row");
			f.employer_1.focus();
			_ok=false;
			return false;
		}
		if ((_ok)&&(_worked=='1')){
			
			
			if ((_day_c_1.length<1 || _day_c_1<1 || _day_c_1>31 || (_month_c_1==2 && _day_c_1>daysInFebruary(_year_c_1)) || _day_c_1 > daysInMonth[_month_c_1])){
				_ok=false;
				f.day_c_1.focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if ((_month_c_1.length<1 || _month_c_1<1 || _month_c_1>12)){
				_ok=false;
				f.month_c_1.focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if (_year_c_1.length != 4 || _year_c_1==0 || _year_c_1<minYear || _year_c_1>maxYear){
				_ok=false;
				f.year_c_1.focus();
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
				return false;
			}
			
			if ((_day_d_1.length<1 || _day_d_1<1 || _day_d_1>31 || (_month_d_1==2 && _day_d_1>daysInFebruary(_year_d_1)) || _day_d_1 > daysInMonth[_month_d_1])){
				_ok=false;
				f.day_d_1.focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if ((_month_d_1.length<1 || _month_d_1<1 || _month_d_1>12)){
				_ok=false;
				f._month_d_1.focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if (_year_d_1.length != 4 || _year_d_1==0 || _year_d_1<minYear || _year_d_1>maxYear){
				_ok=false;
				f._year_d_1.focus();
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
				return false;
			}
			
			if (fechaMayorOIgualQue(_day_c_1,_month_c_1,_year_c_1,_day_d_1,_month_d_1,_year_d_1)){
				_ok=false;
				f.day_c_1.focus();
				alert("Invalid date range");
				return false;
			}
		}	
		var i;
		var _n_rowswork = $("#num_work").val();
		var _n_rowseduca = $("#num_educa").val();
		
				
		var data = {part: _part,cat: _cat,id: _id, title: _title, name: _name, surname: _surname, 
        	address: _address, postcode: _postcode, email: _email, telephone : _telephone , worked: _worked,job: _job, n_rowseduca: _n_rowseduca, n_rowswork: _n_rowswork};
       		
     
		
		for(i=1;i<=_n_rowseduca;i++){
     		var _day=f.elements['day_' + i].value;
     		var _month=f.elements['month_' + i].value;
     		var _year=f.elements['year_' + i].value;
     		var _day_b=f.elements['day_b_' + i].value;
     		var _month_b=f.elements['month_b_' + i].value;
     		var _year_b=f.elements['year_b_' + i].value;
			
     		if ((_day.length<1 || _day<1 || _day>31 || (_month==2 && _day>daysInFebruary(_year)) || _day > daysInMonth[_month])){
				_ok=false;
				f.elements['day_' + i].focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if ((_month.length<1 || _month<1 || _month>12)){
				_ok=false;
				f.elements['month_' + i].focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if (_year.length != 4 || _year==0 || _year<minYear || _year>maxYear){
				_ok=false;
				f.elements['year_' + i].focus();
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
				return false;
			}
			
			if ((_day_b.length<1 || _day_b<1 || _day_b>31 || (_month_b==2 && _day_b>daysInFebruary(_year_b)) || _day_b > daysInMonth[_month_b])){
				_ok=false;
				f.elements['day_b_' + i].focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if ((_month_b.length<1 || _month_b<1 || _month_b>12)){
				_ok=false;
				f.elements['month_b_' + i].focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if (_year_b.length != 4 || _year_b==0 || _year_b<minYear || _year_b>maxYear){
				_ok=false;
				f.elements['year_b_' + i].focus();
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
				return false;
			}
			
			if (fechaMayorOIgualQue(_day,_month,_year,_day_b,_month_b,_year_b)){
				_ok=false;
				f.elements['day_' + i].focus();
				alert("Invalid date range");
				return false;
			}
			
			
     	
     	
			if ((f.elements['day_' + i].value != undefined)&&(f.elements['month_' + i].value != undefined)&&(f.elements['year_' + i].value != undefined)) {
				data['datefrom_' + i] = f.elements['year_' + i].value+"-"+f.elements['month_' + i].value+"-"+f.elements['day_' + i].value;
			}
			if ((f.elements['day_b_' + i].value != undefined)&&(f.elements['month_b_' + i].value != undefined)&&(f.elements['year_b_' + i].value != undefined)) {
				data['dateto_' + i] = f.elements['year_b_' + i].value+"-"+f.elements['month_b_' + i].value+"-"+f.elements['day_b_' + i].value;
			}
			if (f.elements['school_' + i].value != undefined){
				data['school_' + i] = f.elements['school_' + i].value;
			}
			if (f.elements['subject_' + i].value != undefined){
				data['subject_' + i] = f.elements['subject_' + i].value;
			}
			if (f.elements['qualification_' + i].value != undefined){
				data['qualification_' + i] = f.elements['qualification_' + i].value;
			}
			
		}
		if ((_ok)&&(_worked=='1')){
			for(i=1;i<=_n_rowswork;i++){
				
			var _day_c=f.elements['day_c_' + i].value;
     		var _month_c=f.elements['month_c_' + i].value;
     		var _year_c=f.elements['year_c_' + i].value;
     		var _day_d=f.elements['day_d_' + i].value;
     		var _month_d=f.elements['month_d_' + i].value;
     		var _year_d=f.elements['year_d_' + i].value;
			
     		if ((_day_c.length<1 || _day_c<1 || _day_c>31 || (_month_c==2 && _day_c>daysInFebruary(_year_c)) || _day_c > daysInMonth[_month_c])){
				_ok=false;
				f.elements['day_c_' + i].focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if ((_month_c.length<1 || _month_c<1 || _month_c>12)){
				_ok=false;
				f.elements['month_c_' + i].focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if (_year_c.length != 4 || _year_c==0 || _year_c<minYear || _year_c>maxYear){
				_ok=false;
				f.elements['year_c_' + i].focus();
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
				return false;
			}
			
			if ((_day_d.length<1 || _day_d<1 || _day_d>31 || (_month_d==2 && _day_d>daysInFebruary(_year_d)) || _day_d > daysInMonth[_month_d])){
				_ok=false;
				f.elements['day_d_' + i].focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if ((_month_d.length<1 || _month_d<1 || _month_d>12)){
				_ok=false;
				f.elements['month_d_' + i].focus();
				alert("You must insert a valid date");
				return false;
			}
			
			
			
			if (_year_d.length != 4 || _year_d==0 || _year_d<minYear || _year_d>maxYear){
				_ok=false;
				f.elements['year_d_' + i].focus();
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
				return false;
			}
			
			if (fechaMayorOIgualQue(_day_c,_month_c,_year_c,_day_d,_month_d,_year_d)){
				_ok=false;
				f.elements['day_c_' + i].focus();
				alert("Invalid date range");
				return false;
			}
				
				
					if ((f.elements['day_c_' + i].value != undefined)&&(f.elements['month_c_' + i].value != undefined)&&(f.elements['year_c_' + i].value != undefined)) {
						data['datefromw_' + i] = f.elements['year_c_' + i].value+"-"+f.elements['month_c_' + i].value+"-"+f.elements['day_c_' + i].value;
					}
					if ((f.elements['year_d_' + i].value != undefined)&&(f.elements['month_d_' + i].value != undefined)&&(f.elements['day_d_' + i].value != undefined)) {
						data['datetow_' + i] = f.elements['year_d_' + i].value+"-"+f.elements['month_d_' + i].value+"-"+f.elements['day_d_' + i].value;
					}
					if (f.elements['employer_' + i].value != undefined){
						data['employer_' + i] = f.elements['employer_' + i].value;
					}
					if (f.elements['job_' + i].value != undefined){
						data['job_' + i] = f.elements['job_' + i].value;
					}
					if (f.elements['reason_' + i].value != undefined){
						data['reason_' + i] = f.elements['reason_' + i].value;
					}
					
			}
		}
		
		
	}

	else if (_ok && _part==2){
	
		var _example = f.example.value;
		var _team = f.team.value;
		var _why = f.why.value;
		
		var data = {id: _id, part: _part, example: _example, team: _team, why: _why};
		
	}else if (_ok && _part==3){
		var _c_type = $("#c_type option:selected").val();
		var _c_hours = $("#c_hours option:selected").val();
		var _start = f.start.value;
		var _finish = f.finish.value;
		var _days='';
		
		if ((!f.days_1.checked)&&(!f.days_2.checked)&&(!f.days_3.checked)&&(!f.days_4.checked)
		&&(!f.days_5.checked)&&(!f.days_6.checked)&&(!f.days_7.checked)){
			alert("You must select working days");
			f.days_1.focus();
			_ok=false;
			return false;
		}
		var aux=false;
		if (f.days_1.checked){
			aux=true;
			_days=_days+'|0';
		}
		if (f.days_2.checked){
			aux=true;
			_days=_days+'|1';
		}
		if (f.days_3.checked){
			aux=true;
			_days=_days+'|2';
		}
		if (f.days_4.checked){
			aux=true;
			_days=_days+'|3';
		}
		if (f.days_5.checked){
			aux=true;
			_days=_days+'|4';
		}
		if (f.days_6.checked){
			aux=true;
			_days=_days+'|5';
		}
		if (f.days_7.checked){
			aux=true;
			_days=_days+'|6';
		}
		if (aux)
			_days=_days+'|';
			
		var _available = f.available.value;
		
		
		
		if ((f.start_d.value.length<1 || f.start_d.value<1 || f.start_d.value>31 || (f.start_m.value==2 && f.start_d.value>daysInFebruary(f.start_y.value)) || f.start_d.value > daysInMonth[f.start_m.value])){
			_ok=false;
			f.start_d.focus();
			alert("You must insert a valid date");
			return false;
		}
			
			
		
		if ((f.start_m.value.length<1 || f.start_m.value<1 || f.start_m.value>12)){
			_ok=false;
			f.start_m.focus();
			alert("You must insert a valid date");
			return false;
		}
			
			
			
		if (f.start_y.value.length != 4 || f.start_y.value==0 || f.start_y.value<minYear || f.start_y.value>maxYear){
			_ok=false;
			f.start_y.focus();
			alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
			return false;
		}
			
			
		var _date_start = f.start_y.value+"-"+f.start_m.value+"-"+f.start_d.value;
		
		if ((f.holidays_d.value.length>0)||(f.holidays_m.value.length>0)||(f.holidays_y.value.length>0)){
			//var _holidays = f.holidays.value;
			if ((f.holidays_d.value.length<1 || f.holidays_d.value<1 || f.holidays_d.value>31 || (f.holidays_m.value==2 && f.holidays_d.value>daysInFebruary(f.holidays_y.value)) || f.holidays_d.value > daysInMonth[f.holidays_m.value])){
				_ok=false;
				f.holidays_d.focus();
				alert("You must insert a valid date");
				return false;
			}
				
				
			
			if ((f.holidays_m.value.length<1 || f.holidays_m.value<1 || f.holidays_m.value>12)){
				_ok=false;
				f.holidays_m.focus();
				alert("You must insert a valid date");
				return false;
			}
				
				
				
			if (f.holidays_y.value.length != 4 || f.holidays_y.value==0 || f.holidays_y.value<minYear || f.holidays_y.value>maxYear){
				_ok=false;
				f.holidays_y.focus();
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
				return false;
				
			}
			var _date_holidays = f.holidays_y.value+"-"+f.holidays_m.value+"-"+f.holidays_d.value;
		}else
			var _date_holidays = '';
			
			
		
		
		
		var _locations = f.locations.value;
		var _salary = f.salary.value;
		var _c_salary = f.c_salary.value;
		var _benefits = f.benefits.value;
		
		var data = {id: _id, part: _part, c_type: _c_type, 
        	c_hours: _c_hours, start: _start, finish: _finish, 
        	days: _days, available: _available, date_start: _date_start,
        	date_holidays: _date_holidays, locations: _locations, salary: _salary, c_salary: _c_salary, 
        	benefits: _benefits};
        	
	}else if (_ok && _part==4){	
		var _place = $("#place option:selected").val();
		var _visa = $("#visa option:selected").val();
		var _ni = f.ni.value;
		var _convicted = $("#convicted option:selected").val();
		var _position = f.position.value;
		var _act = f.act.value;
		if ((_ok)&&(_convicted=='1')&&(!_act.length>0)){
			alert("If you select 'YES' in 'Have you ever been convicted of a criminal offence?' you must insert the details");
			f.act.focus();
			_ok=false;
			return false;
		}
		
		var _name_1 = f.name_1.value;
		var _address_1 = f.address_1.value;
		var _tel_1 = f.tel_1.value;
		var _name_2 = f.name_2.value;
		var _address_2 = f.address_2.value;
		var _tel_2 = f.tel_2.value;
		
		if (f.f_job.checked)
			var _job='1';
		else 
			var _job='0';
			
			
		if ((_ok)&&(!f.f_job.checked)
			&&(!_name_1.length>0)&&(!_address_1.length>0)&&(!_tel_1.length>0)
			&&(!_name_2.length>0)&&(!_address_2.length>0)&&(!_tel_2.length>0)){
				alert("You must insert at least one reference");
				f.name_1.focus();
				_ok=false;
				return false;
		}
		
		var data = {id: _id, part: _part, place: _place, visa: _visa, ni: _ni, convicted: _convicted, 
        	act: _act, name_1: _name_1, address_1: _address_1, tel_1: _tel_1, name_2: _name_2, address_2: _address_2, tel_2: _tel_2,
        	position: _position,job: _job};
	}
	
	else if (_ok && _part==5){
		//var _signed = f.signed.value;
		var _signed_d = f.signed_d.value;
		var _signed_m = f.signed_m.value;
		var _signed_y = f.signed_y.value;
		
		var _print = f.print.value;
		if ((!_signed_d.length>0)||(!_signed_m.length>0)||(!_signed_y.length>0)||(!_print.length>0)){
				alert("You must sign the declaration");
				f.signed.focus();
				_ok=false;
				return false;
		}
		
				
		if ((_signed_d.length<1 || _signed_d<1 || _signed_d>31 || (_signed_m==2 && _signed_d>daysInFebruary(_signed_y)) || _signed_d > daysInMonth[_signed_m])){
			_ok=false;
			f.signed_d.focus();
			alert("You must insert a valid date");
			return false;
		}
			
			
		
		if ((_signed_m.length<1 || _signed_m<1 || _signed_m>12)){
			_ok=false;
			f.signed_m.focus();
			alert("You must insert a valid date");
			return false;
		}
			
			
			
		if (_signed_y.length != 4 || _signed_y==0 || _signed_y<minYear || _signed_y>maxYear){
			_ok=false;
			f.signed_y.focus();
			alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
			return false;
		}
		
		
		
		var _ethnic = f.ethnic.value;
		var _background = f.background.value;
		var _other = f.other.value;
		var _manager = f.manager.value;
		
		var _gender = $("#gender option:selected").val();

		if (f.birth_d.value.length>0){
			if ((f.birth_d.value.length<1 || f.birth_d.value<1 || f.birth_d.value>31 || (f.birth_m.value==2 && f.birth_d.value>daysInFebruary(f.birth_y.value)) || f.birth_d.value > daysInMonth[f.birth_m.value])){
				_ok=false;
				f.birth_d.focus();
				alert("You must insert a valid date");
				return false;
			}
				
				
			
			if ((f.birth_m.value.length<1 || f.birth_m.value<1 || f.birth_m.value>12)){
				_ok=false;
				f.birth_m.focus();
				alert("You must insert a valid date");
				return false;
			}
				
				
				
			if (f.birth_y.value.length != 4 || f.birth_y.value==0 || f.birth_y.value<minYear || f.birth_y.value>maxYear){
				_ok=false;
				f.birth_y.focus();
				alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
				return false;
			}
			
			var _date_birth = f.birth_y.value+"-"+f.birth_m.value+"-"+f.birth_d.value;
		}else
			var _date_birth = "";
			
		if ((_ok)&&((_ethnic=='other')||(_background=='other')) && (!_other.length>0))
		{
				alert("You must indicate your Ethnicity/background");
				f.other.focus();
				_ok=false;
				return false;
		}
		
		
		var _discrim = $("#discrim option:selected").val();
		var _disability = f.disability.value;
		
		if ((_ok)&&(_discrim=='1')&&(!_disability.length>0)){
			alert("If you select 'YES' in 'Do you consider yourself to have a disability...' you must insert the nature of disability");
			f.disability.focus();
			_ok=false;
			return false;
		}
		
		var _religion = f.religion.value;
		var _sex = f.sex.value;
		
		var data = {id: _id, part: _part, ethnic: _ethnic, background: _background, other: _other, gender: _gender, date_birth: _date_birth, discrim: _discrim, disability: _disability, 	religion: _religion, sex: _sex, manager: _manager};
	}
	
	if (_ok && _part==6){
		var _manager_slow = f.manager_slow.value;
		var _manager_motivated = f.manager_motivated.value;
		var _manager_team = f.manager_team.value;
		var _manager_delegate = f.manager_delegate.value;
		var _manager_needs = f.manager_needs.value;
		var _manager_identify = f.manager_identify.value;
		var _manager_solutions = f.manager_solutions.value;
		var _manager_prioritize = f.manager_prioritize.value;
		var _manager_difficults = f.manager_difficults.value;
		var _manager_change = f.manager_change.value;
		var _manager_change_b = f.manager_change_b.value;
		var _manager_change_c = f.manager_change_c.value;
		
		var data = {id: _id, part: _part, manager_slow: _manager_slow, manager_motivated: _manager_motivated, manager_team: _manager_team,
        	manager_delegate: _manager_delegate, manager_needs: _manager_needs, manager_identify: _manager_identify, 
        	manager_solutions: _manager_solutions, manager_prioritize: _manager_prioritize, manager_difficults: _manager_difficults, 
        	manager_change: _manager_change, manager_change_b: _manager_change_b, manager_change_c: _manager_change_c};
	}
	
	if(_ok) {
		     
        
        $.ajax({
	           url: "sendCV.php",
	           type: "POST",
	           dataType: "text",
	           data: data,	           		
	           error: function(req, err, obj) {
	           	alert('error : ' + err);
	           },
	           success: function(txt) {
	           	
	           	if (txt!="ERR"){
	           		//alert("Your Application form was successfully sent. Thank you.");
	           		//self.location = '08WorkWithUs.html';
	           		if ((_manager=='0'&&_part==5)||(_part==6)){
	           			alert("Thanks for completing your application form."); 
	           			self.location = 'ThankYou.html';
	           		}else{
		           		document.getElementById('sendcv'+_part).id.value=txt;
		           		document.getElementById('sendcv'+(_part+1)).id.value=txt;
		           		/*$("#wwu_"+_part).css({display:"none"});
						$("#wwu_"+(_part+1)).css({display:"block"});*/
		           		showPart(_part+1,false);
	           		}
	           		return false;
	           	}else{
	       			alert("An error occurred while sending your application form. Please try again in a few minutes.");    			
	       			self.location = '08WorkWithUs.html';
	       			return false;
	           	}
	       
	        	}            
	        
	        
			});
		
			
	}
	
	return false;

}

function showPart(part,next){
 		var i;
 		var actual;
 		_ok = true;
 		
 		if (next==true)
 			actual = part - 1;
 			
 		 				
 		
 		if (_ok){
 			for (i=1; i<=6; i++){
 				if (i==part)
	 				$("#wwu_"+i).css({display:"block"});
	 			else
	 				$("#wwu_"+i).css({display:"none"});
	 			}
 		}
 		
 		if (part==5){
 			
 			$("#online3").css({display:"none"});
 			$("#online2").css({display:"block"});
 		}else if (part==6){
 			
 			$("#online2").css({display:"none"});
 			$("#online3").css({display:"block"});
 		}
 		
 		
 	}



/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function fechaMayorOIgualQue(day0,month0,year0,day1,month1,year1){ 
    var bRes = false; 
    
    if (year0 > year1) bRes = true; 
    else { 
     if (year0 == year1){ 
      if (month0 > month1) bRes = true; 
      else { 
       if (month0 == month1) 
        if (day0 >= day1) bRes = true; 
      } 
     } 
    } 
    return bRes; 
   }  
