﻿boxmove = true;

function closebox() {
   document.getElementById('obraz').innerHTML=' ';
   document.getElementById('obraz').style.display='none';
}
         
function updatebox(evt) {

   if (boxmove) {
	   
	   var divX;
	   var divY;
	   var winWidth;
	   var winHeight;  
       var mouseX=evt.pageX?evt.pageX:evt.clientX;
       var mouseY=evt.pageY?evt.pageY:evt.clientY;
	   var bName = navigator.appName;
	   
       document.getElementById('obraz').style.display='block';
	  
       if(bName.substring(0,9) == "Microsoft"){
		   winWidth = document.documentElement.offsetWidth;
		   winHeight = document.documentElement.offsetHeight;
		   mouseY = mouseY + document.documentElement.scrollTop;
       }else{
		   winWidth = window.innerWidth;
		   winHeight = window.innerHeight;
	   }
	   
	   var mX = mouseX+270;
	   var mY = mouseY+450-document.documentElement.scrollTop;
	   
       if(bName.substring(0,9) == "Microsoft"){
		   if(mX>winWidth-3){
			   divX = mouseX-270+"px";
		   }else{
			   divX = mouseX+20+"px";
		   }
       }else{
		   if(mX>winWidth-20){
			   divX = mouseX-270+"px";
		   }else{
			   divX = mouseX+20+"px";
		   }
	   }
	   
	   if(mY>winHeight){
		   divY = mouseY-450+"px";
	   }else{
		   divY = mouseY+"px";
	   }
	  
       document.getElementById('obraz').style.left= divX;
       document.getElementById('obraz').style.top= divY;
    }
}

function imgLoad(name) {
 document.imgFlame.src = 'produkty/'+name+'.jpg';
}

function list_on(element) {
	document.getElementById(element).style.display = 'block';
}

function list_off(element) {
	document.getElementById(element).style.display = 'none';
}

function select_class(e,parent_el,child_el){
	var el;			
	if(window.event && window.event.srcElement) {
		el = window.event.srcElement;
	}
	if(e && e.target) {
		el = e.target;
	}
	if(!el) {
		return;
	}
	
	var table = document.getElementById(parent_el);
	var cells = table.getElementsByTagName(child_el);
	
	for(var i=0;i<cells.length;i++){
		if(cells[i].id == el.id){
			cells[i].className = "td_on";
		}
		else{
			cells[i].className = "td_off";
		}
	}
}

function refresh_class(parent_el,child_el){
	
	var table = document.getElementById(parent_el);
	var cells = table.getElementsByTagName(child_el);
	
	for(var i=0;i<cells.length;i++){
		cells[i].className = "td_off";
	}
}

function select_thumb_class(id,parent_el,child_el){
	
	var table = document.getElementById(parent_el);
	var cells = table.getElementsByTagName(child_el);
	
	for(var i=0;i<cells.length;i++){
		if(cells[i].id == id){
			cells[i].className = "thumb_on";
		}
		else{
			cells[i].className = "thumb_off";
		}
	}
}

function refresh_thumb_class(parent_el,child_el){
	
	var table = document.getElementById(parent_el);
	var cells = table.getElementsByTagName(child_el);
	
	for(var i=0;i<cells.length;i++){
		cells[i].className = "thumb_off";
	}
}

function bookmark(anchor){
if(window.external)
{
window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
return false;
}
return true;
}

function clr_field(){
	var field;
	field = document.getElementById('email');
	field.value = '';
}

function WinOpen(cat,file){
	img_src = cat+"/"+file;
	msg=open(img_src,"DisplayWindow","toolbar=no,directories=no,menubar=no");
}
