var jsimgheight = 770;
if ((jsimgheight + 50) < window.screen.availHeight) {
	var pophigh = jsimgheight + 80;
} else {
	var pophigh = window.screen.availHeight - 30;
}

function ValidateCSLS() {
  if (document.csls.zip.value == "") {
    document.csls.zip.focus();
    return (false);
  }
  if (document.csls.zip.value.length > 5) {
    document.csls.zip.focus();
    return (false);
  }
  return (true);
}

// START EMAIL VALIDATION
function validateEmail(emailValue, emailName) {
	var emleng = emailValue.length;             // entire length
	var fchar = emailValue.charAt(0);           // first character
	var lbchar = emailValue.charAt(emleng - 1); // last character
// if field contain any character from invalidChars, pop-up message will appear
	if (emailValue != "") {
		var invalidChars="/:,;<> "
		for(i=0;i<invalidChars.length;i++) {
			badChar = invalidChars.charAt(i);
			if(emailValue.indexOf(badChar,0) > -1) {
				alert("Your email address contains an invalid character");
				emailName.focus();
				emailName.select();
				return false;
			}
		}
// checks if "@" is the first character of an email address
		if(fchar == "@") {
			alert("The first character in your email address cannot be \"@\"");
			emailName.focus();
			emailName.select();
			return false;
		}
// checks for "@"
		var atPos = emailValue.indexOf("@",1);
		if(atPos == -1) {
			alert("Your email address does not contain \"@\"");
			emailName.focus();
			emailName.select();
			return false;
		}
// checks for multiple "@"
		for(i=atPos+1;i<emailValue.length;i++) {
			if (emailValue.charAt(i) == "@") {
				alert("Your email address contains more than one \"@\"");
				emailName.focus();
				emailName.select();
				return false;
			}
		}
// checks for "."
		var periodPos = emailValue.indexOf(".",1);
		if(periodPos == -1) {
			alert("Your email address does not contain a '.'");
			emailName.focus();
			emailName.select();
			return false;
		}
// checks if "." follows right after "@"
		if(emailValue.charAt(atPos+1) == ".") {
			alert("A period cannot be placed right after \"@\"");
			emailName.focus();
			emailName.select();
			return false;
		}
		var sPeriodFound = "0";
// checks to be sure that there is at least one period after "@"
		for(i=atPos;i<emailValue.length;i++) {
			if(emailValue.charAt(i) == ".") {
				sPeriodFound = "1";
			}
			if (i == emailValue.length-1 && sPeriodFound == "0") {
				alert('A period is missing after the \"@\"');
				emailName.focus();
				emailName.select();
				return false;
			}
		}
// assign position for period after "@"
		var periodPosAfterAt = emailValue.indexOf(".",atPos)
// checks for the last 2 digits of an email address
		if(periodPosAfterAt+3 > emailValue.length) {
			alert("Your email address is not complete");
			emailName.focus();
			emailName.select();
			return false;
		}
    }
}
// END EMAIL VALIDATION
	
function imgOver(moe) {
	if (document.images) {
		document[moe].src = "./images/site/" + moe + "_1.gif";
	}
}

function imgOut(foe) {
	if (document.images) {
		document[foe].src = "./images/site/" + foe + "_0.gif";
	}
}

function imgOutOn(dude) {
	if (document.images) {
		document[dude].src = "./images/site/" + dude + "_2.gif";
	}
}

function poptitle(file,popwidth,popheight)
{
  var popme = "http://www.imagecomics.com/cgi-bin/poptitle.cgi?sub2=" + file;
	newwindow = window.open(popme,'newwindow','location=no,resizable=no,status=no,titlebar=no,directories=no,toolbar=no,menubar=no,scrollbars=1,status=no,width=' + popwidth + ',height=' + popheight);
	newwindow.focus();
	return;
}

function poppreview(file,page,popwidth,popheight,dim,cover,doubles)
{
  var popme = "http://www.imagecomics.com/cgi-bin/poppreview.cgi?sub2=" + file + "&page=" + page + "&dim=" + dim + "&cover=" + cover + "&doubles=" + doubles;
	newwindow = window.open(popme,'newwindow','location=no,resizable=yes,status=no,titlebar=no,directories=no,toolbar=no,menubar=no,scrollbars=yes,status=no,width=' + popwidth + ',height=' + popheight);
	newwindow.focus();
	return;
}

function popfile(file,popwidth,popheight)
{
  var popme = file;
	newwindow = window.open(popme,'newwindow','location=no,resizable=yes,status=no,titlebar=no,directories=no,toolbar=no,menubar=no,scrollbars=yes,status=no,width=' + popwidth + ',height=' + popheight);
	newwindow.focus();
	return;
}

function popfull(file,popwidth)
{
  var popme = file;
	newwindow = window.open(popme,'newwindow','location=no,resizable=yes,status=no,titlebar=no,directories=no,toolbar=no,menubar=no,scrollbars=yes,status=no,width=' + popwidth + ',height=' + window.screen.availHeight);
	newwindow.focus();
	return;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

var preloadFlag = false;
function preloadImages(arg) {
	if (document.images) {
		loadanother = newImage("arg");
		preloadFlag = true;
	}
}
