function DecodeEmail(z)
{
 z=z.replace(/ ~ /,'@');
	return z;
}

function cloneObject(what) {
	for (i in what) {
		this[i] = what[i];
	}
}

function trim(s)
{
 return s.replace(/^\s+|\s+$/g, "");
}

function in_array(k,a)
{
	for(q=0;q<a.length;q++) {
		if (a[q] == k) {
			return true;
		}
	}
	return false;
}

function jsCheckForm(formname,formfields,msg)
{
    var ok = 1>0;
    var fields = formfields.split(',');
    frm = document.forms[formname];
    for (i in fields) {
        if (trim(frm.elements[fields[i]].value) == '') {
            ok = 1<0;
        }
    }
    if (ok == false) {
        alert(msg);
    }
    return ok;
}

ie = (navigator.userAgent.indexOf("MSIE") > -1)?1:0;
js_collapse = (ie?"hidden":"collapse");

function jsHide(what,x)
{
    res = (x?'visible':js_collapse);
    if (document.getElementById(what)) {
        document.getElementById(what).style.visibility = res;
        if (ie) {
            document.getElementById(what).style.display=(x?'block':'none');
        }
    }
}

function jsAttachEvent(to,event,func)
{
 if (ie) {
    eval(to+".attachEvent('on"+event+"',"+func+")");
 } else {
    eval(to+".addEventListener('"+event+"',"+func+",false)");
 }
}

function jsGetEl(name)
{
    if (arguments.length>1) {
        property=arguments[1];
    } else {
        property = '';
    }
    if (property) {
        if (document.getElementById(name)) {
            eval('tmp = document.getElementById(name).'+property);
            return tmp;
        } else {
            return 0;
        }
    } else {
        return document.getElementById(name);
    }
}

function jsGetElVal(name)
{
 	return jsGetEl(name,'value');
}

function jsSetEl(name,property,value)
{
    eval_code = -1;
    if (jsGetEl(name)) {
        eval(eval_code = 'document.getElementById(name).'+property+' = value;');
    }
    return eval_code;
}
function jsSetElVal(name,value)
{
    return jsSetEl(name,'value',value);
}

function var_dump(q)
{
    texts = new Array;functions = new Array;others = new Array;
    //alert('in var_dump');
    //alert(typeof q);
    for (z in q) {
        //alert(z+' = '+typeof(q[z]));
        if (typeof q[z] == 'function') {
         functions.push(z);
        } else if (typeof q[z] == 'unknown') {
         others.push(z);
        } else {
         text = z + ' = '+q[z];
         texts.push(text);
        }
    }
    texts.sort();
    for(i=0;i<texts.length;i++) {
     if (i && !(i%4)) {
      texts[i] = texts[i]+"\n";
     }
    }
    alert(texts.join(', ')+(functions.length?"\nfunctions:"+functions.join(', '):'')+(others.length?"\nothers:"+others.join(', '):''));
}
