function highlightDay(obj, bool) {
	if(bool == true) {
		obj.style.backgroundColor = '#FFFFCC';
	} else {
		obj.style.backgroundColor = '';
	}
}

function loadCalDay(dateurl) {
	location.href = '/calendar/day/'+dateurl;
}
function editChunk(in_id, in_page_id, in_position) {
    var url = '/page/chunkedit/'+in_id+'/';
    if (in_page_id) url += '+/' + in_page_id + '/';
    if (in_position) url += in_position + '/';
    window.open(url,'editPage','width=800,height=550');
    return false;
}
function editPage(in_id) {
    window.open('/page/seo/'+in_id+'/','editPage','width=550,height=250,resizable=yes,scrollbars=yes');
    return false;
}
function chunkClose() {
    window.opener.location.reload(true);
    window.close();
}
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;
		}
	}
};

sfHover = function() {
    if (document.getElementById("banner-main-utility-nav")) {
    	var sfEls = document.getElementById("banner-main-utility-nav").getElementsByTagName("li");
    	for (var i=0; i<sfEls.length; i++) {
        	var sfElUls = sfEls[i].getElementsByTagName("ul");
        	for (var j=0; j<sfElUls.length; j++) {
        	    sfElUls[j].style.width = (sfEls[i].scrollWidth/* - 24*/) + 'px';
        	}
    		sfEls[i].onmouseover=function() {
    		    if (!this.className.length) this.className = 'sfhover';
    			else this.className += ' sfhover';
    		}
    		sfEls[i].onmouseout=function() {
    			this.className=this.className.replace(new RegExp("(\\b)sfhover(\\b)"), "$1$2");
    		}
    	}
    }
}
document.addEvent(window,'load',sfHover);

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.getElementById('page-main-content-leftcenter');

    p.style.fontSize = currentSize+unit;
    p.style.lineHeight = (currentSize*1.5)+unit;
}

// view an image
function openPictureWindow(imageName,imageWidth,imageHeight,alt) {
	var scroll = '';
	var winHeight = imageHeight;
	var winWidth = imageWidth;
	if ( winHeight > 700 ) {
		scroll = ",scrollbars=yes";
		winWidth += 20;
		winHeight = 700;
	}
	if ( /safari/gi.test(navigator.userAgent) ) {
		winWidth+=5;
		winHeight+=5;
	}
   	var left = Math.floor( (screen.width - winWidth) / 2);
    var top = Math.floor( (screen.height - winHeight) / 2);
	newWindow = window.open("","newWindow","resizable=1,width="+winWidth+",height="+winHeight+",left="+left+",top="+top+scroll);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
	newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt="'+alt+'">');
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
	return false;
}

function editRecurringEvent(id,year,month,day) {
    if (confirm("This is a recurring event.\n\nClick \"OK\" to edit the entire series.\nClick \"Cancel\" to edit just this occurrence.")) {
        window.location = '/calendar/edit/'+id+'/';
    } else {
        window.location = '/calendar/edit/+/'+year+'/'+month+'/'+day+'/'+id+'/';
    }
}

function deleteRecurringEvent(id,year,month,day) {
    if (confirm("This is a recurring event.\n\nClick \"OK\" to delete the entire series.\nClick \"Cancel\" to delete just this occurrence.")) {
        window.location = '/calendar/delete/'+id+'/';
    } else {
        window.location = '/calendar/delete/+/'+year+'/'+month+'/'+day+'/'+id+'/';
    }
}

function cvv_win() {
	var thewin = window.open("/cvv.php","cvv","height=435,width=500,toolbar=no,statusbar=no,scrollbars=yes");
	thewin.focus();
}
