 function reporterrorbox(msg, url, linenumber){
  alert('Error message= '+msg+'\nURL= '+url+'\nLine Number= '+linenumber)
  return true
}
//window.onerror=reporterrorbox





agt = navigator.userAgent.toLowerCase();
is_ie	   = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
is_opera  = (agt.indexOf("opera") != -1);
is_mac	   = (agt.indexOf("mac") != -1);




var currentComponentDiv = false;
var currentComponentImg = false;

function openCompDiv(id,imgId){

  if(currentComponentDiv){
    oldDiv = document.getElementById('componentDiv' + currentComponentDiv);
	if(oldDiv){
	  oldDiv.style.display='none';
	}
	if(currentComponentImg && currentComponentImg && document.images['componentImage'+currentComponentDiv]){
	   document.images['componentImage'+currentComponentDiv].src = currentComponentImg;
	}
  }

    newDiv = document.getElementById('componentDiv' + id);
	if(newDiv){
	  newDiv.style.display='block';
	}

	if(document.images['componentImage'+id]){
	   currentComponentImg = document.images['componentImage'+id].src;
	   document.images['componentImage'+id].src = '/images/products/komponenti/empty.gif';
	}

	bigIm = document.images['componentsImage'];
	bigIm.src = componentImgs[imgId].src;
		
//
	//

    currentComponentDiv = id;
  
}










function menuCollection(){

   var menus = [];
   var currentAnimation;

   this.addMenu = addMenu;
   this.init = init;
   this.show = show;

   function addMenu(name,parentName,objName){
    
      m = new theMenu(name,parentName,objName);
      menus[menus.length] = m;
	  return m;
	  
   }

   function init(){
   
      for(i=0;i<menus.length;i++){
	      menus[i].init();
	  }
	 
   }

   function show(id,flag){
      obj = find(id);
   
	  if(obj && obj.getLoaded()){
	     if(flag){

		   if(currentAnimation && currentAnimation!=obj)
		      currentAnimation.stopAnimation();

		   obj.startAnimation();

		   currentAnimation = obj;

		 }else{
		   obj.stopAnimation();
		 }
	  }
   }


   function find(id){
      for(i=0;i<menus.length;i++){
	      if(menus[i].getName()==id)
		     return menus[i];
	  }
	  return false;
   }
  
}


