var errorstr = '';

///////////////////////////////////////////////////////////////////////////////
function onLoad_doc(event){
	if(!event) event = window.event;
	if(window.AntiSpam_mailto) AntiSpam_mailto();
	if(window.alphaFixIE) alphaFixIE();

	if(window.customOnLoad_doc) customOnLoad_doc(event);
	if(window.errorstr) setTimeout('alert(errorstr);', 100);
	}

///////////////////////////////////////////////////////////////////////////////
function AntiSpam_mailto(){
	var arrA = document.getElementsByTagName('A');
	for(var i=0; i<arrA.length; i++){
		if(!arrA[i].getAttributeNode('href')) continue;
		aElementHref = arrA[i].getAttributeNode('href');
		aElementHref.value = aElementHref.value.replace(/^(mailto:.*)_KUKAC_/, '$1@');
		arrA[i].innerHTML = arrA[i].innerHTML.replace(/_KUKAC_/g, '@');
		}
	}

///////////////////////////////////////////////////////////////////////////////
function openPopup(url,name,width,height,left,top,params) {
	if (!params) params = ', location=no, menubar=no, toolbar=no, directories=no, status=no, resizable=yes, scrollbars=yes';
	if (width=='auto') width = Math.round(window.screen.availWidth);
	if (height=='auto') height = Math.round(window.screen.availHeight);
	if (left='center') left = Math.round((window.screen.availWidth-width)/2);
	if (top='center') top = Math.round((window.screen.availHeight-height)/2);
	if (width) width = ', width = '+(width-12); //12 = border
	if (height) height = ', height = '+(height-31); // 31 = border + title
	if (!isNaN(left)) left = ', left = '+left;
	if (!isNaN(top)) top = ', top = '+top;
	params = width+height+left+top+params;
	window.open(url,name,params);
	}

///////////////////////////////////////////////////////////////////////////////
function form_check(formname, notnull, class_good, class_bad){
	var obj_form = document.forms[formname];
	if(!obj_form) return false;

	var badpresent = false;
	for(var i=0; i<notnull.length; i++){
		var obj_notnull = obj_form[notnull[i]];
		if(obj_notnull.value.length == 0){
			obj_notnull.className = class_bad;
			if(!badpresent) obj_notnull.focus();
			badpresent = true;
			}
		else obj_notnull.className = class_good;
		}
	return !badpresent;
	}

///////////////////////////////////////////////////////////////////////////////
function form_passChk(formname, input_pass1, input_pass2, class_good, class_bad){
	var obj_form = document.forms[formname];
	if(!obj_form) return false;

	if(obj_form[input_pass1].value!=obj_form[input_pass2].value){
		obj_form[input_pass1].className = class_bad;
		obj_form[input_pass2].className = class_bad;
		obj_form[input_pass1].focus();
		return false;
		}
	obj_form[input_pass1].className = class_good;
	obj_form[input_pass2].className = class_good;
	return true;
	}



///////////////////////////////////////////////////////////////////////////////
function addUploadInput(deldisp){
	if(uploadInputs>=10) return;
	var obj_fileUploads = document.getElementById('fileUploads');
	var obj_hiddenFileUploads = document.getElementById('hiddenFileUploads');
	if(!obj_fileUploads || !obj_hiddenFileUploads) return;

	uploadInputs++;
	var tpl = jsTPL_fileUploadItem;
	tpl = tpl.replace(/#ID#/g, uploadInputs);
	tpl = tpl.replace(/#DELDISP#/g, deldisp);
	obj_hiddenFileUploads.innerHTML = tpl;

	var obj_uploadItem = document.getElementById('uploadItem'+uploadInputs);
	if(!obj_uploadItem) return;
	obj_fileUploads.appendChild(obj_uploadItem);
	}
///////////////////////////////////////////////////////////////////////////////
function delUploadInput(id){
	var obj_fileUploads = document.getElementById('fileUploads');
	var obj_uploadItem = document.getElementById('uploadItem'+id);
	if(!obj_fileUploads || !obj_uploadItem) return;
	obj_fileUploads.removeChild(obj_uploadItem);
	}


///////////////////////////////////////////////////////////////////////////////
function generatePass(){
	var abc = 'abcdefghijklmnopqrstuvwxyz';
	var rchar = '';
	for(var i=0; i<3; i++){
		rchar += abc.substr(Math.floor(Math.random()*25), 1);//0-25
		if(i==0) rchar = rchar.toUpperCase();
		}
	var rnum = '';
	for(var i=0; i<3; i++) rnum += Math.floor(Math.random()*10);//0-9
	return rchar+rnum;
	}

///////////////////////////////////////////////////////////////////////////////
