var Cookie = { // test
  set: function(name,value,days) {
    if (days) {
	  var date = new Date();
	    date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	  }
	  else var expires = "";
	  document.cookie = name+"="+value+expires+"; path=/";
  },

  get: function(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
	  var c = ca[i];
	  while (c.charAt(0)==' ') c = c.substring(1,c.length);
	  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
    return -1;
  },

  del: function(name) {
    this.set(name,"",-1);
  },
  
  // create unique id
  uId: function() {
    var d = new Date();
    return d.getTime();
  }
};

//////////////////////////////////////
//    ***  HATE LENART ***          //
//    ***  HATE POLICE ***          //
//                                  //
//  JS Functions for List View      //
//            by                    //
//       M.5.I.T. 2006              //
//       V  0.25.12.06               //
//                                  //
//    ***  HATE POLICE ***          //
//    ***  HATE LENART ***          //
////////////////////////////////////// mainGet

// help for prototype.js:
// http://www.sergiopereira.com/articles/prototype.js.html                    !
// http://www.sergiopereira.com/articles/advjs.html 
				  
var List = Class.create();
List.prototype = {
    // constructor
	initialize: function() {
	    this.map1     = [];    // mapX polje z ponavljajocimi mapami
		this.map2     = [];
		this.map3     = [];
		this.file     = [];    // naziv artkila
		this.ident    = [];    // ident artikla
		this.barva    = [];
		this.pak      = []; // po kolkk je pakirano
		this.ost      = []; // ostali podatki
		
		this.ponMap1  = [];    // ponMapX polje z izlocenimi ponavljajocimi mapami
		this.ponMap2  = [];
		this.ponMap3  = [];
		
		// kako si zapomni kot line.. torej je ena vrsta samo.. ampak btk =)
		// za vsako novo vejo se ^X stevilka veca od 0 do 3.. 
		// ^0elementi za spajanje|^1Vrstna sponka|^2VS 2,5 PA|^2VS 4 PAS|^2VS 6 PA|^2VS 10 PA|^3VS 10 PA|^3VS 10 PA N.....
		this.memory   = "";    // spomin za ListView
		this.memBoth  = "01";  // xXx
		
		this.cookieMemOrder = "";    // spomin za narocilo v cookiu
		this.memOrder       = [];    // spomin za narocilo
		this.memNum         = -1;
		this.tmpOrder       = "";
		
		// mainGetTable bgcolor // d6ecf8 bae1f6
		this.mainBg = 0;
		
		this.L0C = "\n";
	},
	
	strGet: function(num) {
		var tNum = num;
		var ozkom = $('ozkom'+num).value;
		var ident = $('ident'+num).value;
		var barva = $('barva'+num).value;
	    var stkom = $('stkom'+num).value;
		
		var opomba = this.strGetValue(this.memOrder[num], 'Opomba', '');
		if(opomba != '')
		    this.tmpOrder = "Opomba:"+opomba+";";
		
		this.memOrder[num] = null;
		this.memOrder = this.memOrder.compact();
		
		$('mainIsci').innerHTML = this.CP(ozkom, ident, barva, stkom);
		$('mainIsci').style.visibility = 'visible';
	},
	
	strToMemory: function() {
		var ozkom = $('ozkom').value;
		var ident = $('ident').value;
		var barva = $('barva').value;
		var stkom = $('stkom').value;
		
		if(this.memOrder.length == 0) {
			var strNar = "File:"+ozkom+"; Ident:"+ident+"; Barva:"+barva+"; Stkom:"+stkom+";";
		    if(this.tmpOrder != '') {
					    strNar += this.tmpOrder;
					    this.tmpOrder = '';
					}
			this.memOrder[this.memOrder.length] = strNar;
		    $('mainIsci').innerHTML = this.CP('', '', '');
		    $('mainIsci').style.visibility = 'visible';
		}
		else {
		for(x = 0; x < this.memOrder.length; x++) {
		    var chk1 = this.strGetValue(this.memOrder[x], 'File')+"\x11"+this.strGetValue(this.memOrder[x], 'Ident');
			var chk2 = ozkom+"\x11"+ident;
			if(chk1 == chk2) {
			    alert("Artikelj z tem identom je ze na listi!\nSpremenite oz. zbrišite ga z dovoljenimi možnostmi.");
				$('mainIsci').innerHTML = this.CP('', '', '', '');
		        $('mainIsci').style.visibility = 'visible';
			}
			else {
				if(x == (this.memOrder.length -1)) {
					var strNar = "File:"+ozkom+"; Ident:"+ident+"; Barva:"+barva+"; Stkom:"+stkom+";";
					if(this.tmpOrder != '') {
					    strNar += this.tmpOrder;
					    this.tmpOrder = '';
					}
					this.memOrder[this.memOrder.length] = strNar;
		            $('mainIsci').innerHTML = this.CP('', '', '', '');
		            $('mainIsci').style.visibility = 'visible';
				}
			}
		}
		}
		this.memToCookie();
	},
	
	memFromCookie: function() {
	   var tmpStr = unescape(Cookie.get('smOrderMemory'));
	   var tmpAry = tmpStr.split("\x11");
	   tmpAry[tmpAry.length-1] = null;
	   tmpAry = tmpAry.compact();
	   this.memOrder = tmpAry;
	},
	
	memToCookie: function() {
	   var tmpStr = "";
	   for(x = 0; x < this.memOrder.length; x++) {
		  if(x == 0)
		     tmpStr = this.memOrder[x]+"\x11";
		  else
		     tmpStr += this.memOrder[x]+"\x11";
	   }
	   tmpStr = escape(tmpStr);
	   Cookie.set('smOrderMemory', tmpStr, 1);
	},
	
	strDelMemory: function(num) {
		this.memOrder[num] = null;
		this.memOrder = this.memOrder.compact();
		
		$('mainIsci').innerHTML = this.CP('', '', '');
		$('mainIsci').style.visibility = 'visible';
		
		this.memToCookie();
	},
	
	strMake: function(name, value) { // ustvarimo string z polja imen in vrednosti za bazo
	    var tmp = "";
		for(x = 0; x < name.length; x++) {
			tmp += name[x]+':'+value[x]+';';
		}
		return tmp;
	},
	
	showCP: function() {
		this.memFromCookie();
	    $('mainIsci').innerHTML = this.CP('', '', '');
		$('mainIsci').style.visibility = 'visible';
	},
	
	setNWindow: function(vis) {
		var strNar             = this.getNarocilo();
	    if(strNar != '') {
	    var idNar              = $('narocilo');
		var GPS                = objSize.getPageSize();
		
		idNar.style.width      = GPS.windowWidth+'px';
		idNar.style.height     = GPS.windowHeight+'px';
		
		idNar.style.background ='#ffffff';
		idNar.style.position   = "absolute";
		idNar.style.top        = '0px';
		idNar.innerHTML        = strNar;
		idNar.style.visibility =vis;
		}
	},
	
	getNarocilo: function() {
	    var strNarocilo = "";
		
		if(cliUName != 'neznan') {
		var d=new Date()
        var day=d.getDate()
        var month=d.getMonth() + 1
        var year=d.getFullYear()
		var date = day + "." + month + "." + year;
		
		strNarocilo = "<table border='0' cellspacing='0' cellpadding='0' class='narocilo_table' width='100%'>      "+
                      "  <tr align='center'>                              "+
                      "    <td> <img src='Glava.png'/></td>"+
                      "  </tr>                             "+
					  "  <tr>                              "+
					  "    <td align='center' valign='top'>"+
					  "      <table width='80%' border='0' cellspacing='0' cellpadding='0'>                       "+
                      "        <tr>                        "+
                      "          <td width='100px'> <img src='Crta.png'/> </td>"+
                      "        </tr>                       "+
					  "      </table>                      "+
					  "    </td>                       "+
					  "  </tr>"+
					  "  <tr>                              "+
                      "    <td align='center' valign='top'>                            "+
					  "      <table width='70%' border='0' cellspacing='0' cellpadding='0'>                       "+
                      "        <tr>                        "+
                      "          <td valign='top' width='33%'>"+
					  "<div class='cliV'>"+cliCompName+"</div>"+
					  "<div class='cliV'>( "+cliName+" "+cliSName+" )"+"</div>"+
					  "<div class='cliM'>"+cliHAddr               +"</div>"+
					  "<div class='cliM'>"+cliCityNum +" "+cliCity+"</div>"+
					  "<div class='cliV'>"+cliCountry +"</div></td>"+
                      "          <td valign='top' width='33%' align='center'>  "+
					  "             <table border='0' cellpadding='0' cellspacing='0' width='30px'><tr><td><div class='nav'>  <ul><li> <a href='#' onclick='nList.setNWindow(\x22hidden\x22);'> Nazaj </a> </li></ul></div> </td></tr></table>"+
					  "          </td>   "+
					  "          <td valign='top' align='center' width='33%'>"+ 
					  "<div class='cliN'> NAROCILO </div>"+
					  "<div class='cliV'>"+ date +"</div></td>"+
                      "        </tr>                       "+
					  "      </table>                      "+
					  "    </td>                           "+
                      "  </tr>                             "+
					  "  <tr>                              "+
                      "    <td align='center' valign='top'>                            "+
					  "      <table width='80%' border='0' cellspacing='0' cellpadding='0'>                       "+
                      "        <tr>                        "+
                      "          <td width='100px'> <img src='Crta.png'/></td>"+
                      "        </tr>                       "+
					  "      </table>                      "+
					  "    </td>                           "+
                      "  </tr>                             "+
					  "  <tr>                              "+
					  "  <tr>                              "+
                      "    <td align='center' valign='top'>                            "+
					  "      <table width='70%' class='narocilo_table' border='0' cellspacing='0' cellpadding='0'>                       "+
                      "        <tr align='left'>                        "+
                      "          <td width='20%'><div class='cliV'> Pozicija </div></td>             "+
                      "          <td width='20%'><div class='cliV'> Oznaka komada</div></td>           "+
					  "          <td width='20%'><div class='cliV'> Ident </div></td>               "+
					  "          <td width='20%'><div class='cliV'> Barva </div></td>               "+
					  "          <td width='20%'><div class='cliV'> Število komadov </div> </td>             "+
                      "        </tr>                       "+
					  "      </table>                      "+
					  "    </td>                           "+
                      "  </tr>                             "+
					  "  <tr>                              "+
                      "    <td align='center' valign='top'>                            "+
					  "      <table width='80%' border='0' cellspacing='0' cellpadding='0'>                       "+
                      "        <tr>                        "+
                      "          <td width='100px'> <img src='Crta.png'/> </td>"+
                      "        </tr>                       "+
					  "      </table>                      "+
					  "    </td>                           "+
                      "  </tr>                             "+
					  "  <tr>                              "+
					  "  <tr>                              "+
                      "    <td align='center' valign='top'>                            "+
					  "      <table width='70%' class='narocilo_table' border='0' cellspacing='0' cellpadding='0'>   ";
	   for(x = 0; x < this.memOrder.length; x++) {			  
           var ozkom, ident, barva, stkom, opomba;
		   ozkom  = this.strGetValue(this.memOrder[x], 'File', '');
		   ident  = this.strGetValue(this.memOrder[x], 'Ident', '');
		   barva  = this.strGetValue(this.memOrder[x], 'Barva', '');
		   stkom  = this.strGetValue(this.memOrder[x], 'Stkom', '');
		   opomba = this.strGetValue(this.memOrder[x], 'Opomba', '');
		   
	   strNarocilo += "        <tr>                        "+
	                  "          <td width='20%' class='cliV' align='left'>"+(parseInt(x)+1)+".)&nbsp;</td>           "+
                      "          <td width='20%'>"+ozkom+"</td>           "+
					  "          <td width='20%'>"+ident+"</td>           "+
					  "          <td width='20%'>"+barva+"</td>           "+
					  "          <td width='20%'>"+stkom+"</td>           "+
                      "        </tr>                       ";
	   strNarocilo += "                            ";
   if(opomba != '') { 
       strNarocilo += "</table><table width='70%' class='narocilo_table' border='0' cellspacing='0' cellpadding='0'>"+  // opomba
                      "        <tr>                        "+
                      "          <td width='100%' valign='top'>"+
					  "<font color='#ff0000'>OPOMBA: </font>"+opomba+"<br></td>"+
                      "        </tr>                       "+
					  "      </table> <table width='70%' class='narocilo_table' border='0' cellspacing='0' cellpadding='0'>  "; } /* opomba end */ } // end for(x loop !
	   strNarocilo += "    </td>                           "+
                      "  </tr>                             "+
                      "</table>                            ";			  
		}
		
		return strNarocilo;
	},
	
	CP: function(ozkom, ident, barva, stkom) { // control pannel for order
	  //alert(this.memOrder.length);
	  
	  var cp = "";
	  cp += "<table border='0' cellpadding='0' cellspacing='0' width='100%' class='T'>";
	  cp += "<tr>";
	  cp += "    <td> &nbsp; </td>";
	  if(ozkom != '') {
	  cp += "    <td width='21%'> <input type='text' class='disable' id='ozkom' readonly='readonly' value='"+ozkom+"'></td>";
	  cp += "    <td width='12%'> <input type='text' class='disable' id='ident' readonly='readonly' value='"+ident+"'></td>";
	  cp += "    <td width='12%'> <input type='text' class='disable' id='barva' readonly='readonly' value='"+barva+"'></td>";
	  cp += "    <td width='12%'> <input type='text' class='enable' id='stkom' name='stkom' value='"+stkom+"'> </td>";
	  cp += "    <td width='43%'> <p class='moznost' id='usr_cpan' onclick='nList.strToMemory(); smf.checkOrderIco();'> Dodaj </p> &nbsp;&nbsp;&nbsp;";
	  cp += "    <p class='moznost' id='usr_cpan' onclick='W.Close();nList.setNWindow(\x22visible\x22);'> Preglej </p> </td>";
	  }
	  else {
	  cp += "    <td width='21%'> </td>";
	  cp += "    <td width='12%'> </td>";
	  cp += "    <td width='12%'> </td>";
	  cp += "    <td width='12%'> </td>";
	  cp += "    <td width='43%'> <p class='moznost' id='usr_cpan' onclick='W.Close();nList.setNWindow(\x22visible\x22);'> Preglej </p>&nbsp;&nbsp;";
	  cp += "    <p class='moznost' id='usr_cpan' onclick='smf.checkOrderSend();'> Pošlji </p> </td>";
	  }
	  cp += "  </tr>";
	  
	  cp += "  <tr bgcolor='#000000'>";
	  cp += "    <td>  </td>";
	  cp += "    <td width='21%'> <img src='images/ozkom.png'> </td>";
	  cp += "    <td width='11%'> <img src='images/narst.png'> </td>";
	  cp += "    <td width='11%'> <img src='images/barva.png'> </td>";
	  cp += "    <td width='11%'> <img src='images/stkom.png'> </td>";
	  cp += "    <td width='43%'> <img src='images/moznosti.png'> </td>";
	  cp += "  </tr>";
	  
	  for(x = 0; x < this.memOrder.length; x++) {
		  cp += "  <tr>";
		  cp += "    <td style='font-size:12px;'> "+x+". </td>";
		  cp += "    <td width='21%'> <input type='text' class='disable1' id='ozkom"+x+"' readonly='readonly' value='"+this.strGetValue(this.memOrder[x], 'File', '')+"'> </td>";
	      cp += "    <td width='12%'> <input type='text' class='disable1' id='ident"+x+"' readonly='readonly' value='"+this.strGetValue(this.memOrder[x], 'Ident', '')+"'> </td>";
	      cp += "    <td width='12%'> <input type='text' class='disable1' id='barva"+x+"' readonly='readonly' value='"+this.strGetValue(this.memOrder[x], 'Barva', '')+"'> </td>";
		  cp += "    <td width='12%'> <input type='text' class='disable1' id='stkom"+x+"' readonly='readonly' value='"+this.strGetValue(this.memOrder[x], 'Stkom', '')+"'> </td>";
	      cp += "    <td valign='top' width='43%'> <p class='moznost1' id='usr_cpan' onclick='nList.strGet(\x22"+x+"\x22);'> Spremeni </p>&nbsp;&nbsp;";
		  cp += "    <p class='moznost1' id='usr_cpan' onclick='nList.strDelMemory(\x22"+x+"\x22); smf.checkOrderIco();'> Briši </p>&nbsp;&nbsp;";
		  if(this.memNum == x)
		  cp += "    <p class='moznost1' id='usr_cpan' onclick='nList.saveOpomba("+x+");'> Shrani opombo </p></td>";
		  else
		  cp += "    <p class='moznost1' id='usr_cpan' onclick='nList.areaOpomba("+x+");'> Dodaj opombo </p></td>";
		  
	      cp += "  </tr>";
		  
		  if(this.memNum > -1 && this.memNum == x) {
			  cp += "</table>";
			  
			  var op = this.strGetValue(this.memOrder[x], 'Opomba', '');
			  
			  cp += "<table class='clsOpomba'>";
		      cp += "  <tr>";
			  cp += "    <td>";
			  cp += "      <textarea class='clsOpArea' id='op_value'>"+op+"</textarea>";
			  cp += "    </td>";
		      /*cp += "    <td>";
              cp += "<a href='#' class='moznost' onclick='nList.saveOpomba("+x+");'> Shrani opombo! </a>";
			  cp += "    </td>";*/
			  cp += "  </tr>";
			  cp += "</table>";
			  
			  cp += "<table border='0' cellpadding='0' cellspacing='0' width='100%' class='T'>";
		  }
	  }
	  
	  cp += "</table>";
	  
	  return cp;
	},
    
	strGetValue: function(str, name, val) {
		var strTmp = str;
		var value  = "";
		var aName = [], aValue = [];
		
		var aryTmp = strTmp.split(';');
		
		for(y = 0; y < aryTmp.length; y++) {
			var info = aryTmp[y].split(':');
			
			if(info[0].charAt(0) == "\x20")
			    info[0] = info[0].substring(1);
			//alert(info[0]);
			
			if(info[0] == name) { // info[0] = ime ; info[1] = value
				if(val == null || val == '') {
					value = info[1]; // vrnemo vrednost zadetega imena
				    break;
				}
			}
			else {
				if((aryTmp.length-1) == y) {
					if(val != '') {
						//alert(val);
				        aName[aName.length]   = name;
				        aValue[aValue.length] = val;
				        value = this.strMake(aName, aValue);
						//alert("nastavlam novi value");
					}
				}
				else {
				    aName[aName.length]   = info[0]; 
			        aValue[aValue.length] = info[1];
					//alert("kreiram novi return string");
				}
			}
		}
		return value;
	},
	
	strDelValue: function(str, name) {
		var n, v; n = []; v = []; // name, value
		var aTmp1 = str.split(';');
		var a1Len = aTmp1.length;
		
		for(x = 0; x < a1Len; x++) {
		   var aTmp2 = aTmp1[x].split(':');
		   if(aTmp2[0] != name) {
			   n[n.length] = aTmp2[0];
			   v[v.length] = aTmp2[1];
		   }
		   else 
		      a1Len -= 1;
		}
		return this.strMake(n, v);
	},
	
	saveOpomba: function(num) {
		this.memNum = -1;
		var t = "";
		
		if($('op_value').value == '') {
			t = this.strDelValue(this.memOrder[num], 'Opomba');
		}
		else {
			t = this.strGetValue(this.memOrder[num], 'Opomba', $('op_value').value);
		}
		
	    if(t != '')
		    this.memOrder[num] = t;
		
		this.memToCookie();
		this.showCP();
	},
	
	areaOpomba: function(num) {
		this.memNum = num;
		this.showCP();
	},
	
	orderNow: function(strOrder) {
		this.memFromCookie();
		
		var ozkom, ident, barva;
		ozkom = this.strGetValue(strOrder, 'File', '');
		ident = this.strGetValue(strOrder, 'Ident', '');
		barva = this.strGetValue(strOrder, 'Barva', '');
		
		$('mainIsci').innerHTML = this.CP(ozkom, ident, barva, '');
		$('mainIsci').style.visibility = 'visible';
	},
	
	////// IZPIS ARTIKLA v LEFT DIVU ///////////
	kaziArtikl: function(oz_id) {
		//alert(oz_id);
		cPRead.ajxGetFile('../n_Katalog', '', 'main', 'Katalog');
		//nList.getArticle(nList.getApos(oz_id));
	    setTimeout("nList.getArticle(nList.getApos('"+oz_id+"'))", 400);
	},
	
	getApos: function(isci) {
		var num = -1;
		for(x = 0; x < this.file.length; x++) {
		    var tmp = this.file[x]+'?'+this.ident[x];
			if(tmp == isci) {
				num = x;
				break;
			}
		}
		
		if(num == -1)
		    alert("Artikel še ni v bazi artiklov!");
		else
		return num;
	},
	
	// cekiramo map3 ce je dodan pdf in katera koncnica slike naj bo uporabljena v artiklu
	chk4pdf: function(map3) {
		var indOf = map3.indexOf('<');
		if(indOf > -1) {   // ce je kaka koncnica not polnimo polje z moznostmi oz. odgovori
		    var s, e; 
			s = map3.indexOf('<'); s+=1;
			e = map3.indexOf('>'); e-=1;
			var opcije = map3.substr(s, e);
			
			var aOpcije = Array();
			aOpcije['kbAry2'] = map3.substr(e+2); // slika 2 oz. polje 2 v kbase.kqs
			
			return aOpcije;
		}
		else return indOf; // vrnemo -1, map3 pripravljen za izpis... 
	},

   chkPriborLink: function(value) {    
       tmpValue = ""; tmpValue=value;       
       if(value == 'NVS 32' || value == 'NVS 35' || value == 'EO3' || value == 'EO4') {
               if(tmpValue == 'EO3' || tmpValue == 'EO4')
                   tmpValue += '_alt';  
               // LPopup: function(e, id, text, vis)
               $('scrlDown1').style.background='lightyellow';
               $('scrlDown1').style.color='#000000';
                                
               if(this.map3.indexOf(tmpValue) >= 0) {
                   return "<p class='katalog_mgs' onclick='nList.LPopup(event,\x22scrlDown1\x22, \x22\x22,\x22hidden\x22); nList.mainGetSearch(\x22"+tmpValue+"\x22, \x22mainIsci\x22);' onmousemove='nList.LPopup(event,\x22scrlDown1\x22,\x22Bli&#382;nica do <strong>"+value+"</strong> artikla.\x22,\x22visible\x22);' onmouseout='nList.LPopup(event,\x22scrlDown1\x22,\x22\x22,\x22hidden\x22);'>"+value+"</p>";
               }
               else return value;
                   //return "Ni artikla: "+value;          
       }
       else {
           if(this.file.indexOf(tmpValue) >= 0)
               return "FLink to: "+value;
           else return value;
               //return "FNi artikla: "+value;
       }
   },	
	
	getArticle: function(num) {
      //alert(this.file[num]);      
      log_start.add("ARTIKL\x11pregled artikla: "+this.file[num]);
      		
		var artInfo  = "";
		var artPolj  = [];
		var chkColor = 0;
	   var order = "File:"+this.file[num]+"; Ident:"+this.ident[num]+"; Barva:"+this.barva[num]+";";
		
		// cekiramo polje 2 v kbase.kqs
		var tmp4pdf = this.chk4pdf(this.map3[num]);
		if(tmp4pdf != -1) {
			C4pdfPic2 = tmp4pdf['kbAry2'];
			C4pdfName = 'pdfs/'+tmp4pdf['kbAry2']+'.pdf';
			C4EMSeng  = 'pdfs/EMS16eng.pdf';
		}
		else C4pdfPic2 = this.map3[num];
		
		artPolj     = this.ost[num].split("|");
    
        artInfo += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";                 // zacetek div table
		artInfo += "    <tr>";
		artInfo += "        <td style='color: #000000;' class='cliV'> "+LA.check(this.map2[num])+" </td>";
      //alert(cPRead.s_chmod);      
      //if(		
      if((cPRead.s_chmod=='CC') || (cPRead.s_chmod=='CA')) {		
		artInfo += "        <td class='cliV'> Cena izdelka: <p id='GetCena'></p> </td>";
		artInfo += "        <td class='cliV'> EAN Koda: <p id='GetEan'></p> </td>";
		}
		else { artInfo +="<td></td>"; artInfo += "<td></td>"; }
		
		artInfo += "    </tr>";
		artInfo += "    <tr>";
		artInfo += "        <td width='40%' align='center' valign='middle'> <img src='slike-1337/"+this.map2[num]+".jpg'/> </td>";
		artInfo += "        <td width='20%' align='center' valign='middle'> <div class='nav'> <ul>";
		artInfo += " <li> <a href='#' onclick='nList.orderNow(\x22"+order+"\x22); smf.checkOrderIco();'>Dodaj <img class='shop_c' src='images/shopping_c.gif'></a></li>";
		artInfo += " <li> <a href='#' onclick='nList.showCP();'>Preglej <img class='shop_c' src='images/shopping_c_f.gif'></a></li>";
		if(tmp4pdf != -1) {
		    artInfo += "<br><li> <a href='"+C4pdfName+"'>Pdf ( SLO )</a></li>"; // ce obstaja pdf za ta artikel izpisemo gumb
			if(this.file[num] == 'EMS 16')
			    artInfo += " <li> <a href='"+C4EMSeng+"'>Pdf ( ENG )</a></li>";
		}
		artInfo += "        </ul> </div> </td>";
		artInfo += "        <td width='40%' align='center' valign='middle'> <img src='slike-1337/"+C4pdfPic2+".jpg'/> </td>";
		artInfo += "    </tr>";
		artInfo += "</table>";
		
		artInfo += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";                 // zacetek div table
		artInfo += "    <tr bgcolor='#000000'>";
		artInfo += "        <td width='49%'> </td>";
		artInfo += "        <td width='17%'> <img src='images/ozkom.png'> </td>";
		artInfo += "        <td width='17%'> <img src='images/narst.png'> </td>";
		artInfo += "        <td width='17%'> <img src='images/stkom.png'> </td>";
		artInfo += "    </tr>";
		artInfo += "</table>";
		
		artInfo += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
		artInfo += "    <tr bgcolor='#e1ecf2'>";
		artInfo += "        <td width='49%'> "+LA.check(this.barva[num])+"</td>";
		artInfo += "        <td width='17%'>"+this.file[num]+"  </td>";
		artInfo += "        <td width='17%'>"+this.ident[num]+" </td>";
		artInfo += "        <td width='17%'>"+this.pak[num]+"   </td>";
		artInfo += "    </tr>";
		for(x = 0; x < artPolj.length-1; x++) {
			
			var cId1 = '';
			if(chkColor == 0) {
			    cId1    = '#e5f4fc';
				chkColor = 1;
			}
			else {
				cId1    = '#e1ecf2';
				chkColor = 0;
			}
			
			artInfo += "<tr bgcolor='"+cId1+"'>";             // vrsta
		   artInfo += "    <td width='49%'>"+LA.check(artPolj[x+0])+"</td>"; // celica
			artInfo += "    <td width='17%'>"+this.chkPriborLink(artPolj[x+1])+"</td>"; // celica
			artInfo += "    <td width='17%'>"+artPolj[x+2]+"</td>"; // celica
			artInfo += "    <td width='17%'>"+artPolj[x+3]+"</td>"; // celica
			artInfo += "</tr>";                          // konec vrste
			
			x += 3;
		}
		artInfo += "</table>";                              // konec div table
      //alert(artPolj);
      if((cPRead.s_chmod=='CC') || (cPRead.s_chmod=='CA')) {
          setTimeout("adList.GetCena('"+this.file[num]+"','"+this.ident[num]+"');", 300);
      }
      
		this.myshow(artInfo, 'mainIsci');
	},
	
	both: function(num) {
		var polje = [], x;
		polje[0] = this.map1[num];
		polje[1] = this.map2[num];
		polje[2] = this.map3[num];

		this.memory = "";
		this.Main();
		this.Set(polje[0], 0);
		this.Set(polje[1], 1);
		this.Set(polje[2], 2);
	},
	
	bothMem: function(txt) {
		//alert(txt);
	    this.memBoth = txt;
	},
	
	////// IZPIS ZADETKOV V LEFT DIVU //////////
	mainCreateTable: function(polje) {
		var mainIsci = "";
		
		mainIsci += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
		mainIsci += "<tr bgcolor='#000000'>";
		mainIsci += "  <td> <img src='images/pskup.png'/> </td>";
		mainIsci += "  <td> <img src='images/ozkom.png'/> </td>";
		mainIsci += "  <td> <img src='images/barva.png'/> </td>";
		mainIsci += "</tr>";
		for(y = 0; y < polje.length; y++) {
		    mainIsci += polje[y];
		}
		mainIsci += "</table>";
		return mainIsci;
	},
	
	mainGetTable:  function(num, t1, t2, t3) {
		var tabTmp  = "";
		var bgcolor = "";
		
		if(this.mainBg == 0) {
		    bgcolor = '#e5f4fc';
			this.mainBg = 1;
		}
		else {
			this.mainBg = 0;
			bgcolor = '#e1ecf2';
		}
		
		tabTmp += "<tr id='c"+num+"' style='cursor:pointer;' bgcolor='"+bgcolor+"' onclick='nList.getArticle(\x22"+num+"\x22); nList.both(\x22"+num+"\x22);' onmouseover='$(\x22c"+num+"\x22).bgColor=\x22#ffffff\x22;' onmouseout='$(\x22c"+num+"\x22).bgColor=\x22"+bgcolor+"\x22;'> <td width='260'>"+t1+"</td>";
		tabTmp += "<td align='left'>"+t2+"</td>";
		tabTmp += "<td>"+t3+"</td></tr>";
		return tabTmp;
	},
	
	mainGetSearch: function(isci, id) {	
		
		if(isci != "\x11") {
		var memIsci = [];
		for(x = 0; x < this.map1.length; x++) {
			if     (this.map1[x].toLowerCase().indexOf(isci.toLowerCase()) != -1) { // najdemo kar iscemo
				memIsci[memIsci.length] = this.mainGetTable(x, LA.check(this.map2[x]), this.file[x], LA.check(this.barva[x]));
			}
			else if(this.map2[x].toLowerCase().indexOf(isci.toLowerCase()) != -1) {
				memIsci[memIsci.length] = this.mainGetTable(x, LA.check(this.map2[x]), this.file[x], LA.check(this.barva[x]));
			}
			else if(this.map3[x].toLowerCase().indexOf(isci.toLowerCase()) != -1) {
				memIsci[memIsci.length] = this.mainGetTable(x, LA.check(this.map2[x]), this.file[x], LA.check(this.barva[x]));
			}
			else if(this.file[x].toLowerCase().indexOf(isci.toLowerCase()) != -1) {
				memIsci[memIsci.length] = this.mainGetTable(x, LA.check(this.map2[x]), this.file[x], LA.check(this.barva[x]));
			}
			else if(this.ident[x].toLowerCase().indexOf(isci.toLowerCase()) != -1) {
				memIsci[memIsci.length] = this.mainGetTable(x, LA.check(this.map2[x]), this.file[x], LA.check(this.barva[x]));
			}
			else if(this.barva[x].toLowerCase().indexOf(isci.toLowerCase()) != -1) {
				memIsci[memIsci.length] = this.mainGetTable(x, LA.check(this.map2[x]), this.file[x], LA.check(this.barva[x]));
			}
		}
		this.myshow(this.mainCreateTable(memIsci), id);
		} // end x11
		else {
		   //this.myshow(test.Uncript(menu), id);
		}
	},
	
	//////////////////////////////////////////
	LPopup: function(e, id, text, vis) {
        if (!e) var e = window.event;
	    if (e.pageX || e.pageY) 	{
		    posx = e.pageX;
		    posy = e.pageY;
	    }
	    else if (e.clientX || e.clientY) 	{
		    posx = e.clientX + document.body.scrollLeft
		 	+ document.documentElement.scrollLeft;
		    posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	    }
	
	    var mydiv = $(id);
	    mydiv.style.top    = (posy+35)+"px";
	    mydiv.style.left   = posx+"px";
		mydiv.style.width  = "auto";
		mydiv.style.height = "auto";
		mydiv.style.position = "absolute";
		mydiv.innerHTML=text;
		mydiv.style.visibility = vis;
    },
	
	myhide: function(id) {
	    idHide = $(id);
		idHide.style.visibility = 'hidden';
	},
	
	myshow: function(html, id)
	{
	    //alert(html);
	    div = $(id);
        div.innerHTML=html;
		div.style.visibility = "visible";
	},
	
	View: function() {
		var sAdd  = "";
	    var aMem  = [];
		var ico = "";
		
		aMem = this.memory.split('|');
		//this.check(aMem);
		for(x = 0; x < aMem.length-1; x++) {
			if     (aMem[x].charAt(1) == 3)
		        ico = "images/arrow.gif";
		    else if(aMem[x].charAt(2) == 0)
		        ico = "images/more.gif";
		    else if(aMem[x].charAt(2) == 1)
		        ico = "images/comment.gif";
			
			var px    = 40;
			var pomik = parseInt(aMem[x].charAt(1));
			pomik = (pomik * px);
			
			if(aMem[x].charAt(1) < 2) // za cekiranje jezika oz. prevajanje
			  aMemTmp = LA.check(aMem[x].substring(3));
			else
			  aMemTmp = aMem[x].substring(3);
			  
			if(aMem[x].charAt(1) == 3) {
				sAdd += "<div class='img1' style='padding:0 0 0 "+pomik+"px;'><img src='"+ico+"'></div><div id='"+x+"' class='myList' onmouseover='' onmouseout='nList.myhide(\x22listToolTip\x22);' style='padding:0 0 0 "+(pomik+15)+"px; ' onclick='nList.Set(\x22"+aMem[x].substring(3)+"\x22, "+aMem[x].charAt(1)+");' onmousemove=''>"+ aMemTmp.truncate(35, '...') +"</div>";
			}
			else {
				// test.sStyle(\x22"+x+"\x22, \x22#808080\x22, \x22\x22); 
				// test.sStyle(\x22"+x+"\x22, \x22#68ADD5\x22, \x22ul\x22)
				// styleObj.mouseTTip(event, \x22"+aMem[x].substring(3)+"\x22,\x22listToolTip\x22);
			sAdd += "<div class='img1' style='padding:0 0 0 "+pomik+"px;'><img src='"+ico+"'></div><div id='"+x+"' class='myList' onmouseover='' onmouseout='nList.myhide(\x22listToolTip\x22);' style='padding:0 0 0 "+(pomik+15)+"px; ' onclick='nList.Set(\x22"+aMem[x].substring(3)+"\x22, "+aMem[x].charAt(1)+"); nList.bothMem(\x22"+aMem[x][1]+aMem[x][2]+"\x22); nList.mainGetSearch(\x22"+aMem[x].substring(3)+"\x22, \x22mainIsci\x22);' onmousemove=''>"+ aMemTmp.truncate(35, '...') +"</div>";
			}
		}
		
		this.myshow(sAdd, 'tooltip');
	},

	Set: function(sel, num) {
		
		var addMaps = [];
		var firstA  = [];
		var secondA = [];
		var chkFile = false;
		
		switch(num) {
			case 0: {
			    addMaps = this.ponMap2;
				firstA  = this.map1;
				secondA = this.map2;
				break;
			}
			case 1: {
			    addMaps = this.ponMap3;
				firstA  = this.map2;
				secondA = this.map3;
				break;
			}
			case 2: {
			    chkFile = true;
				break;
			}
		}
		
		if(this.memory == "") {   // memory je prazn napolnimo ga z this.ponMap1
			for(y = 0; y < this.ponMap1.length; y++) {
			    var add = "^00"+this.ponMap1[y]+"|";
				this.memory += add;
			}
			this.View();
		}
		else { // addamo mape v memory
			var tmp      = []; // mape ki jih zelimo dodat
			var raz      = []; // obstojece mape v memory
			var ost      = []; // obstojece mape ki jih prestavimo za "tmp.length" polj
			
			var add      = []; // polje map pripravljene za dodat v memory string
			
			var poz      = 0;  // pozicija pri kateri zacnemo dodajat mape
			var tmpCount = 0;  // stejem tmp dodane mape
			
			raz   = this.memory.split('|');
			
			if(chkFile) {
			    var n = this.indexOfMemory(sel);
				this.SetFiles(raz, sel, n, num);
				this.View();
			}
			else {
		        for(x = 0; x < addMaps.length; x++) {
		            var nsA = secondA.indexOf(addMaps[x]);
		    	    if(sel == firstA[nsA]) {
				    	tmp[tmpCount] = addMaps[x]; // tmp = mape ki jih zelimo dodat
				    	tmpCount++;
		    	    }
		        }    
			
			    if(this.Switch(tmp, num+1)) {
			    	this.memory = "";
					//alert("remove!");
			    	this.Remove(raz, sel);
			    	this.View();
			    }
			    else {
			        for(x = 0; x < raz.length-1; x++) {
                        if(raz[x].substring(3) == sel) {
		                    poz = x;
			            }
		                else {
		                    ost[ost.length] = raz[x]; // ostale mape sshranimo, za premik polj
			            }
                    }
				    
					if(raz[poz].charAt(1) == 3) {
						this.getArticle(this.getApos(raz[poz].substring(3)));
					}
					else {
					    this.memory = "";
				        this.Move(raz, poz+1, num+1, tmp);
					    this.View();
					}
			    }
			}
		}
	},
	
	Move: function(mem, num, nvst, vst) { // spomin polje, od kje cuta, ^x number, vstavi spomin
		var pOstanek = [];
		var oCount   = 0;
        var nCount   = 0;
        var len      = (vst.length + mem.length)-1;
        
		for(y = 0; y < num; y++) { // moja napaka pa poprawlam grdo :/
			if((y+1) == num) {
			    this.memory += this.rep(mem[y]+'|', 1); //this.rep(mem[y]+'|', 1); // mapo odpiramo 1
			}
			else 
			    this.memory += mem[y]+'|';
		}
		
		for(x = num; x < len; x++) {
	        pOstanek[pOstanek.length] = mem[x];
	 	    if(nCount < vst.length) {
		        if(vst[nCount].charAt(0) == "\x5E")
				    this.memory += vst[nCount]+'|';
				else
				    this.memory += "^"+nvst+'0'+vst[nCount]+'|';
		        nCount++;
		    }
		    else {
			    if(pOstanek[oCount].charAt(0) == "\x5E")
		            this.memory += pOstanek[oCount]+'|';
				else
				    this.memory += "^"+nvst+'0'+pOstanek[oCount]+'|';
			    oCount++;
		    }
	    }
    },
	
	Remove: function(mem, sel)
    {
        var chk  = false;
		var chk1 = false;
        var nSel = -1;
        for(x = 0; x < mem.length; x++) {
	        if((mem[x].substring(3) == sel) && (chk1 == false)) {
		        nSel = mem[x].charAt(1);
		    	this.memory += this.rep(mem[x]+'|', 0);
				chk1 = true;
		    }
		    else if((chk != true) && (nSel > -1)) {
		        if(mem[x].charAt(1) > nSel) {
			    	if(mem[x+1].charAt(1) <= nSel)
			    	    chk = true;
	     		}
	        }
	    	else {
	    	    if(mem[x].length > 3)
				    this.memory += mem[x]+'|';
		    }
	    }
    },
	
	Main: function() {
	    this.ponMap1 = this.SetMaps(this.map1);
		this.ponMap2 = this.SetMaps(this.map2);
		this.ponMap3 = this.SetMaps(this.map3);
		
		this.Set("\x22\x22", "\x22\x22");
	},
	
	Add: function(Map1, Map2, Map3, File, Ident, Bar, Pak, Ost) {
	    this.map1 [this.map1.length]  = Map1;
		this.map2 [this.map2.length]  = Map2;
		this.map3 [this.map3.length]  = Map3;
		this.file [this.file.length]  = File;
		this.ident[this.ident.length] = Ident;
		this.barva[this.barva.length] = Bar;
		this.pak  [this.pak.length]   = Pak;
		this.ost  [this.ost.length]   = Ost;
	},
    
	SetMaps: function(Map) {                  // izlocimo ponavljajoce mape
		var tmp = [];
		for(x = 0; x < Map.length; x++) {     // loop X
		    if(x==0) tmp[0] = Map[0];
			for(y = 0; y < tmp.length; y++) { // loop Y
				if(Map[x] == tmp[y])          // ce je ze mapa v tmp jo preskocimo " break loop Y"
					break;
				if(Map[x] != tmp[y]) {        // ce se mape ni v tmpju in
					if(y == tmp.length-1) {   // konec tmpja mape ni not
					    tmp[y+1] = Map[x];    // mapo dodamo v tmp
					}
				}
			}
		}
		return tmp; // vrnemo Mape v polju
	},
	
	SetFiles: function(mem, sel, num, nnum) { // nastavimo fajle katere zelimo izpisat
	    var nVstavi = 0;
		var tmp = [];
		for(x = 0; x < this.map3.length; x++) {
		    if(this.map3[x] == sel) {
			    tmp[tmp.length] = this.file[x]+'?'+this.ident[x];
			}
		}
		if(this.Switch(tmp, nnum+1)) {
			this.memory = "";
		    this.Remove(mem, sel);
		}
		else {
			this.memory = "";
		    this.Move(mem, num+1, 3, tmp);
		}
	},
	
	Switch: function(pol, num) {
	    var ret = false;
		var mem = [];
		mem = this.memory.split('|');
		for(x = 0; x < pol.length; x++) {
		    if(mem.indexOf("^"+num+'0'+pol[x]) != -1) {
				ret = true;
				break;
			}
			else if(mem.indexOf("^"+num+'1'+pol[x]) != -1) {
				ret = true;
				break;
			}
		}
		return ret;
	},
	
	indexOfMemory: function(sel) {
	    var chk = 0;
		var tmp = [];
		tmp = this.memory.split('|');
		for(x = 0; x < tmp.length; x++) {
		    if(tmp[x].substring(3) == sel) {
			    chk = x;
			    break;
			}
		}
		return chk;
	},
	
	rep: function(sMem, n){ 
       var tmp = "";
	   for(f = 0; f < sMem.length; f++) {
	        if(f == 2)
		       tmp += n;
		    else
			   tmp += sMem.charAt(f); 
	   }
	   return tmp;
    },
	
	check: function(mem) {
		var tmp = "";
		for(i = 0; i < mem.length; i++) {
		    tmp += mem[i]+'\n';
		}
		alert(tmp);
	}
}
