

//
// Set decimal places
//
function rnd(number,decplaces) {
// rounds number to 'decplaces' decimal places, defaults to 2
decplaces = (!decplaces ? 2 : decplaces);
number = (Math.round(number*Math.pow(10,decplaces))/Math.pow(10,decplaces));
return number;
}


//
//Add Zeros for JavaScript
//

function AddZeros(number) {
	var szero = '0'
	var dzero ='.00'
	
	if ((number - parseInt(number)) == 0)	{
		number = (number + dzero);
//		alert(number + ' + ' + dzero + '  = ' + number);
		}
	else {
			if (((number*10) - parseInt(number*10)) == 0)	
			{
				number = (number + szero);
//		alert(number + ' + ' + szero + '  = ' + number);
			}
			else {
			number = parseInt(number*100) / 100;
				}
		}
	
	return number;

}
//
// Set decimal places
//

	function format(expr)	
	{
		var decplaces = 2
		var str = ("" + Math.round(eval(expr) * Math.pow(10,decplaces)));
	
		While (str.length <= decplaces) 
		{
		str = "0" + str;
		
		}
	
	var decpoint = str.length - decplaces;
	
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
	
	}

//
// convert number to dollar value using function decimalPoint
//

//function dollarize(expr){
//	return "$" + decimalPoint(expr,2)
//	}
	
	
//
// Get radio variable
//

function getUsage(form) {
	for (var i = 0; i< form.usage.length; i++)	{
		if (form.usage[i].checked)	{
			break
		}
	}
	var use = form.usage[i].value
}


		
//
//Thumbnail caption
//

function showMsg(text){

	window.status = text;

	return true;

	}
//
//Large image copright notice
//

function ImageClick(){

	alert('For more information or to download this image, complete the form below or contact Thomas Bachand at 510-547-8622 or infoweb@thomasbachand.com . All content on this site, including photography, ©Thomas Bachand.  All rights reserved.');

	return false;

	}


//
//Button change on submit
//

function submitForm(s)  {
s.value = "Thank You";
return true;
}

//
//Add address To Sendmail
//


function emailAdd() {
	var email = usermail + ",order@thomasbachand.com"
	}


	
function emailCheck(form)	{
	if (form.email.value=='email updates')	{
		alert('To subscribe to our email notification list, please type your email address into the Email Updates space and click subscribe. Your email address will not be shared with anyone. Subscribers will periodically recieve email notifications of our new projects and site updates.  To receive mailings, complete the form on our contact page.  Thank you for subscribing.');
	}	
	else {return(form.s.value='Thanks',form.u.value=window.location.href)
		}
}


//
// check email
//

function isEmail (s){

var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz";
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var validDomainNameChars = digits + uppercaseLetters + lowercaseLetters + "-_.";
var whitespace = " \t\n\r";
var defaultEmptyOK = false;

    if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
    if (isWhitespace(s)) return false;
    var atloc = 0;
    var i = 1;
    var sLength = s.length;
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++ }
    if ((i >= sLength) || (s.charAt(i) != "@")) {alert (s + "  is not a valid email address"); return false}
//    if ((i >= sLength) || (s.charAt(i) != "@")) {alert ("no @ sign"); return false}
    else atloc = i;
    j = i+1;
    i += 1;
    while ((j < sLength) && (validDomainNameChars.indexOf(s.charAt(j)) != -1))
    { j++ }
    if (j < sLength) {alert(s + "  is not a valid email address"); return false};
//    if (j < sLength) {alert("invalid character in domain name: "+s.charAt(j)); return false};
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++ }
    if (i == sLength) {alert(s + "  is not a valid email address"); return false}
//    if (i == sLength) {alert("no . in domain name"); return false}
    if (i == (atloc +1)) {alert(s + "  is not a valid email address"); return false}
