// MusicaEnElRioDelOro.com General Script
// Created by Alberto Martinez Perez (http://www.ampsoft.net/web-works/)

var
// topBarHeight=25, menuTop=topBarHeight;
 topBarHeight=30, menuTop=topBarHeight, menuOffset=10;


// ***** Menu *****
function moveMenu() {
 var offset, offsetStyle=new String();
 if (document.getElementById) {
   var element=document.getElementById("menu");
   if (element) {
     if (window.pageYOffset) offset=window.pageYOffset; // Gecko
     else if (document.body.scrollTop) offset=document.body.scrollTop; // IE default mode
     else if (document.documentElement && document.documentElement.scrollTop)
       offset=document.documentElement.scrollTop; // IE Standards mode (IE 6)
     if (!offset || offset<=topBarHeight) offset=topBarHeight;
     offsetStyle=String(offset)+"px";
     if (element.style.top!=offsetStyle) element.style.top=offsetStyle;
   }
 }
}

function calculateMenuTop() {
 if (document.getElementById) {
   var element=document.getElementById("menu");
   if (element) {
     menuTop=topBarHeight; // for forcing the new value when the offset property used have the value 0 (JS doesn't distinguish 0 from false)
     if (window.pageYOffset) menuTop=window.pageYOffset; // Gecko
     else if (document.body.scrollTop) menuTop=document.body.scrollTop; // IE default mode
     else if (document.documentElement && document.documentElement.scrollTop)
       menuTop=document.documentElement.scrollTop; // IE Standards mode (IE 6)
     if (menuTop<=topBarHeight) menuTop=topBarHeight;
   }
 }
}


function setMenuTop() {
 var offsetStyle=new String();
 if (document.getElementById) {
   var element=document.getElementById("menu");
   if (element) {
     if (menuTop+menuOffset!=element.offsetTop) {
       var Distance=Math.abs(element.offsetTop-menuTop-menuOffset), Step=0;
       if (Distance>0 && Distance<=5) Step=1;
       else if (Distance>5 && Distance<=15) Step=3;
       else if (Distance>15 && Distance<=50) Step=10;
       else if (Distance>50 && Distance<=150) Step=20;
       else if (Distance>150 && Distance<=350) Step=50;
       else if (Distance>350) Step=Distance-350;
       if (element.offsetTop-menuTop-menuOffset>0) offsetStyle=String(element.offsetTop-Step)+"px";
       else offsetStyle=String(element.offsetTop+Step)+"px";
       if (element.style.top!=offsetStyle) element.style.top=offsetStyle;
     }
   }
 }
}


if (screen.height>=576) {
  window.setInterval("calculateMenuTop()",200);
  window.setInterval("setMenuTop()",50);
}


var currentItem=null;

function showMenuTip(Id) {
 if (document.getElementById) {
   currentItem=document.getElementById(Id);
   if (currentItem) currentItem.style.display="block";
 }
}

function hideMenuTip() {
 if (currentItem) {
   currentItem.style.display="none";
   currentItem=null;
 }
}

function assignMenuEvents() {
 if (window.addEventListener) // Gecko
   for(i=0;i<document.links.length;i++) {
     document.links[i].addEventListener("mouseout",hideMenuTip,false);
   }
 if (window.attachEvent) // IE
   for(i=0;i<document.links.length;i++) {
     document.links[i].attachEvent("onmouseout",hideMenuTip);
   }
}



// ***** Display adjustments *****
var isIE5=navigator.userAgent.toUpperCase().indexOf("MSIE 5")!=-1;

var targetElementID="container", targetElementStyleOffset=0;

function adjustHeight() {
  if (document.getElementById) {
    var targetElement=document.getElementById(targetElementID),
        documentHeight, totalOffset;

    if (targetElement && document.documentElement.offsetHeight
        && targetElement.offsetHeight && targetElement.offsetTop) {
      documentHeight=document.documentElement.offsetHeight;
      if (targetElement.offsetHeight<documentHeight-targetElement.offsetTop) {
        if (isIE5)
          totalOffset=targetElement.offsetTop;
          else totalOffset=targetElement.offsetTop+targetElementStyleOffset;
        targetElement.style.height=String(documentHeight-totalOffset)+'px';
      }
    }
  }
}

window.onresize=adjustHeight;
window.onload=adjustHeight;




// ***** Misc *****
var WINDOW_TOP=25, WINDOW_LEFT=25, SYSTRAY_HEIGHT=56, WINDOW_TITLEBAR=24;

var lastPopup=null;

function openPopup(page,targetWindow,width,height,scrollBars,resizable){
 var options=new String(), scroll=new String("no"), resize=new String("no");

 if (scrollBars) scroll="yes";
 if (resizable) resize="yes";
 options="width="+width+",height="+height+
  ",screenY="+WINDOW_TOP+",top="+WINDOW_TOP+",screenX="+WINDOW_LEFT+",left="+WINDOW_LEFT+
  ",status=no,location=no,toolbar=no,menubar=no,hotkeys=no"+
  ",resizable="+resize+",scrollbars="+scroll;
 lastPopup=window.open(page,targetWindow,options,true);
 lastPopup.window.focus();
 return lastPopup;
}


function showImage(image,title,width,height) {
  totalWidth=width+75;
  if (totalWidth>screen.width-WINDOW_LEFT-8)
    totalWidth=screen.width-WINDOW_LEFT-8;
  totalHeight=height+125;
  if (totalHeight>screen.height-WINDOW_TOP-SYSTRAY_HEIGHT-WINDOW_TITLEBAR)
    totalHeight=screen.height-WINDOW_TOP-SYSTRAY_HEIGHT-WINDOW_TITLEBAR;
 openPopup("Imagen.php?image="+escape(image)+"&title="+escape(title),"images",totalWidth,totalHeight,true,true);
 return false;
}



function maskedEmail(domain,text,name,suffix) {
  var address=name+'@'+domain+'.'+suffix;
  if (text=="") text=address;
  document.write('<a hr'+'ef="ma'+'i'+'lto:'+address+'">'+text+'</a>');
}

function maskedEmailImage(domain,image,name,suffix,width,height,alt,className) {
  var address=name+'@'+domain+'.'+suffix;
  document.write('<a hr'+'ef="ma'+'i'+'lto:'+address+'"><img src="'+image+
                 '" width="'+width+'" height="'+height+'" alt="'+alt+'"'+' title="'+alt+'"');
  if (className) document.write(' class="'+className+'"');
  document.write('></a>');
}

function isOnlyDigits(str) {
  for (i=0;i<str.length;i++) if (str.charAt(i)<"0" || str.charAt(i)>"9") return false;
  return true;
}

// MusicaEnElRioDelOro.com General Script
// Created by Alberto Martinez Perez (http://www.ampsoft.net/web-works/)
