var brname=navigator.appName, BrVer='';
if(brname.substring(0,2)=="Mi")
   BrVer='E';
var timer = 0;
lastid = -1;

function dslHandler(targetiD) {
                var targetElement = document.getElementById(targetiD);
                if (targetElement.style.display == "none") {
                  targetElement.style.display = "";
                  document.images[targetiD+"img"].src = "/bitrix/templates/well/images/minus_i.gif";
                } 
                else {
                  targetElement.style.display = "none";
                 document.images[targetiD+"img"].src = "/bitrix/templates/well/images/plus_i.gif"; 
                }
}

function ShowWin(url,x,y,name,isscrollbars) {
  cx=screen.width/2-(x/2);
  cy=screen.height/2-(y/2);
  isscrollbars=(isscrollbars=="no")?"no":"yes";
  var wnd  = window.open(url,name,"toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);
  wnd.focus();   
}

function popupWin(url,x,y,name,isscrollbars) {
  cx=0;
  cy=0;
  isscrollbars=(isscrollbars=="no")?"no":"yes";
  var wnd  = window.open(url,name,"toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars="+isscrollbars+",top="+cy+",left="+cx);
  wnd.focus();   
}

function WeekEndWnd() {
  var dt = new Date();
  var day = dt.getDay();
  var hour = dt.getHours();
  var minut = dt.getMinutes()
  var open = false;
  if (day > 0 && day < 6 && hour > 18 && hour < 23) open = true;
  if (day == 6 && hour > 16 && hour < 23) open = true;
  if (day == 0 && hour > 9 && hour < 23) open = true;
  if (open == true)	
  	window.open("/about/weekend.php", "", "toolbar=no,status=no,directories=no,menubar=no,resizable=no,width=380,height=113,scrollbars=no,top=100,left=450");
}

function Rota_banner() {
       var sel=Math.round(Math.random()*3);
       if (sel==0) {
        src="/gazeta/bn09_2009_1.gif";
        gazetlnk="<a href='/gazeta/'>";
       } else if (sel==1) {
        src="/gazeta/bn09_2009_2.gif";
        gazetlnk="<a href='/gazeta/'>";
       } else if (sel==2) {
        src="/gazeta/bn09_2009_3.gif";
        gazetlnk="<a href='/gazeta/'>";
       } else {
        src="/gazeta/bn09_2009_4.gif";
        gazetlnk="<a href='/gazeta/'>";
       }
       return gazetlnk + '<img src="' + src + '" name="Туры из газеты" style = "border: 1px solid rgb(148, 148, 148);" width="349" vspace="10" border="1"' + ' alt="Информация о предложениях, опубликованных в газете ВЕЛЛ" /></a>';
}
  
function Rota_ban2() {
       var sel=Math.round(Math.random()*3);
       if (sel==0) {
        src="/gazeta/bn09_2009_1.png";
        gazetlnk="<a href='/gazeta/'>";
       } else if (sel==1) {
        src="/gazeta/bn09_2009_2.png";
        gazetlnk="<a href='/gazeta/'>";
       } else if (sel==2) {
        src="/gazeta/bn09_2009_3.png";
        gazetlnk="<a href='/gazeta/'>";
       } else {
        src="/gazeta/bn09_2009_4.png";
        gazetlnk="<a href='/gazeta/'>";
       }
       return gazetlnk + '<img src="' + src + '" name="Туры из газеты" style = "border: 1px solid rgb(148, 148, 148);" width="220" vspace="10" border="1"' + ' alt="Информация о предложениях, опубликованных в газете ВЕЛЛ" /></a>';
}
  
function AllHoursWnd() {
  var dt = new Date();
  var hrs = dt.getHours();
  var day = dt.getDay();
  if (hrs >= 17 && hrs < 22 && day > 0 && day < 5) {
    window.open("/about/24hours.php", "", "toolbar=no,status=no,directories=no,menubar=no,resizable=no,width=620,height=100,scrollbars=no,top=0,left=0");
  }
}

function showel(url){
  var top=0, left=0;
  window.open(url, "_blank", "width=750,height=700,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,left="+left+",top="+top);
}

function show_photos(url){
  var top=0, left=0;
  window.open(url, "_blank", "width=900,height=700,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,left="+left+",top="+top);
}


function move2id(id) {
  window.scrollTo(0,100);
}


         function ImgShw(ID, width, height, alt)
         {
            var scroll = "no";
            var top=0, left=0;
            if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
            if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
            if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
            width = Math.min(width, screen.width-10);
            height = Math.min(height, screen.height-28);
            var wnd = window.open("","","scrollbars="+scroll+",resizable=no,width="+width+",height="+height+",left="+left+",top="+top);
            wnd.document.write("<html><head>\n");
            wnd.document.write("<"+"script language='JavaScript'>\n");
            wnd.document.write("<!--\n");
            wnd.document.write("function KeyPress()\n");
            wnd.document.write("{\n");
            wnd.document.write("   if(window.event.keyCode == 27)\n");
            wnd.document.write("      window.close();\n");
            wnd.document.write("}\n");
            wnd.document.write("//-->\n");
            wnd.document.write("</"+"script>\n");
            wnd.document.write("<title>"+(alt == ""? "картинка":alt)+"</title></head>\n");
            wnd.document.write("<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\" onClick=\"window.close()\">\n");
            wnd.document.write("<a title=\"закрыть\" href=\"javascript:void(0)\">\n");
            wnd.document.write("<img src=\""+ID+"\" border=\"0\" alt=\"закрыть\">");
            wnd.document.write("</a>");
            wnd.document.write("</body>");
            wnd.document.write("</html>");
            wnd.document.close();
            
            //return wnd;
         }

function show(id)
{
   if(!((document.all)?document.all['menu'+id]:document.getElementById('menu'+id)))
      return;
   clearTimeout(timer);
   if((id != lastid) && (lastid!=-1))
      ((document.all)?document.all['menu'+lastid]:document.getElementById('menu'+lastid)).style.visibility = 'hidden';
   hideElement("SELECT", document.getElementById('menu'+lastid));
   lastid = id;
   ((document.all)?document.all['menu'+lastid]:document.getElementById('menu'+lastid)).style.visibility = 'visible';
}

function hidden(id)
{
   if(!((document.all)?document.all['menu'+id]:document.getElementById('menu'+id)))
      return;
   showElement("SELECT");
   timer = setTimeout("if('"+id+"' == '"+lastid+"'){((document.all)?document.all['menu"+lastid+"']:document.getElementById('menu"+lastid+"')).style.visibility = 'hidden';}", 500)
}


function GetPos(el)
{
   if (!el || !el.offsetParent)return false;
   var res=Array()
   res["left"] = el.offsetLeft;
   res["top"] = el.offsetTop;
   var objParent = el.offsetParent;
   while (objParent.tagName.toUpperCase()!="BODY")
   {
      res["left"] += objParent.offsetLeft;
      res["top"] += objParent.offsetTop;
      objParent = objParent.offsetParent;
   }
   res["right"]=res["left"]+el.offsetWidth;
   res["bottom"]=res["top"]+el.offsetHeight;
   return res;
}

function hideElement(elName, Menu)
{
   if(BrVer!='E') return;
   for (i = 0; i < document.all.tags(elName).length; i++)
   {
      Obj = document.all.tags(elName)[i];
      if(!(pMenu=GetPos(Menu)))continue;
      if(!(pObj=GetPos(Obj)))continue;

      if(pObj["left"]<pMenu["right"] && pMenu["left"]<pObj["right"] && pObj["top"]<pMenu["bottom"] && pMenu["top"]<pObj["bottom"])
         Obj.style.visibility = "hidden";
   }
}

function showElement(elName)
{
   if(BrVer!='E') return;
   for (i = 0; i < document.all.tags(elName).length; i++)
   {
      obj = document.all.tags(elName)[i];
      if (!obj || !obj.offsetParent)continue;
      if(obj.style.visibility=="hidden")
         obj.style.visibility = "visible";
   }
}
