// JavaScript Document

/*****************Globals****************/
var currentText = new Array();
var textArea = new Array();
var pasteMsg = '';
/****************************************/


void startPreventPaste();
initializes the copy paste monitor.

function startPreventPaste(TextAreaArray, msg){
for(i = 0; i < TextAreaArray.length; i++)
{
textArea = document.getElementById(TextAreaArray);
currentText = textArea.value;
}

if(msg){
pasteMsg = msg
}else if (msg === false){
pasteMsg = msg;
}

if(document.all){
//it it is ie do the onpaste function
var brwsr = navigator.userAgent.toLowerCase();
if(brwsr.search(/opera[\/\s](\d+(\.?\d)*)/) != -1) {
// Opera
doLoop();
}else{
for(i = 0; i < textArea.length; i++)
{
textArea.onpaste = function (){
showMessage();//shoe the message
return false;//don't paste
}
}
}
}else{
doLoop();
}
}
/****************************************************************************/
void doLoop()
starts the timer. Checks the text.
/****************************************************************************/

function doLoop(){
checkText();
pccpTimer = window.setTimeout("doLoop();", 10);
}
/****************************************************************************/
void checkText()

function checkText(){
for(i = 0; i < textArea.length; i++)
{
if(textArea){
newTextLength = textArea.value.length;//gets length of the textarea right now.
currentTextLength = currentText.length;//gets length of the saved text from the textarea

if(newTextLength > (currentTextLength + 50)){//is the new more then 10 characters longer?
textArea.value = currentText;//put the saved text back in/
showMessage();//tell them they cannot paste.
}else{
currentText = textArea.value;//if it is ok then save the text.
}
}
}
}
/****************************************************************************/
void showMessage();
/****************************************************************************/

function showMessage(){
if(pasteMsg !== false){
alert(pasteMsg);
}
}
