// JavaScript Document
// Spawn 1
function wexp_new_attr_s( str ) {
	
	qqq = str.split('_')
	str = qqq[0] + '_' + qqq[1] + '_' + qqq[2] + '_' + job_number;
	return str;
}
function wcoz_new_attr_s( str ) {
	
	qqq = str.split('_')
	str = qqq[0] + '_' + qqq[1] + '_' + qqq[2] + '_' + job_number;
	return str;
}

function edu_new_attr_s( str ) {
	
	qqq = str.split('_')
	str = qqq[0] + '_' + qqq[1] + '_' + qqq[2] + '_' + edu_number;
	return str;
}

function lang_new_attr_s( str ) {
	
	qqq = str.split('_')
	str = qqq[0] + '_' + qqq[1] + '_' + qqq[2] + '_' + lang_number;
	return str;
}

function spawn_w_exp( where ) {

	container = document.getElementById(where);
	str = 'job_desc_'+job_number;
	tableJob = document.getElementById('job_desc_prototype');
	new_table = tableJob.cloneNode(true);
	job_number ++;
	str = 'job_desc_'+job_number; 
	new_table.setAttribute('id',str)
	new_table.style.display='';
	container.appendChild(new_table);
	selects = new_table.getElementsByTagName('select');
//	alert(selects.length)
	for (i=0; i<selects.length; i++) {
//		alert(selects[i].getAttribute('name'));
		selects[i].setAttribute('name', wexp_new_attr_s(selects[i].getAttribute('name')));
	}

	inputs = new_table.getElementsByTagName('input');
	for (i=0; i<inputs.length; i++) {
		inputs[i].setAttribute('name', wexp_new_attr_s(inputs[i].getAttribute('name')))
	}
	last_job = new_table;
}

function spawn_w_exp1( where ) {

	container = document.getElementById(where);
	str = 'coz_desc_'+coz_number;
	tablecoz = document.getElementById('coz_desc_prototype');
	new_table = tablecoz.cloneNode(true);
	coz_number ++;
	str = 'coz_desc_'+coz_number; 
	new_table.setAttribute('id',str)
	new_table.style.display='';
	container.appendChild(new_table);
	selects = new_table.getElementsByTagName('select');
//	alert(selects.length)
	for (i=0; i<selects.length; i++) {
//		alert(selects[i].getAttribute('name'));
		selects[i].setAttribute('name', wcoz_new_attr_s(selects[i].getAttribute('name')));
	}

	inputs = new_table.getElementsByTagName('input');
	for (i=0; i<inputs.length; i++) {
		inputs[i].setAttribute('name', wcoz_new_attr_s(inputs[i].getAttribute('name')))
	}
	last_coz = new_table;
}

function spawn_edu( where ) {


	container = document.getElementById(where);
	str = 'edu_desc_'+edu_number;
	tableEdu = document.getElementById('edu_desc_prototype');
	new_table = tableEdu.cloneNode(true);
	edu_number ++;
	str = 'edu_desc_'+edu_number; 
	new_table.setAttribute('id',str)
	new_table.style.display='';
	container.appendChild(new_table);
	selects = new_table.getElementsByTagName('select');
	for (i=0; i<selects.length; i++) {
		selects[i].setAttribute('name', edu_new_attr_s(selects[i].getAttribute('name')));
	}
	inputs = new_table.getElementsByTagName('input');
	for (i=0; i<inputs.length; i++) {
		inputs[i].setAttribute('name', edu_new_attr_s(inputs[i].getAttribute('name')))
	}
	last_edu = new_table;
}


function spawn_lang( where ) {


	container = document.getElementById(where);
	str = 'lang_desc_'+lang_number;
	tableEdu = document.getElementById('lang_desc_prototype');
	new_table = tableEdu.cloneNode(true);
	lang_number ++;
	str = 'lang_desc_'+lang_number; 
	new_table.setAttribute('id',str);
	new_table.style.display='';
	container.appendChild(new_table);
	selects = new_table.getElementsByTagName('select');
	for (i=0; i<selects.length; i++) {
		selects[i].setAttribute('name', lang_new_attr_s(selects[i].getAttribute('name')));
	}
	inputs = new_table.getElementsByTagName('input');
	for (i=0; i<inputs.length; i++) {
		inputs[i].setAttribute('name', lang_new_attr_s(inputs[i].getAttribute('name')))
	}
	last_lang = new_table;
}

var last_job = null;
var last_coz = null;
var last_edu = null;
var last_lang = null;


var	job_number = 0;
var	coz_number = 0;
var	edu_number = 0;
var	lang_number = 0;

function remove_lang(where) {
	container = document.getElementById(where);

	last_active = lang_number-1;
	last_active = 'lang_desc_' + last_active;
	
//	alert(last_active);

	if (last_lang != null) {
		container.removeChild(last_lang);
		lang_number--;
	}
//	alert(document.getElementById(last_active))
	last_lang = document.getElementById(last_active);
}

function remove_job(where) {
	container = document.getElementById(where);

	last_active = job_number-1;
	last_active = 'job_desc_' + last_active;

	if (last_job != null) {
		container.removeChild(last_job);
		job_number--;
	}
	last_job = document.getElementById(last_active);
}
function remove_coz(where) {
	container = document.getElementById(where);

	last_active = coz_number-1;
	last_active = 'coz_desc_' + last_active;

	if (last_coz != null) {
		container.removeChild(last_coz);
		coz_number--;
	}
	last_coz = document.getElementById(last_active);
}

function remove_edu(where) {
	container = document.getElementById(where);

	last_active = edu_number-1;
	last_active = 'edu_desc_' + last_active;

	if (last_edu != null) {
		container.removeChild(last_edu);
		edu_number--;
	}
	last_edu = document.getElementById(last_active);
}

var state = 'none';
function showhide(layer_ref) {
if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
hza.style.display = state;
}
}
