var frameQuote = {};
//var gd.pricingPreview = {};

//gd.pricingPreview.frameQuote = {};

var imgWI = 0;
var imgHI = 0;
var entrantWI = 0;
var entrantHI = 0;
var inKitCalc = false;
var inFrameCalc = false;
var priceCount = 0;
var countComp = 5;
var editEntrant = false;
var swapEntrant = false;
function sizeChange() {
	entrantSize();
	imgWI = getImgWI();
	imgHI = getImgHI();
	if (($('frameType') == null || ($('frameType') != null && $('frameType') == "ready-made")) && (imgWI < 4 || imgHI < 4)) {
		swapButtonAttr("/scripts/WebObjects/PictureFrames.woa/wa/addToCart?sku=" + getSku() + "&page=Custom%2F" + getSku(), "/images/continueBtn.jpg", "Continue to Order");
		return;
	}
	if (getLL() != "" && getLL().selectedIndex == 0) {
		$('linerOption').style.visibility="hidden";
		$('llPreviewLink').style.visibility="hidden";
		$('llCheck').checked = false;
	} else if (getLL() != "" && getLL().selectedIndex > 0) {
		$('linerOption').style.visibility="visible";
		$('llPreviewLink').style.visibility="visible";
		$('llselect').style.color = "#000000";
		$('llCheck').checked = true;
		disableMats();
	}
	if(imgWI >= 4 && imgHI >= 4) {
		/* Call pricing service */
		disableOrder("<strong>Price: $ <img style='vertical-align: middle;' src=\"/images/ajax-loader.gif\"></strong>");
		if (((imgWI + imgHI) > 89) || (imgWI > 53 || imgHI > 53) || (imgWI > 43 && imgHI > 43)) {
			displayUnassembled();
		} else {
			hideUnassembled();
		}	
		if ($('quickMatChoice') != null) {
		if ($('quickMatChoice').checked) { $('singleMatOptions').show(); }
		if(typeof checkMaxFrameSize == 'function') {
			var maxSizeErreRet = checkMaxFrameSize(imgWI, imgHI);
			if (maxSizeErreRet != "") {
				disableOrder(maxSizeErreRet);
				hideFrameKitError();
				hideUnassembled();
				if ($('quickMatChoice') != null) {
				disableFrameKits();
				}
				$('includeMessage').innerHTML = "";
				return;
			} else {
				enableFrameKits();
				calculateFramingKitPrices();
			}
		} else if ((imgWI > 32 && imgHI > 32) || (imgWI > 40 || imgHI > 40)) {
			$('tooBigForMat').show();
			disableFrameKits();
			disableMats();
			frameKitError();
			frameQuote['none'] = 0;
			frameQuote['clips'] = "unset";
			if($('frameType').value != 'metal') {		
				getKitPrice('cclips', setKitPrice);
			}
		} else {
			$('tooBigForMat').hide();
			enableFrameKits();
			calculateFramingKitPrices();
		}
		}
	
		
		getFramePrice();
		//setTotalPrice();
	} else {
		disableOrder('Select a size.');
		
		hideFrameKitError();
		hideUnassembled();
		if ($('quickMatChoice') != null) {
		disableFrameKits();
		}
	}	
}

function checkMin(pass, justSize) {
	imgWI = getImgWI();
	imgHI = getImgHI();
	if(imgWI >= 4 && $('widthf').disabled==true) {
		$('widthf').disabled=false;
		return true;
	}
	if(imgHI >= 4 && $('heightf').disabled==true) {
		$('heightf').disabled=false;
		return true;
	}
	if ($('heightf').disabled==true || $('widthf').disabled==true) { 
		return true;
	}
	if(((imgWI > 4 && imgHI < 4) ||(imgWI < 4 && imgHI > 4)) && pass) {
		disableOrder('Minimum size must be 4" x 4".');
	} else if((imgWI < 4 || imgHI < 4) && !pass) {
		var minselect = $('width').options[1].value;
		disableOrder('Minimum size must be ' + minselect + '" x ' + minselect + '".');
	} else if (pass) {
		return true;
	} else {
		if ((entrantHI != imgHI || entrantWI != imgWI) && !justSize) { sizeChange(); }
		if ($('matChoice') != null && $('matChoice').checked && !justSize) {
			return frameShopAlert();
			
		}
	}
	return true;
}

