



function addIt(num, msg_id, db_id) {
var stabSel = eval("document.frm" + num + ".elements['articles" + num + "[]']");
var pickSel = eval("document.frm" + num + ".elements['picked" + num + "[]']");
var chosen = stabSel.selectedIndex;
var addctrl = 'add_tbl' + num;

if (chosen != -1) {
var size = pickSel.options.length;
var name = stabSel.options[chosen].text;
var recid = stabSel.options[chosen].value;

var  statDiv = document.getElementById('status');
advAJAX.get({
    url: "/AJAXQueryHandler.php",
parameters : {
  "mode"   :   2,
  "zone"   :   num,
  "msg_id" :   msg_id,
  "db_id"  :   db_id,
  "rec_id" :   recid
},
    onInitialization : function() {
    statDiv.innerHTML = '<img src="/images/indicator_rumbleu.gif" alt="Loading..." width="20" height="21" border="0" style="margin: 3px;" /><br />';
    
    },
    onSuccess : function(obj) {

returnArtId = obj.responseText;
pickSel.options[size] = new Option(name, returnArtId);
    },
    onError : function(obj) {
    statDiv.innerHTML = '';
    },
    retry: 5,
retryDelay: 1000
}
);
document.getElementById('zoneAdd' + num).style.display = 'none';
} else {
alert("Select an item to add");
}
}


function addSurvey(num, msg_id, db_id){
var stabSel = eval("document.sfrm" + num + ".elements['surveys" + num + "[]']");
var pickSel = eval("document.sfrm" + num + ".elements['spicked" + num + "[]']");
var chosen = stabSel.selectedIndex;
var addctrl = 'add_tbl' + num;

if (chosen != -1) {
var size = pickSel.options.length;
var name = stabSel.options[chosen].text;
var recid = stabSel.options[chosen].value;

var  statDiv = document.getElementById('status');
advAJAX.get({
    url: "/AJAXQueryHandler.php",
parameters : {
  "mode"   :   20,
  "zone"   :   num,
  "msg_id" :   msg_id,
  "db_id"  :   db_id,
  "rec_id" :   recid
},
    onInitialization : function() {
    statDiv.innerHTML = '<img src="/images/indicator_rumbleu.gif" alt="Loading..." width="20" height="21" border="0" style="margin: 3px;" /><br />';
    
    },
    onSuccess : function(obj) {

returnArtId = obj.responseText;
if(returnArtId != ''){
pickSel.options[size] = new Option(name, returnArtId);
}
    },
    onError : function(obj) {
    statDiv.innerHTML = '';
    },
    retry: 5,
retryDelay: 1000
}
);
document.getElementById('surveyAdd' + num).style.display = 'none';
} else {
alert("Select an item to add");
}
}


function delIt(num, msg_id) {
var pickSel = eval("document.frm" + num + ".elements['picked" + num + "[]']");
var chosen = pickSel.selectedIndex;

if (chosen != -1) {
var name = pickSel.options[chosen].text;
var recid = pickSel.options[chosen].value;

pickSel.options[chosen] = null;

dropArticle(num, msg_id, recid);
} else {
alert("You must select an item to remove.");
}
}


function delSurvey(num, msg_id) {
var pickSel = eval("document.sfrm" + num + ".elements['spicked" + num + "[]']");
var chosen = pickSel.selectedIndex;

if (chosen != -1) {
var name = pickSel.options[chosen].text;
var recid = pickSel.options[chosen].value;

pickSel.options[chosen] = null;

dropSurvey(num, msg_id, recid);
} else {
alert("You must select an item to remove.");
}
}



function moveOp(dir, num, msg_id) {
var pickSel = eval("document.frm" + num + ".elements['picked" + num + "[]']");
var chosen = pickSel.selectedIndex;
var size = pickSel.options.length-1;

if (chosen != -1) {
if (dir == 'up') {
var prev = pickSel.selectedIndex-1;
} else if (dir == 'down') {
var prev = pickSel.selectedIndex+1;
}

if ((dir == 'up' && chosen > 0) || (dir == 'down' && chosen < size)) {
var val_a = pickSel.options[chosen].value;
var txt_a = pickSel.options[chosen].text;

var val_b = pickSel.options[prev].value;
var txt_b = pickSel.options[prev].text;

pickSel.options[prev].value = val_a;
pickSel.options[prev].text = txt_a;

pickSel.options[chosen].value = val_b;
pickSel.options[chosen].text = txt_b;

pickSel.options[prev].selected = true;
pickSel.options[chosen].selected = false;

moveArticle(num, msg_id, val_a, dir);
}
} else {
alert("You must select an item to move.");
}
}

function editCustom(num, msg_id)
{
var pickSel = eval("document.frm" + num + ".elements['picked" + num + "[]']");
var chosen = pickSel.selectedIndex;
var title = pickSel.options[chosen].text;
var recid = pickSel.options[chosen].value;

var custFrm = eval("document.frm" + num);
custFrm.heading.value = title;

loadCustom(num, msg_id, recid);
}

function doWarnLoad(zone,tp,survey){
if(tp==1){
if(survey==1){
var pickSel = eval("document.sfrm" + zone + ".elements['surveys" + zone + "[]']");
var chosen = pickSel.selectedIndex;
if(chosen>0){
document.getElementById('surveyAdd' + zone).style.display = 'inline';
}
}
else{
var pickSel = eval("document.frm" + zone + ".elements['articles" + zone + "[]']");
var chosen = pickSel.selectedIndex;
if(chosen>0){
document.getElementById('zoneAdd' + zone).style.display = 'inline';
}
}
}
else{
var head = eval("document.frm" + zone + ".heading");
var bd = FCKeditorAPI.GetInstance('article'+zone);
if( head.value == ''  ){
document.getElementById('zoneAdd' + zone).style.display = 'none';
}
else{
document.getElementById('zoneAdd' + zone).style.display = 'inline';
}
}
}

function doCancelSend(msg_id){
var  statDiv = document.getElementById('status');
advAJAX.get({
    url: "/AJAXQueryHandler.php",
parameters : {
  "mode"   :   666,
  "msg_id" :   msg_id
},
    onInitialization : function() {
    statDiv.innerHTML = '<img src="/images/indicator_rumbleu.gif" alt="Loading..." width="20" height="21" border="0" style="margin: 3px;" /><br />';
    },
    onSuccess : function(obj) {
    statDiv.innerHTML = obj.responseText;
    },
    onError : function(obj) {
    statDiv.innerHTML = '';
    },
    retry: 5,
retryDelay: 1000
}
);
}