function theMenu(name,parentName,objName){
   
    var obj;
    var objParent;
	this.getX = getX;
	this.doPosition = doPosition;

	this.startAnimation = startAnimation;
	this.stopAnimation = stopAnimation;
	this.continueAnimation = continueAnimation;
	this.getName = getName;
	this.init = init;
	this.getLoaded = getLoaded;
	this.doStopAnim = doStopAnim;

	var animY = 0;
	var animTimer
	var loaded = false;
	var items = [];
	var thisName = objName;
	var stopTimer = false;

	var divName = name;
	var pName = parentName;

	var loaded = false;

	var direction = 1;

	var change = 5;



	function getX(o) {
		var x = 0;

		while (o && o.offsetParent) {
			x += o.offsetLeft
			o = o.offsetParent
		}
		return x;
	}


	function getName(){
	   return thisName;
	}
	function getLoaded(){
	   return loaded;
	}
	



	function getY(o) {
		var x = 0;

		var temp = o;

		while (o && o.offsetParent) {
			x += o.offsetTop
			o = o.offsetParent
		}

		x+=temp.offsetHeight;

		return x;
	}

	function init(){

	   obj = document.getElementById(divName);
	   objParent = document.getElementById(pName);
	   loaded = true;
	   change = Math.ceil(obj.offsetHeight/15);

	
	}

	function doPosition(){
	   if(obj && objParent){
	      obj.style.visibility = "visible";
	      obj.style.left = getX(objParent) + "px";
	      obj.style.top = getY(objParent) + "px";
	   }
	}


	function startAnimation(){

	   if(stopTimer){
	      
		  clearTimeout(stopTimer);

	   }

	   clearTimeout(animTimer);
	   doPosition();
	   direction = 1;
	   continueAnimation();


	}

    
	function allowAnimation(cord){
	   return (cord>=0 && cord<=obj.offsetHeight);
	}


	function continueAnimation(){

      
	  if(obj){
		  var c = change;
		  var newCord = animY + (direction*c);

		  while(c>1 && !allowAnimation(newCord)){
		      c--;
		      newCord = animY + (direction*c);
		  }
           
	   if(allowAnimation(newCord)){
	     animY=newCord;
	     obj.style.clip="rect(auto auto "+animY+"px auto)";

		 if(animY<5){
		   obj.style.visibility = "hidden";
		 }else{
		   obj.style.visibility = "visible";
		 }

	     animTimer = window.setTimeout(thisName+".continueAnimation()",10);
	   }


	  }


	}


	function doStopAnim(){
	   
	   clearTimeout(animTimer);
	   doPosition();
	   direction = -1;
	   continueAnimation();

	}

	function stopAnimation(){
     
	    stopTimer = window.setTimeout(thisName+".doStopAnim()",200);


	}



}

 
	var mc = new menuCollection();


    function start() {
		 mc.init();
    }

	var lastHead = false;
	var currentHeaderPage = false;

	function animate(id,flag){
			
 
		     mc.show('menu'+id,flag);
			
			if(currentHeaderPage!=id){
			   obj = document.images['headerMenu' + id];
			   imId = (id=='main') ? 0 : id;
			   if(flag){
			      obj.src = headerImageBuffer[imId][1].src;
			   }else{
			      obj.src = headerImageBuffer[imId][0].src;
			   }
			   lastHead = id;
			}
            

	}
   

    var currentSumItemId = false;

    function selectMenuSubitem(id,flag){

		if(flag){
		   if(currentSumItemId){
		      highlightSubItem(currentSumItemId,false);
		   }
		   currentSumItemId = id;
		}

		highlightSubItem(id,flag);

	}

	function highlightSubItem(id,flag){
		im1Obj = document.images['menuItemLeftIm'+id];
		im2Obj = document.images['menuItemRightIm'+id];

		cell1Obj = document.getElementById("menuItemLeftCell"+id);
		cell2Obj = document.getElementById("menuItemRightCell"+id);
		cell3Obj = document.getElementById("menuItemCenter"+id);



        if(flag){
		   im1Obj.src = itemImageLeftS.src;
		   im2Obj.src = itemImageRightS.src;
		}else{
		   im1Obj.src = itemImageLeft.src;
		   im2Obj.src = itemImageRight.src;
		}
		//im1Obj.src='/images/hmenu_item_left'+((flag) ? '_s' : '')+'.gif'
		//im2Obj.src='/images/hmenu_item_right'+((flag) ? '_s' : '')+'.gif'

		cell3Obj.className = ((flag) ? 'menuItemS' : 'menuItem');

		cell1Obj.className = ((flag) ? 'menuItemMiddleS' : 'menuItemMiddle');
		cell2Obj.className = ((flag) ? 'menuItemMiddleS' : 'menuItemMiddle');
	
	
	}



    function preloadImages(){
	
		var d=document; 
		var i,j=d.preloadedIms.length,a=preloadImages.arguments; 
		if(d.images){ 
			if(!d.preloadedIms) 
				d.preloadedIms=new Array();
			for(i=0; i<a.length; i++){
					d.preloadedIms[j]=new Image; 
					d.preloadedIms[j++].src=a[i];

			}
		}	
	}

itemImageLeftS = new Image; 
itemImageLeftS.src="/images/hmenu_item_left_s.gif";

itemImageLeft = new Image; 
itemImageLeft.src="/images/hmenu_item_left.gif";

itemImageRightS = new Image; 
itemImageRightS.src="/images/hmenu_item_right_s.gif";

itemImageRight = new Image; 
itemImageRight.src="/images/hmenu_item_right.gif";



function toggleBlock(id){
    
	obj = document.getElementById('wrapBlock' + id);
	if(obj){
	   if(obj.style.display=='none'){
	      obj.style.display = 'block';
	   }else{
	      obj.style.display = 'none';
	   }
	}

}


















/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////           scrolling       ///////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////




	

