

function toggle_visibility(id, id_sign, i, type) {

	if (document.getElementById)
		{
		var e = document.getElementById(id);
		if (id_sign) { var s = document.getElementById(id_sign); }
		//alert('ok');
		if(e.style.display == 'none') {
			e.style.display = 'block';
			
			if (type == 'q') {			
				var objCheckBoxes = document.forms["manage_questions"].elements["question_id[]"];
				objCheckBoxes[i-1].checked = true;
			} else if (type == 's') {
				var objCheckBoxes = document.forms["manage_survey"].elements["survey_id[]"];
				objCheckBoxes[i-1].checked = true;			
			} else if (type == 'a') {
				var objCheckBoxes = document.forms["manage_answers"].elements["survey_id[]"];
				objCheckBoxes[i-1].checked = true;			
			}	  
			s.innerHTML = '[-]';
			}
		else {
			e.style.display = 'none';
			s.innerHTML = '[+]';
			}
	 } else if (document.all)
		{
		var e = document.all(id);
		if (id_sign) { var s = document.all(id_sign); }
		if(e.style.display == 'none') {
			e.style.display = 'block';
			s.innerHTML = '[-]'; }
		else {
			e.style.display = 'none';
			s.innerHTML = '[+]';
			}
	 } else if (document.layers)
		{
		var e = document.layers(id);
		if (id_sign) { var s = document.layers(id_sign); }
		if(e.style.display == 'none') {
			e.style.display = 'block';
			s.innerHTML = '[-]';
			}
		else {
			e.style.display = 'none';
			s.innerHTML = '[+]';
			}
		}
}

function update_bgcolor(id) {

	if (document.getElementById)
		{
		var f = document.getElementById(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.background = f.options[f_sel].style.background;
		}
	} else if (document.all)
		{
		var f = document.all(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.background = f.options[f_sel].style.background;
		}
	} else if (document.layers)
		{
		var f = document.layers(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.background = f.options[f_sel].style.background;
		}
	}
}

function update_fonttype(id) {

	if (document.getElementById)
		{
		var f = document.getElementById(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.fontFamily = f.options[f_sel].style.fontFamily;
		}
	} else if (document.all)
		{
		var f = document.all(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.fontFamily = f.options[f_sel].style.fontFamily;
		}
	} else if (document.layers)
		{
		var f = document.layers(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.fontFamily = f.options[f_sel].style.fontFamily;
		}
	}
}

function update_fontcolor(id) {

	if (document.getElementById)
		{
		var f = document.getElementById(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.color = f.options[f_sel].style.color;
		}
	} else if (document.all)
		{
		var f = document.all(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.color = f.options[f_sel].style.color;
		}
	} else if (document.layers)
		{
		var f = document.layers(id);
		var f_sel = f.selectedIndex
		if (f.options[f_sel].value != "0") {
			f.style.color = f.options[f_sel].style.color;
		}
	}
}

function check_uncheck(id)
{
	if (document.getElementById)
		{
		var f = document.getElementById(id);
		if (f.value == "off") {
			f.value = "on";
			} else {
			f.value = "off";

			}
		}
		return true;
}

function insert_delim2(id)
{
	if (document.getElementById)
		{
		var f = document.getElementById(id);
		f.value += '|';
		f.focus();
		}
}

function insert_delim(id)
{
	if (document.getElementById)
		{
		var f = document.getElementById(id);
		f.value += '^';
		f.focus();
		}
}


function proc_t2_radio(radio_name, txt_name)  //onclick
{
	if (document.answers[radio_name][(document.answers[radio_name].length)-1].checked) {
		document.answers[txt_name].focus();
	}
}

function proc_t2_text(radio_name, txt_name)  //onclick
{
		document.answers[radio_name][(document.answers[radio_name].length)-1].value = document.answers[txt_name].value;
}

function proc_t5_text(txt_name, field_count, field_names)  //onclick
{
		tmp_txt_5 = '';
		var field_names_tmp = field_names.split("|");
		for (i=0;i<field_count;i++) {
				if (field_names_tmp[i].length == 0) {btwn = '_ ';} else {btwn = '_' + field_names_tmp[i];}
				tmp_txt_5 = tmp_txt_5 + '|' + (i+1) + btwn + '_' + document.answers[txt_name + '_txt_' + i].value;
		}
		document.answers[txt_name + '_global'].value = tmp_txt_5.substring(1,tmp_txt_5.length);
		//alert(document.answers[txt_name + '_global'].value);

}


function proc_t7_radio(radio_name, field_count)  //onclick
{
	tmp_txt_7 = '';
	var c_one = false;
	for (y=0;y<field_count;y++) {
		for (i=0;i<document.answers[radio_name + '_' + y].length;i++) {

			if (document.answers[radio_name + '_' + y][i].checked) {
				c_one = true;
				tmp_txt_7 = tmp_txt_7 + '|' + (y+1) + '_' + document.answers[radio_name + '_' + y][i].value;
				}

		}

		if (!c_one) { 
			tmp_txt_7 = tmp_txt_7 + '|' + (y+1) + '_';  
			}

		c_one = false;
		
	}
	
	document.answers[radio_name + '_global'].value = tmp_txt_7.substr(1,tmp_txt_7.length);
    //alert(document.answers[radio_name + '_global'].value);
}

