/*

06.12.2000.                           
              --------   
                            
           Dyn Tools 0.3
           
 Dependencies: - browsercheck.js         
 
              ---------
 
 */                  


/*----------------------------------
 fades in an element in MS5 and MOzilla
 
 Note: an IE5 element MUSt have defined alpha filter CSS property on
 the element running the script..
-------------------------------------*/


//Mijenja source image-u
//'path'=za NETSCAPE div(ili divovi) u kojima se nalazi slika
//'imgName'=ID(u NETSCAPEU NAME) slike kojoj mijenjamo source
//'source'=path i ime nove slike


function changeSource(imgName, source, path) {
 
 if (browserName=="DOM1"){
     if (document.images[imgName].src!=source){
     document.images[imgName].src=source;
     }
}
 else 
 if (browserName=="MOZ"){
         if (document.images[imgName].src!=source){
      document.images[imgName].src=source;
      }
	  }
 else
 if (browserName=="MS4") {
   if (document.images[imgName].src!=source){
      document.images(imgName).src=source;
   }
      
      }
 else
 if (browserName=="MS5") {
    if (document.images[imgName].src != source) {
      document.images[imgName].src=source;
    }
 } else
 if (browserName=="NS4") {
   //alert(path+"document.images['"+imgName+"'].src='"+source+"'");
	 eval(path+"document.images['"+imgName+"'].src='"+source+"'");
 } 

} // function changeSource


// gets the current window's Width
function getWindowWidth(){
 sirinaProzora=700;
 if ((browserName=='MS5') || (browserName=='MS4'))	{
	 sirinaProzora=window.document.body.clientWidth; 
	 }
 if ((browserName=='NS4') || (browserName=='MOZ')){
	sirinaProzora=window.innerWidth; 
	}
	
 return sirinaProzora;
}

// gets the current window's height
function getWindowHeight(){
 visinaProzora=400;
 if ((browserName=='MS5') || (browserName=='MS4'))	{
	visinaProzora=window.document.body.clientHeight;}
 if ((browserName=='NS4') || (browserName=='MOZ')){
	visinaProzora=window.innerHeight;}
 return visinaProzora;
}


function fadeIn(_divId,_startOp,_endOp,_step,_timer){

	switch(browserName){
	 case 'NS4':showDiv(_divId); break;
	 case 'MS4':showDiv(_divId); break;
	 
	 case 'MS5':_op=_startOp*100;
	            document.getElementById(_divId).filters.alpha.opacity=_op;
	           break;
	 case 'MOZ'://document.getElementById(_divId).style.MozOpacity=_startOp;
	            
	            document.getElementById(_divId).style.MozOpacity=1;
		    //alert (_startOp);
		    return true;
	           break;
	 case 'DOM1':document.getElementById(_divId).style.opacity=_startOp;
	           break;
	}
	//now we move to the next step
	_nextStartOp=_startOp+_step;
	if ((_nextStartOp<=_endOp)&&((browserName=="MS5")||(browserName=="MOZ")||(browserName=="DOM1"))){
	  setTimeout('fadeIn("'+_divId+'",'+_nextStartOp+','+_endOp+','+_step+','+_timer+')',_timer)
	} else {
	  if (browserName=="MOZ"){
	     document.getElementById(_divId).style.MozOpacity=1;
	  }
	}
	
}

/*----------------------------------
 fades out an element in MS5 and Mozilla
-------------------------------------*/
function fadeOut(_divId,_startOp,_endOp,_step,_timer){

	switch(browserName) {
	 case 'NS4':hideDiv(_divId); break;
	 case 'MS4':hideDiv(_divId); break;
	 
	 case 'MS5':var _op=_startOp*100;
	            document.getElementById(_divId).filters.alpha.opacity=_op;
	         
	            
	           break;
	 case 'MOZ':document.getElementById(_divId).style.MozOpacity=_startOp;
	           document.getElementById(_divId).style.MozOpacity=0;		   
		   return true;
	           break;
	 case 'DOM1':document.getElementById(_divId).style.opacity=_startOp;
	           break;
	}
	//now we move to the next step
	var _nextStartOp=_startOp-_step;
	if ((_nextStartOp>=_endOp)&&((browserName=="MS5")||(browserName=="MOZ")||(browserName=="DOM1"))){
	  setTimeout('fadeOut("'+_divId+'",'+_nextStartOp+','+_endOp+','+_step+','+_timer+')',_timer)
	} else {
	 hideDiv (_divId);
	}
	
}


/*----------------------------------
 Moves Div to a specified location
-------------------------------------*/
function moveDivTo(divId,toX,toY){
//alert(divId+"-"+toX+"-"+toY);

	switch(browserName){
	 case 'NS4':window.document.layers[divId].moveTo(toX,toY);break;
	 case 'MS4':window.document.all(divId).style.left=toX; document.all(divId).style.top=toY; break;
	 case 'MS5':window.document.getElementById(divId).style.left=toX; document.getElementById(divId).style.top=toY; break;
	 case 'MOZ':window.document.getElementById(divId).style.left=toX; document.getElementById(divId).style.top=toY; break;
	 case 'DOM1':window.document.getElementById(divId).style.left=toX; document.getElementById(divId).style.top=toY; break;
	}
  
}


