﻿// JScript File

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
      // Internet Explorer
      try
      {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    return xmlHttp;
}
function PreloadImages() {
  var d=document; 
  if(d.images){
    if(!d.MM_p) 
        d.MM_p=new Array();
    var i,j=d.MM_p.length, a=PreloadImages.arguments; 
    for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0)
            { 
                d.MM_p[j]=new Image; 
                d.MM_p[j++].src=a[i];
             }
   }
}
function Ajax(file, value, div)
{
    //alert("Going to " + value);
    document.getElementById("waitAnim").style.visibility="visible";
    document.getElementById("SearchBtn").value = "Molimo sačekajte...";

    var http = GetXmlHttpObject();
    http.onreadystatechange=function()
    {
	    if(http.readyState==4 /*&& http.status == 200*/)
	    {
		    document.getElementById(div).innerHTML=http.responseText;
		    //sakrij wait
	        document.body.style.cursor = "default";
	        document.getElementById("waitAnim").style.visibility="hidden";
            document.getElementById("SearchBtn").value = "Pretraga";
        }
    }
    http.open("GET",file+"?ID="+value,true);
    http.send(null);	
}
function AjaxImage(MyImage)
{
    document.getElementById("ImageDiv").innerHTML="<img style=\"margin-top:18px; border:none\" src=\"/images/wait_anim.gif\" />";
    var http = GetXmlHttpObject();
    http.onreadystatechange=function()
    {
	    if(http.readyState==4)
	    {
		    document.getElementById("ImageDiv").innerHTML=http.responseText;
        }
    }
    http.open("GET","GalleryImage.aspx?img="+MyImage,true);
    http.send(null);	
}
function CallCalendar(calendar, box, anchor)
{
    calendar.select(document.getElementById(box),anchor,'dd.MM.yyyy.');
}
