var AllItems = new Array(18);
AllItems[1] = "Pearl and Amber Spoke Necklace";
AllItems[2] = "Global Charm Necklace";
AllItems[3] = "Emerald Carnation Hermitage Necklace";
AllItems[4] = "Mini Pearl and Amethyst Carnation Hermitage Necklace";
AllItems[5] = "Crescent and Stone Necklace";
AllItems[6] = "Global Pearl and Tassel Bracelet (Gold)";
AllItems[7] = "Green Pearl and Amethyst Spoke Necklace";
AllItems[8] = "Topography Pendant Necklace";
AllItems[9] = "Penny Cuff";
AllItems[10] = "Red Tassel and Pyrite Necklace";
AllItems[11] = "Silver Carnation Necklace";
AllItems[12] = "Double Strand Peacock Necklace";
AllItems[13] = "Gold Carnation Wreath Necklace";
AllItems[14] = "Diamante Tassel Bracelet";
AllItems[15] = "Sprinkle Sunken Treasure Necklace";
AllItems[16] = "Sprinkle Dot Double Strand Necklace";
AllItems[17] = "Black Crystal Hermitage Necklace";
AllItems[18] = "Mega Cluster Tassel Necklace";

var AllPrices = new Array(18);
AllPrices[1] = "1400.00";
AllPrices[2] = "480.00";
AllPrices[3] = "1600.00";
AllPrices[4] = "1400.00";
AllPrices[5] = "780.00";
AllPrices[6] = "480.00";
AllPrices[7] = "1400.00";
AllPrices[8] = "820.00";
AllPrices[9] = "560.00";
AllPrices[10] = "600.00";
AllPrices[11] = "2800.00";
AllPrices[12] = "720.00";
AllPrices[13] = "2250.00";
AllPrices[14] = "460.00";
AllPrices[15] = "600.00";
AllPrices[16] = "480.00";
AllPrices[17] = "1100.00";
AllPrices[18] = "780.00";

//contactOff = new Image();
//contactOff.src = "contact.gif";
//contactOn  = new Image();
//contactOn.src = "contact2.gif";
//design1a = new Image();
//design1a.src = "design1a.gif";
//design2a = new Image();
//design2a.src = "design2a.gif";
//design1b = new Image();
//design1b.src = "design1b.gif";
//design2b = new Image();
//design2b.src = "design2b.gif";

var tnA = new Array(18);
var tnB = new Array(18);
var txt = new Array(18);
var itm = new Array(18);

// Uses the Image() prototype to preload images [variables declared above]
for (var i = 1; i <= 18; i++) {
    if (i < 10) {
        itm[i] = new Image();
        itm[i].src = 'topography/item0' + i.toString() + '.jpg';
        txt[i] = new Image();
        txt[i].src = 'topography/0' + i.toString() + 't.jpg';
        tnA[i] = new Image();
        tnA[i].src = 'topography/tn0' + i.toString() + 'a.jpg';
        tnB[i] = new Image();
        tnB[i].src = 'topography/tn0' + i.toString() + 'b.jpg';
    }
    else {
        itm[i] = new Image();
        itm[i].src = 'topography/item' + i.toString() + '.jpg';
        txt[i] = new Image();
        txt[i].src = 'topography/' + i.toString() + 't.jpg';
        tnA[i] = new Image();
        tnA[i].src = 'topography/tn' + i.toString() + 'a.jpg';
        tnB[i] = new Image();
        tnB[i].src = 'topography/tn' + i.toString() + 'b.jpg';
    }
}  

// Called by CloseItems(), itself called by ToggleItem() - resets display and arrays
function CloseAll() {
    for (var i = 2; i <= 18; i++) {
        document.getElementById('item' + i.toString()).style.display = "none";
        document.getElementById('txt' + i.toString()).style.display = "none";
	}
    document.form1.item_name.value = AllItems[1];
    document.form1.amount.value = AllPrices[1];
}

// Called by href property of thumbnail <a> tags
function ToggleItem(saleitem, textbox) {
    CloseItems();
    if (document.getElementById(saleitem).style.display !== "block") {
        document.getElementById(saleitem).style.display = "block";
        document.getElementById(textbox).style.display = "block";
    }
}

/*
 * EXPLANATION:
 *
 * The function below was added to work around an oversight in the code whereby,
 * because item1 is always "display: block," paypal1 can never be hidden.  This unfortunate
 * bit of code should be removed in future pages if a <select> is not required for item1.
 *
 * Please also note the code which should be removed from swapInput() [which invokes
 * hidePaypal1()] in that circumstance.
 *
 */
 