/*----------------------------------
 Moves Nested div to a specified location
-------------------------------------*/
function moveNestedDivTo(divId,toX,toY,parentDivId){
	switch(browserName){
	 case 'NS4':if (parentDivId!=""){
	               window.document.layers[parentDivId].document.layers[divId].left=toX; 
                 window.document.layers[parentDivId].document.layers[divId].top=toY; 
	              }else{
	                window.document.layers[divId].left=toX; document.layers[divId].top=toY;
	              } break;
	 case 'MS4':window.document.all(divId).style.left=toX; document.all(divId).style.top=toY; break;
	 case 'MS5':window.document.getElementById(divId).style.left=toX; document.getElementById(divId).style.top=toY; break;
	 case 'MOZ':window.document.getElementById(divId).style.left=toX; document.getElementById(divId).style.top=toY; break;
	 case 'DOM1':window.document.getElementById(divId).style.left=toX; document.getElementById(divId).style.top=toY; break;
	}
}

// Moves Div relatively to a present position
function moveDivBy(divId,byX,byY){
 return false;
}


/*----------------------------------
             setZIndex of div
-------------------------------------*/
function setZIndex(divId,_zindex){
	
      if ((browserName=="MS5")||(browserName=="MOZ")||(browserName=="DOM1")) {
        	document.getElementById(divId).style.zIndex=_zindex;
	}
      if (browserName=="NS4") {
	        document.layers[divId].zIndex=_zindex;
        }
      if (browserName=="MS4") {
		document.all(divId).style.zIndex=_zindex;
        }
	
}

/*----------------------------------
             Hides div
-------------------------------------*/
function hideDiv(divId){

      if ((browserName=="MS5")||(browserName=="MOZ")||(browserName=="DOM1")) {
        	document.getElementById(divId).style.visibility="hidden"
	}
      if (browserName=="NS4") {
	        document.layers[divId].visibility="hide"
        }
      if (browserName=="MS4") {
		document.all(divId).style.visibility="hidden";
        }
	
	
	
}

/*----------------------------------
             Shows div
-------------------------------------*/
function showDiv(divId){
	
      if ((browserName=="MS5")||(browserName=="MOZ")||(browserName=="DOM1")) {
        	document.getElementById(divId).style.visibility="visible"
	}
	
      if (browserName=="NS4") {

	        document.layers[divId].visibility="show"
        }
      if (browserName=="MS4") {
		document.all(divId).style.visibility="visible";
        }
	
	
}


/*----------------------------------
             Hides nested div
-------------------------------------*/
function hideNestedDiv(containerDiv,divId){
	
      if ((browserName=="MS5")||(browserName=="MOZ")||(browserName=="DOM1")) {
        	document.getElementById(divId).style.visibility="hidden"
	}
	
      if (browserName=="NS4") {
	        document.layers[containerDiv].document.layers[divId].visibility="hide"
        }
      if (browserName=="MS4") {
		document.all(divId).style.visibility="hidden";
        }
	
	

}

/*----------------------------------
             Shows nested div
-------------------------------------*/
function showNestedDiv(containerDiv,divId){

      if (browserDOM) {
            document.getElementById(divId).style.visibility="visible";
	}

      if (browserName=="NS4") {
	        document.layers[containerDiv].document.layers[divId].visibility="show";
        }
      if (browserName=="MS4") {
		document.all(divId).style.visibility="visible";
        }
	
	
}


/*------------------------------------
          Colors div 
                                                        
---------------------------------------*/
function colorDiv(divId,col){
	
  if ((browserName=="MS5")||(browserName=="MOZ")||(browserName=="DOM1")) {
      document.getElementById(divId).style.backgroundColor=col;
  }
  if (browserName=="NS4") {
      document.layers[divId].document.bgColor=col;
  }
  if (browserName=="MS4") {document.all[name].style.backgroundColor=col;
      document.all[divId].style.backgroundColor=col;
  }
}


/*----------------------------------
     Return div's left position
-------------------------------------*/
function getDivLeft(divId){

switch (browserName) {
		case "NS4":
		             return document.layers[divId].left;
				 break;
		case "MOZ":
		            return document.getElementById(divId).offsetLeft;
		         break;
	       case "DOM1":
		            return document.getElementById(divId).offsetLeft;
		         break;
		case "MS4": return document.all(divId).offsetLeft;	
		         break;	 
		case "MS5": return document.all(divId).offsetLeft;	
		         break;	 
	
	}

}

