BROWSER = new Object();
BROWSER.isOpera = navigator.userAgent.indexOf("Opera") > -1;
BROWSER.isIE    = navigator.userAgent.indexOf("MSIE") > 1 && !BROWSER.isOpera; 
BROWSER.isMoz   = navigator.userAgent.indexOf("Mozilla/5.") == 0 && !BROWSER.isOpera;

if (typeof($) != "function") $ = function(ID){ return document.getElementById(ID); }

function redirect(id) {
   alert("This link works only in front-end site!")
}

function popupimg(img) {
    var d = new Date()
    var ID = d.getDate()+""+d.getMonth()+1+""+d.getFullYear()+""+d.getHours()+""+d.getMinutes()+""+d.getSeconds();

    var loc = "/enlarge.php?src="+img;
	var win = window.open(loc, "_new"+ID,"toolbar=yes,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=200,height=200");
	win.location.href = loc;
	win.focus();
}

/* highlist elements onmouse over event
 */
function highlight(groupElements, classOver) {
   var i, j, Obj, groupObjects = [];
   for(j=1; j<100; j++) {
   	   for(i in groupElements) {
   	   	   Obj = $(groupElements[i]+j);
           if (Obj) {
               Obj.ind = j; 
               groupObjects[groupObjects.length] = Obj;
           }
       }
   }
   
   for(i in groupObjects) {
      Obj = groupObjects[i];
      Obj.classDefault = Obj.className;
      Obj.classOver = classOver;
      Obj.groupObjects = groupObjects;
      
      Obj.onmouseover = function() {
      	  this.className = this.classOver;
      	  for(var i in this.groupObjects){
      	      var Obj = this.groupObjects[i]; 
      	  	  if (Obj.ind == this.ind) Obj.className = Obj.classOver;
      	  }
      }
      Obj.onmouseout = function() {
      	  this.className = this.classDefault;
      	  for(var i in this.groupObjects){
      	  	  var Obj = this.groupObjects[i];
      	  	  if (Obj.ind == this.ind) Obj.className = Obj.classDefault;
      	  }
      }
   }
}

function openLink(link) {
   location.href = link;
}

function setLabel(objID, passDiv) {
    var Obj = document.getElementById(objID);
    if (!Obj) return;
    Obj.defaultText = Obj.value;
    Obj.onclick = Obj.onfocus = function(){
        if (this.value == Obj.defaultText) this.value = "";
        if (this.divObj) {
            this.divObj.style.display = "none";
        }
    }
    
    Obj.onblur = function(){
        if (this.value.match(/^\s*$/)) {
            this.value = this.defaultText;
            if (this.divObj){
                this.divObj.style.display = "inline";
            }
        }
    }
    
    if (passDiv) {
        var divObj = document.getElementById(passDiv);
        divObj.inputObj = Obj;
        Obj.divObj = divObj;
        divObj.onclick = function() {
           this.style.display = "none";
           this.inputObj.focus();
        }
        Obj.onfocus = function(){ 
           Obj.divObj.style.display = "none";
        }
    }
}