function loaddynamic()
{
  /* Nav */
  if (document.all&&document.getElementById)
  {

    var navs = new Array("share-menu", "artists-nav", "news-nav", "blogs-nav", "reviews-nav", "photos-nav", "videos-nav", "politics-nav", "listen-nav");

    for(i=0;i<navs.length;i++)
    {
      var node = document.getElementById(navs[i]);
      
      if(node)
      {
        node.onmouseover=function() 
        {
          if(this.className != "current selected")
            this.className="selected";
        }
        node.onmouseout=function()
        {
          if(this.className == "selected")
            this.className="";
        }
      }


    }
  }


  /* Tabs */
  var nodes = document.getElementsByTagName("ul");
  for(i=0;i<nodes.length;i++)
  { 
    if(nodes[i].className == "tabs")
    {
      var tabs = nodes[i].getElementsByTagName("a");

      for(j=0;j<tabs.length;j++)
      {
        // Move href link (for javascript-off state) int select-tab attribute
        var href = tabs[j].getAttribute("href");
        href = href.substring(href.indexOf('#'), href.length);
        tabs[j].setAttribute("select-tab", href.replace("#",""));
        //tabs[j].removeAttribute("href");
        tabs[j].setAttribute("href", "javascript:void(0);");

        // Tab mousedown handler
        tabs[j].onmousedown=function()
        {
          // Deselect other tabs
          others = this.parentNode.parentNode.getElementsByTagName("li");
          for(k=0;k<others.length;k++)
          {
            others[k].className="";
          }         

          // Set clicked tab as current

          this.parentNode.className="current";

          // Set associated tab page as current
          others = this.parentNode.parentNode.parentNode.getElementsByTagName("div");

          for(k=0;k<others.length;k++)
          {

            if(others[k].className.indexOf("page-module ") != -1 )
            { 
              others[k].className = others[k].className.replace("current ","");
            }

          } 

          page = document.getElementById(this.getAttribute("select-tab"));

          page.className = "current " + page.className

        }


      }
    }
  }

  var nodes = document.getElementsByTagName("div");
  for(i=0;i<nodes.length;i++)
  { 
    /* Polls */
    if(nodes[i].className.match("poll-module"))
    { 

      var forms = nodes[i].getElementsByTagName("form");
      for(j=0;j<forms.length;j++)
      {     
        var inputs = forms[j].getElementsByTagName("input");

        for(k=0;k<inputs.length;k++)
        {
          // Replace buttons with links
          if(inputs[k].type == "submit")
          {
            inputlink = document.createElement("a");
            inputlink.className = "button";

            linktext = document.createTextNode(inputs[k].value);
            inputlink.appendChild(linktext);

            inputlink.setAttribute("href","#");

            inputs[k].parentNode.appendChild(inputlink);

            inputs[k].parentNode.removeChild(inputs[k]);

            inputlink.onclick=function()
            {

              var s = this.parentNode.action;

              var inputs = this.parentNode.getElementsByTagName("input");

              for(k=0;k<inputs.length;k++)
              {
                s += "&" + inputs[k].name + "=" + inputs[k].value;
              }

              var iframe = this.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("iframe")[0];

              iframe.src=s;
              iframe.className="poll-results-frame";

              return false;

            }
          }

        }         
      }
    }
    
    else if(nodes[i].className.match("event-list"))
    { 
       /* Events List */
      
      setTimeout('eventListSlideshow("' + nodes[i].id + '")', 6000);


    }

  }
  


  /* Slideshow */
  var anchors = document.getElementsByTagName("a");
  for(i=0;i<anchors.length;i++)
  { 
    if(anchors[i].className.match("slideshowlink"))
    { 
      
      
        anchors[i].onclick=function()
        {   
          
          popupurl = this.href;
          
          window.open(popupurl, 'popupsupersize', 'toolbar=0,scrollbars,location=0,menubar=0,width=828,height=600');
          
          return false;
          
        }
        
    
      }
      
    
      

    }
    

}



