function addBookmark() {
    if (window.sidebar) { // firefox
    	window.sidebar.addPanel(window.document.title, window.document.location, "");
    } else if(window.opera && window.print) { // opera
    	var elem = document.createElement('a');
    	elem.setAttribute('href',window.document.location);
    	elem.setAttribute('title',window.document.title);
    	elem.setAttribute('rel','sidebar');
    	elem.click();
    } else if(document.all) {// ie
    	window.external.AddFavorite(window.document.location, window.document.title);
    }
}
var unit = 'px';
var defaultSize = 12;
var currentSize = 12;
var minSize = 8;
var maxSize = 24;
var fs = 0;
var lh = 0;
function changeFontSize(increase) {

    if ((currentSize == minSize && !increase) || (currentSize == maxSize && increase)) return;
    currentSize = (increase) ? currentSize + 2 : currentSize - 2;

    var p = document.getElementsByTagName('p');
    for (var i = 0; i < p.length; i++) {

        p[i].style.fontSize = currentSize+unit;
        p[i].style.lineHeight = (currentSize*1.5)+unit;
    }
}
function editChunk(in_id) {
    window.open('/page/chunkedit/'+in_id+'/','editPage','width=550,height=450');
    return false;
}
function editPage(in_id) {
    window.open('/page/edit/'+in_id+'/','editPage','width=550,height=400');
    return false;
}
function chunkClose() {
    //window.opener.location.reload(true);
    window.close();
}
//popup window for viewing accessory
function showPicture(imageName,caption) {
    var img = new Image();
    img.src = imageName;
    img.onload = function () { eval('showPictureProceed("'+imageName+'",'+img.width+','+img.height+',"'+caption+'")'); }
}

function showPictureProceed(imageName,imageWidth,imageHeight,caption) {

   	var left = Math.floor( (screen.width - imageWidth) / 2);
    var top = Math.floor( (screen.height - imageHeight) / 2);
	newWindow = window.open("","imageWindow","scrollbars=0,width="+imageWidth+",height="+(imageHeight+50)+",left="+left+",top="+top);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+caption+'</title>');
	newWindow.document.write('<head>');
	newWindow.document.write('<link rel="stylesheet" type="text/css" href="/css/screen.css" media="screen,print,handheld" />');
	newWindow.document.write('<style>body { background-color: #fff; }</style>');
	newWindow.document.write('</head>');
	newWindow.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" >');
	newWindow.document.write('<center><p class="strong"><br />'+caption+'</p>');
	newWindow.document.write('<img src="'+imageName+'" alt="'+imageName+'" ></center>');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}
document.getElementsByClassName = function(className) {
  var children = document.getElementsByTagName('*') || document.all;
  var elements = new Array();

  for (var i = 0; i < children.length; i++) {
    var child = children[i];
    var classNames = child.className.split(' ');
    for (var j = 0; j < classNames.length; j++) {
      if (classNames[j] == className) {
        elements.push(child);
        break;
      }
    }
  }
  return elements;
}
document.addEvent = function(object, eventType,fn, useCapture) {
	if (object.addEventListener) {
		object.addEventListener(eventType, fn, useCapture);
		return true;
	} else {
		if (object.attachEvent) {
			var r = object.attachEvent("on"+eventType, fn);
			return r;
		}
	}
};

Array.prototype.random = function() {
    return this[Math.floor((Math.random()*this.length))];
}
function ccWindow(){
    ccWindow = window.open("http://www.sentact.com/cc1.html","1","fullscreen=yes");
}
var rmLiShown = false;
function rmDropdown() {
    rmLiShown = !rmLiShown;
    document.getElementById('rmLi').style.display = rmLiShown ? 'block' : 'none';
}
function rmWindow(in_obj) {
    if (in_obj.value == '') return;
    rmWin = window.open("http://www.sentact.com/"+in_obj.value+".html","1","fullscreen=yes");
}