/**
* @version $Id: mypms_common.js 268 2006-08-11 11:49:19Z danial $
* Clexus Private Messaging Component
* @package ClexusPM
* @Copyright (C) 2003 - 2006 Danial Taherzadeh All rights reserved
* @license Released as a commercial component
* @link http://www.clexus.com
**/

var ie  = document.all  ? 1 : 0;

function submitenter(myfield,e,m_a,m_b)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   fetchUsers(m_a, m_b);
   return false;
   }
else
   return true;
}

function CheckAll() {

    var fmobj = document.mutliact;
    
if (fmobj.allbox.checked) {
fmobj.allbox.checked = false;
}
else {
fmobj.allbox.checked = true;
}

    for (var i=0;i<fmobj.elements.length;i++) {
        var e = fmobj.elements[i];
        if ((e.name != 'allbox') && (e.type=='checkbox') && (!e.disabled)) {
            e.checked = fmobj.allbox.checked;
        }
    }
}



/**
* Pops up a new window in the middle of the screen
*/
function popupWin(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function setStatus(s,n, type) {
	//$('statusContainer').style.visibility = "visible";
	$('mypms_topmessage').innerHTML = "<div class=\""+ type +"\">" + s + "</div>";
	new Effect.Appear('mypms_topmessage');
	setTimeout( "new Effect.Fade('mypms_topmessage');", n );
}


Array.prototype.contains = function (element) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == element) {
			return true;
		}
	}
	return false;
};

Array.prototype.walk = function( f ) {
	var a = [],
	i = this.length;
	while(i--) {
		a.push( f( this[i] ) );
	}
	return a.reverse();
};

function ShowALertBox () {
Effect.Center('clexus-alertbox');
Element.show('clexus-alertbox');
Effect.Shake('clexus-alertbox');
}

function increaseNotesHeight(thisTextarea, add) {
	if (thisTextarea) {
		newHeight = parseInt(thisTextarea.style.height) + add;
		thisTextarea.style.height = newHeight + "px";
	}
}

function decreaseNotesHeight(thisTextarea, subtract) {
	if (thisTextarea) {
		if ((parseInt(thisTextarea.style.height) - subtract) > 150) {
			newHeight = parseInt(thisTextarea.style.height) - subtract;
			thisTextarea.style.height = newHeight + "px";
		}
		else {
			newHeight = 150;
			thisTextarea.style.height = "150px";
		}
	}
}