function proc_t8_text(radio_name, txt_name)  //onclick
{		
	var old_val = document.answers[radio_name][0].value;
	var io_1 = old_val.indexOf('^');
	var io_2 = old_val.lastIndexOf('^');
	
	
	for (i=0;i<document.answers[radio_name].length;i++){
			document.answers[radio_name][i].value = '|' + document.answers[txt_name].value + document.answers[radio_name][i].value.substring(io_2,document.answers[radio_name][i].value.length);
		}
}

function proc_t4_check(check_name, txt_name)  //onclick
{
	tmp_txt_4 = '';
	if (document.answers[check_name][(document.answers[check_name].length)-1].checked) {
		document.answers[txt_name].focus();
	}

	for (i=0;i<document.answers[check_name].length;i++){
			
			if (document.answers[check_name][i].checked) {
				tmp_txt_4 = tmp_txt_4 + '|' + (i+1) + '_' + document.answers[check_name][i].value;
			} else {
				tmp_txt_4 = tmp_txt_4 + '|' + (i+1) + '_';
				}
			
		}
		document.answers[check_name + '_global'].value = tmp_txt_4.substr(1,tmp_txt_4.length);
}

function proc_t4_text(check_name, txt_name)  //onclick
{		
		tmp_txt_4 = '';
		document.answers[check_name][(document.answers[check_name].length)-1].value = document.answers[txt_name].value;
		
		for (i=0;i<document.answers[check_name].length;i++){
			if (document.answers[check_name][i].checked) {
				tmp_txt_4 = tmp_txt_4 + '|' + (i+1) + '_' + document.answers[check_name][i].value;
			} else {
				tmp_txt_4 = tmp_txt_4 + '|' + (i+1) + '_';
				}
		}
		document.answers[check_name + '_global'].value = tmp_txt_4.substr(1,tmp_txt_4.length);
}

function proc_t3_check(check_name, txt_name)  //onclick
{	
	tmp_txt_3 = '';

	for (i=0;i<document.answers[check_name].length;i++){
			
			if (document.answers[check_name][i].checked) {
				tmp_txt_3 = tmp_txt_3 + '|' + (i+1) + '_' + document.answers[check_name][i].value;
			} else {
				tmp_txt_3 = tmp_txt_3 + '|' + (i+1) + '_';
				}
			
		}
		document.answers[check_name + '_global'].value = tmp_txt_3.substr(1,tmp_txt_3.length);
}

function proc_t10_text(txt_name, field_count_x, field_count_y)  //onclick
{		
		tmp_txt_10_y = '';
		tmp_txt_10_xy = '';
		tmp_txt_10_extdef = '';
		
		for (i=0;i<extdef.length;i++) {
			if (extdef[i][0] == txt_name) {
				tmp_txt_10_extdef = tmp_txt_10_extdef + extdef[i][1];
			}
		}
		var tmp_txt_10_extdef_tmp_row = tmp_txt_10_extdef.split("^"); 
		
		for (y=0;y<field_count_y;y++) { 
			for (x=0;x<field_count_x;x++) { 
				
				tmp_txt_10_y = tmp_txt_10_y + tmp_txt_10_extdef_tmp_row[y].split("|")[x] + '_' + document.answers[txt_name + '_' + x + '_' + y].value + '|';
			}
			tmp_txt_10_y = tmp_txt_10_y.substring(0,(tmp_txt_10_y.length)-1);
			tmp_txt_10_xy = tmp_txt_10_xy + tmp_txt_10_y + '^';
			tmp_txt_10_y = '';
		}
			tmp_txt_10_xy = tmp_txt_10_xy.substring(0,(tmp_txt_10_xy.length)-1);
			document.answers[txt_name + '_global'].value = tmp_txt_10_xy;
}

function check_analyze()  //ajax
{
	analyze_question = '';
	if (document.manage_analyse.question_analyse.value) { 
		analyze_question = '|' + document.manage_analyse.question_analyse.value;
	} else {
	for (i=0;i<document.manage_analyse.question_analyse.length;i++){
			
			if (document.manage_analyse.question_analyse[i].checked) {
				analyze_question = analyze_question + '|' + document.manage_analyse.question_analyse[i].value;
				
			}
			
		}
		}
		analyze_question = analyze_question.substring(1,(analyze_question.length));
		document.manage_analyse.analyze_questions.value = analyze_question;
}

function self_filter() {

	var self_filter = '';
	for (i=0;i<document.manage_analyse.filter_self_tmp.length;i++){
		if (document.manage_analyse.filter_self_tmp[i].checked) {		
			self_filter = self_filter + '|' + document.manage_analyse.filter_self_tmp[i].value;
		} 
	}
	document.manage_analyse.filter_self.value = self_filter.substr(1,self_filter.length);
 
}
function OtvorOkno(theURL,winName,features) {
		window.open(theURL,winName,features);
	}
function proc_t1_radio(radio_name, txt_name)  //onclick
{	
	tmp_txt_1 = '';
	
	for (i=0;i<document.answers[radio_name].length;i++){
			if (document.answers[radio_name][i].checked) {
				tmp_txt_1 = (i+1) + '_' + document.answers[radio_name][i].value;
			}
		}
	
		document.answers[radio_name + '_global'].value = tmp_txt_1;
		
}

function proc_t9_list(list_name, txt_name)  //onclick
{	
	tmp_txt_9 = '';
	
	
	for (i=0;i<document.answers[list_name].length;i++){
	
			if (i == document.answers[list_name].selectedIndex) {
				tmp_txt_9 = (i) + '_' + document.answers[list_name].options[i].value;
			}
		}
	
		document.answers[list_name + '_global'].value = tmp_txt_9;
}