// JavaScript Document
/*
*	Filename: misc.js
*	Last update: 2007 01 30
*	Developed by Milan Jovanovic PlumDesign, Belgrade 2007
*	admin@plum-design.net
*	www.plum-design.net
*/
// onload focus field
 function putFocus(formInst, elementInst) {
  if (document.forms.length > 0) {
   document.forms[formInst].elements[elementInst].focus();
  }
 }
 
 
 /* Displaing explanations 
 *	expNum - element identifier of ExpString array in **_strings.js
 *	expContainerID - ID of html tag that will display explanation string
 *	expShow - defines is HTML tag will be displayed or not (u can use onMouseOver and onMouseOut hendlers)
 */
 function displayExplanation(expNum,expContainerID,expShow){
//
	 expContainer = document.getElementById(expContainerID);
	 //alert(expContainer);
	 expContainer.innerHTML = ExpString[expNum];
	 
	 if(expShow){
	 	expContainer.style.visibility = "visible";
	 }else{
		 expContainer.style.visibility = "hidden";
	 }
 }
 
 
 // PopUpMenu - koristim ga pri sortiranju po proizvodjacima i ostalo
function PopUpImage(IdPopUp,IdAnchorPopUp,imgSRC,Yoffset,Xoffset){ 
AnchorElement = document.getElementById(IdAnchorPopUp);
TopPos = findPosY(AnchorElement);
LeftPos = findPosX(AnchorElement);
//alert(TopPos +" - " + LeftPos);
box = document.getElementById(IdPopUp);
	if (box.style.display == "block"){
		box.style.display="none";
	}else{
		
		box.style.display="block";
		box.style.left = LeftPos + Yoffset;
		box.style.top = TopPos + Xoffset;
		
		box.innerHTML = "<img src='"+imgSRC+"'>";
		//alert("<img src='"+imgSRC+"' >");
	} 
}

/*  Apsolutna pozicija elemenata */
  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
  
/* OPEN PAGE IN NEW MODIFIED WINDOW */
// funkcija za otvaranje novog prozora sa zadatim parametrima preko promenljivih
function NoviProzor(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


