<!-- Begin
function HP_frmValidate(val,myfrm,catwarning){
if (val.substring(0,1)=='A'){myfrm.action='seznam_izdelkov.asp'}
if (val.substring(0,1)=='#'){alert(catwarning)}
if (val!='#') {myfrm.submit()}}

function ErrWrite(){
if (window.writeErr) {writeErr();}}

function dateselected(oList,depList,AssocArray){
sethourval=false;
depList.selectedIndex=0
if (depList.value){sethourval=true; hourval=depList.value;}
var curform=oList.form;
clearCombo(depList);
if (oList.selectedIndex<0){oList.selectedIndex=0;}
var newvalue=oList.options[oList.selectedIndex].value;
fillCombo(depList,newvalue,AssocArray);
if (sethourval){selectByValue(depList,hourval)};}

function distributionselected(oList,depList,assocArray,prefix){
var curform=oList.form;
clearCombo(depList);
if (oList.selectedIndex<0){oList.selectedIndex=0}
if (oList.selectedIndex>=0){
 var newvalue=oList.options[oList.selectedIndex].value;
 fillComboDistr(depList,newvalue,assocArray,prefix);}
}

function dcomboselected(oList1,oList2,depList,assocArray,prefix1,prefix2){
var curform1=oList1.form;
var curform2=oList2.form;
clearCombo(depList);
if (oList1.selectedIndex<0){oList1.selectedIndex=0;}
if (oList2.selectedIndex<0){oList2.selectedIndex=0;}
if (oList1.selectedIndex>=0 && oList2.selectedIndex>=0){
 var newvalue1=oList1.options[oList1.selectedIndex].value;
 var newvalue2=oList2.options[oList2.selectedIndex].value;
 fillDCombo(depList,newvalue1,newvalue2,assocArray,prefix1,prefix2);}
}

function clearCombo(oList){
for (var i=oList.options.length - 1; i>=0; i--){oList.options[i]=null;}
oList.selectedIndex=-1;}

function fillCombo(oList,vValue,assocArray){
if (vValue!="" && assocArray['date='+vValue]){
 var arrX=assocArray['date='+vValue];
 for (var i=0; i < arrX.length; i=i+2){oList.options[oList.options.length]=new Option(arrX[i+1],arrX[i]);}}
else {
 var myArray=vValue.split('.');
 var output=new Date(myArray[2],myArray[1]-1,myArray[0]);
 var dayofweek=output.getDay();
 if (vValue!="" && assocArray['day='+dayofweek]){
  var arrX=assocArray['day='+dayofweek];
  for (var i=0; i < arrX.length; i=i+2){oList.options[oList.options.length]=new Option(arrX[i+1],arrX[i]);}}
 else {oList.options[0]=new Option("Ni dostave","");}
}}

function fillComboDistr(oList,vValue,assocArray,prefix){
if (vValue!="" && assocArray[prefix+vValue]){
 var arrX=assocArray[prefix+vValue];
 for (var i=0; i < arrX.length; i=i+2){oList.options[oList.options.length]=new Option(arrX[i+1],arrX[i]);}
 oList.selectedIndex=0;}
else{oList.options[0]=new Option("Ni podatkov","");}}

function fillDCombo(oList,vValue1,vValue2,assocArray,prefix1,prefix2){
if (vValue1!="" && assocArray[prefix1+vValue1+'&'+prefix2+vValue2]){
 var arrX=assocArray[prefix1+vValue1+'&'+prefix2+vValue2];
 for (var i=0; i < arrX.length; i=i+2){oList.options[oList.options.length]=new Option(arrX[i+1],arrX[i]);}
 oList.selectedIndex=0;}
else {oList.options[0]=new Option("Ni podatkov","");}}

function selectByValue(selectName,selectedValue){
for (i=0;i<selectName.length - 1;i++){
if (selectName[i].value==selectedValue) {selectName.selectedIndex=i;}
}}

function selectByDateValue(selectName,selectedValue){
for (i=0;selectName[i].value!=selectedValue && i<selectName.length - 1;i++){
if (selectName[i].value==selectedValue) {selectName.selectedIndex=i;}
}}

function evaluateMoney(moneyStr){
if (moneyStr==''){return true;}
csigns=countInstances(moneyStr,'.')+countInstances(moneyStr,',');
if (csigns>1) {return false;}
moneyVal=moneyStr.replace(',','').replace('.','')
if (!IsNumeric(moneyVal)){return false;}
return true;}

