function selectFrameColor(newcolor) {

	if (newcolor == "") {
		alert("Error selecting new color");
		return false;
	}
	
//alert("newcolor id:[" + newcolor.id + "]");

	var curFrameStyleObj = document.getElementById("framestyleID");
	var curFrameStyle = curFrameStyleObj.value;
	var curFrameStyleAbbrev = frameStyleArray[curFrameStyle][FRAME_ABBREV];
	
	var curFrameColorObj = document.getElementById("framecolorID");
	var curFrameColor = curFrameColorObj.value;

	var curLensColorObj = document.getElementById("lenscolorID");
	var curLensColor = curLensColorObj.value;
	var curLensColorAbbrev = lensColorArray[curLensColor][LENS_COLOR_ABBREV];
	var curLensColorText = lensColorArray[curLensColor][LENS_COLOR_NAME];

	var frameColorField = document.getElementById("framecolortxt");

	var newFColorID = newcolor.id.substring(2);

//alert("current frame color value:[" + curFrameColor + "]");

	if (newFColorID == curFrameColor) return true;
	else {
		var newFrameColorAbbrev = frameColorArray[newFColorID][FRAME_COLOR_ABBREV];
		var newFrameColorText = frameColorArray[newFColorID][FRAME_COLOR_NAME];
		var newStyleImageSrc = "product/styleimage/SC_" + curFrameStyleAbbrev + "_" + newFrameColorAbbrev +  "_" + curLensColorAbbrev + ".jpg";

//alert("styleimage source to become: [" + newStyleImageSrc + "]");

		var styleImageObj = document.getElementById("styleimage");
		styleImageObj.src = newStyleImageSrc;

		var fc1Obj = document.getElementById("fc1");
		var fc2Obj = document.getElementById("fc2");

//alert("setting frame color text box to: [" + newFrameColorText + "]");		
		if (newFColorID == 1) {
			fc1Obj.src = "product/frameimage/gunmetal_on.gif";
			fc2Obj.src = "product/frameimage/bronze_off.gif";
			curFrameColorObj.value = 1;
			frameColorField.value = newFrameColorText;
		}
		else {
			fc1Obj.src = "product/frameimage/gunmetal_off.gif";
			fc2Obj.src = "product/frameimage/bronze_on.gif";
			curFrameColorObj.value = 2;
			frameColorField.value = newFrameColorText;
		}
	}

	return true;
}

function selectLensColor(newcolor) {

	if (newcolor == "") {
		alert("Error selecting new lens color");
		return false;
	}
	
//alert("newcolor id:[" + newcolor.id + "]");

	var curFrameStyleObj = document.getElementById("framestyleID");
	var curFrameStyle = curFrameStyleObj.value;
	var curFrameStyleAbbrev = frameStyleArray[curFrameStyle][FRAME_ABBREV];
	
	var curLensColorObj = document.getElementById("lenscolorID");
	var curLensColor = curLensColorObj.value;

	var lensColorField = document.getElementById("lenscolortxt");

	var newLColorID = newcolor.id.substring(2);
//alert("and newcolor id:[" + newLColorID + "]");

	if (newLColorID == curLensColor) return true;
	else {
		var newLensColorAbbrev = lensColorArray[newLColorID][LENS_COLOR_ABBREV];
		var newLensColorText = lensColorArray[newLColorID][LENS_COLOR_NAME];
		var newStyleImageSrc = "product/styleimage/GFO_" + curFrameStyleAbbrev +  "_" + newLensColorAbbrev + ".jpg";

//alert("styleimage source to become: [" + newStyleImageSrc + "]");

		var styleImageObj = document.getElementById("styleimage");
		styleImageObj.src = newStyleImageSrc;

		var lcObj;
		for (idx in lensColorArray) {
			if (idx == 0) continue;
//alert ("idx: [" + idx + "]");
			lcObj = document.getElementById("lc" + idx);
			if (lcObj) {
//alert("found swatch [" + lcObj.id + "]");
//alert("checking [" + lcObj.id.substring(2) + "] against [" + newLColorID + "]");
				if (lcObj.id.substring(2) == newLColorID) {
//alert("setting src = product/lensimage/" + lensColorArray[idx][LENS_COLOR_ABBREV].toLowerCase() + "_on.gif");
					lcObj.src = "product/lensimage/" + lensColorArray[idx][LENS_COLOR_ABBREV].toLowerCase() + "_on.gif";
					curLensColorObj.value = idx;
					lensColorField.value = newLensColorText;
				}
				else {
					lcObj.src = "product/lensimage/" + lensColorArray[idx][LENS_COLOR_ABBREV].toLowerCase() + "_off.gif";
				}
			}
		}

/*
		var lc1Obj = document.getElementById("lc4");
		var lc2Obj = document.getElementById("lc5");
		var lc3Obj = document.getElementById("lc6");


		switch (newLColorID) {
			case "4":
				lc1Obj.src = "product/lensimage/grey_on.gif";
				lc2Obj.src = "product/lensimage/brown_off.gif";
				lc3Obj.src = "product/lensimage/copper_off.gif";
				curLensColorObj.value = 4;
				lensColorField.value = newLensColorText;
				break;
			case "5":
				lc1Obj.src = "product/lensimage/grey_off.gif";
				lc2Obj.src = "product/lensimage/brown_on.gif";
				lc3Obj.src = "product/lensimage/copper_off.gif";
				curLensColorObj.value = 5;
				lensColorField.value = newLensColorText;
				break;
			case "6":
				lc1Obj.src = "product/lensimage/grey_off.gif";
				lc2Obj.src = "product/lensimage/brown_off.gif";
				lc3Obj.src = "product/lensimage/copper_on.gif";
				curLensColorObj.value = 6;
				lensColorField.value = newLensColorText;
				break;
		}
*/
	}
	return true;
}

