function instanceOf(object, constructorFunction) {
	if (!constructorFunction || object == null) 
		return false;
		
  	while (object != null) {
    	if (object == constructorFunction.prototype)
     		return true;
    	object = object.__proto__;
  	}
  	return false;
}
function submit_form(formid) {
	try {
		var form = $(formid || 'frm');
		
		form.submit();
	} catch (e) { alert(e) }
}
function save_item(formid) {
	var result = true;
	try {
		if (instanceOf(window["v"], validator)) {
			result = window["v"].exec();
		}
		
		if (result)
			submit_form(formid);
		
	} catch (e) { alert(e) }
	return true;
}

function delete_item(formid) {
	if (confirm_msg()) {
		input = document.createElement('INPUT');
		input.type = 'hidden';
		input.name = 'remove';
		
		$(formid || 'frm').appendChild(input);
		submit_form(formid);
	}
}

function confirm_msg(msg) {
	if (!msg) msg = '¿Está seguro de eliminar este elemento?';
	return confirm(msg);
}

function map(m) {
	window.open('view-map.php?pic=' + m , 'map', 'width=200, height=200, top=10, left=10, scrollbars=no');
	return false;
}