function scrollObj(){

	var loaded = false;
	var tableWidth = 0;
	var frameWidth = 296;
	var timeOut;
	var flag;
	var theTimer;
	var tableTimer;
	var windowObj = false;
	var xPos = 0;
	var change = 2;
	var comId;
	var tableEventX;

	var tableNewPos;
	var tableRatio;

	this.startScroll = startScroll;
	this.stopScroll = stopScroll;
	this.continueScroll = continueScroll;
	this.init = init;
	this.tableMouseMoved = tableMouseMoved;
	this.loadComponent = loadComponent;
	this.doWheel = doWheel;
	this.tableScroll = tableScroll;

	function tableMouseMoved(event){
		if(is_mac)
			return;

		tableEventX = event.clientX;
		dif = 25;
		if(tableEventX<20){
		   tableEventX-=dif;
		}else{
		   tableEventX+=dif;
		}
        startTableScroll();  
	}


	function startTableScroll(){
	   if(tableTimer)
	      clearTimeout(tableTimer);

		ratio = (tableEventX/frameWidth);

		newPos = parseInt((tableWidth - frameWidth) * ratio);
		
		tableNewPos = newPos;
		tableRatio = ratio;

        tableScroll();

		
	}


	function tableScroll(){



		dif = (tableNewPos - xPos)/10;

	    if(windowObj){

		   newPos = xPos+parseInt(dif);

		   if(!allowScroll(newPos))
			   return;

           windowObj.scrollTo(newPos,0);
		   xPos = newPos;
           
		   if(Math.abs(dif*3)>1){
		     tableTimer = window.setTimeout("theScrollObj.tableScroll()",20);
		   }
		   

		}	
	}


	function doWheel(delta){
		     return;
			 f = -1;

			 incr = 7;
			 c = change * incr;
			 if(delta<0)
				f = 1;

			 while(incr>1 && !allowScroll( xPos + (c*f) )){
				incr--;
				c = change * incr;
			 }

			  if(allowScroll( xPos + (c*f) )){
				   windowObj.scrollTo( xPos + (c*f),0);
				   xPos =  xPos + (c*f);
			  }
	}


	function loadComponent(id,imageSrc){

		oldObj = document.getElementById("componentDiv"+comId);
		if(oldObj){
		   obj.style.display='none';
		}

	    obj = document.getElementById("componentDiv"+id);
		if(obj){
		   obj.style.display='block';
		   comId = id;
		}

		imObj = document.images['bigComponentImage'];
		if(imageSrc && imObj){
		   imObj.src = imageSrc;
		}
			
	}

	function startScroll(f){
	   flag = f;
       continueScroll();
	}

	function allowScroll(newPos){
	   if(newPos<0){
	      return false;
	   }

	   if(newPos>(tableWidth-frameWidth)){
	      return false;
	   }

	   return true;
	}


	function init(tableW,winObj,componentId){
	   windowObj = winObj;
	   tableWidth = tableW;
	   loaded = true;
	   loadComponent(componentId)
	}


	function doScroll(){
	   if(windowObj){

		   if(flag){
			  newPos = xPos+change;
		   }else{
		      newPos = xPos-change;
		   }

		   if(!allowScroll(newPos))
			   return;

           windowObj.scrollTo(newPos,0);
		   xPos = newPos;

		}
	}

	function continueScroll(){
		 doScroll();
         theTimer = window.setTimeout("theScrollObj.continueScroll()",18);
	}

	function stopScroll(){
	   if(theTimer){
	      clearTimeout(theTimer);
	   }
	}

}

var theScrollObj = new scrollObj();
	
function componentsLoaded(id){

    if(parent){
		obj = parent.theScrollObj;  
		obj.init(document.getElementById('contentTable').offsetWidth,window,id);
	}
       

}


function tableMouseMoved(event){
    if(parent){
		parent.theScrollObj.tableMouseMoved(event);

	}
}


var currentSmallCompImage;
var currentSmallCompImageSrc;

