
/*************************************************************/
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}


/*************************************************************/		
function disableCtrlKeyCombination(e,BlockKeys)
/*
this function will thro an alert if the user press Ctrl + (any of the "BlockKeys").  

EXAMPLE: BlockKeys = 'v';  the user tries to paste with Ctrl+V, an alert will appear and the clipboard will NOT be pasted
*/
{

	//list all CTRL + key combinations you want to disable
	//var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'j');
	var forbiddenKeys = new Array(BlockKeys.length);
	var key;
	var isCtrl;
	
	for (i=0;i<BlockKeys.length;i++)
	{
		forbiddenKeys[i] = BlockKeys.substring(i,i+1);
	}
	

	if(window.event)
	{
		key = window.event.keyCode;     //IE
		if(window.event.ctrlKey)
			isCtrl = true;
		else
			isCtrl = false;
	}
	else
	{
		key = e.which;     //firefox
		if(e.ctrlKey)
			isCtrl = true;
		else
			isCtrl = false;
	}
		
	//if ctrl is pressed check if other key is in forbidenKeys array
	if(isCtrl)
	{
		for(i=0; i<forbiddenKeys.length; i++)
		{
			//case-insensitive comparation
			if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
			{
				alert('Key combination CTRL + '	+ String.fromCharCode(key) + ' has been disabled.');
				return false;
			}
		}
	}
	return true;
}