//DOM-ready watcher
function domReady()
{
  //start or increment the counter
  this.n = typeof this.n == 'undefined' ? 0 : this.n + 1;
  
  //if DOM methods are supported, and the body element exists
  //(using a double-check including document.body, for the benefit of older moz builds [eg ns7.1] 
  //in which getElementsByTagName('body')[0] is undefined, unless this script is in the body section)
  //>>> and any elements the script is going to manipulate exist
  if
  (
    typeof document.getElementsByTagName != 'undefined' 
    && (document.getElementsByTagName('body')[0] != null || document.body != null)
      && document.getElementById('news-nav') != null 
  )
  {
  //>>>-- DOM SCRIPTING GOES HERE --<<<
  
  
    loaddynamic();


  //>>>-----------------------------<<<
  }

  //otherwise if we haven't reached 60 (so timeout after 15 seconds)
  //in practise, I've never seen this take longer than 7 iterations [in kde 3.2.2 
  //in second place was IE6, which takes 2 or 3 iterations roughly 5% of the time]
  else if(this.n < 60)
  {
    //restart the watcher
    //using the syntax ('domReady()', n) rather than (domReady, n)
    //because the latter doesn't work in Safari 1.0
    setTimeout('domReady()', 250);
  }
};
//start the watcher
domReady();

function getQSParam(name) {  
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
  var regexS = "[\\?&]"+name+"=([^&#]*)";  
  var regex = new RegExp( regexS );  
  var results = regex.exec( window.location.href );  

  if(results == null)    
    return null;  
  else    
    return results[1];
}


function validate_form(thisform)
{
with (thisform)
{


if (validate_search(query,"Please enter an artist name, album title, or other search term.")==false)
  {query.focus();return false}
}



}



function validate_search(field,alerttxt)
{



with (field)
{
if (value==null||value=="")
{
  alert(alerttxt);
  return false
}

else if (value.match(/^\s+$/)) {
  alert(alerttxt);
  return false
}

else if (value.length > 200) {
  allerttxt = "The search item length is more than limit - 200 characters "
  alert(allerttxt);
  return false
}


else {
   return true
}
  
}
}


function openRhapPlayer(url,id,type,title,page,pageRegion,guid)
{
  SIMPLE__tryFlashPlayer('play', id, type);
}




function popupVideo(video, title, description)
{
     popup =  window.open("http://" + window.location.hostname + "/flashplayer?feature=" + video + "&title=" + escape(title) + "&desc=" + escape(description) ,"flashplayer","width=720,height=410,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
  
     popup.focus();
     
     return false;
}

function popupVideoPlayer(video, preroll)
{
      var url = "http://" + window.location.hostname + "/videos/player/" + video;
      
      if (preroll == false)
        url = url + "?preroll=false";
      
     popup =  window.open(url,"flashplayer","width=720,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
      
     popup.focus();
     
     return false;
}

function popupPoll(poll)
{
     popup =  window.open("http://" + window.location.hostname + "/community/polls/" + poll,"pollpopup","width=745,height=470,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1");
  
     popup.focus();
     
     return false;
}

function toggleElement(id)
{
  var node = document.getElementById(id);

  if (node.style.display == 'none')
    node.style.display = 'block';
  else
    node.style.display = 'none';
  
  return false;
}

function swapElements(id1, id2)
{
  var node1 = document.getElementById(id1);
  var node2 = document.getElementById(id2);
  
  node2.style.visibility = 'visible';
  node1.style.visibility = 'hidden';
  
  return false;
}

function eventListSlideshow(id)
{
  var currentNode = 0;
  var node = document.getElementById(id);

  var nodes = node.getElementsByTagName("li");
  for(i=0;i<nodes.length;i++)
  { 
    if(nodes[i].style.visibility == 'visible')
      currentNode = i;
  }
  
  nextNode = currentNode + 1;
  if (nextNode >= nodes.length)
    nextNode = 0;
    
  nodes[nextNode].style.visibility = 'visible';
  nodes[currentNode].style.visibility = 'hidden';
  
  setTimeout('eventListSlideshow("' + id + '")', 6000);  
}



