//
// bullshit workaround 
//
function write_code (code) {
    document.write(code);
}

//
// append a function into onload
//
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


function change_display_by_id (id,style) {
    var element = document.getElementById(id);
    if (element) {
        element.style.display = style;
    }
}


function switchtoplayer(object_code) {

    var playme = document.getElementById('playme');
    playme.innerHTML = object_code;

}


function ToggleCollapsiblePanel(panel_id, header_id, hide_id, row_id, image_path) { 

    var panel_element = document.getElementById(panel_id);
    var hide_element = document.getElementById(hide_id);
    var header_element = document.getElementById(header_id);
    var row_element = document.getElementById(row_id);
    if (!image_path) {
        image_path = '/img';
    }

    if( panel_element.style.display == '' ) {
        panel_element.style.display = 'none';
        //header_element.style.background = '#f8f9fb url('+image_path+'/panel_arrow_right.gif) 2px 4px no-repeat';
        header_element.style.backgroundImage = 'url('+image_path+'/panel_arrow_right.gif)';
        hide_element.style.display = 'none';
        //row_element.style.background = '#f8f9fb';
    }
    else if( panel_element.style.display == 'none' ) {
        panel_element.style.display = '';       
        //header_element.style.background = '#f8f9fb url('+image_path+'/panel_arrow_down.gif) 2px 4px no-repeat';
        header_element.style.backgroundImage = 'url('+image_path+'/panel_arrow_down.gif)';
        hide_element.style.display = '';
        //row_element.style.background = '#fefefe';
    }
        
}

// sharing articles
function CheckShareArticleFormData() {

    if( document.sharearticleform.name.value &&
        document.sharearticleform.from.value &&
        document.sharearticleform.to.value ) {
        return true;
    }
    else {
    var message = 'Please provide the following:';
        if( !document.sharearticleform.name.value ) {message += "\nYour Name";}
        if( !document.sharearticleform.from.value ) {message += "\nYour Email";}
        if( !document.sharearticleform.to.value ) {message += "\nSend To";}
        alert(message);
    }

    return false;
}


