/*======================================================================*\
|| Standard Javascript functions used in LDM                              ||
\*======================================================================*/

function ldm_show(object, k, n) {
	for (var i=1; i <= n; i++) {
		obj = fetch_object(object+i);
		if (i==k) {
			obj.style.display = '';
		}
		else {
			obj.style.display = 'none';
		}
	}
}

function ldm_textLimit(field, maxlen) {
	if (field.value.length > maxlen) {
		field.value = field.value.substring(0, maxlen);
	}
}

function ldm_textDOI(field) {
	field.value = field.value.replace(/[^a-zA-Z0-9-_]+/g, "");
}

function ldm_popup(URL) {
	window.open(URL, 'player', 'width=$links_defaults[musicbox_standalone_width],height=$links_defaults[musicbox_standalone_height],toolbar=no,personalbar=no,location=no,directories=no,statusbar=no,menubar=no,status=no,resizable=yes,left=60,screenX=60,top=100,screenY=100');
}

function ldm_resize_area(rows, cols, id) {
	var area = fetch_object(id);
	if (typeof area.orig_rows == 'undefined') {
		area.orig_rows = area.rows;
		area.orig_cols = area.cols;
	}

	var newrows = area.rows + rows;
	var newcols = area.cols + cols;

	if (newrows >= area.orig_rows && newcols >= area.orig_cols) {
		area.rows = newrows;
		area.cols = newcols;
	}

	return false;
}

function ldm_size_style(height, width, id) {
	var myobj = fetch_object(id);
	myobj.style.height = height;
	myobj.style.width = width;
	return false;
}

function ldm_noenter() {
	return !(window.event && window.event.keyCode == 13);
}

if (location.search.substring(1)=="focuswin") {
	window.focus();
}