function IsNumeric(sText){
var ValidChars="0123456789.";var IsNumber=true;var Char;
for (i=0; i < sText.length && IsNumber==true; i++){ 
Char=sText.charAt(i);
if (ValidChars.indexOf(Char)==-1){IsNumber=false;}}
return IsNumber;}

function countInstances(string,word){
var substrings=string.split(word);
return substrings.length - 1;}

function isEmailAddress(string){
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
//      var filter=/^[a-zA-Z0-9][a-zA-Z0-9.\-\_]*@[a-zA-Z0-9][a-zA-Z0-9.\-\_]*\.[a-zA-Z0-9]{2,3,4}$/;
return filter.test(string);}

function clearform(frmobj){
for (i=0; i<frmobj.length; i++){
if (frmobj.elements[i].type=='text' || frmobj.elements[i].type=='password'){frmobj.elements[i].value='';}
if (frmobj.elements[i].type=='select-one'){frmobj.elements[i].selectedIndex=0;}
if (frmobj.elements[i].type=='checkbox'){frmobj.elements[i].checked=false;}
}}

function ResetOnFocusIfStr(obj,ifWhat){
if (obj.value==ifWhat){obj.value='';obj.style.color='black';}}		

function setalert(alertStr){
alert(alertStr);}

function openWin(urlStr,winName,winWidth,winHeight){
leftPos=parseInt(screen.availWidth/2 - winWidth/2)
topPos=parseInt(screen.availHeight/2 - winHeight/2)
window.open(urlStr,'winName','left='+leftPos+',top='+topPos+',width='+winWidth+',height='+winHeight+',status=no,toolbar=no,menubar=no,location=no')}

function gn(e,frm){
if (e.keyCode==13){
 i=getIndex(frm); eventindex=i;
 frm.form.elements[i].value=frm.form.elements[i].value;
 ln=frm.form.length; i++; test=true;
 while (i<ln && test){
 if (frm.form.elements[i].getAttribute('TAB',false)=='1'){
  if (getDim(frm.form.elements[i]).y>parseInt(screen.availHeight/2)) {window.scrollBy(0,getDim(frm.form.elements[i]).y-getDim(frm.form.elements[eventindex]).y)}
  frm.form.elements[i].focus();
  if (frm.form.elements[i].type!='select-one'){frm.form.elements[i].select()}
  test=false;}
 i++;}
 if (e.keyCode==13 && test) {doaction(frm.form)}
 e.returnValue=false;
 e.keycode=0;
 return false;
}}

function getIndex(input){
var index=-1,i=0,found=false;
while (i < input.form.length && index==-1)
if (input.form[i]==input){index=i;}
else {i++;}
return index;}

function getDim(el){
for (var lx=0,ly=0;el!=null;
lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
return {x:lx,y:ly}}

function trim(strText){ 
while (strText.substring(0,1)==' '){strText=strText.substring(1,strText.length);}
while (strText.substring(strText.length-1,strText.length)==' '){strText=strText.substring(0,strText.length-1);}
return strText;} 

function validateTaxNumber(value){
sum=0;weight=1;inArg=value;
inArg=inArg.replace(/^\s*/,"").replace(/\s*$/,"");
if (isNaN(parseInt(inArg)) || inArg.length!=8){return false;}
for (i=inArg.length-1; i>=0; i--){
 num=parseInt(inArg.substring(i,i+1));
 sum+=num*weight;
 weight++;}
if (sum % 11==0 || sum % 11==1) 
  {return true;} 
  else 
  {return false;}

}

function validateTaxNumberHR(value){
sum=0;weight=1;inArg=value;
inArg=inArg.replace(/^\s*/,"").replace(/\s*$/,"");
if (isNaN(parseInt(inArg)) || !(inArg.length==11 || inArg.length==8)){return false;}
else 
  {return true;}
}

var dtCh=".";
var minYear=2006;
var maxYear=2100;

function isInteger(s){
var i;
for (i=0; i < s.length; i++){var c=s.charAt(i); if (((c < "0") || (c > "9"))) return false;}
return true;}

function stripCharsInBag(s,bag){
var i;
var returnString="";
for (i=0; i < s.length; i++){   
 var c=s.charAt(i);
 if (bag.indexOf(c)==-1) returnString+=c;}
 return returnString;}

function daysInFebruary (year){
 return (((year % 4==0) && ( (!(year % 100==0)) || (year % 400==0))) ? 29 : 28 );
 }
function DaysArray(n) {
for (var i=1; i<=n; i++) {
 this[i]=31
 if (i==4 || i==6 || i==9 || i==11) {this[i]=30}
 if (i==2) {this[i]=29}} 
return this}

function isDate(dtStr){
var daysInMonth=DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strDay=dtStr.substring(0,pos1)
var strMonth=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i=1; i<=3; i++){if (strYr.charAt(0)=="0" && strYr.length>1){strYr=strYr.substring(1)}}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1){alert("Oblika datuma mora biti [dd.mm.yyyy]!"); return false;}
if (strMonth.length<1 || month<1 || month>12){alert("Vnesite veljaven mesec!");return false;}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){alert("Vnesite veljaven dan!"); return false;}
if (strYear.length!=4 || year==0 || year<minYear || year>maxYear){alert("Vnesite veljavno leto med "+minYear+" and "+maxYear+"!");return false;}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr,dtCh))==false){alert("Vnesite veljaven datum!");return false;}
return true;}

