function FramesOkay() {
	var AppName= navigator.appName;
	var AppVersion = navigator.appVersion;
	var MajorVer = parseInt(AppVersion.substring(0, 1));
	var SubVer = parseInt(AppVersion.substring(2,4));
	var ShowVer = MajorVer + "." + SubVer;
	if ( (AppName == "Netscape") && ( MajorVer >= 3 ) ) return 1;
	if ( (AppName == "Microsoft Internet Explorer") && (MajorVer >= 4) ) return 1;
	if ( (AppName == "Microsoft Internet Explorer") && (MajorVer >= 3) && (SubVer >= 2) ) return 1;
	return 0;
}

function loadup() {
    if (FramesOkay()) {
	if (parent.frames.length <= 3) {
		alert("Please bookmark us at " + location.host + "  --Thanks!");
		window.location.href="../default.htm";
	} else {
		return (loadMenus());
	}
    }	
}




function lister(phrase) {
		phrase =  "    [x] " + phrase + "    ";
		return (phrase);
}

function makeLetter(Extra) {
	var DoSub = 1;
	var thisform = document.forms[0];
	var LetterSubject = thisform.FormName.value;
	var CName = thisform.ClientName.value ;
	var CEMail = thisform.EMail.value;
	var CPhone = thisform.Phone.value;
	var CFax = thisform.Fax.value;
	var ViaFax = (false);
	var ViaPhone = (false);
	var ViaEMail = (false);
	
	if (thisform.ReplyByFax.checked) {
		ViaFax = (true) ;
	}
	if (thisform.ReplyByPhone.checked) {
		ViaPhone = (true);
	}
	if (thisform.ReplyByEMail.checked) {
		ViaEMail = (true);
	}
//set check boxes in case user forgot (if all clear)
	var GoodMatches = 0;
	if ((CFax.length >= 6) & (ViaFax == (true))) {
		GoodMatches = GoodMatches + 1;
	}
	if ((CPhone.length >= 6) & (ViaPhone == (true))) {
		GoodMatches = GoodMatches + 1;
	}
	if ((CEMail.length >= 6) & (ViaEMail == (true))) {
		GoodMatches = GoodMatches + 1;
	}

	if ((GoodMatches == 0)|((ViaFax == (false)) & (ViaPhone == (false))& (ViaEMail == (false)))) {	
		if ((CPhone.length >= 7)) {
			ViaPhone = (true);
		}	
		if ((CEMail.length >= 7)) {
			ViaEMail = (true);
		}	
		if ((CFax.length >= 7)) {
			ViaFax = (true);
		}	
	}

//If contact box checked but no corresponding address or number...
	var contactprobbies = "";
	
	if ((ViaFax == (true)) & (CFax.length <= 6)) {
		contactprobbies = contactprobbies + "If you wish for us to contact you via Fax, please provide a fax number.  ";
		thisform.Fax.focus();

		ViaFax = (false);
	}
	if ((ViaPhone == (true)) & (CPhone.length <= 6)) {
		contactprobbies = contactprobbies + "If you wish for us to contact you by telephone, please provide a phone number.  ";
		thisform.Phone.focus();
		ViaPhone = (false);
	}	
	if ((ViaEMail == (true)) & (CEMail.length <= 6)) {
		contactprobbies = contactprobbies + "If you wish for us send you e-mail, please provide an e-mail address.  ";
		ViaEMail = (false);
		thisform.EMail.focus();

	}
	if ((ViaEMail == (true)) & (CEMail.length > 6)) {
		if (CEMail.indexOf("@") < 1) {
			contactprobbies = contactprobbies + "Please provide an e-mail address which includes the '@' symbol.  ";
			ViaEMail = (false);
			thisform.EMail.focus();
		}
		if (CEMail.indexOf(".") < 1) {
			contactprobbies = contactprobbies + "Please provide an e-mail address which includes the dot '.' symbol.";
			ViaEMail = (false);
			thisform.EMail.focus();
		}

	}

	if (contactprobbies.length >= 1) {
		contactprobbies = contactprobbies + "(please use the back button now on your web browser to change -- thanks!)";
	}

// now write lines to confirm how to contact
	var HowContact = "";
	var HowFax = "";
	var HowPhone = "";
	var HowEMail = "";
	var Twigger = "";
	var ReplyHow = "";
	if (ViaFax == (true)) {
		HowFax = "send you a fax";
		Twigger = "F";
	}
	if (ViaPhone == (true)) {
		HowPhone = "telephone you";
		Twigger = Twigger + "T";
	}
	if (ViaEMail == (true)) {
		HowEMail = "send you an e-mail message";
		Twigger = Twigger + "E";
	}
	HowContact = "We will ";
	if (Twigger == "F") {
		HowContact = HowContact + HowFax;
		ReplyHow = "fax on " + CFax + ".";
	}
	if (Twigger == "FT") {
		HowContact = HowContact + HowPhone + " or " + HowFax;
		ReplyHow = "telephone on " + CPhone + " or by fax on " + CFax + ".";
	}
	if (Twigger == "FE") {
		HowContact = HowContact + HowFax + " and " + HowEMail;
		ReplyHow = "fax on " + CFax + " or by e-mail on " + CEMail + ".";
	}
	if (Twigger == "FTE") {
		HowContact = HowContact + HowFax + " or " + HowPhone + ", as well as " + HowEMail;
		ReplyHow = "telephone on " + CPhone + ", by fax on " + CFax + " as well as by e-mail on " + CEMail + ".";
	}
	if (Twigger == "TE") {
		HowContact = HowContact + HowPhone + " and " + HowEMail;
		ReplyHow = "telephone on " + CPhone + " and by e-mail on " + CEMail + ".";
	}	
	if (Twigger == "E") {
		HowContact = HowContact + HowEMail;
		ReplyHow = "e-mail on " + CEMail + ".";
	}
	if (Twigger == "T") {
		HowContact = HowContact + HowPhone;
		ReplyHow = "telephone on " + CPhone + ".";
	}
	var thanktext = "Thank you for your " + LetterSubject + " enquiry " + CName + "!  "
	
	if (Twigger == "") {
		DoSub = 0;
		HowContact = "Please provide us with a contact number or e-mail address so way may contact you";

		thisform.EMail.focus();

		ReplyHow = "(The client did not specify how they preferred to be contacted)";
		contactprobbies = " ";
		thanktext = "Please review your " + LetterSubject + " form " + CName + "!       ";
	} else {
		ReplyHow = "The client prefers to be contacted by " + ReplyHow;
		//now include extra contact numbers not preferred by client
		var ExtraContact = "";
		if ((Twigger.indexOf("T") == -1) & (CPhone.length >=6)) {
			ExtraContact = ExtraContact + "phone on " + CPhone + ", ";	
		}
		if ((Twigger.indexOf("F") == -1) & (CFax.length >=6)) {
			ExtraContact = ExtraContact + "Fax on " + CFax + ", ";	
		}
		if ((Twigger.indexOf("E") == -1) & (CEMail.length >=6)) {
			ExtraContact = ExtraContact + "e-mail on " + CEMail + ", ";	
		}
		if (ExtraContact.length >= 1) {
			ExtraContact = ExtraContact.substring(0,ExtraContact.length-2);
				ReplyHow = ReplyHow + "  The client may also be contacted by " + ExtraContact + ".  ";
		    }
	}
	HowContact = HowContact + " with the " + LetterSubject + " confirmation and information you requested soon.  "
	var ReplyTo = "The client, " + CName + ", requested " + LetterSubject + " information: " + Extra;
	var LtrSent = " The following reply letter was sent to them online:  '" 
	if (CName == "Your Name") {
		contactprobbies = contactprobbies + "  Please supply us with a name so we may contact you. ";
		thisform.ClientName.focus();
		ReplyTo = "The client name was not specified, and the client was prompted to provide a name";
		LtrSent = " Please Retry! ";
		thanktext = " (form incomplete) " ;
		HowContact = "";
		ReplyHow = "";
		DoSub = 0;
	}
	var NoMsg = 0;
	var credit = (false);
	//alert('total is ' + thisform.Total.value + ', ma len is ' + thisform.MailingAddress.value.length);
	if ((thisform.Total.value > 0) && (thisform.MailingAddress.value.length < 7)) {
		alert("Please provide a mailing address for the product(s) you ordered.  Thanks!");
		thisform.MailingAddress.focus();
		DoSub = 0;
		NoMsg = 1;
	}
	PayHow = thisform.PayHow.value;
	if (PayHow == 'CreditCard') {
		credit = (true);
	}
	if (credit == (true)) {
		if (thisform.CreditCard_Name.value.length < 3) {
			alert("Please provide a credit card name if you're paying by credit card.  Thanks!");
			thisform.CreditCard_Name.focus();
			DoSub = 0;
			NoMsg = 1;
		} else {
			if (thisform.CreditCard_Number.value.length < 12) {
				alert("Please provide a credit card number if you're paying by credit card.  Thanks!");
				thisform.CreditCard_Number.focus();
				DoSub = 0;
				NoMsg = 1;
			}
		}
		if (thisform.CreditCard_Expiry.value.length < 7) {
			if (thisform.CreditCard_Expiry.value.length != 5) {
				alert("Please provide an expiry date in the format MM/YYYY.  Thanks!");
				thisform.CreditCard_Expiry.focus();
				DoSub = 0;
				NoMsg = 1;
			}
		}
	} else {
		if (PayHow == 'Cheque') {
			alert("Please mail your cheque today (address on the following screen).   Thanks very much for the order!");
		} else {
			if (Extra == "INFO") {
				// if this was from the info form, and JUST INFO was checked;
				if (thisform.Total.value > 0) {
					alert("Please select a payment option for the items you have selected.  Thanks!");
					thisform.CreditCard_Name.focus();
					DoSub = 0;
					NoMsg = 1;
				}
			}
		}
		if ((DoSub == 1) && (NoMsg == 0)) {
			thisform.CreditCard_Type.value = "";
			thisform.CreditCard_Expiry.value = "";
			thisform.CreditCard_Name.value = "";
			thisform.CreditCard_Number.value = "";
		}

	}
	thisform.APhrase.value = "- " + LetterSubject + " Enquiry from " + CName + "  -----";
	thisform.BPhrase.value = "  " + ReplyTo;
	thisform.CPhrase.value = "  " + ReplyHow;

	thisform.ReplyBody.value = ("  " + thanktext + HowContact + contactprobbies);

	thisform.DPhrase.value = ("  " + LtrSent + thisform.ReplyBody.value + "'      ");
	if (CEMail.length >= 5) {
		thisform.EPhrase.value = CEMail;
		thisform.CPhrase.value = thisform.CPhrase.value + " (Use the Reply Button in your e-mail program to send mail to " + CName + " on " + CEMail + ")"
	} else {
		thisform.EPhrase.value = "help@siteware.com.au";
	}
	if (thisform.ShowMore.value == "YES") {
		thisform.EPhrase2.value = " _____ The client is also interested in the following _____ ";
	}
	if (DoSub == 1) {
		alert('Please note that your deposit is not secured unless accompanied by a waiver form.  Please print out and send the waiver form today!  (There will be a link on the next booking page if you have not done so already)');
	 	thisform.submit();
	} else {
		if (NoMsg = 0) { alert(thisform.ReplyBody.value); }
	}
}

function swtch(num, imgname) {
    if (FramesOkay()) {
	if (parent.frames[3].document.title != imgname) {
		document[imgname].src = img[num].src;
	}
    }
}
