function addToBookmarks(url, title) {
	window.external.AddFavorite(url, title);
}

function clearContent(element, defaultValue) {
    if (element.value == defaultValue)
        element.value = '';
}

function cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.top = location.y - 2 + 'px';
    top.style.left = location.x + 'px';
    
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}

function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = '; expires=' + date.toGMTString();
	} else {
		var expires = '';
	}
	
	document.cookie = name + '=' + value + expires + '; path=/';
}

function readCookie(name) {
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	
	return null;
}

function eraseCookie(name) {
	createCookie(name, '', -1);
}

function widthToggle() {
	var fixedWidth = readCookie('FixedWidth');
	
	if (fixedWidth == 'false' || fixedWidth == null) {
		fixedWidth = 'true';
	} else {
		fixedWidth = 'false';
	}
	
	createCookie('FixedWidth', fixedWidth, 365);
	document.location.reload();
}

function validateEditorLength(sender, args) {
    var editor = FCKeditorAPI.GetInstance(sender.controltovalidate);
    var maxLength = sender.maxLength != null ? sender.maxLength : 10;
    args.IsValid = editor.GetXHTML(true).length <= maxLength;
}