var RhiJs = {
/**
  * hides all tags, except one, under a parentnode
  * @pxpAttribToShow: the pxp attribute of the remaining visible tag,
  * @pxpAttribPrefixForRest: pxp attribute prefix for all the brothers, which should be hidden
  * @outerTagId: thze parent node id, where w manipulate the tags (must be passed bec IE cannot make it with parentnode)
  */
 showOnlyOne : function(pxpAttribToShow, pxpAttribPrefixForRest, outerTagId) {
  var pxpAttribElements = $$('#'+outerTagId+ ' [pxp^='+pxpAttribToShow+']');
  var innerTags = $$('#'+outerTagId+' [pxp^='+pxpAttribPrefixForRest+']');  for(var i=0;i<innerTags.length;i++){
      var item=innerTags[i];
      if(pxpAttribElements[0] == item){
          item.style.display = 'block';
      }else{
          item.style.display = 'none';
      }
  } 
},
/**
  * hides all tags, except the ones, has a special prefix in hteir pxp attribute, under a parentnode
  * @pxpAttribPrefixToShow: the pxp attribute of the remaining visible tags,
  * @pxpAttribPrefixForRest: pxp attribute prefix for all the brothers, which should be hidden
  * @outerTagId: thze parent node id, where w manipulate the tags (must be passed bec IE cannot make it with parentnode)
  */
 showElementsForPrefix : function(pxpAttribPrefixToShow, pxpAttribPrefixForRest, outerTagId) {
  var innerTags = $$('#'+outerTagId+' [pxp^='+pxpAttribPrefixForRest+']');
  for(var i=0;i<innerTags.length;i++){
      var item=innerTags[i];
      item.style.display='none';
  }  var innerTags = $$('#'+outerTagId+' [pxp^='+pxpAttribPrefixToShow+']');
  for(var i=0;i<innerTags.length;i++){
      var item=innerTags[i];
      item.style.display='block';
  } 
}, 
goToSelectedPage: function(selectId){
  var gotoUrl = $(selectId).options[$(selectId).options.selectedIndex].value;
  document.location.href = gotoUrl;
 },
 meta_nav_dropdown: function (parent,id){
  var i=1;  if (document.getElementById(id).style.display == 'block'){
   document.getElementById(id).style.display = 'none';
  }  else {
   while(i < 100 ){
    if (document.getElementById('dropdown_list_' + i) != null) {
    document.getElementById('dropdown_list_' + i).style.display = 'none';
    }
    else {
    i = 100;
    }
    i++;
   }   if (typeof document.body.style.maxHeight != "undefined") {
    document.getElementById(id).style.left = RhiJs.getPageCoords_x(parent) + "px";
   }   else {
    document.getElementById(id).style.left = RhiJs.getPageCoords_x(parent) - 486 + "px";
   }   document.getElementById(id).style.top = RhiJs.getPageCoords_y(parent) + 15 + "px";
   document.getElementById(id).style.display = 'block';
  } }, getPageCoords_x: function(elementId) {
     var element;
  if (document.all)
   element = document.all[elementId];
  else if (document.getElementById)
   element = document.getElementById(elementId);
  if (element) {
   var coords = {x: 0, y: 0};
  do {
   if(element.currentStyle){
    if(element.currentStyle.position!='relative'){
     coords.x += element.offsetLeft;
     coords.y += element.offsetTop;
    }
   } else {
    coords.x += element.offsetLeft;
    coords.y += element.offsetTop;
   }          element = element.offsetParent;
       }while (element)
       return coords.x;
     }
     else
       return null;
    }, getPageCoords_y:function(elementId) {
     var element;
     if (document.all)
       element = document.all[elementId];
     else if (document.getElementById)
       element = document.getElementById(elementId);
     if (element) {
       var coords = {x: 0, y: 0};
       do {
  if(element.currentStyle)
  {
   if(element.currentStyle.position!='relative')
   {
    coords.x += element.offsetLeft;
    coords.y += element.offsetTop;
   }
  }
  else
  {
   coords.x += element.offsetLeft;
   coords.y += element.offsetTop;
  }         element = element.offsetParent;
       }
       while (element)
       return coords.y;
     }
     else
       return null;
    },
  contact_display: function(id){
    document.getElementById("compose_" + id).style.display = 'none';
    document.getElementById("send_" + id).style.display = 'block';
    document.getElementById("text_" + id).style.display = 'block';
  },
 
  openRhiMap: function() {  if (document.getElementById('flash').style.display == 'none') {
   document.getElementById('flash').style.display = 'block';
   document.getElementById('flashTeaserContainer').style.display = 'none';
  }
  },
 closeRhiMap: function() {
  if (document.getElementById('flash').style.display == 'block'){
   document.getElementById('flash').style.display = 'none';
   document.getElementById('flashTeaserContainer').style.display = 'block';
  }
  }
}

Event.observe(window, 'load', function() {
 var overlayElements = $$('#content_items a.background-color--black');
 
 for(i=0; i<overlayElements.size(); i++) {
  overlayElements[i].observe('click', function(event) {
   openOverlayPopup(this.href);
   event.stop();
  });
 }
});function openOverlayPopup(url) {
 contentUrl = url+"?view=asIframe";
/* Fix the height of the overlay */
myLightWindow._getPageDimensions();
document.getElementById("lightwindow_overlay").setStyle({ height: myLightWindow.pageDimensions.height + 'px'});
 myLightWindow.activateWindow({
  href: contentUrl,
  title: '',
  height: 560,
  width: 540,
  type: 'external'
 });
}


