function MessageBox(_d0,s){
	return doConfirm(_d0,s);
}
function doConfirm(_bf,_c0){
	ret=window.confirm(_c0);
	if(ret){
		_bf.select();
		_bf.focus();
		_bf.select();
		return false;
	}
	return (true);
}

function CheckCurrency2(box,_fc,nozero){
	var _fd=box.value;
	if(_fd.length==0){
	return (true);
	}
	var _fe=_fd.replace(",",".");
	if(parseFloat(_fe)<0 && nozero==1){
		return MessageBox(box,"Nedovoljena vrednost! želite popraviti?");
	}
	var _ff="0123456789.,";
	var _100=true;
	var _101=box.value.length;
	var _102=false;
	for(i=0;i<_fd.length;i++){
	ch=_fd.charAt(i);
	for(j=0;j<_ff.length;j++){
	if(ch==_ff.charAt(j)){
	break;
	}
	}
	if(j==_ff.length){
	_100=false;
	break;
	}
	}
	if(!_100){
	return MessageBox(box,"V polje "+_fc+" vpi\u0161ite samo \u0161tevilke.");
	box.focus();
	return (false);
	}
	if(_fd.charAt(0)==","){
	return MessageBox(box,"V polje "+_fc+" pravilno postavite decimalno vejico.");
	box.focus();
	return (false);
	}
	while(_fd.charAt(0)=="0"){
	_fd=_fd.substring(1,box.value.length);
	}
	dec=-1;
	for(i=_fd.length-1;i>=0;i--){
	if(_fd.charAt(i)==","){
	if(!(dec==-1)){
	return MessageBox(box,"V polje "+_fc+" pravilno postavite decimalno vejico.");
	box.focus();
	return (false);
	}
	_102=true;
	dec=i;
	}
	if(_fd.charAt(i)=="."){
	if(dec==-1){
	dec=_fd.length;
	}
	if(!((dec-i)%4==0)){
	return MessageBox(box,"V polje "+_fc+" pravilno postavite piko oz. decimalno piko nadomestite z decimalno vejico.");
	box.focus();
	return (false);
	}
	if(i==0){
	return MessageBox(box,"V polje "+_fc+" pravilno postavite piko oz. decimalno piko nadomestite z decimalno vejico.");
	box.focus();
	return (false);
	}
	}
	}
	all=_fd.split(".");
	tmpvalue="";
	for(i=0;i<all.length;i++){
	tmpvalue+=all[i].replace(",",".");
	}
	if(_102){
	tmpvalue=Math.round(parseFloat(tmpvalue)*100)/100;
	if((tmpvalue%1)==0){
	_fd=tmpvalue+"";
	n=_fd.length;
	for(i=1;i<((n-1)-((n-1)%3))/3+1;i++){
	_fd=_fd.substring(0,_fd.length-3*(i)-i+1)+"."+_fd.substring(_fd.length-3*(i)-i+1,_fd.length);
	}
	}else{
	_fd=tmpvalue+"";
	_fd=_fd.replace(/\./,",");
	if(_fd.charAt(_fd.length-2)==","){
	_fd+="0";
	}
	n=_fd.length;
	for(i=1;i<((n-1)-((n-1)%3))/3;i++){
	_fd=_fd.substring(0,_fd.length-2-4*(i))+"."+_fd.substring(_fd.length-2-4*(i),_fd.length);
	}
	}
	}else{
	_fd=tmpvalue+"";
	n=_fd.length;
	for(i=1;i<((n-1)-((n-1)%3))/3+1;i++){
	_fd=_fd.substring(0,_fd.length-3*(i)-i+1)+"."+_fd.substring(_fd.length-3*(i)-i+1,_fd.length);
	}
	}
	if(_fd.search(",")==-1){
	_fd+=",00";
	}
	if(_fd.charAt(0)==","){
	_fd="0"+_fd;
	}
	box.value=_fd;
	return (true);
}

