function show(cont_id) {
    target = document.getElementById(cont_id);
	if (target && typeof target.style != "undefined"
    && typeof target.style.display != "undefined"){
    target.style.display = ""; }
}
function hide(cont_id) {
    target = document.getElementById(cont_id);
	if (target && typeof target.style != "undefined"
    && typeof target.style.display != "undefined"){
    target.style.display = "none"; }
}
function toggle(what,targetId) {
    target = document.getElementById(targetId);
	target.style.display = (what.checked)?'':'none';
}
function showIt(cont_id) {
    target = document.getElementById(cont_id);
	if (target && typeof target.style != "undefined"
    && typeof target.style.display != "undefined"){
    target.style.visibility = "visible"; }
}
	var _b = new Array("#ffffdd","#eeeeee");
function changeButton(i) {
	document.form1.subButton.style.background = _b[i];
}
	var keys = document.all?true:false;
function keyHandler(e) {
 	var _ret=true;
 	var _char=keys?window.event.keyCode:e.which;
 	if(_char==13) {_ret=false;}
 	return _ret;
}
	/* onkeypress="return onlyDigits(event,'decOK');"
	Code: decOK = decimal point OK; all = allow all except 13; slash=allow / only  */
	var kStroke = document.all?true:false;
function onlyDigits(e,decReq) {
	var _ret=true;
	var key = kStroke?window.event.keyCode:e.which;
	if(key==13) {_ret=false;return _ret;}
	if (decReq == 'all') {return true;}
	var obj = kStroke?event.srcElement:e.target;
	isNum = (key > 47 && key < 58) ? true:false;
	if (decReq == 'slash') {isNum = (key >= 47 && key < 58) ? true:false;}
	if (decReq == 'dash') {isNum = (key == 45 || (key >= 48 && key< 58)) ? true:false;}
	var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length===0)) ? true:false;
	if(key < 32) {return true;}   
	return (isNum || dotOK);
}
function changeTxt(what) {
	document.getElementById(what).style.color = "#000000";
}
function setCookie(c_name,value,expiredays) {
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate)+"; path=/";
}
function setLogin (username) {
	counter=+0;pt_id="";examDate="";subCnt=+0;
	lValue=counter+"}"+pt_id+"}"+examDate+"}"+username+"}"+subCnt+"}";
	setCookie('login',lValue);//	login
}
function getCookieValue(c_name) {
	if (document.cookie.length>0) {
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1) { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(",",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return null
}
function killAll() {
	cookies = document.cookie.split(";");
	for (i=0;i<cookies.length;i++) {
	indCookie = cookies[i].indexOf("=");
	cName=cookies[i].substring(0,indCookie);
	setCookie(cName,'',-1);
	}
} 
function killLogin () {
	setCookie ('login','',-1);
}
function getCkieData () {
if (navigator.cookieEnabled) {hide('cookiesOff');show('cookiesOn');}
	else {show('cookiesOff');hide('cookiesOn');}
	hide('commentDiv');
	l_value = getCookieValue('login');
	if (!l_value) {alert("Error - gCD");}
	l_array = l_value.split("}");
	username=l_array[3];
	c_value = getCookieValue(username);
	tal=getCookieValue('tal');
	if (!username) {alert("No username");
	if (tal=='tal') {window.location="../tal.html";}
	else {window.location="../index.html";}
	}
	c_value=getCookieValue(username);
    if (!c_value) {c_value=null;}
    if (c_value!=null) { 
    c_array = c_value.split("{");
	if (username!=c_array[0]) {alert("Conflict: username!=array(0)");return false;}
	else {
	document.getElementById('docName').innerHTML = c_array[2];
	document.getElementById('clinic').innerHTML = c_array[1];
	}
  }
}
function init() {
	if (navigator.cookieEnabled) {hide('jsOn');show('theForm');
	document.forms["form1"].elements['regName'].focus();
	}
	else {show('jsOn');}
}
