var zntimer = 0;
var scrollamnt = 0;

String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
}

function isValidEmail(emailAddress) {
    var re = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
    return re.test(emailAddress);
}

function isValidPW(checkpw) {
	var re = /^\w+$/;
	return re.test(checkpw) && checkpw.length > 5 && checkpw.length < 13;
}

function showZN(thiszn) {
	for(x=0;x<=4;x++) { document.getElementById('zoomnail' + x).className = ''; }
	document.getElementById('galleryimage').src = document.getElementById(thiszn).src;
	document.getElementById(thiszn).className='curzn';
	if(thiszn != 'zoomnail0') {
		clearTimeout(zntimer);
		zntimer = setTimeout("showZN('zoomnail0')", 15000);
	} else {
		clearTimeout(zntimer);
	}
}

function textCounter(count, counter, maxlen) {
	
	if (count.value.length > maxlen) {
		count.value = count.value.substring(0, maxlen);
	} else {
		charleft = maxlen - count.value.length;
		if (charleft < 51) {
			counter.innerHTML = '<font color="#cc0000"><blink>' + charleft + '</blink></font>';
		} else {
			counter.innerHTML = charleft;
		}
	}
}


function scroll(amount, maxamount) {
	scrollamnt = scrollamnt + amount;
	if(scrollamnt > maxamount) { scrollamnt = maxamount; document.getElementById('scrolldn').value = 'bottom'; } else { document.getElementById('scrolldn').value = 'scroll down'; }
	if(scrollamnt < 0) { scrollamnt = 0; document.getElementById('scrollup').value = 'top'; } else { document.getElementById('scrollup').value = 'scroll up'; }
	document.getElementById('qf').scrollTop = scrollamnt;
	return false;
}

function prints(x) {
	pid = document.getElementById('p' + x.toString());
	bid = document.getElementById('b' + x.toString());
	pval = parseInt(pid.value);
	pval = pval + 1;
	if(pval == 1) pval = 2;
	if(pval == 6) pval = 0;
	pid.value = pval;
	bid.className = "prints" + pval.toString();
}

function multiprints(x) {
	a = prompt("Starting point", "");
	b = prompt("Ending point", "");
	for(c=a;c<=b;c++) {
		pid = document.getElementById('p' + c.toString());
		bid = document.getElementById('b' + c.toString());
		pid.value = x;
		bid.className = "prints" + x.toString();
	}
}
