// UrbanAura funky js file, use it and abuse it!

// begin_inbox_area
function _num(form, chkName) {
	var i=0, j=0;
	df = document.forms[form];
	len = df.elements.length;
	for (i=0; i<len; i++){
		fldname = df.elements[i].name;
		if(fldname.match(chkName) == chkName) {
			if(df.elements[i].checked == true) {
				j++;
			}
		}
	}
	return j;
}
function _check(form,chkName,val) {
	var i=0, j=0;
	dml = document.forms[form];
	len = dml.elements.length;
	for(i=0; i<len; i++){
		if (dml.elements[i].name == (chkName+"_"+j)) {
			dml.elements[i].checked = val;
			j++;
		}
	}
}
function inboxActions(form,action) {
	if (!action) {
		return;
	}
	if (_num(form, 'check_') == 0) {
		alert('Please select at least one item.');
		return;
	}
	
	if (action == 'del') {
		if (!confirm("Are you sure you want to delete this messages?")) {
			return;
		}
	}
	
	document.getElementById('action').value = action;
	document.forms[form].submit();	
}

function requestActions(form,action) {
   if (!action) {
      return;
   }
   if (_num(form, 'check_') == 0) {
      alert('Please select at least one request.');
      return;
   }
   if (action == 'accept') {
      if (!confirm("Are you sure you want to accept these requests?")) {
         return;
      }
   }
   if (action == 'reject') {
      if (!confirm("Are you sure you want to reject these requests?")) {
         return;
      }
   }
   document.getElementById('action').value = action;
   document.forms[form].submit();
}


// userdeleterequest
function sConfirm(msg) {
	if (!confirm(msg)) { return false }
}
function confirmAction(url,msg) {
	if (confirm(msg)) {
		location.href = url;
	}
}
function forward(form,url,field) {
	id = document.getElementById(field).value;
	document.forms[form].action = url+id;
	document.forms[form].submit();
}

// follow a new link
function follow(home,loc) {
	if (!home) { return; }
	if (!loc) { return; }
	location.href = home + loc
}

// miscfuncs
function _display(id) {
	if (document.layers) {
		document.layers[id].display = (document.layers[id].display != 'block') ? 'block' : 'none';
	} else if (document.all) {
		document.all[id].style.display = (document.all[id].style.display != 'block') ? 'block' : 'none';
	} else if (document.getElementById) {
		document.getElementById(id).style.display = (document.getElementById(id).style.display != 'block') ? 'block' : 'none';
	}
}
