
function hideLayer(str, doc) {
	var obj = doc.getElementById(str);
	obj.style.display = 'none';
}


function showLayer(str, doc) {
	var obj = doc.getElementById(str);
	obj.style.display = '';
}

// ***********************************************************************

var HexChars = "0123456789ABCDEF";

function Hex2Dec(HexVal){
	HexVal=HexVal.toUpperCase();
	var DecVal=0;
	var HV1=HexVal.substring(0,1);
	DecVal=(HexChars.indexOf(HV1)*16);
	HV1=HexVal.substring(1);
	DecVal+=HexChars.indexOf(HV1);
	return DecVal;
}

function Dec2Hex(DecVal){
	DecVal=parseInt(DecVal);
	if (DecVal > 255 || DecVal < 0){
		DecVal=255;
	}
	var Dig1 = DecVal % 16;
	var Dig2 = (DecVal-Dig1) / 16;
	var HexVal = HexChars.charAt(Dig2)+HexChars.charAt(Dig1);
	return HexVal;
}

// ***********************************************************************

function email_decode(str) {
	var out = '';
	for (i=0; i<str.length/2; i++) {
		out += String.fromCharCode((Hex2Dec(str.substring(i*2,i*2+2))^i)/2);
	}
	return out;
}

// ***********************************************************************

function handler_error(message, url, line) {
    if (!handler_error_ignore) {
        cutpos = url.lastIndexOf('?');
        if (cutpos==0) {
            cutpos=url.length();
        }
        uri = url.substring(0,cutpos);
        var str = "An error occured in\n  "+uri+"\n\n Line "+line+"\n  "+message+"\n\nIgnore further errors and continue?";
        handler_error_ignore = confirm(str);
        return true;
    } else {
        return false;
    }
}

window.onerror = handler_error;
var handler_error_ignore = false;


function doNothing(e) {  }


function jumpOnChecked(obj, s) {
    if (obj.accept.checked==true) {
        return true;
    } else {
        alert(s);
        return false;
    }
}


function jumpConditional(msg, url) {
    if (confirm(msg)) {
        document.location= url;
    }
}


function jump(url) {
    if (url!='') {
        document.location= url;
    }
}


function popUp(url, w, h) {
    t = (screen.availHeight-h)/11*3;
    l = (screen.availWidth-w)/11*3;
    var winCheckup=window.open(url,'checkup','location=no, toolbar=no, status=no, scrollbars=yes, menubar=no, resizable=yes, left='+l+', width='+w+', top='+t+', height='+h);
}