function entrantSize() {
	if (!editEntrant) {
	var pageparams = (document.location.search).toQueryParams();
	if (pageparams.editFromCart && pageparams.ewidth >= 4 && pageparams.eheight >= 4) {
		var wa = pageparams.ewidth.split('.');
		var ha = pageparams.eheight.split('.');
		//alert(wa[0] + " " + matchFract(wa[1]) + " " + selectedIndexMatch($('width'),wa[0]));
		
		selectedIndexMatch($('width'),wa[0]);
		selectedIndexMatch($('widthf'),matchFract(wa[1]));
		selectedIndexMatch($('height'),ha[0]);
		selectedIndexMatch($('heightf'),matchFract(ha[1]));
	}
	}
	editEntrant = true;
}

function selectedIndexMatch(select, match) {
	return $A(select).find(function(option, index) {
	if(option.value == match) {
		select.selectedIndex = index; 
		return true;
	}
	return false;
	});
}

function frameShopAlert() {
	if (getCookie("FrameShopAlert") == "") {
		showFrameShopAlert();
		return false;
	}
	return true;
}

function setCookie(c_name,value,expiredays) {
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
if (document.cookie.length>0) {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1) {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
  return "";
}

function framingKitChange() {
	$('matWithKitMessage').innerHTML = "";
	$('matWithKitMessage').style.display = "none";
	if ($('radioCClips').checked) {
		if ($('quickMatChoice').checked) {
			$('quickMatChoice').checked = false;
			calculatePrice(false, true);
			sizeChange();
		}
		disableMats();
		if (getLL() != "") {
			getLL().disabled=false;
			 $('llCheck').disabled=false;
			$('llselect').style.color = "#000000";
		}
		enableOrder();
	}  else if ((imgWI >= 4 && imgHI >= 4) && ( !((imgWI > 32 && imgHI > 32) || (imgWI > 40 || imgHI > 40) )) ) {
		if ($('llCheck') == null || ($('llCheck') != null && $('llCheck').checked == false)) {
			enableMats();
		}
		if ($('matChoice').checked && !$('radioNone').checked) {
			$('matWithKitMessage').innerHTML = "<div class='matNote'>*Please note:</div> Finishing Option prices will change with the addition of mats. Adding a mat increases the overall size of your frame, acrylic and backing.";
			$('matWithKitMessage').style.display = "block";
		}
	}
	setIncludesMessage();
	setTotalPrice();
}

function llCheckChange(noEnableMat) {
	if ($('llCheck') != null && $('llCheck').checked) {
		$('linerOption').style.visibility="visible";
		$('llPreviewLink').style.visibility="visible";
		getLL().disabled=false;
		disableMats();
	} else if ($('llCheck') != null && $('llCheck').checked == false){
		if (getLL().selectedIndex > 0) {
			getLL().selectedIndex = 0;
			getLL().disabled=false;
			sizeChange();
			noEnableMat = true;
		}
		$('linerOption').style.visibility="hidden";
		$('llPreviewLink').style.visibility="hidden";
		if (!noEnableMat) {enableMats();}
	}
}

function disableMats() {
	try {
	$('singleMatOptionsInner').style.color = "#666666";
	$('matChoicesInner').style.color = "#666666";
	$('matChoice').checked = false;
	$('quickMatChoice').checked = false;
	$('singleMatOptions').hide();
	} catch (err) {}
}

function enableMats() {
	if ((imgWI >= 4 && imgHI >= 4) && ( !((imgWI > 32 && imgHI > 32) || (imgWI > 40 || imgHI > 40) ))) {
	try {
	$('matChoice').disabled=false;
	$('quickMatChoice').disabled=false;
	$('singleMatOptionsInner').style.color = "#000000";
	$('matChoicesInner').style.color = "#000000";
	} catch (err) {}
	}
}

function calculateFramingKitPrices()
{
	entrantHI = imgHI;
	entrantWI = imgWI;
	inKitCalc = true;
	if ($('llselect') != null) {
		getLL().disabled=true;
		$('llselect').style.color = "#666666";
		$('llCheck').disabled = true;
		$('llPreviewLink').style.visibility="hidden";
	}
	try{
	$('singleMatOptionsInner').style.color = "#666666";
	$('matChoicesInner').style.color = "#666666";
	$('matChoice').disabled=true;
	$('quickMatChoice').disabled=true;
	} catch (err) {}
	disableOrder();

	frameQuote['cclips'] = "unset";
	frameQuote['cac'] = "unset";
	frameQuote['caf'] = "unset";
	frameQuote['ngf'] = "unset";
	frameQuote['puv'] = "unset";

	if($('frameType').value != 'metal')
	{		
		getKitPrice('cclips', setKitPrice);
	} else {
		countComp = 4;
	}
	getKitPrice('cac', setKitPrice);
	getKitPrice('caf', setKitPrice);
	getKitPrice('ngf', setKitPrice);
	getKitPrice('puv', setKitPrice);
	
	frameQuote['none'] = 0;
	
}

function getFramePrice()
{
	$('calculatedPrice').innerHTML = "Calculating";
	inFrameCalc = true;
	disableSizeChange();
	var ps = new pricingService(getKit(), getSku(), imgWI, imgHI, getLL().value, getMatSku(), getMatBorders(), false);
	ps.frameOnlyCost(setFramePrice);
	ps.linerCost(setLinerPrice);
	ps.matCost(setMatPrice);
	ps.frameCost(setTotalPrice);
}

function setFramePrice(cost)
{
	frameQuote.price = cost;
}
function setMatPrice(cost)
{
	frameQuote.mat = cost;
}


function setLinerPrice(cost)
{
	    frameQuote.liner = cost;
}

function getKitPrice(kit, handler)
{
	
	var ps = new pricingService(kit, "hp4", imgWI, imgHI, "", getMatSku(), getMatBorders(), true);
	$(kit + 'PriceDiv').style.display = "inline";
	$(kit + 'Price').innerHTML = '';
	$(kit + 'Wait').style.display = "inline";
	//ps.linerCost(setLinerPrice);
	//ps.matCost(setMatPrice);
	ps.Kit(kit);
	ps.kitCost(handler);
}

function setKitPrice(kit, price)
{
	$(kit + 'Wait').style.display = "none";
	$(kit + 'Price').innerHTML = '<span class="redPrice">$' + price.toFixed(2) + '</span>';
	frameQuote[kit] = price.toFixed(2);
	priceCount++;
	if (priceCount == countComp) {
		if (entrantHI != imgHI || entrantWI != imgWI) { 
			disableOrder("<strong>Price: $ <img style='vertical-align: middle;' src=\"/images/ajax-loader.gif\"></strong>");
			sizeChange();
		}
		if ($('llselect') != null) {
			getLL().disabled=false;
			$('llselect').style.color = "#000000";
			$('llCheck').disabled = false;
			if ($('llCheck').checked) {
			$('llPreviewLink').style.visibility="visible";
			}
		}
		if ($('radioCClips').checked == false) {
		if (!($('llselect') != null && getLL().selectedIndex > 0) && (imgWI >= 4 && imgHI >= 4) && ( !((imgWI > 32 && imgHI > 32) || (imgWI > 40 || imgHI > 40) )) ) {
			enableMats();
		} 
		}
		inKitCalc = false;
		enableOrder();
		priceCount = 0;
	}
		
}

function getSku()
{
	var size_el = $('ppfsize');
	if (size_el != null && imgWI > 0 && imgHI >0) {
		return $('ppfsku').value + getImgWI() + getImgHI();	
	}
	return $('ppfsku').value;	
}


function getImgWI()
{
		var size_el = $('ppfsize');
		if (size_el != null) {
			return readyReturn(size_el, false);
		}
	var w_el = $('width');  	//width
	var wf_el = $('widthf'); 	//widthf
	
	return eval(w_el.options[w_el.selectedIndex].value + ".0+(1.0*(" + wf_el.options[wf_el.selectedIndex].value + "))" );
}

function getImgHI()
{
	var size_el = $('ppfsize');
		if (size_el != null) {
			return readyReturn(size_el, true);
		}
	var h_el = $('height');	//height
	var hf_el = $('heightf');	//heightf

	return eval(h_el.options[h_el.selectedIndex].value + ".0+(1.0*(" + hf_el.options[hf_el.selectedIndex].value + "))" );
}

function matchFract(decNum) {
	if (decNum == null) { return "0"; }
	decNum = decNum.replace(/[0]+$/,'');
	switch(decNum) {
		case "0":
			return "0";
		case "125":
			return "1/8";
		case "25":
			return "1/4";
		case "375":
			return "3/8";
		case "5":
			return "1/2";
		case "625":
			return "5/8";
		case "75":
			return "3/4";
		case "875":
			return "7/8";			
		default:
			return "0";
	}
}

function readyReturn(size_el, height) {
		var size = size_el.options[size_el.selectedIndex].value;
		var sizePattern = new RegExp('(.*)" x (.*)"', 'i');
		var sizeMatch = sizePattern.exec(size);
		if (!sizeMatch) { return false;}
		return height ? sizeMatch[2] : sizeMatch[1]; 
	
}

function getKit() {
	try {
	for (var i=0; i < document.pricingPreview.framingKitRadio.length; i++)
	{
	   if (document.pricingPreview.framingKitRadio[i].checked)
	   {
		   return document.pricingPreview.framingKitRadio[i].value;
	   }
	}
	} catch (err){
		return "";
	}
}

function getLL() {
	if ($('linerOption') != null) {
		return $('linerOption');
	} else {
		return "";
	}
}

function setTotalPrice()
{
	if(inKitCalc || isNaN(frameQuote[getKit()]) || isNaN(frameQuote.price) || isNaN(frameQuote.liner) || isNaN(frameQuote.mat))
	{
		setTimeout ( "setTotalPrice()", 50 );
	} else {
		//alert("frame: " + frameQuote.price + "liner: " + frameQuote.liner + "kit: " + frameQuote[getKit()]);
		$('calculatedPrice').innerHTML = "$"+ (Number(frameQuote[getKit()]) + Number(frameQuote.price) + Number(frameQuote.liner)+ Number(frameQuote.mat)).toFixed(2);
		setIncludesMessage();
		enableOrder();
		inFrameCalc = false;
	}
	enableSizeChange();
}

function setIncludesMessage() {
	var inclMessStr = "";
	var inc = "Includes: ";
	var frameOnly = true;
	var kitn = "";
	if (getKit() != "") {
		var justkitText = $(getKit() + "Text2").innerHTML.split("-");
		frameOnly = (justkitText[0].indexOf("Frame Only") > -1);
		if (frameOnly) {inc="";}
		kitn = justkitText[0];
	}
	if (getLL() != "" && getLL().value != "") {
		inclMessStr = frameOnly ? "Includes: Linen Liner<br />" : "Linen Liner, ";
	}
	if ($('quickMatChoice') != null && $('quickMatChoice').checked) {
		var matStr = $F('matBorder') + "\" " + $('matname').value  + " Mat";
		inclMessStr = frameOnly ? "Includes: " + matStr + "<br />" : matStr + ", ";
		$('matNameDis').innerHTML = "Color: " + $('matname').value + " Mat";
	} 
	$('includeMessage').innerHTML = inc + inclMessStr  + kitn;
}

function enableOrder() {
	
	if ($('matChoice') != null && $('matChoice').checked) {
		swapButtonAttr(getOrderLink(true), "/images/continueToSelectMatsBtn.jpg", "Continue to PersonalFrameShop");
	} else {
		swapButtonAttr(getOrderLink(false), "/images/addToCart.gif", "Add to Cart");
	}
	
}


function getOrderLink(mat) {
	var ccadd = "";
	var lladd = "";
	entrantHI = imgHI;
	entrantWI = imgWI;
	if(getKit() == "cclips") {
		ccadd = "&canvClips=true";
	}
	if ($('matChoice') != null && $('matChoice').checked) {
		return "/scripts/WebObjects/PictureFrames.woa/wa/FrameShop/default?&sku=" + orderGetStr() + "&frameKit=" + getKit() + ccadd;
	} else if ($('quickMatChoice') != null && $('quickMatChoice').checked) {
		return "/scripts/WebObjects/PictureFrames.woa/wa/addToCart?toCart=true&sku=" + orderGetStr() + "&matBorder=" + getMatBorders() + "&mat=" + getMatSku() + "&frameKit=" + getKit() + ccadd;
	} else {
		if (getLL() != "" && getLL().value != "") {
			lladd = "&LL=" + getLL().value;
		}
		return "/scripts/WebObjects/PictureFrames.woa/wa/addToCart?qty=1&sku=" + orderGetStr() + "&toCart=true&frameKit=" + getKit() + ccadd + lladd;
	}
}

function swapButtonAttr(link, img, alt) {
	var orderLink = $('orderCalculatedLink');
	var orderLink2 = $('orderCalculatedLink2');
	var orderImg = $('orderCalculatedImage');
	var matLink = $('orderCalculatedLinkMat');
	if (orderLink != null) {
	orderLink.href = link;
	orderImg.src = img;
	orderImg.alt = alt;
	if (orderLink2 != null) {
		var orderImg2 = $('orderCalculatedImage2');
		orderLink2.href = link;
		orderImg2.src = img;
		orderImg2.alt = alt;
	}
	if (matLink != null) {
		var orderImgMat = $('orderCalculatedImageMat');
		matLink.href = link;
	}
	}

	
}

function orderGetStr() {
	//var f_lookup = [0, 0.125, 0.25, 0.375, 0.50, 0.625, 0.75, 0.875];
	//var w_el_mod = $('width').options[$('width').selectedIndex].value;// - $('width').options[1].value;
	//var wf_el_mod = f_lookup[$('widthf').selectedIndex];
	//var h_el_mod = $('height').options[$('height').selectedIndex].value;// - $('height').options[1].value;
	//var hf_el_mod = f_lookup[$('heightf').selectedIndex];
	return getSku() + "&width=" + imgWI + "&height=" + imgHI;
}

function matCheckChange(swap, id) {
    var enablLL = false;
    var recheck = false;
    if ($('matChoice').checked && $('quickMatChoice').checked){
    	if (id != null && id == 'quickMatChoice' && $('quickMatChoice').checked) {
    		$('matChoice').checked = false;
    	}
    	if (id != null && id == 'matChoice' && $('matChoice').checked) {
    		$('quickMatChoice').checked = false;
    		recheck = true;
    	}
    }
	if ( recheck || swap || swapEntrant) {
		calculatePrice(false, true);
		sizeChange();
	}
    if (!swap) { swapEntrant = true; }
	if ($('quickMatChoice').checked) {
		$('singleMatOptions').show();
	} else {
		$('singleMatOptions').hide();
	}
	if ($('matChoice').checked || $('quickMatChoice').checked){
		
		if ($('matChoice').checked) {
			$('addToCartBtnMat').show();
			$('addToCartBtn').hide();
		  	if (!$('radioNone').checked) {
				$('matWithKitMessage').innerHTML = "<span class=matNote>*Please note:</span> Finishing Option prices will change with the addition of mats. Adding a mat increases the overall size of your frame, acrylic and backing.";
				$('matWithKitMessage').style.display = 'block';
			} else {
				$('matWithKitMessage').innerHTML = "";
				$('matWithKitMessage').style.display = "none";
			}
		}
		if (getLL() != "") {
			$('llCheck').checked = false;
			llCheckChange(true);
			$('llselect').style.color = "#666666";
		}
	} else {
		$('matWithKitMessage').innerHTML = "";
		$('matWithKitMessage').style.display = "none";
		if (getLL() != "") {
			getLL().disabled=false;
			$('llCheck').disabled = false;
			$('llselect').style.color = "#000000";
		}
	}
	if ($('matChoice').checked  == false) {
			$('addToCartBtnMat').hide();
			$('addToCartBtn').show();
	}
	enableOrder();
	setIncludesMessage();
}
function getMatSku(){
	if ($('quickMatChoice') != null && $('quickMatChoice').checked) {
		if ($('matsku')) return $('matsku').value;
	}
	return null;
}
function getMatBorders() {
	if ($('quickMatChoice') != null && $('quickMatChoice').checked) {
		if ($('matBorder')) return $('matBorder').value;
	}
	return null;
}

function disableOrder(message)
{
	frameQuote.price = "&nbsp;";
	
	$('calculatedPrice').innerHTML = message;
	if($('frameType') == "ready-made") {
	swapButtonAttr("#", "/images/continueBtn_gray.jpg", "Select size.");
	} else {
	swapButtonAttr("#", "/images/orderNowRed_off.gif", "Select height and width.");
	}
}

function disableSizeChange() {
	$('width').disabled=true;
	$('widthf').disabled=true;
	$('height').disabled=true;
	$('heightf').disabled=true;
}
function enableSizeChange() {
	$('width').disabled=false;
	$('widthf').disabled=false;
	$('height').disabled=false;
	$('heightf').disabled=false;
}

function disableFrameKits() {
	disableMats();
	$('matWithKitMessage').innerHTML = "";
	$('matWithKitMessage').style.display = "none";
	if (getLL() != "") {
		getLL().disabled=true;
		$('llCheck').disabled = true;
		$('llselect').style.color = "#666666";
	}
	
	//these should really have ids....	
	if (!(document.pricingPreview.framingKitRadio[0].checked || document.pricingPreview.framingKitRadio[1].checked)) {
		document.pricingPreview.framingKitRadio[0].checked=true;
	}
	
	if($('frameType').value == 'metal' || imgWI < 4 || imgHI < 4) {
		document.pricingPreview.framingKitRadio[1].disabled=true;
		$('cclipsText').style.color = "#666666";
		$('cclipsPriceDiv').style.display = "none";
	} else {
		if(imgWI >= 4 && imgHI >= 4)
		{
			document.pricingPreview.framingKitRadio[1].disabled=false;
			$('cclipsText').style.color = "#000000";
			$('cclipsPriceDiv').style.display = "inline";
			if (getLL() != "") {
			getLL().disabled=false;
			$('llCheck').disabled = false;
			$('llselect').style.color = "#000000";
			}
		}
	}
	
	document.pricingPreview.framingKitRadio[2].disabled=true;
	document.pricingPreview.framingKitRadio[3].disabled=true;
	document.pricingPreview.framingKitRadio[4].disabled=true;
	document.pricingPreview.framingKitRadio[5].disabled=true;
		
	$('cacPriceDiv').style.display = "none";
	$('cafPriceDiv').style.display = "none";
	$('ngfPriceDiv').style.display = "none";
	$('puvPriceDiv').style.display = "none";
	
	$('cacText').style.color = "#666666";
	$('cafText').style.color = "#666666";
	$('ngfText').style.color = "#666666";
	$('puvText').style.color = "#666666";
	$('cacText2').style.color = "#666666";
	$('ngfText2').style.color = "#666666";
	$('puvText2').style.color = "#666666";	
	try {
	$('singleMatOptionsInner').style.color = "#666666";
	$('matChoicesInner').style.color = "#666666";
	} catch (err) {}
}

function frameKitError() {
	if ($('largeFrameErr')){
		$('largeFrameErr').innerHTML = "You've selected an oversized frame. Please call Customer Care at 800.221.0262 to order finishing options for frame sizes greater than 32\" x 40\".";
		$('largeFrameErr').show();
	} else {
		$('largeFrameErr').style.display = 'block';
	}	
}

function hideFrameKitError()
{
	if($('largeFrameErr'))
		$('largeFrameErr').style.display = "none";	
}

function enableFrameKits() {
	enableMats();
	if (getLL() != null && getLL() != "") { 
		getLL().disabled=false;
		$('llCheck').disabled = false;
		$('llselect').style.color = "#000000";
	}
	if($('frameType').value == 'metal' || imgWI == 0 || imgHI == 0)
	{
		document.pricingPreview.framingKitRadio[1].disabled=true;
		$('cclipsText').style.color = "#666666";
		$('cclipsPriceDiv').style.display = "none";
	}
	else
	{
		if(imgWI >= 4 && imgHI >= 4)
		{
			document.pricingPreview.framingKitRadio[1].disabled=false;
			$('cclipsText').style.color = "#000000";
			$('cclipsPriceDiv').style.display = "inline";
		}
	}
	
	document.pricingPreview.framingKitRadio[2].disabled=false;
	document.pricingPreview.framingKitRadio[3].disabled=false;
	document.pricingPreview.framingKitRadio[4].disabled=false;
	document.pricingPreview.framingKitRadio[5].disabled=false;
		
	$('cacText').style.color = "#000000";
	$('cafText').style.color = "#000000";
	$('ngfText').style.color = "#000000";
	$('puvText').style.color = "#000000";	
	$('cacText2').style.color = "#000000";
	$('ngfText2').style.color = "#000000";
	$('puvText2').style.color = "#000000";
	try {
	$('singleMatOptionsInner').style.color = "#000000";
	$('matChoicesInner').style.color = "#000000";
	} catch (err) {}
	if ($('largeFrameErr')) {
	$('largeFrameErr').style.display = 'none';
	}
}
function setFocus(id) {
	$(id).style.visibility="visible";
	$(id).focus(); 
	$(id).style.visibility="hidden";
}
function sizeFocused() {
	return ($('width').hasFocus ||
	$('widthf').hasFocus ||
	$('height').hasFocus ||
	$('heightf').hasFocus);
}
//probably should refactor this and largeframe check
function displayUnassembled () {
	if ($('frameType').value != 'metal') {
	if (document.createTextNode && !$('unassembled')){
		var errText = document.createElement('div');
		errText.id = "unassembled";
		errText.className = "unassembled";
		errText.innerHTML = "Due to the size, this frame will be shipped unassembled along with easy instructions and assembly materials.  If you need this item shipped assembled, please contact us for a special delivery quote.";
		$('freebies').appendChild(errText);
		$('freebies').style.display = 'block';
	} else {
		$('unassembled').style.display = 'block';
	}
	}
}
function hideUnassembled() {
	if ($('unassembled')) {
		$('unassembled').style.display = 'none';
		$('freebies').style.display = 'none';
		}
}
