function cv_sterge_job(id) {
	if (!confirm('Esti sigur ca vrei sa stergi jobul ?')) return false;
	if (id < 1) {
		$('#cv_job_0').remove();
		return;
	}
	$.ajax({
		url: '/ajax.php?section=cv',
		type: 'post',
		data: {
			id : id,
			enforcer: 'delete_job'
		},
		success: function(response) {
			$('#cv_job_'+id).remove();
		}
	});
}	
function cv_sterge_study(id) {
	if (!confirm('Esti sigur ca vrei sa stergi studiul ?')) return false;
	if (id < 1) {
		$('#cv_study_0').remove();
		return;
	}
	$.ajax({
		url: site_url+'/ajax.php?section=cv',
		type: 'post',
		dataType : 'json',
		data: {
			id: id,
			enforcer: 'delete_study'
		},
		success: function(result) {
			if (result.code == 2) {
				$('#cv_study_'+id).remove();
			} else {
				alert(result.msg);
			}
		}
	});
}	
function cv_sterge_file(id) {
	if (!confirm('Esti sigur ca vrei sa stergi fisierul atasat ?')) return false;
	$.ajax({
		url: site_url+'/ajax.php?section=cv',
		type: 'post',
		dataType : 'json',
		data: {
			id: id,
			enforcer: 'delete_file_cv'
		},
		success: function(result) {
			if (result.code == 2) {
				$('#cv_file').hide();
			} else {
				alert(result.msg);
			}
		}
	});
}
function cv_make_visible(id) {
	$.ajax({
		url: site_url+'/ajax.php?section=cv',
		type: 'post',
		dataType : 'json',
		data: {
			id: id,
			enforcer: 'cv_make_visible'
		},
		success: function(result) {
			if (result.code == 2) {
				$('#info_1').hide();
				$('#info_2').show();
			}
		}
	});
}
function mycv_make_visible(id) {
	$.ajax({
		url: site_url+'/ajax.php?section=cv',
		type: 'post',
		dataType : 'json',
		data: {
			id: id,
			enforcer: 'mycv_make_visible'
		},
		success: function(result) {
			if (result.code == 2) {
				$('#info_1').hide();
				$('#info_2').show();
			}
		}
	});
}
function cv_add_company(){
	$('#cv_job_0').show();
	$('#cv_add_company').hide();
}
function cv_add_study(){
	$('#cv_study_0').show();
	$('#cv_add_study').hide();
}

var jobs = {
	sterge_companie: function(id) {
		if (!confirm('Esti sigur ca vrei sa stergi aceasta companie ?')) return false;
		$.ajax({
			url: '/ajax.php?section=jobs',
			type: 'post',
			data: {
				enforcer: 'delete_company',
				id: id
			},
			success: function(rasp) {
				$('#comp_'+id).fadeOut('slow')
			}
		});
	},
	job_delete: function(id) {
		if (!confirm('Esti sigur ca vrei sa stergi acest anunt?')) return false;
		$.ajax({
			url: '/ajax.php?section=jobs',
			type: 'post',
			data: {
				enforcer: 'job_delete_company',
				id: id
			},
			success: function(rasp) {
				$('#job_'+id).fadeOut('slow')
			}
		});
	},/*
	delete_job_seek: function(id) {
		if (!confirm('Esti sigur ca vrei sa stergi acest anunt?')) return false;
		$.ajax({
			url: '/ajax.php?section=jobs',
			type: 'post',
			data: {
				enforcer: 'delete_job_seek',
				id: id
			},
			success: function(rasp) {
				//alert(rasp);
			}
		});
	},*/
	sterge_jobseek: function(id) {
		if (!confirm('Esti sigur ca vrei sa stergi acest anunt?')) return false;
		$.ajax({
			url: '/ajax.php?section=jobs',
			type: 'post',
			data: {
				enforcer: 'job_delete_jobseek',
				id: id
			},
			success: function(rasp) {
				//alert(rasp);
				$('#jobseek_'+id).fadeOut('slow');
			}
		});
	},
	save_job: function() {
		var position = $('#position').val();
		var description = $('#description').val();
		var requirements = $('#requirements').val();
		var localitate = $('#localitate').val();
		
		var areas = new Array();
		var domains = new Array();
		var domenii = $(".domain_chk:checked").length;
		var zone = $(".area_chk:checked").length;
		if (position.length < 1) {
			alert('Nu ati specificat pozitia');
			return false;
		}
		if (description.length < 1) {
			alert('Nu ati specificat atributiile si responsabilitatile postului');
			return false;
		}
		if (requirements.length < 1) {
			alert('Nu ati specificat profilul candidatului');
			return false;
		}
		if (domenii < 1) {
			alert('Nu ati specificat domeniile de activitate');
			return false;
		}
		/*
		if (zone < 1) {
			alert('Nu ati specificat zonele in care se desfasoara activitatea');
			return false;
		}
		*/
		return true;
		
		var i = 0;
		$('.domain_chk').each(function(){
			if ($(this).attr('checked') == true) {
				domains[i] = $(this).val()
				i++;
			}
		});
		
		if (i < 1) {
			alert('Nu ati specificat ');
		}
		
		var i = 0;
		$('.area_chk').each(function(){
			if ($(this).attr('checked') == true) {
				areas[i] = $(this).val()
				i++;
			}
		});
	},
	clear_form: function() {
		$('#position').val('');
		$('#description').val('');
		$('#requirements').val('');
		$('#localitate').val('');
		$('#jobid').val('');
		$('.domain_chk').each(function(){
			$(this).removeAttr("checked");
		});
		$('.area_chk').each(function(){
			$(this).removeAttr("checked");
		});
	},
	hide_form: function() {
		jobs.clear_form();
		$('#job_add').fadeOut('slow');
	},
	show_form: function() {
		jobs.clear_form();
		$('#job_add').fadeIn('slow');
	}
}
function deleteCompanyPicture(id) {
	if (!confirm('Esti sigur ca vrei sa stergi poza?')) return false;
	$.ajax({
		url: '/ajax.php?section=jobs',
		type: 'post',
		data: {
			id: id,
			enforcer: 'companyDeletePicture'
		},
		success: function(resp) {
			//alert(resp);
			$('#image_logo_delete').fadeOut('slow');
			$('#image_link_logo_delete').fadeOut('slow');
			$('#link_logo_delete').fadeOut('slow');
		}
	});
}
function kj_privat() {
	if ($('#cv_privat').is(':checked')) {
		$('#show_a').show();
	} else {
		$('#show_a').hide();
	}
}
