function ImgChange(LOC,IMAGE) {
     document.getElementById(LOC).src = IMAGE;
}

function swapTab2 (TAB) {
	if ( (TAB == 'options') && ($('options').style.display == 'none') ) {
		$('opt2').removeClassName('deactive');
		$('opt2').addClassName('active');
		$('opt1').addClassName('deactive');
		$('opt1').removeClassName('active');
		$('opt3').addClassName('deactive');
		$('opt3').removeClassName('active');
		$('options').style.display = '';
		$('standards').style.display = 'none';
		$('specs').style.display = 'none';
	} else if ( (TAB == 'standards') && ($('standards').style.display == 'none') ) {
		$('opt1').removeClassName('deactive');
		$('opt1').addClassName('active');
		$('opt2').addClassName('deactive');
		$('opt2').removeClassName('active');
		$('opt3').addClassName('deactive');
		$('opt3').removeClassName('active');
		$('options').style.display = 'none';
		$('standards').style.display = '';
		$('specs').style.display = 'none';
	} else if ( (TAB == 'specs') && ($('specs').style.display == 'none') ) {
		$('opt3').addClassName('active');
		$('opt3').removeClassName('deactive');
		$('opt1').removeClassName('active');
		$('opt1').addClassName('deactive');
		$('opt2').addClassName('deactive');
		$('opt2').removeClassName('active');
		$('options').style.display = 'none';
		$('standards').style.display = 'none';
		$('specs').style.display = '';
	}
	
}

function swapTab (TAB) {
	if ( (TAB == 'options') && ($('options').style.display == 'none') ) {
		$('opt2').removeClassName('deactive');
		$('opt2').addClassName('active');
		$('opt1').addClassName('deactive');
		$('opt1').removeClassName('active');
		$('options').style.display = '';
		$('standards').style.display = 'none';
	} else if ( (TAB == 'standards') && ($('standards').style.display == 'none') ) {
		$('opt1').removeClassName('deactive');
		$('opt1').addClassName('active');
		$('opt2').addClassName('deactive');
		$('opt2').removeClassName('active');
		$('options').style.display = 'none';
		$('standards').style.display = '';
	}
}

function Show_Stuff(ID) {
	if (document.getElementById(ID).style.display == "none")
		document.getElementById(ID).style.display = "";
	else
		document.getElementById(ID).style.display = "none";
}

function validateAddress(incoming) {
	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
		// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
		// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
		// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
		// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));
	var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/
		// index of -1 means "not found"
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) &&
		(email_regex.test(emailstring)) ) {
		  return true;
	} else {
		return false;
	}
}

function isBlank(s) {
	return (s == null || s == '');
}


function checkContact(form) {

	if ((form.email.value == "") || !validateAddress(form.email.value)) {
		alert( "You must specify a valid email address..." );
		form.email.value = "";
		form.email.focus();
		return false ;
	}
   
	if (form.code.value == "") {
		alert( "Please enter the CAPTCHA code..." );
		form.code.focus();
		return false;
	}

	return true;
}

function checkTestimonial (form) {
	
	if (form.content.value == "") {
		alert( "Please enter your testimonial..." );
		form.content.focus();
		return false;
	}
	
	if (form.by.value == "") {
		alert( "Please enter your name..." );
		form.by.focus();
		return false;
	}
	
	if (form.code.value == "") {
		alert( "Please enter the CAPTCHA code..." );
		form.code.focus();
		return false;
	}
	
	return true;
}


function validateCredit(form)
{
	var b = false;
	resetCredit(form);

	if ( isBlank(form.txtName.value) || isBlank(form.txtPhone1.value) || isBlank(form.txtPhone2.value) || isBlank(form.txtPhone3.value) || isBlank(form.txtDOBd.value) || isBlank(form.txtDOBm.value) || isBlank(form.txtDOBy.value) || isBlank(form.txtSIN.value) || isBlank(form.txtDLN.value) || isBlank(form.txtAddress.value) || isBlank(form.txtPostal.value) || isBlank(form.txtHowLong.value) || isBlank(form.txtOccupation.value) || isBlank(form.txtEmployer.value) || isBlank(form.txtWrkPhone1.value) || isBlank(form.txtWrkPhone2.value) || isBlank(form.txtWrkPhone3.value) || isBlank(form.txtWrkHowLong.value) || isBlank(form.txtWrkAddress.value) || isBlank(form.txtMonthlyIncome.value) || isBlank(form.txtYearlyIncome.value) || isBlank(form.txtFormCode.value))
	{

		alert("Please complete ALL fields in the form.");
		if (isBlank(form.txtName.value))
			document.getElementById("txtName").style.color = "red";
		if (isBlank(form.txtPhone1.value) || isBlank(form.txtPhone2.value) || isBlank(form.txtPhone3.value))
			document.getElementById("txtPhone").style.color = "red";
		if (isBlank(form.txtDOBd.value) || isBlank(form.txtDOBm.value) || isBlank(form.txtDOBy.value))
			document.getElementById("txtDOB").style.color = "red";
		if (isBlank(form.txtSIN.value))
			document.getElementById("txtSIN").style.color = "red";
		if (isBlank(form.txtDLN.value))
			document.getElementById("txtDLN").style.color = "red";
		if (isBlank(form.txtAddress.value))
			document.getElementById("txtAddress").style.color = "red";
		if (isBlank(form.txtMunicipality.value))
			document.getElementById("txtMunicipality").style.color = "red";
		if (isBlank(form.txtPostal.value))
			document.getElementById("txtPostal").style.color = "red";

		if (isBlank(form.txtOccupation.value))
			document.getElementById("txtOccupation").style.color = "red";
		if (isBlank(form.txtEmployer.value))
			document.getElementById("txtEmployer").style.color = "red";
		if (isBlank(form.txtWrkPhone1.value) || isBlank(form.txtWrkPhone2.value) || isBlank(form.txtWrkPhone3.value))
			document.getElementById("txtWrkPhone").style.color = "red";
		if (isBlank(form.txtWrkAddress.value))
			document.getElementById("txtWrkAddress").style.color = "red";
		if (isBlank(form.txtMonthlyIncome.value))
			document.getElementById("txtMonthlyIncome").style.color = "red";
		if (isBlank(form.txtYearlyIncome.value))
			document.getElementById("txtYearlyIncome").style.color = "red";
		if (isBlank(form.txtFormCode.value))
			document.getElementById("txtFormCode").style.color = "red";

		return false;
	}
	else
	{
		b = window.confirm("Are you sure the information entered is correct?");
		if (b)
			return true;
		else
			return false;
	}
}

function resetCredit(f)
{
	fld = new Array();

	fld[fld.length] = 'txtName';
	fld[fld.length] = 'txtPhone';
	fld[fld.length] = 'txtDOB';
	fld[fld.length] = 'txtSIN';
	fld[fld.length] = 'txtDLN';

	fld[fld.length] = 'txtAddress';
	fld[fld.length] = 'txtMunicipality';
	fld[fld.length] = 'txtPostal';
	fld[fld.length] = 'txtOccupation';
	fld[fld.length] = 'txtEmployer';
	fld[fld.length] = 'txtWrkPhone';
	fld[fld.length] = 'txtWrkAddress';
	fld[fld.length] = 'txtMonthlyIncome';
	fld[fld.length] = 'txtYearlyIncome';
	fld[fld.length] = 'txtFormCode';

	for(i=0;i<fld.length;i++)
	{
		document.getElementById(fld[i]).style.color = "#000";
	}
}


