function nuiansongtra_startFckEditor(id) {
        var oFCKeditor = new FCKeditor( id ) ;
        oFCKeditor.BasePath = '/fckeditor/' ;
        oFCKeditor.Width = 580 ;
        oFCKeditor.Height = 600 ;
        oFCKeditor.ToolbarSet = 'nuiansongtra' ;
        oFCKeditor.ReplaceTextarea() ;
}

function closePhoto() {
        var picframeborder=document.getElementById('picframeborder');
        var picframe = document.getElementById('picframe');
        picframe.innerHTML = '';
        picframeborder.style.display='none';
}

function enlargePhoto_cb(request) {
  var picframe = document.getElementById('picframe');
  picframe.innerHTML = request.responseText;
}

function enlargePhoto(photoid) {
  var screenWidth = document.body.clientWidth;
  var screenHeight = document.body.clientHeight;
  var picframeborder=document.getElementById('picframeborder');
  var picframe = document.getElementById('picframe');

  picframeborder.style.display='block';
  picframeborder.style.left=(screenWidth-parseInt(picframeborder.style.width))/2;
  picframeborder.style.top=(screenHeight-parseInt(picframeborder.style.height))/2+document.body.scrollTop;
  picframe.innerHTML = 'Please wait ...';
  return sendRequest('index.php','c=photo&p='+photoid,enlargePhoto_cb);
}

function getHtmlRequest() {
  var request = false;
  try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = false;
      }
    }
  }

  if (!request)
    alert("Error initializing XMLHttpRequest!");
  return request;
}

function sendRequest(url,query,callback_func) {
  request = getHtmlRequest();
  if (!request) return true;
  request.open("POST", url, true);
  request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  request.setRequestHeader("Content-length", query.length);
  request.setRequestHeader("Connection", "close");

  request.onreadystatechange =
    function () {
      if (request.readyState==4 && request.status==200) {
        callback_func(request);
      }
    };
  request.send(query);
  return false;
}

function setupFlashPlayer(id,width,height,file,autostart) {
  so = new SWFObject('mediaplayer.swf','player_'+id,width,height,'20');
  so.addParam('allowscriptaccess','always');
  so.addParam('allowfullscreen','true');
  so.addVariable('fullscreen','true');
  so.addVariable('autostart',autostart);
  so.addVariable('repeat','list');
  so.addVariable('enablejs','false');
  so.addVariable('javascriptid','player_'+id);
  so.addVariable('file',file);
  so.write(id);
}

function confirmDelete(url) {
    window.name='main';
    if (confirm('Delete?')) window.open(url,'main');
    else return;
}

function addEvent(obj, evType, fn)
{
  if (obj.addEventListener)
  {
    obj.addEventListener(evType, fn, false);
    return true;
  }
  else if (obj.attachEvent)
  {
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  }
  else
  {
    return false;
  }
}