function CheckCurrency(box, name) //checkiram, ee je znesek v standardni obliki
	{

	var value = box.value;
	var tmpvalue='';
	var decvalue='';
	var validText = "0123456789,.";
	var validNum = "0123456789";
	var validDec = ",.";
	var firstDec = '';
	var nextDec = '';
	var ch;

//	value.replace(/[^0-9]/g);

	for (i = value.length;  i >= 0; i--)
	{
		ch = value.charAt(i);
		for (j = 0;  j < validText.length;  j++) {
			if (ch == validText.charAt(j)) {
				tmpvalue = ch+tmpvalue;
				for (k = 0;  k < validDec.length;  k++) {

					if (ch == validDec.charAt(k))
					{
						if (firstDec == '')
						{
							firstDec = ch;
						} else {
							nextDec = ch;
						}

					}
				}
			}
			
		}
	}

	if (firstDec && nextDec)
	{
		tmpvalue2 = tmpvalue;
		tmpvalue = '';
		decPos = tmpvalue2.lastIndexOf(firstDec);

		for (i = 0;  i < tmpvalue2.length;  i++)
		{
			if (tmpvalue2.charAt(i) != nextDec)
			{
				if (i<decPos && tmpvalue2.charAt(i) != firstDec || i>=decPos)
				{
					tmpvalue += tmpvalue2.charAt(i);
				}
			}
		}
		alert('Numerični vnos ni pravilen, zato bo spremenjen: ' + tmpvalue2 + ' => ' + tmpvalue);
	}

	value=tmpvalue.replace(/\,/g, '.');

	box.value=value;
	return(true);
}

//=======================================================================================-
//=======================================================================================-

