/**
 * Global library
 * @author Mauricio Poveda <mauricio@poveda.co.cr>
 */
/**
 * Returns a DOM object
 */
function getObject(name)
 {
 return document.getElementById(name);
 }
/**
 * Returns a instance of DOM element from an event triggered
 * @access public
 * @return element
 * @param string obj Object name
 */
function getTarget(ev)
 {
 var target;
 if(window.event&&window.event.srcElement)target=window.event.srcElement;
 else if(ev&&ev.target)target=ev.target;
 if(!target)return null;
 else return target;
 }
/**
 * Adds events to the page
 * @access public
 * @return mixed
 * @param node el DOM element
 * @param event ev Event
 * @param function fn Call back function
 * @param bool useCapture Capture bubble events
 */
function addEvent(el,ev,fn,useCapture)
 {
 var r;
 if(useCapture==null)useCapture=false;
 if(el.addEventListener)
  {
  el.addEventListener(ev,fn,useCapture);
  r=true;
  }
 else if(el.attachEvent)
  {
  r=el.attachEvent('on'+ev,fn);
  EventCache.add(el,ev,fn);
  }
 else
  {
  elem['on'+evType]=fn;
  r=false;
  }
 return r;
 }
/**
 * Disables the default action of the element
 * @access public
 * @return bool
 * @param element el Element
 */
function disableDefault(el)
 {
 if(el&&el.preventDefault)el.preventDefault();
 if(window.event)window.event.returnValue=false;
 return false;
 }
/**
 * Disables bubble up
 * @access public
 * @return bool
 * @param element el Element
 */
function disablePropagation(el)
 {
 if(el&&el.stopPropagation)el.stopPropagation();
 if(window.event)window.event.cancelBubble=true;
 return false;
 }
/**
 * Sets the class for an object
 * @access public
 * @return void
 * @param element obj Reference to tha object to be manipulated
 * @param string c Name of the new class
 */
function setClass(obj,c)
 {
 if(obj)
  {
  obj.setAttribute('class',c);
  obj.setAttribute('className',c);
  }
 }
/**
 * Sets the transparency of an object
 * @access public
 * @return void
 * @param element obj Reference to tha object to be manipulated
 * @param integer per Percentage of tranparency
 */
function setTransparency(obj,per)
 {
 if(typeof obj=='object')
  {
  if(document.all)obj.style.filter='alpha(Opacity='+per+')';
  else obj.style.MozOpacity=(per/100);
  }
 }
/**
 * Unsets the and free memory for events
 */
var EventCache=function()
 {
 var listEvents=[];
 return{
  listEvents:listEvents,
  add:function(node,sEventName,fHandler,bCapture){listEvents.push(arguments);},
  flush:function()
   {
   var i,item;
   for(i=listEvents.length-1;i>=0;i=i-1)
    {
    item=listEvents[i];
    if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);};
    if(item[1].substring(0,2)!='on'){item[1]='on'+item[1];};
    if(item[0].detachEvent){item[0].detachEvent(item[1],item[2]);};
    item[0][item[1]]=null;
    };
   }
  };
 }();
/**
 * Gets the key code on key action
 * @access public
 * @return void
 */
function getKey(e)
 {
 if(document.all)return e.keyCode;
 else return e.which;
 }
/**
 * Pops up a window with content
 * @access public
 * @return void
 */
function showFull(url,artist,thumb)
 {
 var oWin;
 try
  {
  oWin=window.open('','WINpodcast','status=no,toolbar=no,menubar=no,location=no,resizable=no,width=300,height=443,scrollbars=no');
  if(oWin!=null)
   {
   var code='<html>';
   code+=' <head>';
   code+='  <title>LA506 - Podcast</title>';
   code+='  <style type="text/css">/*<![CDATA[*/@import "../../common/styles/styles.css";/*]]>*/</style>';
   code+=' </head>';
   code+=' <body id="BODYpopUpPod">';
   code+='  <div id="DIVpodcastContainer">';
   code+='  <img src="'+thumb+'" alt="'+artist+'"/>';
   code+='  <p><span class="fucsiaFont">Now Playing:</span> '+artist+' Podcast</p>';
   code+='  <embed src="'+url+'" width="300" height="17"></embed>';
   code+='  <!--<a href="http://www.la506.com/tres/" target="_blank">--><img class="podcastAdd" src="../../common/images/podcast_ad/love-jam.png" alt="Podcast" title="Podcast"><!--</a>-->';
   code+='  </div>';
   code+=' </body>';
   code+='</html>';
   oWin.document.open('text/html','replace');
   oWin.document.write(code);
   oWin.document.close();
   }
  }
 catch(e){alert('Error: no se pudo crear la ventana del Podcast.'/* Error: '+e*/);}
 }
/**
 * Fires up all the events and functions
 * @access public
 * @return void
 */
function init_scripts()
 {
 if(!document.getElementsByTagName||!document.getElementById)return;
 //sets the rel="external" on each anchor element
 var anchors=document.getElementsByTagName('a');
 for(var i=0;i<anchors.length;i++)
  {
  var anchor=anchors[i];
  if(anchor.getAttribute('href')&&anchor.getAttribute('rel')=='external')anchor.target='_blank';
  }
 //Begin
 startMenu();
 }
//=========================================================================\\
addEvent(window,'load',init_scripts);
addEvent(window,'unload',EventCache.flush);