//detect browser settings for showing and hiding DIVs
isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

var viewImageWnd     = null;
var openWebDialogWnd = null;
var openPopUpWnd     = null;

function viewImage(URL, dwidth, dheight, dname)
{
   var leftpos = (self.screen.width / 2) - (dwidth / 2);
   var toppos = (self.screen.height / 2) - (dheight / 2);
   
   if (viewImageWnd) viewImageWnd.close();
   
   viewImageWnd = window.open(URL,dname,'status=no,modal=yes,width='+dwidth+',height='+dheight+',left='+leftpos+',top='+toppos+'');
}

function openPopUp(URL, dwidth, dheight, dname, scrollbars)
{
   var leftpos = (self.screen.width / 2) - (dwidth / 2);
   var toppos = (self.screen.height / 2) - (dheight / 2);
   
   closePopUp();
   
   openPopUpWnd = window.open(URL,dname,'status=no, toolbar=no, menubar=no, location=no, resizable=no, modal=yes, width='+dwidth+', height='+dheight+', left='+leftpos+', top='+toppos+', scrollbars=' + (scrollbars ? 'yes' : 'no') + ', dependent=yes');
   
   //return false;
}
function closePopUp()
{
   if (openPopUpWnd) openPopUpWnd.close(); 
}

function openWebDialog(URL, dwidth, dheight, dname, scrollbars)
{
   var leftpos = (self.screen.width / 2) - (dwidth / 2);
   var toppos = (self.screen.height / 2) - (dheight / 2);
   
   closeWebDialog();
   
   if (isIE5)
      openWebDialogWnd = window.showModalDialog(URL,dname,'dialogHeight:'+dheight+'px; dialogWidth:'+dwidth+'px; resizable:no; status:no');
   else
      openWebDialogWnd = window.open(URL,dname,'status=no, toolbar=no, menubar=no, location=no, resizable=no, modal=yes, width='+dwidth+', height='+dheight+', left='+leftpos+', top='+toppos+', scrollbars=no, dependent=yes');
   
   //return false;
}
function closeWebDialog()
{
   if (openWebDialogWnd) openWebDialogWnd.close();
}

function DeleteConfirm()
{
    if (confirm("Ali ste prepricani?"))
    {
        return true;
    }
    return false;
}

function GetRadioGroupCheckedValue(rg_obj)
{
    if (rg_obj.length > 1)
    {
        for (i = 0; i < rg_obj.length; i++)
        {
            if (rg_obj[i].checked == true)
            {
                return rg_obj[i].value;
            }
        }
    }
    else
    {
        return rg_obj.value;
    }
    return;
}

function GetCurrentTime()
{
    var d = new Date();
    return d.getTime();
}

//Change visibility for DIV object
function switchDiv(strDivName, bolVisible){
    //identify the element based on browser type
    if (isNS4) {
       objElement = document.layers[strDivName];
    } else if (isIE4) {
       objElement = document.all[strDivName].style;
    } else if (isIE5 || isNS6) {
       objElement = document.getElementById(strDivName).style;
    }
    if(isNS4){
         if(!bolVisible) {
           objElement.visibility ="hidden"
         } else {
           objElement.visibility ="visible"
         }
    }else if(isIE4 || isIE5 || isNS6){
         if(!bolVisible) {
           objElement.visibility = "hidden";

         } else {
           objElement.visibility = "visible";
         }
    }
    return objElement;
}

