	productsDir='b2b/products';	//must be same as in PHP!
   float_img=true;
   active_img_mark=null;
   show_delay=null;
   ims=new Object;
   window.onerror = function() { return true;}

function myOnLoad() {
   document.onmousemove=document_onmousemove;
   if (window.onscroll) window.onscroll=hide_div();
   setInterval("imgSwaper();",500);
}

function get_obj(id_name) {
   if (document.getElementById) {
      return document.getElementById(id_name);
   } else if (document.all) {
      return document.all[id_name];
   } else {
      return null;
   }
}

function document_onmousemove(e){
   if (!float_img) return;
   var pos_X=0;
	 var pos_Y=0;
   if (!e)
	 	e=window.event;
   if (e){
      if (typeof(e.pageX)=='number'){
         pos_X=e.pageX;
				 pos_Y=e.pageY;
      } else if (typeof(e.clientX)=='number'){
         pos_X=e.clientX;
				 pos_Y=e.clientY;
         
				 if (document.body && (document.body.scrollTop || document.body.scrollLeft) && !(window.opera || window.debug || navigator.vendor=='KDE')){
            pos_X+=document.body.scrollLeft;
						pos_Y+=document.body.scrollTop;
         } else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft) && !(window.opera || window.debug || navigator.vendor == 'KDE')){
            pos_X+=document.documentElement.scrollLeft;
						pos_Y+=document.documentElement.scrollTop;
         }
      }
   }

   var scroll_X=0;
	 var scroll_Y=0;
   if (document.body && (document.body.scrollTop || document.body.scrollLeft) && !(window.debug || navigator.vendor=='KDE')){
      scroll_X=document.body.scrollLeft;
			scroll_Y=document.body.scrollTop;
   } else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft) && !(window.debug || navigator.vendor=='KDE')){
      scroll_X=document.documentElement.scrollLeft;
			scroll_Y=document.documentElement.scrollTop;
   }

   var wndSize_X=0;
	 var wndSize_Y=0;
   if (window.innerWidth && window.innerHeight) {
      wndSize_X=window.innerWidth;
			wndSize_Y=window.innerHeight;
   } else if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientHeight) {
      wndSize_X=document.documentElement.clientWidth;
			wndSize_Y=document.documentElement.clientHeight;
   } else if (document.body && document.body.clientWidth && document.body.clientHeight) {
      wndSize_X=document.body.clientWidth;
			wndSize_Y=document.body.clientHeight;
   }

	pos_X+=20;
	pos_Y+=20;
	 
   if (float_img.offsetWidth && float_img.offsetHeight){
      if (pos_X-scroll_X+float_img.offsetWidth+5>wndSize_X)
				pos_X-=(float_img.offsetWidth+25);
      if (pos_Y-scroll_Y+float_img.offsetHeight+5>wndSize_Y)
				pos_Y-=(float_img.offsetHeight+20);
   }
	
   float_img.style.left=pos_X+"px";
	 float_img.style.top=pos_Y+"px";
	 float_img.style.display="block";
}

//dodelat preloading obrazku do ims uz pri nacitani stranky!!!

// show float image
function floatShow(imgId, index) {
	if (!index) index=0;
   if (show_delay) {
      clearTimeout(show_delay); show_delay=null;
   } else {
      float_img=get_obj('float-img-border');
      show_delay=setTimeout('floatShow("'+imgId+'","'+index+'");', 0);
      return;
   }
   var img_mark='img_index_'+imgId+'_'+index;
   active_img_mark=img_mark;
   if (ims[img_mark] && ims[img_mark].complete) {
      swapImg(img_mark);
   } 
   
   if (!ims[img_mark]) {
      ims[img_mark]=new Image;
      ims[img_mark].src=productsDir+"/"+imgId+"/s_"+index+".jpg";
   }
   show_div('float-img-border');
}

function imgSwaper(){
   if (!float_img || !ims[active_img_mark] || !get_obj('float-img')) return;
   if (get_obj('float-img').src!=ims[active_img_mark].src && ims[active_img_mark].complete ) 
	 	swapImg(active_img_mark);
}

function swapImg(img_mark){
   var obj_base_img=get_obj('float-img');
   if (!obj_base_img) return;
   obj_base_img.src=ims[img_mark].src;
}

function show_div(div_mark){
   
   if (show_delay){
      clearTimeout(show_delay); show_delay = null;
   } else{
      float_img = get_obj(div_mark);
      show_delay = setTimeout('show_div("' + div_mark + '");', 200);
      return;
   }
   if (!float_img) return;
   
   document_onmousemove;
   float_img.style.display='block';
}

function hide_div() {
   clearTimeout(show_delay); show_delay = null;
   if (!float_img) return;
   float_img.style.display='none';
   float_img=false;
}

        