//    if (i == (atloc +1)) {alert("not enough space between @ and ."); return false}
    k = atloc+1;
    while (k < sLength){
      if ((s.charAt(k) == ".") && (s.charAt(k+1) == ".")) {alert(s + "  is not a valid email address"); return false}
//      if ((s.charAt(k) == ".") && (s.charAt(k+1) == ".")) {alert("too many .'s"); return false}
      k++
    }
    l = sLength;
    while ((i < sLength -2) && (l != i) && (s.charAt(l) != "."))
    { l = l-1 }
    if ((i >= sLength - 2) || (s.charAt(i) != ".") || (l >= sLength - 2)) {alert(s + "  is not a valid email address"); return false}
//    if ((i >= sLength - 2) || (s.charAt(i) != ".") || (l >= sLength - 2)) {alert("not enough chars after ."); return false}
    else return true;


function isEmpty(s) {
    return ((s == null) || (s.length == 0))
}

function isWhitespace(s) {
    var i;

    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false; // not whitespace
    }
    return true;
}

}

//
//Image order/download form
//


//
// HEADERS
//



//
//STEAMING MULE PAGE STRUCTURE
//
//Index.html
function page1Steaming(subject) {
document.write("<div id='banner'>");
document.write("	<img src='images/smBannerMule.gif' width='689' height='100'> ");
document.write("</div> ");
document.write("<div id='navigation'> ");
document.write("	<ul id='nav1'> ");
document.write("		<li> ");
document.write("			<a class='first' href='index.html'>home</a> ");
document.write("		</li> ");
document.write("		<li class='spacer'> ");
document.write("			:: ");
document.write("		</li> ");
document.write("		<li> ");
document.write("			<a href='services.html'>services</a> ");
document.write("		</li> ");
document.write("		<li class='spacer'> ");
document.write("			:: ");
document.write("		</li> ");
document.write("		<li> ");
document.write("			<a href='clients.html'>clients</a> ");
document.write("		</li> ");
document.write("		<li class='spacer'> ");
document.write("			:: ");
document.write("		</li> ");
document.write("		<li> ");
document.write("			<a href='contact.html'>contact</a> ");
document.write("		</li> ");
document.write("	</ul> ");
document.write("</div> ");
				}


function page3Steaming(subject) {
document.write("<BR CLEAR=ALL>");
document.write("<CENTER>web design &amp; development by Thomas Bachand</CENTER>");
document.write("<BR><BR>");
				}

//
//STEAMING MULE SubPAGE STRUCTURE
//

function subpage1Steaming(subject) {
document.write("<div id='banner'>");
document.write("	<img src='../images/smBannerMule.gif' alt='' width='689' height='100'> ");
document.write("</div> ");
document.write("<div id='navigation'> ");
document.write("	<ul id='nav1'> ");
document.write("		<li> ");
document.write("			<a class='first' href='../index.html'>home</a> ");
document.write("		</li> ");
document.write("		<li class='spacer'> ");
document.write("			:: ");
document.write("		</li> ");
document.write("		<li> ");
document.write("			<a href='../services.html'>services</a> ");
document.write("		</li> ");
document.write("		<li class='spacer'> ");
document.write("			:: ");
document.write("		</li> ");
document.write("		<li> ");
document.write("			<a href='../clients.html'>clients</a> ");
document.write("		</li> ");
document.write("		<li class='spacer'> ");
document.write("			:: ");
document.write("		</li> ");
document.write("		<li> ");
document.write("			<a href='../contact.html'>contact</a> ");
document.write("		</li> ");
document.write("	</ul> ");
document.write("</div> ");
				}

function subpage3Steaming(subject) {
document.write("<BR CLEAR=ALL>");
document.write("<CENTER><A HREF=\"http://www.thomasbachand.com/\" TARGET=\"_blank\">web design &amp; development by Thomas ");
document.write("Bachand</A> </CENTER>");
document.write("<BR><BR><BR><BR><BR><BR>");
				}

//