function doLoadComponent(id,big,white){

    if(parent){
		parent.theScrollObj.loadComponent(id,big);
	}

	if(currentSmallCompImage){
	   imObj = document.images['smallCompImage' + currentSmallCompImage];
	   imObj.src = currentSmallCompImageSrc;
	}

	imObj = document.images['smallCompImage' + id];

	if(imObj){
	  currentSmallCompImageSrc =  imObj.src;
	  currentSmallCompImage = id;
      imObj.src = white;
	}

	
	

}




function doWheel(event){
    if(parent){
		parent.theScrollObj.doWheel(event);

	}
}






/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////           advanced search       ///////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

















function advancedSearch(){


    var items = [];
	var ancor;
	var lang;
	var table;
	var thisName;
	var level = 0;
	var isIE = false;
	var req;
	var section;
	var choose_text;
	var parents = [];

    this.buildItem = buildItem;
    this.doBuildItem = doBuildItem;
    this.init = init;
    this.go = go;

        
        function init(initAncor,l,t,s,name,c_t){
		   ancor = initAncor;
		   lang = l;
		   table = t;
		   section = s;
		   thisName = name;
           choose_text = c_t;
		}


		function parseLongString(text){
			limit = 50;

			if(text.length>limit){
			  text = text.substr(0,limit) + "...";
			}
		   return text;
		}

		function buildSelect(data){
		   sItems = data.split("||");
		   html = '<img src="/images/1x1.gif" width="1" height="7"><br /><select class="searchSelect" onChange="'+thisName+'.doBuildItem(this,this.options[this.selectedIndex].value,'+level+')">';
		   html += '<option value="0">' + choose_text + '...</option>';

		   for(i=0;i<sItems.length;i++){
			 subItems = sItems[i].split(":");
		     html += '<option value="'+subItems[0]+'">'+parseLongString(subItems[1])+'</option>';
		   }
		   
		   html += '</select><br /><img src="/images/1x1.gif" width="1" height="7">';

		   return html;
		}


		function go(){
		    if(parents.length>0){
			   document.location.href = '/'+lang+'/products/'+section+'/?cat='+parents[parents.length-1];
			}
		}


		function getData(table,parent){
	
	        url = "/get_structure.php?lang="+lang+"&table="+table+"&parent="+parent;

			if (window.XMLHttpRequest) {
				req = new XMLHttpRequest();
				req.onreadystatechange = processReqChange;
				req.open("GET", url, true);
				req.send(null);
			// branch for IE/Windows ActiveX version
			} else if (window.ActiveXObject) {
				isIE = true;
				req = new ActiveXObject("Microsoft.XMLHTTP");
				if (req) {
					req.onreadystatechange = processReqChange;
					req.open("GET", url, true);
					req.send();
				}
			}
// 
		
		}

        
		function processReqChange() {
			// only if req shows "loaded"
			if (req.readyState == 4) {
				// only if "OK"
				if (req.status == 200) {
					its  = req.responseXML.getElementsByTagName("response");
					text = getElementTextNS("","result", its[0], 0);
					buildItem(text);
				 } else {
					alert("There was a problem retrieving the XML data:\n" +
						req.statusText);
				 }
			}
		}


		function getElementTextNS(prefix, local, parentElem, index) {
			var result = "";
			if (prefix && isIE) {
				result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
			} else {
				result = parentElem.getElementsByTagName(local)[index];
			}

			if (result) {
				    if(result.firstChild){
					   return result.firstChild.nodeValue;
					}else{
					   return false;
					}
					
			} else {
				return "n/a";
			}
		}

		function doBuildItem(obj,parent,lev){
		

			if(parent==0 || (lev<(level-1)) ){

			    //delete unused//

				
                cur_len = items.length;
				for(i=(cur_len-1);i>=(lev+1);i--){
					   if(isIE){
						  items[i].removeNode(true);
					   }else{
						  ancor.removeChild(items[i]);
					   }

				      items.pop();
					  parents.pop();
				   
				}

				level  = lev + 1;

			}


            if(parent>0){
			   parents.push(parent);
			}else{
			   parents.pop();
			}


			if(lev==0){
				s_Obj = document.getElementById("chooseDiv");
				if(s_Obj){
				   if(parent==0){
				      s_Obj.style.visibility = "hidden";
				   }else{
				      s_Obj.style.visibility = "visible";
				   }
				   
				}
			}

			if(parent==0)
				return;

			getData(table,parent);





			
		}

	    function buildItem(data){
			if(!data)
				return;
		    newElem = document.createElement('div');

            selectData = buildSelect(data);
			
			newElem.innerHTML = getBlock(selectData);

            if(ancor)ancor.appendChild(newElem);
            items.push(newElem);
			level++;
		}
	    

		function getBlock(data){
           
		   type = (items.length%2);

		   if(type == 0){
			  html = '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0"><TR><TD><img src="/images/shoplist/top_left.gif" width="3" height="3"></TD><TD width="100%" style="background: #FFEDCC url(\'/images/shoplist/border.gif\') top left repeat-x;"><img src="/images/1x1.gif" width="3" height="3"></TD><TD><img src="/images/shoplist/top_right.gif" width="3" height="3"></TD></TR><TR><TD style="background: #FFEDCC url(\'/images/shoplist/border.gif\') top left repeat-y;"><img src="/images/1x1.gif" width="3" height="21"></TD><TD width="100%" bgcolor="#FFEDCC"><TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD><img src="/images/1x1.gif" width="10" height="1"></TD><TD><b>'+data+'</b></TD></TR></TABLE></TD><TD style="background: #FFEDCC url(\'/images/shoplist/border.gif\') top right repeat-y;"><img src="/images/1x1.gif" width="3" height="21"></TD></TR><TR><TD><img src="/images/shoplist/bottom_left.gif" width="3" height="3"></TD><TD width="100%" style="background: #FFEDCC url(\'/images/shoplist/border.gif\') bottom left repeat-x;"><img src="/images/1x1.gif" width="3" height="3"></TD><TD><img src="/images/shoplist/bottom_right.gif" width="3" height="3"></TD></TR></TABLE>';
		   }else{
			  html = '<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BORDER="0"><TR><TD><img src="/images/shoplist/list_top_left.gif" width="3" height="3"></TD><TD width="100%" style="background: #FFE2B0 url(\'/images/shoplist/list_border.gif\') top left repeat-x;"><img src="/images/1x1.gif" width="3" height="3"></TD><TD><img src="/images/shoplist/list_top_right.gif" width="3" height="3"></TD></TR><TR><TD style="background: #FFE2B0 url(\'/images/shoplist/list_border.gif\') top left repeat-y;"><img src="/images/1x1.gif" width="3" height="21"></TD><TD width="100%" bgcolor="#FFE2B0"><TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD><img src="/images/1x1.gif" width="10" height="1"></TD><TD>'+data+'</TD></TR></TABLE></TD><TD style="background: #FFE2B0 url(\'/images/shoplist/list_border.gif\') top right repeat-y;"><img src="/images/1x1.gif" width="3" height="21"></TD></TR><TR><TD><img src="/images/shoplist/list_bottom_left.gif" width="3" height="3"></TD><TD width="100%" style="background: #FFE2B0 url(\'/images/shoplist/list_border.gif\') bottom left repeat-x;"><img src="/images/1x1.gif" width="3" height="3"></TD><TD><img src="/images/shoplist/list_bottom_right.gif" width="3" height="3"></TD></TR></TABLE>';
		   }
		   
           html +='<img src="/images/1x1.gif" width="1" height="8">';
		   return html;


		}



}


function openBigImage(im,type){

   if(type=='hor'){
      w = 520;
      h = 342;
   }else{
      w = 350;
      h = 467;
   }
       var aw = screen.availWidth;
       var ah = screen.availHeight;
       var t = (ah - h) / 2;
       var l = (aw - w) / 2;
	   window.open("/popup.php?im="+im,"","top="+t+",left="+l+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+w+",height="+h+",");
}

function img_in_popup(src, w, h) {
	return windows.popup('', 'img_in_popup', w, h, '', '', '', 'auto', '<img src="'+ src +'" alt="" width="'+ w +'" height="'+ h +'" onclick="window.close();" style="cursor:pointer" />');
}