// JavaScript Document

function calculate1() {
	var quantity = document.getElementById("quantity1").value;
	var price = document.getElementById("price1").value;
	var total = quantity * price
	document.getElementById("total1").value = total;
	document.getElementById("grand").value = grandTotal();
}


function calculate2() {
	var quantity = document.getElementById("quantity2").value;
	var price = document.getElementById("price2").value;
	var total = quantity * price;
	document.getElementById("total2").value = total;
	document.getElementById("grand").value = grandTotal();
}

function calculate3() {
	var quantity = document.getElementById("quantity3").value;
	var price = document.getElementById("price3").value;
	var total = quantity * price;
	document.getElementById("total3").value = total;
	document.getElementById("grand").value = grandTotal();
}

function calculate4() {
	var quantity = document.getElementById("quantity4").value;
	var price = document.getElementById("price4").value;
	var total = quantity * price;
	document.getElementById("total4").value = total;
	document.getElementById("grand").value = grandTotal();
}

function checkName() {
	var name = document.getElementById("customer_name").value
	var error = "";
	if (name == "") 
		error = "Enter Your Name in 'Name' Box\n";
	return error;
}

function checkAddress() {
	var error = ""
	var add = document.getElementById("address").value
	if (add == "")
		error = "Enter Your Address in 'Address' Box\n"
	return error;
}

function checkCity() {
	var error = ""
	var cty = document.getElementById("city").value
	if (cty == "")
		error = "Enter Your City In The 'City' Box\n"
	return error;
}

function checkState() {
	var error = ""
	var st = document.getElementById("state").value
	if (st == "")
		error = "Enter Your State In The 'State' Box\n"
	return error;
}

function checkZip() {
	var zip = document.getElementById("zip").value;
	var error = "";
	if ((zip.length < 5) || (zip.length > 5)) 
    	error = "The Zip Code is the wrong length or invalid.\n";
	return error;
}

function checkQty() {
	var error = ""
	var qty1 = document.getElementById("quantity1").value;
	var qty2 = document.getElementById("quantity2").value;
	var qty3 = document.getElementById("quantity3").value;
	var qty4 = document.getElementById("quantity4").value;
	if ((qty1 >= 1) || (qty2 >= 1) || (qty3 >= 1) || (qty4 >= 1))
		return error;
	else error = "Please Enter A Quantity For The Desired Print";
		return error;
}

function checkEmail() {
	var email = document.getElementById("email").value;
	var error = ""
	var format =/^.+@.+\..{2,3}$/;
	if (!(format.test(email))) 
       error = "Email Address Is Not Valid.\n";
	return error;
}

function grandTotal() {
	var quantity1 = document.getElementById("quantity1").value;
	var price1 = document.getElementById("price1").value;
	var total1 = quantity1 * price1
	var quantity2 = document.getElementById("quantity2").value;
	var price2 = document.getElementById("price2").value;
	var total2 = quantity2 * price2;
	var quantity3 = document.getElementById("quantity3").value;
	var price3 = document.getElementById("price3").value;
	var total3 = quantity3 * price3
	var quantity4 = document.getElementById("quantity4").value;
	var price4 = document.getElementById("price4").value;
	var total4 = quantity4 * price4;
	var gTotal = total1 + total2 + total3 + total4;
	return gTotal
}
	
function validate() {
	
	var info = checkName();
	info += checkAddress();
	info += checkCity();
	info += checkState();
	info += checkZip();
	info += checkEmail();
	info += checkQty();

    if (info != "") {
        alert(info);
		return false;
	}
return document.getElementById("submit").disabled = false + popUp();
}


function order() {
	var name = document.getElementById("customer_name").value;
	var address = document.getElementById("address").value;
	var city = document.getElementById("city").value;
	var state = document.getElementById("state").value;
	var zip = document.getElementById("zip").value;
	var email = document.getElementById("email").value;
	var order = quantity();
	alert(name + '\n' + address + '\n' + city + '\n' + state + '\n' + zip + '\n' + email + '\n' + order)
}

function quantity() {
	var order = ""
	var qty1 = document.getElementById("quantity1").value;
	var prc1 = document.getElementById("price1").value;
	var qty2 = document.getElementById("quantity2").value;
	var prc2 = document.getElementById("price2").value;
	var qty3 = document.getElementById("quantity3").value;
	var prc3 = document.getElementById("price3").value;
	var qty4 = document.getElementById("quantity4").value;
	var prc4 = document.getElementById("price4").value;
	var totalDue = document.getElementById("grand").value;
	
	if (qty1 != 0) 
		order += qty1 + " each: Winner Takes All - 20 x 30 - print  $" + prc1 + " each\n";
	if (qty2 != 0) 
		order += qty2 + " each: To Late To Turn Back - 40 x 60 - print  $" + prc2 + " each\n";
	if (qty3 != 0) 
		order += qty3 + " each: The Coming Storm - 20 x 30 - print  $" + prc3 + " each\n";
	if (qty4 != 0) 
		order += qty4 + " each: Last of the Big Thunderheads - 30 x 60 - print  $" + prc4 + " each\n";
	if ((qty1 != 0) || (qty2 != 0) || (qty3 != 0) || (qty4 != 0))
		order += "Grand Total:  $" + totalDue;
	return order;
}

