//  the first parameter passed must be the full image path up to and including the last '/'
//  after that list all images with extension (.gif, .jpg) and they will be cached

function cacheImgs(){
	cached = new Array();
	for (var i=1;i<arguments.length;i++){
		cached[i]=new Image();
		cached[i].src = arguments[0] + arguments[i];
	}
}
	

//  for rollovers - the first parameter passed should be the name of the image followed by the rollover image with extension (.gif, .jpg)   

function imgSwap(nom,pik){
	var end_path=document[nom].src.lastIndexOf('/') + 1;
	var image_path=document[nom].src.substring(0,end_path);
	document[nom].src = image_path + pik;
}


function validEmail(e){
	invalidChars = " /:;,";
	if(e == "")return false;
	for(i=0;i<invalidChars.length;i++){
		badChar = invalidChars.charAt(i);
		if(e.indexOf(badChar,0) > -1)return false;
	}
	atPos = e.indexOf("@",1);
	if(atPos == -1)return false;
	if(e.indexOf("@",atPos+1) > -1)return false;
	periodPos = e.indexOf(".",atPos);
	if(periodPos == -1)return false;
	if(periodPos + 3 > e.length)return false;
	return true;
}

function isblank(s){
	for(var i=0; i<s.length; i++){
		var c = s.charAt(i);
		if((c != ' ') && (c != '\n') && (c != '')){return false}
	}
	return true;
}

function submitForm(frm){
	var f = frm;
	for(i=0;i<f.elements.length;i++){
		if(f.elements[i].type != "hidden" && (f.elements[i].value == "" || f.elements[i].value == null || isblank(f.elements[i].value))){
			alert("You can't leave '" + f.elements[i].name + "' blank.");
			f.elements[i].value = "";
			f.elements[i].focus();
			return false;
		}
	}
	if(f.email && !validEmail(f.email.value)){
		alert("Your email address is not validating. Please try again.");
		f.email.focus();
		return false;
	}
	return true;
}

function validateForm(frm){
	var f = frm;
	for(i=0;i<f.elements.length;i++){
		if(((f.elements[i].type == "text") || (f.elements[i].type == "textarea")) && !f.elements[i].optional)
			if(f.elements[i].value == "" || f.elements[i].value == null || isblank(f.elements[i].value)){
				alert("You can't leave '" + f.elements[i].name + "' blank.");
				f.elements[i].value = "";
				f.elements[i].focus();
				return false;
			}
	}
	return true;
}


