var ns4=(document.layers)?true:false;
var ie4up=(document.all)?true:false;
var ns5up=(document.getElementById && !ie4up)?true:false;

function cacheImgs(){
	cached = new Array();
	for (var i=1;i<arguments.length;i++){
		cached[i]=new Image();
		cached[i].src = arguments[0] + arguments[i];
	}
}
	
function imgSwap(nom,pik){
	var end_path;
	var image_path;
	end_path=document[nom].src.lastIndexOf('/') + 1;
	image_path=document[nom].src.substring(0,end_path);
	document[nom].src = image_path + pik;
}

function validateCCForm(){
	var cc_errors = new Array(2);
	var are_errors = 0;
	
	var cc_number = document.forms["Form1"]["cardnumber"].value;
	var cc_first_digit = cc_number.substring(0, 1);
	if (cc_first_digit != '4' && cc_first_digit != '5'){
		cc_errors[are_errors] = "Please enter a valid Visa or MasterCard number";
		are_errors++;
	}
	
	var phone_number = document.forms["Form1"]["phone"].value;
	phone_number = phone_number.replace(/[^0-9]/g,'');
	if (phone_number.length != 10){
		if (phone_number.length == 7){
			cc_errors[are_errors] = "Please enter an area code";
			are_errors++;
		}
		else {
			cc_errors[are_errors] = "Please enter a valid phone number (10 digits)";
			are_errors++;
		}
	}
	
	if (are_errors > 0){
		for (each_error in cc_errors){
			alert(cc_errors[each_error]);
		}
		return false;
	}
	else {
		return true;
	}
}
