﻿function popWin(theURL,winName,width,height) { 
    var window_width = width;
    var window_height = height;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ', toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no');
    //newWindow.focus();
}

function cloWin() {
	window.close();
	window.opener.focus();
}
function cloWinAuto(iTime) {
	// Close window after 2000 ms (2 sec.)
	setTimeout('cloWin()', iTime);	
}

function textCounter(field, displayName, maxlimit, countfield) {
    if (field.value.length > maxlimit) {
        field.value = field.value.substring( 0, maxlimit );
        alert(displayName + ' cannot exceed ' + maxlimit + ' characters in length.' );
        return false;
    }
    else if (countfield) {  // can have an input field that shows the count to the user, don't pass countfield to ignore this
        countfield.value = maxlimit - field.value.length;
        
    }
    return true ;
}