function mqIds(){
  var mqMsgCks = document.cookie.split('; ');
  var arrMgMsgIds = new Array();
  var j = 0;
  for (var i = 0; i < mqMsgCks.length; i++){
    if(mqMsgCks[i].substr(0, 5)=='mqdiv'){
      arrMgMsgIds[j] = mqMsgCks[i].substr(0, mqMsgCks[i].indexOf('='));
      j++;
    }
  }
  mgMsgIds = arrMgMsgIds;
  delete arrmgMsgIds;
  delete mqMsgCks;
}

function btnMulti(id){
  var mqQuoted = false;
	for (var i = 0; i < mgMsgIds.length; i++){
    if(mgMsgIds[i] == ('mqdiv' + id)) mqQuoted = true;
  }  
  if(mqQuoted){
    document.getElementById("mqdiv"+ id).innerHTML = '<a href="javascript:void(0);" onclick="btnMultiClick(' + "'" + id + "'" + ')";><img src="' + images_url + '/buttons/' + muqimmgname + '" alt="' + multi_unquote + '" align="middle" /><b>' + un_multi + '</b></a>'; //document.write('<li><div name="mqdiv'+ id + '" id="mqdiv' + id + '" style="display: inline;"><a href="javascript:void(0);" onclick="return btnMultiClick(' + '"' + id + '"' + ');"><img src="' + images_url + '/buttons/' + muqimmgname + '" alt="' + multi_unquote + '" align="middle" /><b>' + un_multi + '</b></a></div></li>');
  }else{
    document.getElementById("mqdiv"+ id).innerHTML = '<a href="javascript:void(0);" onclick="btnMultiClick(' + "'" + id + "'" + ')";><img src="' + images_url + '/buttons/' + mqimmgname + '" alt="' + multi_quote + '" align="middle" /><b>' + multi + '</b></a>'; //document.write('<li><div name="mqdiv'+ id + '" id="mqdiv' + id + '" style="display: inline;"><a href="javascript:void(0);" onclick="btnMultiClick(' + '"' + id + '"' + ');"><img src="' + images_url + '/buttons/' + mqimmgname + '" alt="' + multi_quote + '" align="middle" /><b>' + multi + '</b></a></div></li>');
  }
}

function btnMultiClick(id){
  mqIds();
  var mqQuoted = false;
  var date = new Date();
  for (var i = 0; i < mgMsgIds.length; i++){
    if(mgMsgIds[i] == ('mqdiv' + id)) mqQuoted = true;
  }
  if(mqQuoted){
    document.getElementById("mqdiv"+ id).innerHTML = '<a href="javascript:void(0);" onclick="btnMultiClick(' + "'" + id + "'" + ')";><img src="' + images_url + '/buttons/' + mqimmgname + '" alt="' + multi_quote + '" align="middle" /><b>' + multi + '</b></a>'; 
    date.setTime(date.getTime()-(24*60*60*1000));
    document.cookie = 'mqdiv' + id + "=; expires=" + date.toGMTString() + "; path=/";
  }else{
  	date.setTime(date.getTime()+(24*60*60*1000));
    document.cookie = 'mqdiv' + id + "=1; expires=" + date.toGMTString() + "; path=/";
    document.getElementById("mqdiv"+ id).innerHTML = '<a href="javascript:void(0);" onclick="btnMultiClick(' + "'" + id + "'" + ')";><img src="' + images_url + '/buttons/' + muqimmgname + '" alt="' + multi_unquote + '" align="middle" /><b>' + un_multi + '</b></a>';
  }
  mqIds();  
}

function pasteMulti(){
  mqIds();
  if(mgMsgIds.length > 0) insertMQ(mgMsgIds[0].replace("mqdiv",""));
}

function clearMulti(){
  mqIds();
  var date = new Date();
  date.setTime(date.getTime()-(24*60*60*1000));
  for (var i = 0; i < mgMsgIds.length; i++){    
    document.cookie = mgMsgIds[i] + "=; expires=" + date.toGMTString() + "; path=/";    
  }
  mqIds();
}
