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 currentSize = 11;
var minSize = 8;
var maxSize = 24;
var fs = 0;
var lh = 0;
function setCurrentSize(in_size) {
    currentSize = in_size;
}
function changeFontSize(increase) {

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

    setFontSize();
    ajaxSetFontSize(currentSize);
}
function setFontSize() {
    var p = document.getElementById('page-main-content-leftcenter');

    p.style.fontSize = currentSize+unit;
    p.style.lineHeight = (currentSize*1.5)+unit;

}
function editChunk(in_id) {
    window.open('/page/chunkedit/'+in_id+'/','editPage','width=550,height=550');
    return false;
}
function editPage(in_id) {
    window.open('/page/edit/'+in_id+'/','editPage','width=550,height=550,scrollbars=yes,resizable=yes');
    return false;
}
function chunkClose() {
    window.opener.location.reload(true);
    window.close();
}
function email(in_id) {
    window.open('/home/email/'+in_id+'/','emailPage','width=450,height=400');
}
function qtvr(in_size) {
    var width = 0;
    var height = 0;
    switch (in_size) {
        case 1: width = 575;  height = 310; break;
        case 2: width = 750;  height = 505; break;
        case 3: width = 1100; height = 800; break;
        default: break;
    }
    window.open('/home/qtvr/'+in_size+'/','qtvrPage'+in_size,'width='+width+',height='+height+',resizable=1');
}

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;
		}
	}
};

var clickmessage="Right click has been disabled.";
function associateimages(){
	//function from dynamicdrive.com
	for(i=0;i<document.images.length;i++)
	document.images[i].onmousedown=disableclick;
}

function disableclick(e) {
if ( (navigator.appName == 'Netscape' && (e.which == 2 || e.which == 3 || e.ctrlKey || e.altKey) && e.target.tagName!='A' ) || (navigator.appName != 'Netscape' && (event && (event.button==2||event.button==3||event.ctrlKey||event.altKey) && event.srcElement.tagName=='IMG')) ) {
	alert(clickmessage);
	return false;
}
	return true;
}

function protectImages() {
	if ( (/pelago/gi).test(document.domain) ) return false;
	if (document.all)
		document.onmousedown=disableclick
	else if (document.getElementById)
		document.onmouseup=disableclick
	else if (document.layers)
		associateimages();
	window.onmousedown=disableclick;

}

document.addEvent(window,'load',protectImages, false);

var oXml = null;
var callback = null;

function ajaxSetFontSize(in_size) {
    var uri = '/home/changefontsize/' + in_size + '/';
    ajaxRequest(uri);
}

function ajaxRequest(uri) {
	oXmlInit();
	if( oXml != null ) {
		oXml.open("GET", uri, true); //asynchronously or not
		/*
		readyState Status Codes:
		0 = uninitialized
		1 = loading
		2 = loaded
		3 = interactive
		4 = complete
		*/
		oXml.onreadystatechange = function() {
			if (oXml.readyState == 4) {
				if (oXml.status == 200) {
				    if (callback != undefined) {
				        if (callback != null) {
				            eval(callback+'();');
				        }
				    }
				}
			}
		}
		oXml.send(null);
	}
}

function oXmlInit() {
	try {
		oXml = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			oXml=new ActiveXObject("Microsoft.XMLHTTP");
		} catch (oc) {
			oXml=null;
		}
	}
	if(!oXml && typeof XMLHttpRequest != "undefined") {
		oXml = new XMLHttpRequest();
	}
}

