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

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
 */
/* highlist elements onmouse over event
 */
 function highlight(groupElements, classOver, excludeInds) {
   var i, j, Obj, groupObjects = [];
   for(j=1; j<100; j++) {
       if (excludeInds && in_array(j, excludeInds)) continue;
   	   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 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 + "px";
	      	   sObj.style.top = fObj.style.top = "0px";
	       }
	       
       	   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";
		   	   this.mainmenu.onmouseover();
		   }
		   sObj.onmouseout = function () {
		   	   this.style.display = "none";
		   	   this.mainmenu.onmouseout();
		   }
       }
   }
}

function setContextOpen(clickArr, showArr, changeArr) {
	var i, j, k, m;
	for (j in clickArr) {
		for(i=1; i<200; i++) {
		    var Obj = document.getElementById(clickArr[j] + i);
		    if (!Obj) break;
		    for(k in showArr) {
			    var sObj = document.getElementById(showArr[k] + i);
			    if (!sObj) break;
			    Obj.showObj = sObj;
			    Obj.openView = false;
			    for(m in changeArr) {
			        var cElemFir = document.getElementById(changeArr[m][0]+i);
			        var cElemSec = document.getElementById(changeArr[m][1]+i);
				    if (cElemFir && cElemSec) {
				        Obj.cElemFir = cElemFir;
				        Obj.cElemSec = cElemSec;
				    }
				}
			    Obj.onclick = function() {
			        if (this.openView) {
			           this.showObj.style.display = "none";
			           this.openView = false;
			           if (this.cElemFir) {
			           	   this.cElemFir.style.display = "block";
			           	   this.cElemSec.style.display = "none";
			           }
			        } else {
			           this.showObj.style.display = "block";
			           this.openView = true;
			           if (this.cElemFir) {
			           	   this.cElemFir.style.display = "none";
			           	   this.cElemSec.style.display = "block";
			           }
			        }
			    }
			}
		}
    }
}


function CreateBookmarkLink(title, url, E) { 
   if (BROWSER.isMoz || BROWSER.isSafari) { // Mozilla Firefox, Safari
       alert("You need to press CTRL + D to bookmark our site.")
       //window.sidebar.addPanel(title, url, url);
   } else if ( window.external ) { // IE Favorite
   	   window.external.AddFavorite( url, title); 
   } else if (window.opera && window.print) { // Opera Hotlist
       E.href = url;
       E.title = title;
       E.rel = "sidebar";
	   E.click();
   }
}

function showFlashMessage(objId, objWidth, objHeight, objColor) {
    var msg = 'To see this video, you need to upgrade your Flash player.<br />'+
              '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=shockwaveFlash" target="_blank">Please visit the Adobe site to download.</a>';
    var Obj = document.getElementById(objId);
    if (!Obj) return false;
    Obj.innerHTML = '<table cellpadding="10" cellspacing="0" border="0" width="'+objWidth+'" height="'+objHeight+'" style="background:'+objColor+';">'+
                    '<tr><td align="center" valign="center">'+ msg+'</td></tr></table>';
}
 