function CheckDate(box, name) //checkiram, �e je datum v standardni obliki
	{

	var value = box.value;
	var tmpvalue='';

   for (i=0; i < value.length; i++)
   {
	   value=value.replace(',','.');
		value=value.replace(/\//, '.');
   }
	
	box.value=value;
	return(true);
}

//=======================================================================================-
//=======================================================================================-
	function DisplayLen (thisForm, o,ln)
	  {
		var nRemain;

		nRemain=ln-o.value.length;

		if (nRemain<0)
		  {
		    thisForm.idTest.style.color="#990000";
			thisForm.idTest.value="0";
			TrimExcess(thisForm,o,ln);
		  }
		else
		  {
		    thisForm.idTest.style.color="#000000";
			thisForm.idTest.value=nRemain;
			return false;
		  }
	  }

	function LooseFocus(obj)
	  {
		obj.blur;
	  }

	function TrimExcess(thisForm,o,ln)
	  {
		if (o.value.length>ln)
		  {
			alert ("Presegli ste omejitev znakov. Skrajsajte opombe! "+o.value.length+'/'+ln);	
			o.value=o.value.substr(0,ln);
		  }
	  }

//=======================================================================================-
//=======================================================================================-
function CheckPhone(theForm,theField) {

var mobi = new Array("030","031","040","041","050","051","064","070","081");
var four = new Array("080","090");
var iptel = new Array("059");
var xtelefonska = "";
var konec =0;
var z=0;

var telefonska=theField.value;

if ( telefonska.substring(0,1)!="+" && telefonska.substring(0,2)!="00" ) {
	for(x=0;x<20;x++){

		if(	telefonska.charAt(x)=="-" || telefonska.charAt(x)==" " || telefonska.charAt(x)=="/" || 
			telefonska.charAt(x)=="(" || telefonska.charAt(x)==")" || telefonska.charAt(x)==",") { continue;
		}

		xtelefonska =   xtelefonska + telefonska.charAt(x);

		var dolzina = xtelefonska.length;
	}
} else {
	xtelefonska = telefonska;
	var dolzina = xtelefonska.length;
}

if(xtelefonska.indexOf("00")==0){
	xtelefonska = "+" + xtelefonska.substring(2,dolzina)
}

if(xtelefonska.substring(0,1)!="+") {

	for(x=0;x<20;x++){
		var prvi = xtelefonska.charAt(x)
		var drugi = parseInt(xtelefonska.charAt(x))

		if(prvi==drugi || (xtelefonska.charAt(x)=="+" && x==0)) {
			z++;
		}
	}

	if(dolzina != z) {
		alert("Napaka! Vnesli ste črke")
		konec=1}
	else konec=0;
} else {
	z=dolzina
}

if(konec==0){ 

r=0

telefonska = xtelefonska;

if((telefonska.substring(0,3) == iptel[0]) && z==9){

	izpis = telefonska.substring(0,4) + "/" + telefonska.substring(4,6)+ "-" + telefonska.substring(6,9)
	theField.value=izpis;
	r=1
}
else{
if((telefonska.substring(0,3) == four[0] 
|| telefonska.substring(0,3) == four[1]) && z==7){

	izpis = telefonska.substring(0,3) + "/" + telefonska.substring(3,5)+ "-" + telefonska.substring(5,7)
	theField.value=izpis;
	r=1
}
else{
if((telefonska.substring(0,3) == mobi[0] 
|| telefonska.substring(0,3) == mobi[1]
|| telefonska.substring(0,3) == mobi[2]
|| telefonska.substring(0,3) == mobi[3]
|| telefonska.substring(0,3) == mobi[4]
|| telefonska.substring(0,3) == mobi[5]
|| telefonska.substring(0,3) == mobi[6]
|| telefonska.substring(0,3) == mobi[7]
|| telefonska.substring(0,3) == mobi[8]) && z==9){

	izpis = telefonska.substring(0,3) + "/" + telefonska.substring(3,6)+ "-" + telefonska.substring(6,9)
	theField.value=izpis;
	r=1
}
else{
if(z>8 && telefonska.substring(0,1)=="+"){
izpis = telefonska;

	theField.value=izpis;
	r=1
}
else{
if(telefonska.substring(0,1)=="+" &&r!=1){
alert(" NAPAKA !!! Mednarodna telefonska številka je prekratka. ")
}}


if(z==9 && telefonska.substring(0,1)!="+"){
	izpis = telefonska.substring(0,2) + "/" + telefonska.substring(2,5)+ "-" + telefonska.substring(5,7) + "-" + telefonska.substring(7,9)
	theField.value=izpis;
r=1
}}
}
if(z==17 && telefonska.substring(0,1)!="+"){
izpis = telefonska.substring(0,3)+ "-" + telefonska.substring(3,5) + "-" + telefonska.substring(5,7)

alert("Vpišite celotno tel. številko z omrežno skupino: " + izpis)
r=1
}
else{
if(telefonska.length>0 && telefonska.substring(0,1)!="+" && r!=1){
alert(" NAPAKA !!! Telefonska številka je prekratka ali predolga. ")
}}
}
}
}

function oglasPics(imageSrc,oglasId) { 
	fileName = '/nepremicnine_slike.html?pic='+imageSrc + '&detail=' + oglasId;
	myWindowHandle = window.open(fileName,'Slikeoglasa','directories=no, location=no, menubar=0, scrollbars=no, status=no, toolbar=no, resizable=no, top=10, screenX=10, screenY=10');
	myWindowHandle.focus();
}

function serviceWin(oper,oglasId,par) { 
	fileName = '/service.html?oper=' + oper + '&detail=' + oglasId + '&' + par
	myWindowHandle = window.open(fileName,'NOservice','width=300, height=240, directories=no, location=no, menubar=no, scrollbars=no, status=no, toolbar=no, resizable=no, top=200, left=200');
	myWindowHandle.focus()
}

function printWin(oper,oglasId,par) { 
	fileName = '/print.html?oper=' + oper + '&detail=' + oglasId + '&' + par
	myWindowHandle = window.open(fileName,'NOprint','width=700, height=700, directories=no, location=no, menubar=no, scrollbars=yes, status=no, toolbar=no, resizable=yes, top=10, left=50');
	myWindowHandle.focus()
}
