function mfMask(p_num, addon)
{
	var x_num = Math.round(p_num * 100) / 100;
	var whole = ''+Math.floor(x_num);
	var output = '';


	for (i = whole.length-1; i >= 0 ; i--)
	{
		output = whole.charAt(i)+output;

		if (((whole.length-i)%3==0)&&(i>0))
		{
			output = '.'+output;
		}

	}
	if (output.charAt(output.length-1)=='.')
	{
		output = output.substring(0,output.length-2);
	}
	if (output == '') {	output = '0';}


	var wdec = ''+Math.round((x_num - Math.floor(x_num))*100);
	if (wdec.length <2)
	{
		wdec = '0'+wdec;
	}
	if (wdec == '') {	wdec = '00';}

	output = output+','+wdec+ addon;

	return output;
}

function mfUnMask(p_val, addon) {

	var output = p_val;
	output = output.replace(addon, '');
        while (output.indexOf('.') > -1) 
        {
        	output = output.replace('.', '');
        }	
        output = output.replace(',', '.');
	if (output.charAt(output.length-1) == '0') output.substr(0, output.length-2);
	if (output.charAt(output.length-1) == '0') output.substr(0, output.length-2);
	if (output.charAt(output.length-1) == '.') output.substr(0, output.length-2);
	return output;
}

function mfMaskSet(obj, addon) {
	if (!obj) return;
	if (obj.value=='') obj.value='0';

	obj.value = mfMask(obj.value, addon);
}

function mfMaskClear(obj, addon) {
	if (!obj) return;
	if (obj.value=='') return;
	
	obj.value = mfUnMask(obj.value, addon);
}

function isNumber(num1) {
	if ((num1 == "")||(num1 == " ")||(num1 == "  ")||(num1.length==0))
	  	return false
        else if ((num1 / 2 >= 0)||(num1 / 2 < 0)) 
	        return true
        else
	        return false
}

function onFocusClear0(obj) {
	if (obj.id.charAt(0) == 'n') {
		if (obj.value == '0') 
			obj.value='';
		else
		  obj.value=obj.value*1;
	} else if (obj.id.charAt(0) == 'm') {
		if (obj.value == '0') 
			obj.value='';
		else
		// tuki je treba replejsat vejco ce se ta funkcija pri onbluru prva klice
		  obj.value=parseFloat(Math.round(obj.value.replace(/,/,".")*100)/100);
	}
}

function getValue(obj) {
	if ((obj.id.charAt(0) == 'n') || (obj.id.charAt(0) == 'm')) {
		if (obj.value == '') 
			return 0;
		else
		  	return obj.value*1;
	}
	return obj.value;
}

function getSelectValue(selectid) {
	var select_obj;
	
	if (!getElementById(selectid)) return "";

	select_obj = getElementById(selectid);
	
	for(i=0; i<select_obj.length; i++) {
		if (select_obj.options[i].selected == true) return select_obj.options[i].value;
	}
	
	return "";
	
}

function getSelectID(selectid) {
	var select_obj;
	
	if (!getElementById(selectid)) return -1;

	select_obj = getElementById(selectid);
	
	for(i=0; i<select_obj.length; i++) {
		if (select_obj.options[i].selected == true) return i;
	}
	
	return -1;
	
}


function Izpis_Send(p_sendtopage) {
  var newWin = window.open(p_sendtopage, 'Izpis','width=680,scrollbars=yes,status=yes');
}


function izpisNove() {
	var v_out;
	var v_form;
	var v_element;
	var v_field;
	var v_divs;
	var v_spans;

	v_divs = document.getElementsByTagName('DIV');
	for (i=0; i<v_divs.length; i++)
	{
		if (v_divs[i].value == '') {
			v_divs[i].innerHTML = '<I>&nbsp;</I>';
		} else {
			v_divs[i].innerHTML = '<B>&nbsp;'+window.opener.document.getElementById(v_divs[i].id).value+'</B>';
		}
	}

	v_spans = document.getElementsByTagName('SPAN');
	for (i=0; i<v_spans.length; i++)
	{
		if (v_spans[i].value == '' || v_spans[i].id == '') {
			v_spans[i].innerHTML = '<I>&nbsp;</I>';
		} else {
			v_spans[i].innerHTML = '<B>&nbsp;'+window.opener.document.getElementById(v_spans[i].id).value+'</B>';
		}
	}
	setTimeout('window.print()', 400);
}


