function my_confirm(str) {
	var conf = window.showModalDialog('../dialogs/confirm.php?sid='+sid,str,'center:yes;scroll:yes;dialogWidth:350px;dialogHeight:150px');
	return (conf);
}

function my_confirm_yes_no(str,l) {
	var conf = window.showModalDialog('../dialogs/confirm_yes_no.php?l='+l,str,'center:yes;scroll:no;dialogWidth:350px;dialogHeight:150px');
	return (conf);
}

function applyToAllPages() {
	var curr_page = document.getElementById('pall');
	var curr_selection = curr_page.options.selectedIndex;
	var pos = 0;
	while (pos < pages.length) {
		var page = document.getElementById('p'+pos);
		page.options.selectedIndex = curr_selection;
		pos++;
	}
}

function applyToSubpages(pos,level) {
	var curr_page = document.getElementById('p'+pos);
	var curr_selection = curr_page.options.selectedIndex;
	pos++;
	while ((pos<pages.length) && (pages[pos]['level'] > level)) {
		var next_page = document.getElementById('p'+(pos));
		next_page.options.selectedIndex = curr_selection;
		pos++;
	}
}

function toggleVisibility(img,id) {
	var div_ref = document.getElementById(id);
	if (div_ref.style.display == "none") {
		img.src = '../images/collapse.gif';
		div_ref.style.display = "block";
	} else {
		div_ref.style.display = "none";
		img.src = '../images/expand.gif';
	}
}

function insideList(val,lists) {
	var arrList = lists.split(',');
	var result = false;
	
	for (key in arrList) {
		if (val == arrList[key]) {
			result = true;
			break;
		}
	}
	return result;
}