function hidePaypal1() {
    for (var x = 2; x <= 18; x++) {
		if (document.getElementById('item' + x).style.display === "block") {
			document.getElementById('paypal1').style.display = "none";
			document.getElementById('paypal').style.left = "445px";//added for styling

		}
	}
	if (document.getElementById('item3').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item4').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item5').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item6').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item7').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item8').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item9').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item13').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item16').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
	else if (document.getElementById('item17').style.display === "block") {//added for styling

		document.getElementById('paypal').style.left = "390px";
	}
}

// Called by href property of thumbnail <a> tags [see EXPLANATION above]
function swapInput(i) {
    document.form1.item_name.value = AllItems[i];
    document.form1.amount.value = AllPrices[i];
    if (document.getElementById('item1').style.display === "block") {
        document.getElementById('paypal1').style.display = "block";
        document.getElementById('paypal').style.left = "390px";
    }
    else { 
        document.getElementById('paypal1').style.display = "none";
    }
    if (document.getElementById('item3').style.display === "block") {
        document.getElementById('paypal3').style.display = "block";
    }
    else {
        document.getElementById('paypal3').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item4').style.display === "block") {
        document.getElementById('paypal4').style.display = "block";
    }
    else {
        document.getElementById('paypal4').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item5').style.display === "block") {
        document.getElementById('paypal5').style.display = "block";
    }
    else {

        document.getElementById('paypal5').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item6').style.display === "block") {
        document.getElementById('paypal6').style.display = "block";
    } 
    else {
        document.getElementById('paypal6').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item7').style.display === "block") {
        document.getElementById('paypal7').style.display = "block";
    } 
    else {

        document.getElementById('paypal7').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item8').style.display === "block") {
        document.getElementById('paypal8').style.display = "block";
    } 
    else {

        document.getElementById('paypal8').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item9').style.display === "block") {
        document.getElementById('paypal9').style.display = "block";
    } 
    else {

        document.getElementById('paypal9').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item13').style.display === "block") {
        document.getElementById('paypal13').style.display = "block";
    } 
    else {

        document.getElementById('paypal13').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item16').style.display === "block") {
        document.getElementById('paypal16').style.display = "block";
    } 
    else {

        document.getElementById('paypal16').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item17').style.display === "block") {
        document.getElementById('paypal17').style.display = "block";
    } 
    else {

        document.getElementById('paypal17').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
    if (document.getElementById('item18').style.display === "block") {
        document.getElementById('paypal18').style.display = "block";
        document.getElementById('paypal1').style.display = "none";//see EXPLANATION above
        document.getElementById('paypal').style.left = "390px";
    }
    else {

        document.getElementById('paypal18').style.display = "none";
        hidePaypal1();//see EXPLANATION above
    }
}



//The functions below are called when options are changed on the various forms
function checkPrices1() {
    var m1 = document.form1b.opt1.options[document.form1b.opt1.selectedIndex].value;
	if (m1 === "Type1") {
		document.form1.item_name.value = AllItems[1];
		document.form1.amount.value = AllPrices[1];
	}
	else if (m1 === "Type2") {
		document.form1.item_name.value = "Pearl and Amber Spoke Earrings";
		document.form1.amount.value = "420.00";
	}
	else
	{
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices3() {
    var m3 = document.form3.opt3.options[document.form3.opt3.selectedIndex].value;
	if (m3 === "Type1") {
		document.form1.item_name.value = AllItems[3];
		document.form1.amount.value = AllPrices[3];
	}
	else if (m3 === "Type2") {
		document.form1.item_name.value = "Emerald Wrapped Crystal Drop Earrings";
		document.form1.amount.value = "420.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices4() {
    var m4 = document.form4.opt4.options[document.form4.opt4.selectedIndex].value;
	if (m4 === "Type1") {
		document.form1.item_name.value = AllItems[4];
		document.form1.amount.value = AllPrices[4];
	}
	else if (m4 === "Type2") {
		document.form1.item_name.value = "Wrapped Amethyst Crystal Drop Earrings";
		document.form1.amount.value = "420.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices5() {
    var m5 = document.form5.opt5.options[document.form5.opt5.selectedIndex].value;
	if (m5 === "Type1") {
		document.form1.item_name.value = AllItems[5];
		document.form1.amount.value = AllPrices[5];
	}
	else if (m5 === "Type2") {
		document.form1.item_name.value = "Crescent and Stone Earrings";
		document.form1.amount.value = "420.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices6() {
    var m6 = document.form6.opt6.options[document.form6.opt6.selectedIndex].value;
	if (m6 === "Type1") {
		document.form1.item_name.value = AllItems[6];
		document.form1.amount.value = AllPrices[6];
	}
	else if (m6 === "Type2") {
		document.form1.item_name.value = "Global Pearl and Tassel Bracelet (Silver)";
		document.form1.amount.value = "480.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices7() {
    var m7 = document.form7.opt7.options[document.form7.opt7.selectedIndex].value;
	if (m7 === "Type1") {
		document.form1.item_name.value = AllItems[7];
		document.form1.amount.value = AllPrices[7];
	}
	else if (m7 === "Type2") {
		document.form1.item_name.value = "Green Pearl and Amethyst Earrings";
		document.form1.amount.value = "420.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices8() {
    var m8 = document.form8.opt8.options[document.form8.opt8.selectedIndex].value;
	if (m8 === "Type1") {
		document.form1.item_name.value = AllItems[8];
		document.form1.amount.value = AllPrices[8];
	}
	else if (m8 === "Type2") {
		document.form1.item_name.value = "Topography Cuff (Gold)";
		document.form1.amount.value = "560.00";
	}
	else if (m8 === "Type3") {
		document.form1.item_name.value = "Topography Cuff (Silver)";
		document.form1.amount.value = "560.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices9() {
    var m9 = document.form9.opt9.options[document.form9.opt9.selectedIndex].value;
	if (m9 === "Type1") {
		document.form1.item_name.value = AllItems[9];
		document.form1.amount.value = AllPrices[9];
	}
	else if (m9 === "Type2") {
		document.form1.item_name.value = "Button Ring";
		document.form1.amount.value = "420";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices13() {
    var m13 = document.form13.opt13.options[document.form13.opt13.selectedIndex].value;
	if (m13 === "Type1") {
		document.form1.item_name.value = AllItems[13];
		document.form1.amount.value = AllPrices[13];
	}
	else if (m13 === "Type2") {
		document.form1.item_name.value = "Gold Carnation Ring";
		document.form1.amount.value = "420.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices16() {
    var m16 = document.form16.opt16.options[document.form16.opt16.selectedIndex].value;
	if (m16 === "Type1") {
		document.form1.item_name.value = AllItems[16];
		document.form1.amount.value = AllPrices[16];
	}
	else if (m16 === "Type2") {
		document.form1.item_name.value = "Sprinkle Dot Earrings";
		document.form1.amount.value = "420.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices17() {
    var m17 = document.form17.opt17.options[document.form17.opt17.selectedIndex].value;
	if (m17 === "Type1") {
		document.form1.item_name.value = AllItems[17];
		document.form1.amount.value = AllPrices[17];
	}
	else if (m17 === "Type2") {
		document.form1.item_name.value = "Chain Wrapped Earrings";
		document.form1.amount.value = "420.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}
function checkPrices18() {
    var m18 = document.form18.opt18.options[document.form18.opt18.selectedIndex].value;
	if (m18 === "Type1") {
		document.form1.item_name.value = AllItems[18];
		document.form1.amount.value = AllPrices[18];
	}
	else if (m18 === "Type2") {
		document.form1.item_name.value = "Lava Tassel Earrings";
		document.form1.amount.value = "420.00";
	}
	else {
		document.form1.item_name.value = "Please select an option";
		document.form1.amount.value = "";
	}
}

// Unfortunate use of eval.  Creates mouseover effect
function Highlight(imageID, newImage) {
	document.images[imageID].src = eval(newImage + ".src");
}

function wstatus(m) {
	window.status = m;
	return true;
}

function CloseCommonBio() {
	document.getElementById('primary').style.display = "none";
	document.getElementById('biopage').style.display = "none";
	document.getElementById('biotext').style.display = "none";
	document.getElementById('biolink').style.display = "none";
}

function CloseDrawers() {
	document.getElementById('CDrawer').style.display = "none";
	document.getElementById('BDrawer').style.display = "none";
	document.getElementById('PDrawer').style.display = "none";
	document.getElementById('NDrawer').style.display = "none";
}

function ShowPage(pagetitle) {
	document.getElementById('revert').style.display = "block";
	CloseItems();
	if (pagetitle === "About") {
		document.getElementById('biopage').style.display = "block";
		document.getElementById('biotext').style.display = "block";
	} else if (pagetitle === "Revert") {
		CloseCommonBio();
		document.getElementById('primary').style.display = "block";
		document.getElementById('revert').style.display = "none";
	}
}

function OpenDrawer(drawer) {
	CloseDrawers();
	document.getElementById(drawer).style.display = "block";
}

function CloseItems() {
	CloseAll();
}

function ToggleBioText(b) {
	document.getElementById('biolink').style.display = b;
}