/*----------------------------------
     Return div's left position
-------------------------------------*/
function getDivTop(divId){

switch (browserName) {
		case "NS4":  
		        return document.layers[divId].top;
			break;
		case "MOZ":
		            return document.getElementById(divId).offsetTop;
		         break;
	        case "DOM1":
		            return document.getElementById(divId).offsetTop;
		         break;
		case "MS4": return document.all(divId).offsetTop;	
		         break;	 
		case "MS5": return document.all(divId).offsetTop;	
		         break;	 
	
	}

}

/*----------------------------------
     Return div's Width
-------------------------------------*/
function getDivWidth(divId){

switch (browserName) {
		case "NS4": 
		        return document.layers[divId].clip.width;
			break;
		case "MOZ":
		         return document.getElementById(divId).offsetWidth;
		         break;
	        case "DOM1":
		         return document.getElementById(divId).offsetWidth;
		         break;
		case "MS4":
		         return document.all(divId).offsetWidth;	
		         break;	 
		case "MS5": return document.all(divId).offsetWidth;	
		         break;	 
	
	}

}

/*----------------------------------
     Return div's height
-------------------------------------*/
function getDivHeight(divId){

switch (browserName) {
		case "NS4":  
		             return document.layers[divId].clip.height;
				 break;
		case "MOZ":
		            return document.getElementById(divId).offsetHeight;
		         break;
  	         case "DOM1":
		            return document.getElementById(divId).style.height;
		         break;
		         
		case "MS4": 
		          return document.all(divId).offsetHeight;	
		         break;	 
		case "MS5": return document.all(divId).offsetHeight;	
		         break;	 
	
	}

}


/*----------------------------------
     Return nested div's left position
-------------------------------------*/
function getNestedDivHeight(divId,parentDivId){

switch (browserName) {
		case "NS4":if (parentDivId!="") {
		          return document.layers[parentDivId].document.layers[divId].clip.height;
		         } else {return window.document.layers[divId].clip.height;}
				 break;
		case "MOZ":
		           return window.document.getElementById(divId).offsetHeight;
		         break;
		case "DOM1":
		           return window.document.getElementById(divId).offsetHeight;
		         break;
		case "MS4": return window.document.all(divId).offsetHeight;	
		         break;	 
		case "MS5": 
		            return window.document.getElementById(divId).offsetHeight;	
		
		         break;	 
	
	}

}

//writes something into target div
function writeDiv(divId,content){

switch (browserName) {
		case "NS4":document.layers[divId].document.write(content);
				   document.layers[divId].document.close();
				 break;
		case "MOZ": return window.document.getElementById(divId).innerHTML=content;
		         break;
		case "DOM1": return window.document.getElementById(divId).innerHTML=content;
		         break;
		case "MS4": return document.all(divId).innerHTML=content;	
		         break;	 
		case "MS5": return document.all(divId).innerHTML=content;
		         break;	 
	
	}
}

//writes something into nested div (NS4 compatibility)
function writeNestedDiv(divId,parentDivId,content){

switch (browserName) {
		case "NS4":if (parentDivId!="") {
		           document.layers[parentDiv].document.layers[divId].document.write(content);
				   document.layers[parentDiv].document.layers[divId].document.close();
		         } else { document.layers[divId].document.write(content);
				   document.layers[divId].document.close();}
				 break;
		case "MOZ": return window.document.getElementById(divId).innerHTML=content;
		         break;
		case "DOM1": return window.document.getElementById(divId).innerHTML=content;
		         break;
		case "MS4": return document.all(divId).innerHTML=content;	
		         break;	 
		case "MS5": return document.all(divId).innerHTML=content;
		         break;	 
	
	}

}

function animateDiv(ciljniId, posX, endX, interval, korak, smjer) {
 eval("posX"+smjer+"= korak;");
 posY = 0;
 moveDivTo(ciljniId, posX, posY);
 if ((smjer=="-" && posX>endX) || (smjer=="+" && posX<endX)) {
 	vrtise = true;
 	setTimeout("animateDiv('"+ciljniId+"',"+posX+","+endX+","+interval+","+korak+",'"+smjer+"')", interval);
 } else {
 	moveDivTo(ciljniId, endX, posY);
 	vrtise = false;
 }
}

function popup2(file, w, h) {
	if ( parent.noviProzor ) { noviProzor.close(); }
	noviProzor = window.open( file, "pero", 'width='+w+', height='+h+', toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	noviProzor.focus();
}


function popup3(file) {
	noviProzor = window.open(file, 'popup', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, width=300, height=225');
	noviProzor.focus();
}


function popup(src, w, h) {
	var d = new Image;
	d.src = src;
	if ( parent.pero ) { pero.close(); }
	pero = window.open( "", "pero", 'width='+w+', height='+h+', toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	pero.document.write('<head><title>Big Image</title></head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">');
	pero.document.write("<a href='javascript:window.close()'><img border=0 src='"+src.replace("Š", "%b5").replace("ž", "%ba").replace("è", "%e8").replace("ð", "%f0")+"' alt='Close window'></a></body>")
	pero.focus();
}



