function addEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType,fn,useCapture);
		return true;
	} else if(obj.attachEvent){
		return obj.attachEvent("on"+evType,fn);
	} else {
		return false;
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if (node == null) node = document;
	if (tag == null) tag = '*';
	var elems = node.getElementsByTagName(tag);
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	var i = 0;
	for (var j = 0; j < elems.length; j++) {
		if ( pattern.test(elems[j].className) ) {
			classElements[i++] = elems[j];
		}
	}
	return classElements;
}

function collapsible() {
	var collap = getElementsByClass("collapsible",null,"div");
	if (collap) {
		for(i in collap) {
			var dt = collap[i].getElementsByTagName("dt");
			for(j in dt) {
				dt[j].onclick = function() {
					this.parentNode.className = this.parentNode.className?'':'active';
					return false;
				}
			}
		}
	}
}

addEvent(window, 'load', collapsible);

function popup(url,name,width,height,wplus,hplus,focus,left,top,menubar,status,toolbar,scrollbar,resizable,scrx,scry,directories,loc) {
	if ( !url ) return false;
	if ( !name ) name = 'popupWin';
	if ( !width ) width = '';
	if ( !height ) height = '';
	if ( !directories ) directories = 'no';
	if ( !loc ) loc = 'no';
	if ( !menubar ) menubar = 'no';
	if ( !status ) status = 'no';
	if ( !toolbar ) toolbar = 'no';
	if ( !scrollbar ) scrollbar = 'no';
	if ( !resizable ) resizable = 'no';
	if ( !scrx ) scrx = '100';
	if ( !scry ) scry = '100';
	if ( !left ) left = '100';
	if ( !top ) top = '100';
	if ( wplus ) width  += wplus;
	if ( hplus ) height += hplus;

    var popupWin = window.open(url,name,'width='+width+'px,height='+height+'px,left='+left+',top='+top+',menubar='+menubar+',status='+status+',toolbar='+toolbar+',scrollbars='+scrollbar+',resizable='+resizable+',screenX='+scrx+',screenY='+scry+'directories='+directories+',location='+loc);

	if ( focus ) popupWin.focus();
}

function copyField(from, to) {
  document.getElementById(to).value = document.getElementById(from).value;
}

function set(input) {

  input.value = '';
}

function leave(input) {

  input.value = (input.value == '') ? input.defaultValue : input.value;
}
function changeImage(img, img_src) {

  img.src = img_src;
}

function toggle_home( table ) {

    table_obj = document.getElementById(table);
	
	to = table_obj.style.display == 'none' ? 'block': 'none';

	table_obj.style.display = to;

}

var old_table_02 = '';
var is_opened  = 'none';

function toggle( table ) {

    table_obj = document.getElementById(table);
    is_opened = table_obj.style.display;

	/*if (table != 'a01')
	{
		document.getElementById('a01').style.display = 'none';
	}*/

    if (old_table_02 != '') {
        old_table_obj = document.getElementById(old_table_02);
        old_table_obj.style.display = 'none';
    }

    if (old_table_02 != table || is_opened == 'none') {

        table_obj.style.display = 'block';
    }

    old_table_02 = table;
}

var old_span_02 = 'sm00';
function toggle_sitemap( table ) {

    table_obj = document.getElementById(table);
    is_opened = table_obj.style.display;

	/*if (table != 'a01')
	{
		document.getElementById('a01').style.display = 'none';
	}*/

	if (old_span_02 == table)
	{
		return false;
	}

    if (old_span_02 != table) {

        table_obj.style.visibility = 'visible';
    }

	if (old_span_02 != '') {
        old_table_obj = document.getElementById(old_span_02);
        old_table_obj.style.visibility = 'hidden';
    }


    old_span_02 = table;
}


function confirmMsg (msg)
{
	var con = confirm(msg);
	if (con)
			return true ;
	else
			return false ;
}