var website_full_address = 'http://www.vietbang.com/';

function vb_startFckEditor(id) {
        var oFCKeditor = new FCKeditor( id ) ;
        oFCKeditor.BasePath = '/fckeditor/' ;
        oFCKeditor.Width = 580 ;
        oFCKeditor.Height = 600 ;
        oFCKeditor.ToolbarSet = 'Vietbang' ;
        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 = parseInt(document.body.clientWidth);
  var screenHeight = parseInt(document.body.clientHeight);
  var picframeborder=document.getElementById('picframeborder');
  var picframe = document.getElementById('picframe');

  picframeborder.style.display='block';
  picframeborder.style.left=Math.round((screenWidth-parseInt(picframeborder.style.width))/2)+'px';
  picframeborder.style.top=Math.round((screenHeight-parseInt(picframeborder.style.height))/2)+parseInt(document.body.scrollTop)+'px';
  picframeborder.style.top=parseInt(document.body.scrollTop)+10+'px';
  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 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;
  }
}

