

///////////////////////////////////////////////////////////////////////////////////
//	function:	wlOpenPU()
//	parameters:	strUrl- the url to open in the pop-up window
//				strName- the name of the window- (used for reference to it)
//				intW- width in pixels of new window
//				intH- height in pixels of new window
//				intType- an integer used to choose window type (see notes)
//	returns:	the open window
//	notes:(types)	0 (default) - centered window with scroll bars
//					1 - centered window with no scroll bars
///////////////////////////////////////////////////////////////////////////////////
function wlOpenPU(winUrl, winName, winWidth, winHeight, intType) {
	var winFeatures;
	
 	//do math to center window
 	var screenH = screen.availHeight;
 	var screenW = screen.availWidth;
 	var moveX = (screenW - winWidth)/2;
 	var moveY = (screenH - winHeight)/2;
	
	switch (intType) {
		case 1:
			winFeatures = "width=" + winWidth + ",height=" + winHeight + ",scrollbars=no";
		break;
		default:
			winFeatures = "width=" + winWidth + ",height=" + winHeight + ",scrollbars=yes";
		break;
	}
	
	var openWindow = window.open("", winName, winFeatures);
	openWindow.moveTo(moveX, moveY);
	openWindow.resizeTo(winWidth, winHeight);
	openWindow.location.href = winUrl;
	openWindow.self.focus();
	openWindow.onblur="self.focus()";
	//return openWindow;
}
// end wlOpenPU()

///////////////////////////////////////////////////////////////////////////////////
//	function:	wlClosePU()
//	parameters:	nothing
//	returns:	nothing
//	notes:	Closes the windwo after attempting to focus the window that opened it
///////////////////////////////////////////////////////////////////////////////////
function wlClosePU() {
	try {
		window.opener.focus();
	} catch (err) {}

	window.close();
}
// wlClosePU()

///////////////////////////////////////////////////////////////////////////////////
//	function:	wlClosePU_Refresh()
//	parameters:	nothing
//	returns:	nothing
//	notes:	Closes the window after attempting to reload and focus the window that 
//				opened it
///////////////////////////////////////////////////////////////////////////////////
function wlClosePU_Refresh(strUrl) {
	try {
		if (strUrl && strUrl!= "") {
			opener.location = strUrl;
		} else {
			opener.location.reload();
		}
		window.opener.focus();
	} catch (err) {}

	window.close();
}
// end wlClosePU_Refresh()

//******************************************************************************
//* Name: limitIt
//* Parameters: form element (from this), number of characters
//* Returns: nothing
//* Notes:  limits number of characters in a textarea
//******************************************************************************

function limitIt(formElement, intMaxLimit) {
	var intTmp = formElement.value.length;
	var strTmp;
	if (intTmp > intMaxLimit) {
		strTmp = formElement.value;
		formElement.value = strTmp.slice(0,intMaxLimit);
		alert("limit reached!");
	}
}
//end limitIt

///////////////////////////////////////////////////////////////////////////////////
//	function:	Spell Checking Clientside Functions
//	parameters:	
//	returns:	
//	notes:		XDE Server no-applet spellchecker
///////////////////////////////////////////////////////////////////////////////////
var xdecurrentItem=0,xdecurrentSpellWindow;
var xdearr,xdegLanguage;
var xdeisBusy=false;
function noblanks(astring, frm){
/*Contributed by Corey Alguire @ METAL-TECHNOLOGIES.COM
2003-01-18
checks if text area has any data prior to launching window
*/
    bstring = '';
    myarray = astring.split(",");
    for(var item = 0; item < myarray.length; item++){
      if(eval(myarray[item] + '.value') != ''){
        if(bstring == ''){
          bstring += myarray[item];
        }else{
          bstring += ',' + myarray[item];
        }
      }
    }
    return bstring;
}

function xde_checkWindow() {
   // something to do
	if(!xdeisBusy&&xdecurrentItem<xdearr.length){
		var tmpval=xdearr[xdecurrentItem];
		xdeisBusy=true;
		xdecurrentSpellWindow=doSpell( this,xdegLanguage,tmpval, false);
	}
	if(typeof(xdecurrentSpellWindow) == "object")
		if(xdecurrentSpellWindow.closed){
			xdeisBusy=false;
		xdecurrentItem++;
		}
   setTimeout('xde_checkWindow()',500);
}

function doSpellMultiple(opener,Language,p_ctrl,reloadnow){
	xdegLanguage=Language;
	xdearr = p_ctrl.split(",");
	xdecurrentItem=0;
	xde_checkWindow(); // start the funtion
}

function wlDoSpellCheck(elms,me) {
	var chkstring = noblanks(elms, me); 
	if(chkstring != ''){
		doSpellMultiple( me,'', chkstring, true);
	}else{
		alert('Nothing to check...');
	}
}
// end Spell Checking Clientside Functions


