ie = document.all && navigator.userAgent.indexOf("Opera")==-1;

function showDiv(divName) {
  openhash = divName.substr(10, (divName.length -1));
  divs = document.getElementsByTagName('div');
  for(i=0;i<divs.length;i++) {
    if (divs[i].getAttribute('id')) {
      if (divs[i].getAttribute('id').length > 10) {
        currhash = divs[i].getAttribute('id').substr(10, (divs[i].getAttribute('id').length - 1));
        if (divs[i].getAttribute('id').substr(0, 10) == 'list_open_') {
          divs[i].style.display = 'none';
          divs[i].style.visibility = 'hidden';
          if (currhash != openhash) {
            document.getElementById('list_closed_' + currhash).style.display = 'block';
            document.getElementById('list_closed_' + currhash).style.visibility = 'visible';
          } else {
            document.getElementById('list_closed_' + currhash).style.display = 'none';
            document.getElementById('list_closed_' + currhash).style.visibility = 'hidden';
            document.getElementById('list_open_' + currhash).style.display = 'block';
            document.getElementById('list_open_' + currhash).style.visibility = 'visible';
          }
        }
      }
    }
  }
}

function showDivAlbums() {
  document.getElementById('grpLatestSingles').style.display = 'none';
  document.getElementById('grpLatestAlbums').style.display  = 'block';
  document.getElementById('grpLatestVinyls').style.display  = 'none';
}

function showDivVinyls() {
  document.getElementById('grpLatestSingles').style.display = 'none';
  document.getElementById('grpLatestAlbums').style.display  = 'none';
  document.getElementById('grpLatestVinyls').style.display  = 'block';
}

function showDivSingles() {
  document.getElementById('grpLatestSingles').style.display = 'block';
  document.getElementById('grpLatestAlbums').style.display  = 'none';
  document.getElementById('grpLatestVinyls').style.display  = 'none';
}

function addEvent(obj, type, fn) {
  if (obj.addEventListener) {
    obj.addEventListener( type, fn, false );
  } else if (obj.attachEvent) {
    obj['e' + type + fn] = fn;
    obj[type + fn] = function() { obj['e' + type + fn]( window.event ); }
    obj.attachEvent('on' + type, obj[type + fn] );
  }
}

function loadContent(uri) {
  ajax_loadContent('siteContent', '/v2/' + uri);
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin) if(!popUpWin.closed) popUpWin.close();
  popUpWin = window.open(URLStr, 'popUpWin', 'scrollbars=0,width='+width+',height='+height+',left='+left+',top='+top);
}

var popUpWin4=0;
function popUpWindow4(URLStr, left, top, width, height)
{
  if(popUpWin4) if(!popUpWin4.closed) popUpWin4.close();
  popUpWin4 = window.open(URLStr, 'popUpWin4', 'scrollbars=1,width='+width+',height='+height+',left='+left+',top='+top);
}

function doSearch() {
  ajax_postContent('siteContent', 'dxSearch'); document.getElementById('grpSearchField').value = 'Search now!';
}

function searchFocus() {
  var fld = document.getElementById('grpSearchField');
  if (fld.value == 'Search now!') {
    fld.value = '';
  }
}

function searchLeave() {
  var fld = document.getElementById('grpSearchField');
  if (trim(fld.value) == '') {
    fld.value = 'Search now!';
  }
}

function trim(sString)
{
  while (sString.substring(0,1) == ' ') {
    sString = sString.substring(1, sString.length);
  }
  while (sString.substring(sString.length-1, sString.length) == ' ') {
    sString = sString.substring(0,sString.length-1);
  }
  return sString;
}