var active_tab=-1;

function add_coprod(e) {
    if ( e.value == '' ) return;
    showWait(1);
    xajax_add_co_producer(e.value, xajax.getFormValues('frm_show_edit'));
}

function del_coprod(i) {
    document.getElementById('tbl_co').deleteRow(i);
}

function checkdate(myfield) {
    if ( myfield.value != '' && ! isDate(myfield.value) ) {
        alert('Λάθος ημερομηνία: ' + myfield.value + ' !');
        myfield.value='';
        return false;
    }
    return true;
}

function new_article(e) {
    var cid=document.getElementById('cid');
    cid.value=e;
    showWait(1);
    xajax_edit_article(xajax.getFormValues('frm_cid'));
}

function dl_demo(e) {
    var cid=document.getElementById('cid');
    cid.value=e;
    showWait(1);
    xajax_dl_demo(xajax.getFormValues('frm_cid'));
}

function show_article(e) {
    var cid=document.getElementById('aid');
    cid.value=e;
    showWait(1);
    xajax_show_article(xajax.getFormValues('frm_aid'));
}

function edit_article(a,c) {
    var aid=document.getElementById('aid');
    var cid=document.getElementById('cid');
    aid.value=a;
    cid.value=c;
    showWait(1);
    xajax_edit_article(xajax.getFormValues('frm_aid'));
}

function del_article(a,t) {
    if ( ! confirm('Να διαγραφεί το άρθρο;' + t) ) return;
    var aid=document.getElementById('aid');
    aid.value=a;
    showWait(1);
    xajax_del_article(xajax.getFormValues('frm_aid'));
}

function del_photo(n,v,d) {
    var f=document.getElementById("frm_edit_article");
    var newElement = document.createElement('input');
    newElement.setAttribute("type", "hidden");
    newElement.setAttribute("name", n);
    newElement.setAttribute("id", n);
    f.appendChild(newElement);
    newElement.value = v;
    document.getElementById(d).innerHTML='';

}

/*
 * tabber stuff
 */



var tabberOptions = {

  /* Optional: instead of letting tabber run during the onload event,
     we'll start it up manually. This can be useful because the onload
     even runs after all the images have finished loading, and we can
     run tabber at the bottom of our page to start it up faster. See the
     bottom of this page for more info. Note: this variable must be set
     BEFORE you include tabber.js.
  */
  'manualStartup':true,

  /* Optional: code to run after each tabber object has initialized */

  'onLoad': function(argsObj) {
    /* Display an alert only after tab2 */
    if (argsObj.tabber.id == 'tab2') {
//      alert('Finished loading tab2!');
    }
  },

  /* Optional: code to run when the user clicks a tab. If this
     function returns boolean false then the tab will not be changed
     (the click is canceled). If you do not return a value or return
     something that is not boolean false, */

  'onClick': function(argsObj) {

    var t = argsObj.tabber; /* Tabber object */
    var id = t.id; /* ID of the main tabber DIV */
    var i = argsObj.index; /* Which tab was clicked (0 is the first tab) */
    var e = argsObj.event; /* Event object */
    active_tab = i;
    if (id == 'tab_pod' || id=='tab_mag') {
    	showWait(1);
        switch (i) {
            case 0: //shows_issues
                xajax_shows_issues();
                break;
            case 1: //next show_issue
                xajax_next_show_issue();
                break;
            case 2: // articles or writer
                if ( media_active && media_active == 'mag' ) xajax_articles();
                if ( media_active && media_active == 'pod' ) xajax_writer();
                break;
            case 3: // writer or nothing
                xajax_writer();
                break;
            case 4: // columns
                xajax_columns();
                break;
            case 5: // writers_edit
                xajax_writers_edit();
                break;
            default:
        	showWait(0);
                return '';
                break;
        }
    }

  },

  /* Optional: set an ID for each tab navigation link */
  'addLinkId': true

};