function selectSize(newsize) {

	var sizeObj = document.getElementById("size");
	sizeObj.value = newsize;

	return true;
}

function gclip_form_validate() {

	var prodName = 'G Clip';

	if (! document.forms['gc_order_form'].framestyletxt.value) {
		alert ('No frame style specified.  Please click on a frame style and then resubmit your order');
		document.forms['gc_order_form'].framestyletxt.focus();
		return (false);
	}
//	if (! document.forms['gc_order_form'].framecolortxt.value) {
//		alert ('No frame color specified.  Please click on a frame color swatch and then resubmit your order');
//		document.forms['gc_order_form'].framecolortxt.focus();
//		return (false);
//	}
	if (! document.forms['gc_order_form'].lenscolortxt.value) {
		alert ('No lens color specified.  Please click on a lens color swatch and then resubmit your order');
		document.forms['gc_order_form'].lenscolortxt.focus();
		return (false);
	}
//	if (! document.forms['gc_order_form'].size.value) {
//		alert ('No size specified.  Please choose your frame size and resubmit your order');
//		return (false);
//	}
	if (! document.forms['gc_order_form'].quantity.value) {
		alert ('No quantity specified.  Please specify the quantity you would like to purchase and resubmit your order');
		document.forms['gc_order_form'].quantity.focus();
		return (false);
	}
	
	if (document.forms['gc_order_form'].gcliptype && (document.forms['gc_order_form'].gcliptype.value == 'pc')) {
		prodName = 'G clip PolyCarb';
	}

	// check ship weight
	if (document.forms['gc_order_form'].quantity.value > 0 && document.forms['gc_order_form'].quantity.value < 7) {
		weight = 1;
	}
	else if (document.forms['gc_order_form'].quantity.value >= 7 && document.forms['gc_order_form'].quantity.value < 14) {
		weight = 2;
	}
	else if (document.forms['gc_order_form'].quantity.value >= 14 && document.forms['gc_order_form'].quantity.value < 20) {
		weight = 3;
	}
	else if (document.forms['gc_order_form'].quantity.value >= 20 && document.forms['gc_order_form'].quantity.value < 25) {
		weight = 4;
	}
	else if (document.forms['gc_order_form'].quantity.value >= 25) {
		alert ("Shipping cost for quantities over 25 pcs, please contact us directly at 1-800-423-7688");
		return(false);
	}
	
	document.forms['gc_order_form'].AddItem.value = '9815308|' + prodName + ' - ' + document.forms['gc_order_form'].framestyletxt.value + ' (' + document.forms['gc_order_form'].framestyleabbrev.value + ') ' + ', lens: ' + document.forms['gc_order_form'].lenscolortxt.value + ' VAR000 19.95 |VARQuantity|||prompt|' + weight + '||||||';
	document.forms['gc_order_form'].VARQuantity.value = document.forms['gc_order_form'].quantity.value;
	document.forms['gc_order_form'].submit();
}

