textCounter = function(targetField, maxLength){
	var target = $('#' + targetField);
	var counter = $('#' + targetField + "_counter");
	var len = target.val().length;
	var msg = '';
	
	if(len > maxLength){
		target.val(target.val().substring(0, maxLength));
	} else {
		if(len > 0){
			msg = "Characters left: " + (maxLength - len);
		} else {
			msg = "Maximum length: " + maxLength;
		}
		counter.text(msg);
	}
}

jumpTo = function(anchor, duration){
	target = $('a[name=' + anchor + ']');
	duration = duration || 250;
	$.scrollTo(target, duration);
	return false;
}

/* example : <a href="http://www.myopenbox.org" onclick="popUp(this.href, '', 725, 450, location, scrollbars, resizable, status, toolbar, menubar); return false;"> test </a> */
popUp = function(href, winName, w, h, location, scrollbars, resizable, status, toolbar, menubar){
	var winLeft=(screen.width - w) / 2;
	var winTop=(screen.height - h) / 2;
	winProps="width=" + w + ",height=" + h + ",top=" + winTop + ",left=" + winLeft + ",location=" + location + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",status=" + status + ",toolbar=" + toolbar + ",menubar=" + menubar;
	winOpen=window.open(href, winName, winProps);
	winOpen.window.focus();
}

// selectAll = function(targetSelectId){
// 	var targetSelect = $(targetSelectId);
// 	for(var i=0; i < targetSelect.options.length; i++){
// 		targetSelect.options[i].selected = true;
// 	}
// 	targetSelect.options[0].selected = false;
// }
// selectNone = function(targetSelectId){
// 	var targetSelect = $(targetSelectId);
// 	for(var i=0; i < targetSelect.options.length; i++){
// 		targetSelect.options[i].selected=false;
// 	}
// }