function setVisible(control){
document.all(control).style.visibility='visible'}

function showMe (it,box){
var vis=(box.checked) ? "block" : "none";
document.getElementById(it).style.display=vis;}

function VKos(frmObj,full){
loaded=false; setakcija=true;
if (full>=10) {setakcija=false;full=full-10;}
if (full==0) {frmObj.action="kos_mini.asp";}
if (full==1) {frmObj.action="kos_mini.asp";}
if (full==2) {frmObj.action="pregled_nakupa.asp"; frmObj.target="";} else {frmObj.target="kosarica";}
if (setakcija) {frmObj.akcija.value="add2basket";}
frmObj.submit();}

function NarociloVKos(frmObj,full){
loaded=false;
if (full==0) {frmObj.action="kos_mini.asp"}
if (full==1) {frmObj.action="kos_mini.asp"}
if (full==2) {frmObj.action="pregled_nakupa.asp"; frmObj.target="";}
frmObj.akcija.value="order2basket";
frmObj.submit();}

function VIzbor(frmObj){
if (frmObj.action=="moj_izbor.asp") {frmObj.target="";} else {frmObj.target="kosarica"; frmObj.action="kos_mini.asp"}
frmObj.akcija.value='add2book';
frmObj.submit()}

function DelIzbor(frmObj){
frmObj.action="moj_izbor.asp";
tmptarget=frmObj.target;
frmObj.target='';
frmObj.akcija.value='delfrombook';
frmObj.submit();
frmObj.target=tmptarget;
frmObj.akcija.value='add2basket';}

function showhide(id)
{
	object_uc = document.getElementById('user_comments');
	object_wc = document.getElementById('write_comment');
	object_wclist = document.getElementById('user_comm_list');
	object_wct = document.getElementById('write_commentt');
	
	if (object_wct !=null){object_wct.style.display = "none";}
	
	var stid = document.getElementById(id).style.display;
	//var showa = document.getElementById('showUserAsAnonymous');
	//showa.checked = true;
	
	if (id =="user_comments")
	{
		if (stid == "block")
		{
			object_uc.style.display = "none";
			object_wc.style.display = "block";
		}else{
			object_uc.style.display = "block";
			object_wc.style.display = "none";
		}	
	}
	if (id =="write_comment")
	{
		if (stid == "block")
		{
			if (object_uc == null)
			{
				object_wclist.style.display = "block";
			}else{
				object_uc.style.display = "block";
			}	
			object_wc.style.display = "none";
		}else{
			if (object_uc == null)
			{
				object_wclist.style.display = "none";
			}else{
				object_uc.style.display = "none";
			}
			object_wc.style.display = "block";
		}
	}
	if (id =="user_comm_list")
	{
		object_wc.style.display = "block";
	}
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function submitComment(frmObj)
{
	var len = frmObj.elements['notes'].value.length;
	if (len ==0)
	{
		alert('Za oddajo komentarja je potrebno v polje Moje mnenje vnesti vsaj 50 znakov.');
	}else{
		frmObj.submit();
	}
}
//  End -->

