// ########## GET ELEMENTS BY CLASS NAME ##########

document.getElementsByClassName = function(n) {
  var list = document.getElementsByTagName("*");
  var r = new Array();
  var i = 0;
  var j = 0;
  var theClass = " "+n+" ";
  for( i=0 ; i < list.length ; i++ ) {
    if( (" "+list[i].className+" ").indexOf(theClass) != -1 )
      r[j++] = list[i];
  }
  return r;
}


// ########## DISABLE CLICK ##########

function disableClick() {
  links = document.getElementsByClassName('default_cur');
  for(i = 0; i < links.length; i++){
    if(links[i].firstChild.nodeType == 3)
      node = links[i].firstChild.nextSibling;
    else
      node = links[i].firstChild;
    node.onclick = function() {
      return false;
    }
  }
}
window.onload = function() {
  disableClick();
}

// ########## HIGHSLIDE addSlideshow ##########

hs.addSlideshow({
  slideshowGroup: 'group1',
  interval: 5000,
  repeat: false,
  useControls: true,
  fixedControls: true,
  overlayOptions: {
    opacity: .6,
    position: 'top center',
    hideOnMouseOut: true
  }
});

// ########## HIGHSLIDE onSetClickEvent ##########

hs.onSetClickEvent = function ( sender, e ) {
  switch(e.type){
    case undefined :
      // Case thumbnail
      var slideshow = e.element.className.match(/slideshow/);
      var inlineContent = e.element.className.match(/inlineContent/);
      if (slideshow) {
        // Case slideshow
        e.element.onclick = function () {
          return hs.expand(this, { outlineType: 'rounded-white', slideshowGroup: 'group1', align: 'center', dimmingOpacity: '0.75', transitions: ['expand', 'crossfade'] });
        }
      }
      else if (inlineContent) {
        // Case html content without iframe
        e.element.onclick = function () {
          return hs.htmlExpand(this, { outlineType: 'rounded-white', contentId: 'highslide_html', height: '600', width: '850' });
        }
        hs.onActivate = function() {
           var moveTo = document.getElementById("container");
           if (moveTo) moveTo.appendChild(hs.container);
        }
      }
      else{
        // Case greybox like
        e.element.onclick = function () {
          return hs.expand(this, { outlineType: 'rounded-white' });
        }
      }
    break;
    case 'iframe' :
      // Case iframe
      var hs_big = e.element.className.match(/hs_big/);
      var hs_media = e.element.className.match(/hs_media/);
      var hs_video = e.element.className.match(/hs_video/);
      var hs_iframe = e.element.className.match(/hs_iframe/);
      if (hs_big) {
        e.element.onclick = function () {
          return hs.htmlExpand(this, { objectType: 'iframe', outlineType: 'glossy-dark', height: '480' });
        }
      }
      else if (hs_media) {
        e.element.onclick = function () {
          return hs.htmlExpand(this, { objectType: 'iframe', outlineType: 'glossy-dark', width: '800', height: '600' });
        }
      }
      else if (hs_video) {
        e.element.onclick = function () {
          return hs.htmlExpand(this, { objectType: 'iframe', width: '922', height: '333', targetX: 'content_main', targetY: 'content_main 10px', wrapperClassName: 'highslide-video', preserveContent:false});
        }
      }
      else if (hs_iframe) {
        e.element.onclick = function () {
          return hs.htmlExpand(this, { objectType: 'iframe', outlineType: 'glossy-dark', width: '560', height: '440', align:'center', dimmingOpacity: '0.75' });
        }
      }
      else{
        e.element.onclick = function () {
          return hs.htmlExpand(this, { objectType: 'iframe', outlineType: 'glossy-dark', height: '75', anchor: 'top left' });
        }
      }
    break;
  }

  // return false to prevent the onclick being set once again
  return false;
}



