
function dodacheck(val) {

////////////////////////////////////////////////////////////
// bad character check (SQL won't handle apostrophes)
////////////////////////////////////////////////////////////
	var badExp = /[\^*\(\)\[\]\+\_\{\}\'\`~|]/;

	var strPass = val.value;
	var strLength = strPass.length;
	var lchar = val.value.charAt((strLength) - 1);
	
	if(lchar.search(badExp) != -1) {
		var tst = val.value.substring(0, (strLength) - 1);
		val.value = tst;
	}
}

function checkYear(theForm, val) {
	var strPass = document.forms[theForm].dobYear.value;
	var strLength = strPass.length;
	if (strLength < 4 ){
		alert("Please enter a 4-digit year\n\nThe one you put in was only "+ strLength +" characters long.");
	}else{
		return true;
	}
}

function checkOrderPlaceForm(){
	if (document.orderForm.firstname.value == ""){
		alert("What's your First Name!?!");
		document.orderForm.firstname.focus();
		return false;
	}else if (document.orderForm.lastname.value == ""){
		alert("What's your Last Name!?!");
		document.orderForm.lastname.focus();
		return false;
	}else if (document.orderForm.street1.value == ""){
		alert("What's your Street Address!?!");
		document.orderForm.street1.focus();
		return false;
	}else if (document.orderForm.city.value == ""){
		alert("What City do you live in!?!");
		document.orderForm.city.focus();
		return false;
	}else if (document.orderForm.zip.value == ""){
		alert("What's your Zip/Postal code!?!");
		document.orderForm.zip.focus();
		return false;
	}else if (document.orderForm.state.value == ""){
		alert("Which State do you live in!?!");
		document.orderForm.state.focus();
		return false;
	}else if (document.orderForm.phone.value == ""){
		alert("What's a good Phone Number we can use to reach you!?!");
		document.orderForm.phone.focus();
		return false;
	}else{
		number=Math.floor(Math.random()*69)
		document.orderForm.placeOrder.value=number;
		document.orderForm.submit();
		return true;
	}
}

function checkModelApForm(){
	if (document.modelApForm.firstname.value == ""){
		alert("What's your First Name!?!");
		document.modelApForm.firstname.focus();
		return false;
	}else if (document.modelApForm.lastname.value == ""){
		alert("What's your Last Name!?!");
		document.modelApForm.lastname.focus();
		return false;
	}else if (document.modelApForm.street1.value == ""){
		alert("What's your Street Address!?!");
		document.modelApForm.street1.focus();
		return false;
	}else if (document.modelApForm.city.value == ""){
		alert("What City do you live in!?!");
		document.modelApForm.city.focus();
		return false;
	}else if (document.modelApForm.zip.value == ""){
		alert("What's your Zip/Postal code!?!");
		document.modelApForm.zip.focus();
		return false;
	}else if (document.modelApForm.state.value == ""){
		alert("Which State do you live in!?!");
		document.modelApForm.state.focus();
		return false;
	}else if (document.modelApForm.phone.value == ""){
		alert("What's a good Phone Number we can use to reach you!?!");
		document.modelApForm.phone.focus();
		return false;
	}else{
		number=Math.floor(Math.random()*69)
		document.modelApForm.addMe.value=number;
		document.modelApForm.submit();
		return true;
	}
}

if(navigator.appVersion.indexOf("AOL")==-1)
if(navigator.appVersion.indexOf("AOL 3.0")==-1)
if(navigator.appVersion.indexOf("AOL 4.0")==-1)
if(navigator.appVersion.indexOf("AOL 5.0")==-1)
if(navigator.appVersion.indexOf("AOL 6.0")==-1)
if(navigator.appName.indexOf("WebTV")==-1) {
}

function statesCheck() {

	if (document.repselect.user_country.value == "UNITED STATES")	{
		//show the list of states and none provinces list

		StateCellDescrip.style.display=""
		StateCell.style.display=""
		ProvinceCellDescrip.style.display="none"
		ProvinceCell.style.display="none"
	} else if (document.repselect.user_country.value == "CANADA")	{
		//show the list of provinces and none states list

		StateCellDescrip.style.display="none"
		StateCell.style.display="none"
		ProvinceCellDescrip.style.display=""
		ProvinceCell.style.display=""
	} else {
		// Otherwise none both

		StateCellDescrip.style.display="none"
		StateCell.style.display="none"
		ProvinceCellDescrip.style.display="none"
		ProvinceCell.style.display="none"
	}
}

function browserCheck(){
	if (navigator.appName == "Netscape"){
		document.repselect.browser.value = "NETSCAPE";
	}else if (navigator.appName == "IE"){
		document.repselect.browser.value = "IE";
	}else{
		document.repselect.browser.value = "navigator.appName";
	}
	return document.repselect.browser.value;
}

function jsCheck() {
	document.repselect.jsenabled.value = "true";
	return true;
}

function spawnWindow(name, location, _width, _height) {
	if (!name){
		name = "newWindow"
	}
	if (!_height){
		_height = screen.height
	}
	if (!_width){
		_width = screen.width
	}

	window.open(location, name, "left=0,top=0,screenX=0,screenY=0,toolbar=yes,location=yes,directories=no,scrollbars=yes,status=yes,menubar=yes,resizable=yes,width=" + _width + ",height=" + _height)
	return false;
}

function spawnSmallWindow(location) {
	myWidth = 600
	myHeight = 450
	number=Math.floor(Math.random()*69)
	window.open(location, number, "left=0,top=0,screenX=0,screenY=0,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes,width="+myWidth+",height="+myHeight+"")
	return false;
}

function spawnFullWindow(location) {
	myWidth = screen.width - 15
	myHeight = screen.height - 33
	number=Math.floor(Math.random()*69)
	window.open(location, number, "left=0,top=0,screenX=0,screenY=0,toolbar=no,location=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes,width="+myWidth+",height="+myHeight+"")
	return false;
}


function toTop() {
	self.scrollTo(0, 0)
}

function closeWindow(){
	window.close();
}

function submitForm(avalue){
	document.forms[avalue].submit();
}

function animateDelayed() {
	if (imageNum%2 ) {
			delay = 500
	} else {
			delay = 1500
	}
   //Wait a bit before putting up the next image
   setTimeout('animate("animation")', delay)
}

function animate(imageName) {
   document.images[imageName].src = theImages[imageNum].src
   imageNum++
   if(imageNum > 4) {
	  imageNum = 1
   }
   while ( ! theImages[imageNum].complete ) { ; }
	animateDelayed()
}

function redirectTo(form) {
	var myindex=form.serviceselector.selectedIndex

	if (myindex!=0) {
			top.location.href=(form.serviceselector.options[myindex].value)
	}
}

function IsEmailValid(FormName,ElemName){

////////////////////////////////////////////////////////////
// JavaScript Email Checking ...
////////////////////////////////////////////////////////////

	var EmailOk  = true
	var Temp     = document.forms[FormName].elements[ElemName]
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if ((AtSym < 1) ||                     // '@' cannot be in first position
		(Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		(Period == Length ) ||             // Must be atleast one valid char after '.'
		(Space  != -1))                    // No empty spaces permitted
	   {
		  EmailOk = false
		  	alert('Please enter a valid e-mail address!')
		  Temp.focus()
	   }
	return EmailOk
}

function IsTimeValid(FormName,ElemName){
	alert (FormName)
	alert (ElemName)
	// USAGE:  IsTimeValid("FormName","ElemName")
	var TimeOk  = true
	var Temp     = document.forms[FormName].elements[ElemName]
	var AtSym    = Temp.value.indexOf(':')
	var Colon   = Temp.value.lastIndexOf('0')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1

	if ((AtSym < 1) ||                     // ':' cannot be in first position
		(Colon == Length ) ||             // Must be atleast one valid char after ':'
		(Space  != -1))                    // No empty spaces permitted
	   {
		  TimeOk = false;
		  alert('Please enter a valid format (MM:ss)!');
		  Temp.focus();
	   }
	return TimeOk
}

function ignoreError() {
	return true;
}

////////////////////////////////////////////////////////////
// JavaScript Browser Detect...
////////////////////////////////////////////////////////////

isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;


////////////////////////////////////////////////////////////
// currency formatting
////////////////////////////////////////////////////////////
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) num = "0";
		cents = Math.floor((num*100+0.5)%100);
		num = Math.floor((num*100+0.5)/100).toString();
	if(cents < 10) cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
			return (num + '.' + cents);
}

