// JavaScript Document

function xajax_module_wl_rh() {
	slidingForm();
}

$(document).ready(function() {
	slidingForm();
	
	$('#add-languages').live('click',function() {		
		cloneDivAndId(".content_form1","#count_language");				
	});
	
	$('#add-experience').live('click',function() {
		cloneDivAndId(".content_form2","#count_experience");		
	});
	
	$('#add-education').live('click',function() {
		cloneDivAndId(".content_form3","#count_education");	
	});
	
	$('#add-course').live('click',function() {
		cloneDivAndId(".content_form4","#count_course");					
	});
});



function cloneDivAndId(objDiv,objCount) {
    countObjDiv = $(objDiv).length +1;                   
    $(objDiv + ":last").clone().insertAfter($(objDiv + ":last"));
    
    $(objDiv + ":last input," + objDiv + ":last select," + objDiv + ":last textarea," + objDiv + ":last checkbox").each(function(index){
        newName = $(this).attr("name");                 
        newName = newName.substr(0, newName.lastIndexOf("_"));
        newName = newName + "_" + countObjDiv;
        $(this).attr("name", newName);     
        $(this).attr("value", "");
    });
    
    $(objCount).val(countObjDiv)
}

