/* NAVIGATION BUTTONS */


	////////// IMAGE SWAPPING SCRIPT //////////

	if (document.images) {
		relPath = "resources/gifs/interface/"
		photoPath = "resources/gifs/photos/"

		imag = new Array();

		imag[0] = relPath + "author.gif";
		imag[1] = relPath + "author-o.gif";
		imag[2] = relPath + "author-d.gif";
		imag[3] = relPath + "excerpts.gif";
		imag[4] = relPath + "excerpts-o.gif";
		imag[5] = relPath + "excerpts-d.gif";
		imag[6] = relPath + "home.gif";
		imag[7] = relPath + "home-o.gif";
		imag[8] = relPath + "home-d.gif";
		imag[9] = relPath + "order.gif";
		imag[10] = relPath + "order-o.gif";
		imag[11] = relPath + "order-d.gif";
		imag[12] = relPath + "photos.gif";
		imag[13] = relPath + "photos-o.gif";
		imag[14] = relPath + "photos-d.gif";
		imag[15] = relPath + "testimonials.gif";
		imag[16] = relPath + "testimonials-o.gif";
		imag[17] = relPath + "testimonials-d.gif";
		imag[18] = relPath + "friends.gif";
		imag[19] = relPath + "friends-o.gif";
		imag[20] = relPath + "friends-d.gif";
		imag[21] = relPath + "videos.gif";
		imag[22] = relPath + "videos-o.gif";
		imag[23] = relPath + "videos-d.gif";


		imag[50] = photoPath + "alycia-tb.jpg"
		imag[51] = photoPath + "alycia-tbo.jpg"
		imag[52] = photoPath + "at_ease-tb.jpg"
		imag[53] = photoPath + "at_ease-tbo.jpg"
		imag[54] = photoPath + "eben-tb.jpg"
		imag[55] = photoPath + "eben-tbo.jpg"
		imag[56] = photoPath + "equestrian-tb.jpg"
		imag[57] = photoPath + "equestrian-tbo.jpg"
		imag[58] = photoPath + "jillian-tb.jpg"
		imag[59] = photoPath + "jillian-tbo.jpg"
		imag[60] = photoPath + "little_lauren-tb.jpg"
		imag[61] = photoPath + "little_lauren-tbo.jpg"
		imag[62] = photoPath + "luke-tb.jpg"
		imag[63] = photoPath + "luke-tbo.jpg"
		imag[64] = photoPath + "maiden-tb.jpg"
		imag[65] = photoPath + "maiden-tbo.jpg"
		imag[66] = photoPath + "true_love-tb.jpg"
		imag[67] = photoPath + "true_love-tbo.jpg"

		im = new Array();
		for (var i = 0; i < imag.length; i++) {
			im[i] = new Image; im[i].src = imag[i];
			}
		}

	function swapImage(imgName, num) {
		if (document.images && imgName) {
			imgName.src = im[num].src;
			}

		return;
		}


/* MAIL POPUP */

function mailto() {

	var theMail = "mail.html";
	var theTitle = "Contact Twombly Publishing";
	var mailAttributes = "width=600,height=450";

	window.open(theMail,"", mailAttributes);
	return false;
	}


/* CALCULATE THE SHOPPING CART */

function calculateTax() {
	var myForm = document.getElementsByTagName("input");
	var subTotal = myForm[0].value;
	var taxable = myForm[1].checked;
	var shipping = myForm[3].value;

	subTotal = parseFloat(subTotal);	// string to number

	if (taxable == true) {
		var theTax = subTotal * .0625;
		theTax = parseFloat(theTax);	// string to number
		} else {
		var theTax = 0;
		}

	shipping = parseFloat(shipping); 	// string to number
	var theTotal = subTotal + theTax + shipping;


	// FIX FORMAT
	subTotal = Math.round(subTotal * 100)/100;
	shipping = Math.round(shipping * 100)/100;
	theTax = Math.round(theTax * 100)/100;
	theTotal = Math.round(theTotal * 100)/100;

	myForm[2].value = theTax;
	myForm[4].value = theTotal;
	myForm[9].value = theTotal;


	}

function calculateTotal(cart) {
	var myForm = document.getElementsByTagName("input");
	var taxable = myForm[1].checked;

	theVal = cart.value;
	subTotal = theVal * 16.99;


	if (taxable == true) {
		var theTax = subTotal * .05;
		theTax = parseFloat(theTax);	// string to number
		} else {
		var theTax = 0;
		}

	if (theVal == 1) {
		var shipping = 4.00;
		} else {
		var shipping = (theVal * 2) + 2;
		}

	shipping = parseFloat(shipping); 	// string to number
	var theTotal = subTotal + theTax + shipping;

	// FIX FORMAT
	theTotal = Math.round(theTotal * 100)/100;
	subTotal = Math.round(subTotal * 100)/100;
	shipping = Math.round(shipping * 100)/100;
	theTax = Math.round(theTax * 100)/100;


	// APPLY TO THE FORM
	myForm[0].value = subTotal;
	myForm[2].value = theTax;
	myForm[3].value = shipping;
	myForm[4].value = theTotal;
	myForm[9].value = theTotal;

//	alert (theTotal)

	return false;
	}

// SHOW PICTURE IN NEW WINDOW


function showPic(name, width, height) {
	var thePic = name;
	var theWidth = width;
	var theHeight = height;

	var thePicPath = "resources/gifs/photos/" + thePic + ".jpg";
	var theAttributes = "width=" + theWidth + ",height=" + theHeight + ",scrollbars=auto,status=no,toolbar=no";

	picWin = window.open(thePicPath, thePic, theAttributes);
	return false;
	}




/* ASSIGN ADDITIONAL STYLESHEET FOR IE */

		if (navigator.appName.indexOf('Microsoft Internet Explorer') != -1) {
			// IE
			document.write ('<link rel="stylesheet" href="resources/css/winIE.css" type="text/css">')
			}






// =================================== //
// VIDEO GALLERY -- load the gallery
// ================================= //

function loadGallery(thePage) {

	var thePage = thePage;

	if (thePage == "gallery") {
		theURL = "http://www.twomblypublishing.com/resources/video-gallery.txt";
		} else {
		theURL = "http://www.twomblypublishing.com/resources/video/" + thePage;
		}




	// TEST AJAX COMPATIBILITY

	var xmlHttp;
	try {   // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		}

	catch (e){ // Internet Explorer
	try {
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e) {
	try {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	catch (e) {
		alert("Your browser does not support AJAX!");
		return false;
		}
		}
	}

	xmlHttp.open("GET",theURL,true);
	xmlHttp.send(null);

	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
		document.getElementById('video-content').innerHTML = xmlHttp.responseText;
		}
	}

}





