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 menuon(el){
  el.className='Item Selected';
  if (sel = document.getElementById('selectedMenu0')){
    sel.className = 'Item';
  }
}
function menuoff(el){
  el.className='Item';
  if (sel = document.getElementById('selectedMenu0')){
    sel.className = 'Item Selected';
  }
}



var slideStep = 99*7;
var slideSpeed = 500;

function slideGetX(elId){
  return parseInt(document.getElementById(elId).style.left);
}

function slideRight(elId){
  x = slideGetX(elId);
  cnt = parseInt(parseInt(document.getElementById(elId).style.width)/slideStep);
  pos = parseInt(x / slideStep);
  //alert(cnt+'-'+pos);
  //if ((cnt + pos) > 7){
  if ((cnt > -pos)){
    x -= slideStep;
    jQuery('#'+elId).animate({left: x + 'px'}, slideSpeed);
    //document.getElementById(elId).style.left = x + 'px';
  }
}
function slideLeft(elId){
  x = slideGetX(elId);
  pos = parseInt(x / slideStep);
  if (pos){
    x += slideStep;
    jQuery('#'+elId).animate({left: x + 'px'}, slideSpeed);
    //document.getElementById(elId).style.left = x + 'px';
  }
}

function pad(n){ return (n<10)?'0'+n:n; }
function setDates(f){
  var st = f.arrivalDate.value;
  var arrDate = st.split('-');
  var d = new Date();
  d.setYear(arrDate[2]);
  d.setMonth(arrDate[1]-1);
  d.setDate(arrDate[0]);
  f.Arrival_day.value = d.getDate();
  f.Arrival_yearmonth.value = d.getFullYear()+''+pad(d.getMonth()+1);
  //alert(d.toDateString()+'+'+f.nights.value);
  d.setDate(d.getDate()+1*f.nights.value);
  //alert(d.toDateString());
  f.Departure_day.value = d.getDate();
  f.Departure_yearmonth.value = d.getFullYear()+''+pad(d.getMonth()+1);
}