if(document.all){
var IW= 0;
var IH= 0;
var PX= 0;
var PY= 0;
var brand= null;
var pop_menu= null;
var IMGW= 107;
var IMGH= 41;
var LSAFETY= 40;
var TSAFETY= 17;
var mouseOverColor= "cc0000";
var normal_backgroundColor= "cccccc";
var special_backgroundColor= "cc0000";
var pop_menuSafety= 20;
var linkText= "";
var textLength= 0;
var letterSize= 8;
var defaultTextLength= 20;
var ourWidth= 0;
var ourSum=5;
var ourLeft= 5;
var smallSum= 0;
var gandalf= 0;
var ourLays= new Array();
var alldivs= new Array();
alldivs= document.all.tags("DIV");

function BrandInit(){
if (brand!= null) return;
else{ 
  ID_CHECK:  for (i=0; i<alldivs.length; i++){
    if(alldivs(i).id == "Branding"){
      alldivs(i).style.display= "none";
    }
    if ((gandalf==0)&&(alldivs(i).id == "Branding1")){
      gandalf=1;
      brand= alldivs(i);
      continue ID_CHECK;
    }
    if(gandalf==1){
      if(alldivs(i).id== "nh1"){
        pop_menu= alldivs(i);
        continue ID_CHECK;
      }
    ourLays[ourLays.length]= alldivs(i);
    }
  }
}
brand.onclick= PositionMenu;
brand.onmouseover= neat_mouseover;
brand.onmouseout= neat_mouseout;
}

function neat_mouseover(){
window.status= "";
return true;
}

function neat_mouseout(){
window.status= "";
return true;
}

function BrandPosition(){
if(brand!= null){
  IH= document.body.clientHeight;
  IW= document.body.clientWidth;
  PX= document.body.scrollLeft;
  PY= document.body.scrollTop;
  brand.style.top= (IH+PY-(IMGH+TSAFETY));
  brand.style.left=(IW+PX-(IMGW+LSAFETY));
  for (i=0; i<alldivs.length; i++){
    if (alldivs(i).style.zIndex > brand.style.zindex)
      brand.style.zindex= (alldivs(i).style.zIndex + 1);
  }
}
}

function BrandShow(toggle){
if(brand!= null)
  brand.style.display= toggle;
}

function Branding(){
if (navigator.appVersion.indexOf("Mac") == -1){
  oldIW= IW;
  oldIH= IH;
  oldPX= PX;
  oldPY= PY;
  if ((document.body.clientHeight != oldIH)||(document.body.clientWidth != oldIW)||(document.body.scrollLeft != oldPX)||(document.body.scrollTop != oldPY)){
    BrandInit();
    if(window != window.top){
      pop_menuSafety= 0;
      var window_checker= 1;
      var frameToShow= "";
      var frameToShowWidth= 0;
      var frameToShowHeight= 0;
      var frameToShowTest= 0;
      var frameToShowTemp= 0;
      var frameToShowFull= "";
      var allFrames= window.top.document.all.tags('frame');
      if(allFrames.length==0) allFrames= window.top.document.all.tags('FRAME')
      for(i=0;i<allFrames.length; i++){
        var tempLoc= allFrames(i).src;
        if(tempLoc.indexOf("http") == -1){          
          frameToShowTemp= allFrames(i).width * allFrames(i).height;
          if(frameToShowTemp>frameToShowTest){
            frameToShow= allFrames(i);
            frameToShowTest= frameToShowTemp;
          }
        var temp= /\/Avenues\/f\/frame.html/;
        if(window.top.location.href.search(temp)>0){
          frame_search= window.location.href;
          var tailURL= frameToShow.src.substr((frameToShow.src.indexOf("?")+1));
          var params= tailURL.split("&");
          var urlsign= /^url/;
          for(i=0;i<params.length;i++){
            thisP= params[i];
            if(thisP.search(urlsign)==0){
              tailURL= thisP.substr(4);
            }
          }
          frameIndex= tailURL.substring(0,tailURL.lastIndexOf("/"));
          frameIndex= "http://www.fobos.poltava.ua"+frameIndex;
          tailURL= tailURL.substr((tailURL.lastIndexOf("/")+1));
        } else {
          frame_search= window.top.location.href;
          var tailURL= frameToShow.src;
          frameIndex= frame_search.substring(0,frame_search.lastIndexOf("/"));
        }

        frameToShowFull= frameIndex+"/"+tailURL;
        }
      }
    } 
    if((brand != null)&&((frameToShowFull== window.location.href)||((!frameToShowFull)&&(!window_checker)))){
      ShowMenu("none");
      BrandShow("none");
      BrandPosition();
      BrandShow("");
    }
    else{
      if(brand != null){
        BrandShow("none");
      }
    }
  }
}
}

var row_count= 0;
var height_of_menu_layer= 22;

function MenuInit(){
if(textLength != 0)return;
else{
  BrandInit();
  for(i=0;i<ourLays.length;i++){
    linkText= ourLays[i].innerText;
    if((linkText == "Women")||(linkText == "Women>")){
      letterSize= 10;
    }
    if(linkText.length>textLength){
      textLength= linkText.length;
    }
  }
var sum_of_layer_widths= 0;
var menu_layer_spacing= 0;
  for(i=0; i<ourLays.length; i++){
    tempLay= ourLays[i];
    prevLay= ourLays[i-1];
    if((tempLay.id== "nada")||(tempLay.id== "hr")){
      if(tempLay.id=="nada"){
        tempLay.style.backgroundColor= special_backgroundColor;
        tempLay.style.left= 0;
        tempLay.style.top= smallSum;
        smallSum+= tempLay.style.pixelHeight; 
        row_count++;
        tempLay.onmouseover= null;
        tempLay.onmouseout= null;
      } else {
        tempLay.style.backgroundColor= normal_backgroundColor;
        tempLay.style.left= 0;
        tempLay.style.top= smallSum;
        smallSum+= tempLay.style.pixelHeight; 
        row_count++;        
        tempLay.onmouseover= null;
        tempLay.onmouseout= null;
      }
    } else {
      if(((sum_of_layer_widths+(tempLay.innerText.length*letterSize))>(textLength*letterSize))||(prevLay.id == "hr")||(prevLay.id== "nada")){
        tempLay.style.top= prevLay.style.pixelTop + height_of_menu_layer;
        tempLay.style.left= ourLeft;
        row_count++;
        sum_of_layer_widths= (tempLay.innerText.length*letterSize);
      } else {
        tempLay.style.top= prevLay.style.pixelTop;
        tempLay.style.left= sum_of_layer_widths;
        sum_of_layer_widths+= (tempLay.innerText.length*letterSize);
      }
    }
  }
  pop_menu.style.width= pop_menu.style.pixelWidth= (textLength * letterSize);
  pop_menu.style.clip= "rect(0 "+pop_menu.style.pixelWidth+" "+row_count*height_of_menu_layer+" 0)";
  }
}

function ShowMenu(toggle){
    for(i=0; i<ourLays.length; i++){
      tempLay= ourLays[i];
      tempLay.style.display= toggle;
    }
    pop_menu.style.display= toggle;
    if(pop_menu.style.display=="")
      window.document.onmousedown= verify_click;
    else
      window.document.onmousedown= null;
}

function PositionMenu(){
MenuInit();
if(pop_menu != null){
  var clipAr= pop_menu.style.clip.split(" ");
  var ht= /^[0-9]/
  for(i=0;i<clipAr.length;i++){
    if((ht.test(clipAr[i]) == true)&&(i==2)){
      var height= parseInt(clipAr[i]);
    }
  }
  pop_menu.style.top= brand.style.pixelTop - height;
  pop_menu.style.left= brand.style.pixelLeft + (IMGW+LSAFETY) - pop_menu.style.pixelWidth - pop_menuSafety;
  (pop_menu.style.display=="")? ShowMenu("none") : ShowMenu("");
}
return false;
}

function verify_click(){
  if((window.event.clientX > (pop_menu.style.pixelLeft-PX))&&(window.event.clientY > (pop_menu.style.pixelTop-PY)))
    window.event.returnValue= true;
  else
    ShowMenu("none");
}
var dir3= /advert.htm/;
var dir4= /advert.htm/;
var dir5= /advert.htm/;
var dir6= /advert.htm/;
var dir7= /advert.htm/;

if((window.document.location.pathname.search("ad_container")<0)&&((window.document.location.pathname != "/join/PlanetAll/index.html")&&(window.document.location.pathname != "/join/PlanetAll/"))&&(window.document.location.pathname.search(dir3)<0)&&(window.document.location.pathname.search(dir4)<0)&&(window.document.location.pathname.search(dir5)<0)&&(window.document.location.pathname.search(dir6)<0)&&(window.document.location.pathname.search(dir7)<0))
  setInterval("Branding()",100);
}