function charCheck(string) {
var badExp = / ' \" /;
	
	/*if(string.value.length < 1) {
		alert("Please enter something first.");
		return false;
	}*/
	if(string.value.search(badExp) == -1) {
		/*if (confirm("You sure you want to add?")) {
			submitForm(formname)
			document.prj_add.submit();
		}*/
	}
	else {
		alert("Sorry, but the apostrophe ['] and quotes [\"] characters are not allowed!\n\nYou typed: "+ string);
		string.select();
		string.focus();
		return false;
	}
}

////////////////////////////////////////////////////////////
// running clock code...
////////////////////////////////////////////////////////////

var timer = null

function stop(){
	clearTimeout(timer)
}

function start(){
	var time = new Date()
	var hours = time.getHours()
	var minutes = time.getMinutes()
	minutes=((minutes < 10) ? "0" : "") + minutes
	var seconds = time.getSeconds()
	seconds=((seconds < 10) ? "0" : "") + seconds
	var clock = hours + ":" + minutes + ":" + seconds
	document.runningClock.display.value = clock
	timer = setTimeout("start()",1000)
}

function autoFillDates(form){
	var date1 = form.dateApplied;
	form.firstContact = date1;
	form.lastContact = date1;
	form.whenToCall = date1;
}
function printpage(){
	window.print();
}

function narrowOptions(myValue){

////////////////////////////////////////////////////////////
// hidden/visible select boxes code...
////////////////////////////////////////////////////////////



	//var choice = myValue.value;

	if (myValue == 'Abstract') {
		//alert ('---' + myValue + '---');	
		Abstract.style.visibility = 'visible';
		CDROM.style.visibility = 'hidden';
		Manuscript.style.visibility = 'hidden';
		Other.style.visibility = 'hidden';

	}else if (myValue == 'CDROM') {
		//alert ('---' + myValue + '---');
		Abstract.style.visibility = 'hidden';
		CDROM.style.visibility = 'visible';
		Manuscript.style.visibility = 'hidden';
		Other.style.visibility = 'hidden';

	}else if (myValue == 'Manuscript') {
		//alert ('---' + myValue + '---');
		CDROM.style.visibility = 'hidden';
		Abstract.style.visibility = 'hidden';
		Manuscript.style.visibility = 'visible';
		Other.style.visibility = 'hidden';

	}else if (myValue == 'Other') {
		//alert ('---' + myValue + '---');
		Abstract.style.visibility = 'hidden';
		CDROM.style.visibility = 'hidden';
		Manuscript.style.visibility = 'hidden';
		Other.style.visibility = 'visible';
	}else{
		Abstract.style.visibility = 'visible';
	}
}
