BROWSER = new Object();
BROWSER.isOpera = navigator.userAgent.indexOf("Opera") > -1;
BROWSER.isIE    = navigator.userAgent.indexOf("MSIE") > 1 && !BROWSER.isOpera;
BROWSER.isIE6   = BROWSER.isIE && navigator.userAgent.indexOf("MSIE 6.0") > 1; 
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=no,location=no,status=no,menubar=no,scrollbars=no,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 openResizer(img, title) {
	newwin = window.open('imageresizer.php?img='+img+'&title='+title, 'imageresizer', 'width=800,height=600,resizable=yes');
	newwin.focus();
	
}

function initMenuRange(menuName, smenuName, sInd, eInd, initPos) {
   var Obj, x, y, nat=77;
   for(var i=sInd; i<=eInd; i++){
       Obj = document.getElementById(menuName + i);
       sObj = document.getElementById(smenuName + i);
       fObj = document.getElementById(smenuName + "-frame" + i);
       if (Obj && sObj && fObj){
           if (initPos) {
	      	   fObj.style.width = sObj.offsetWidth + "px";
	      	   fObj.style.height = sObj.offsetHeight + "px";
               sObj.style.display = "none";
    	       sObj.style.left = fObj.style.left = Obj.offsetLeft + (BROWSER.isIE6 ? 362 : 359) + "px";
	      	   sObj.style.top = fObj.style.top = "100px";
	       }
	       
       	   Obj.submenuFrame = fObj;
       	   Obj.submenu = sObj;
       	   Obj.otheronmouseover = Obj.onmouseover;
       	   Obj.otheronmouseout = Obj.onmouseout;
		   Obj.onmouseover = function () {
		   	   this.submenu.style.display = "block";
		   	   this.submenuFrame.style.display = "block";
		   	   if (this.otheronmouseover) this.otheronmouseover();
		   }
		   Obj.onmouseout = function () {
		   	   this.submenu.style.display = "none";
		   	   this.submenuFrame.style.display = "none";
		   	   if (this.otheronmouseout) this.otheronmouseout();
		   }
		   
		   sObj.mainmenu = Obj;
		   sObj.onmouseover = function() {
		   	   this.style.display = "block";
		   	   //setBackground(this.mainmenu.id, false);
		   	   //this.open = true;
		   	   this.mainmenu.onmouseover();
		   }
		   sObj.onmouseout = function () {
		   	   this.style.display = "none";
		   	   //if (!this.open) setBackground(this.mainmenu.id, true);
		   	   //setTimeout('this.open = false;', 10);
		   	   this.mainmenu.onmouseout();
		   }
       }
   }
}


function setBackground(ObjID, setEmpty) {
    var Obj = document.getElementById(ObjID);
    if (typeof Obj == 'undefined') return false;
    if (setEmpty === false) {
		Obj.style.background = 'url(\"/images/NavTop.BckgrHover.gif\") 0px 0px repeat-x';
    }
    if (setEmpty === true) {
    	Obj.style.background = '';
    }
}

// open classic popup window
var win_array = [];
function openWin(loc, winName, winWidth, winHeight, winParams){
   if (!win_array[winName]) win_array[winName] = null;
   if (!win_array[winName] || (win_array[winName] && win_array[winName].closed)){
      if (winParams=='full'){
         winParams = 'resizable=yes,menubar=yes,status=yes,toolbar=yes,titlebar=yes,location=yes,directories=yes,scrollbars=yes';
      }
      win_array[winName] = window.open(loc, winName, "width="+winWidth+",height="+winHeight+","+winParams);
   }
   
   win_array[winName].location = loc;
   win_array[winName].focus();
}

function displayManualSubscribe(){
    document.getElementById('superManual').style.display='block'
}

function ajaxGetUrl(divId,url)
{
	new Ajax.Updater(divId,url,  { 

		method: 'post',     
		parameters: '',
		evalScripts: true,
		onSuccess: function(transport){   
					var response = transport.responseText || "no response text";       
					//alert("Success! \n\n" + response); 
					document.getElementById(divId).innerHTML = ''; 
					document.getElementById(divId).innerHTML = response; 
		},     
		onFailure: function(){ alert('Something went wrong...') }   
	});
}