function popUp() {
	return MM_openBrWindow('http://www.paypal.com','paypal','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=640,height=480');
}

	var curImage = "1";
function imageChange() {
	if (curImage == "1") {
		document.getElementById("dean").src="images/dean_1.jpg";
		curImage = "2";
	}
	else if (curImage == "2") {
		document.getElementById("dean").src="images/dean_2.jpg";
		curImage = "3";
	}
	else if (curImage == "3") {
		document.getElementById("dean").src="images/dean_3.jpg";
		curImage = "4";
	}
	else if (curImage == "4") {
		document.getElementById("dean").src="images/deannoel.jpg";
		curImage = "1";
	}
}

function recentImage() {
	if (curImage == "1") {
		document.getElementById("recent_art").src="images/turquoise.jpg";
		document.getElementById("recent_desc").innerHTML = "<h1>King of the Turquoise Pool</h1>";
		curImage = "2";
	}
	else if (curImage == "2") {
		document.getElementById("recent_art").src="images/timberisland.jpg";
		document.getElementById("recent_desc").innerHTML = "<p><h1>Timber Island Challenge</h1></p>";
		curImage = "3";
	}
	else if (curImage == "3") {
		document.getElementById("recent_art").src="images/hotfootin.jpg";
		document.getElementById("recent_desc").innerHTML = "<p><h1>Hot Footin' it Across</h1></p>";
		curImage = "1";
	}
}
//Script for Drop Down Menu
//SuckerTree Horizontal Menu (Sept 14th, 06)
//By Dynamic Drive: http://www.dynamicdrive.com/style/

var menuids=["treemenu1"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal)

//End of Drop Down Menu Script

/*
function galleryPics(x) {
	switch (x) {
		case 1:
			document.getElementById("picture").src="images/leopardslie.jpg";
			document.getElementById("picture").alt="Where Leopards Lie";
			document.getElementById("title").innerHTML = "Where Leopards Lie";
			document.getElementById("desc").innerHTML = "Painting by Dean Noel<br /><br />Oil on Canvas<br /><br />Painting Size: 22&quot; x 28&quot;"
			break;
		case 2:
			document.getElementById("picture").src="images/sniffinair.jpg";
			document.getElementById("picture").alt="Sniffin' The Air";
			document.getElementById("title").innerHTML = "Sniffin' The Air";
			document.getElementById("desc").innerHTML = "Painting by Dean Noel<br /><br />Oil on Hard Board<br /><br />Painting Size: 30&quot; x 40&quot;"
			break;
		case 3:
			document.getElementById("picture").src="images/comingstorm.jpg";
			document.getElementById("picture").alt="The Coming Storm";
			document.getElementById("title").innerHTML = "The Coming Storm";
			document.getElementById("desc").innerHTML = "Painting by Dean Noel<br /><br />Oil on Canvas<br /><br />Painting Size: 30&quot; x 40&quot;"
			break;
		case 4:
			document.getElementById("picture").src="images/standoff.jpg";
			document.getElementById("picture").alt="The Stand Off";
			document.getElementById("title").innerHTML = "The Stand Off";
			document.getElementById("desc").innerHTML = "Painting by Dean Noel<br /><br />Oil on Canvas<br /><br />Painting Size: 30&quot; x 40&quot;"
			break;
		case 5:
			document.getElementById("picture").src="images/attitude.jpg";
			document.getElementById("picture").alt="It's All About Attitude";
			document.getElementById("title").innerHTML = "It's All About Attitude";
			document.getElementById("desc").innerHTML = "Painting by Dean Noel<br /><br />Oil on Hard Board<br /><br />Painting Size: 36&quot; x 48&quot;"
			break;
		case 6:
			document.getElementById("picture").src="images/thunderhead.jpg";
			document.getElementById("picture").alt="The Last of the Big Thunderheads";
			document.getElementById("title").innerHTML = "The Last of the Big Thunderheads";
			document.getElementById("desc").innerHTML = "Painting by Dean Noel<br /><br />Oil on Canvas<br /><br />Painting Size: 34&quot; x 72&quot;"
			break;
	}

}

function loadSurvey() {
	var choice = confirm("Please take our customer survey.");
	if (choice == true) {
	return window.open('survey.html','','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600');
	}
}
*/