// JavaScript Document

function popWindow(thefile)
{
 var popWindow =  window.open(thefile,'popWindow','toolbar=yes,width=600,height=300,directories=yes,status=yes,scrollbars=yes,resizable=yes,menubar=no');
 
 browserName = navigator.appName;
 if (browserName == "Netscape") {
	popWindow.focus();
 }
}


function createCookie(name,value,days)
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";

	var ck = name+"="+value+expires+"; path=/";
	document.cookie = ck;
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
	var c = ca[i];
	while (c.charAt(0)==' ') c = c.substring(1,c.length);
	if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function setCategory (catValue) {
	createCookie("yesCategory",catValue,7);
}
function getCategory () {
	return readCookie("yesCategory");
}
function writeLeftNav() {
	theCat = getCategory();
	if ((theCat=='home') || (theCat==null)) {
	} else {
		document.write('<!--if we are in a category, show this column-->');
		document.write('<div id="leftCol"><img src="Images/spacer.gif" border="0" width="135" height="1"/><br>');
		document.write('<div style="padding:5px; margin: 0px; width=135;" id="leftNav">');
		document.write('<ul style="width="100%;">');
	if (theCat=='barn') {
		document.write('<h3>Barn</h3>');

		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=22">Accessories</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=12">Buckets & Tubs</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=10">Carts & Storage</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=167">Fencing</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=121">Forks & Rakes</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=19">Hardware</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=21">Mounting Blocks</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=125">Name Plates</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=18">Racks & Boxes</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=126">Stable Boards</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=123">Stall Gates</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=122">Stall Guards</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=77">Tack Trunk Accessories</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=20">Tack Trunks</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=162">Tack Trunks - Wooden</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=124">Traps</a></li>');	
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=166">Waterers &amp; Feeders</a></li>');	
	} else if (theCat=='arena') {
		document.write('<h3>Arena</h3>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=14">Dressage</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=13">Jumps</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=15">Course Packages</a></li>');

		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=121">Forks & Rakes</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=122">Stall Guards</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=123">Stall Gates</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=124">Traps</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=125">Name Plates</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=126">Stable Boards</a></li>');

	}  else if (theCat=='show') {
		document.write('<h3>Show</h3>');
		document.write('<li><a  title="Blankets" href="index.asp?PageAction=VIEWCATS&amp;Category=54">Blankets</a></li>');
		document.write('<li><a  title="Buckets &amp; Tubs" href="index.asp?PageAction=VIEWCATS&amp;Category=57">Buckets &amp; Tubs</a></li>');
		document.write('<li><a  title="Door Panels" href="index.asp?PageAction=VIEWCATS&amp;Category=52">Door Panels</a></li>');
		document.write('<li><a  title="Racks &amp; Boxes" href="index.asp?PageAction=VIEWCATS&amp;Category=53">Racks &amp; Boxes</a></li>');
		document.write('<li><a  title="Show Accessories" href="index.asp?PageAction=VIEWCATS&amp;Category=58">Show Accessories</a></li>');
		document.write('<li><a  title="Stable Boards" href="index.asp?PageAction=VIEWCATS&amp;Category=59">Stable Boards</a></li>');
		document.write('<li><a  title="Stall Gates" href="index.asp?PageAction=VIEWCATS&amp;Category=56">Stall Gates</a></li>');
		document.write('<li><a  title="Stall Gaurds" href="index.asp?PageAction=VIEWCATS&amp;Category=55">Stall Gaurds</a></li>');
		document.write('<li><a  title="Tack Trunks" href="index.asp?PageAction=VIEWCATS&amp;Category=48">Tack Trunks</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=162">Tack Trunks - Wooden</a></li>');	

	}  else if (theCat=='horse') {
		document.write('<h3>Horse</h3>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=62">Bandages</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=66">Bits</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=27">Blankets</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=64">Bridles</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=28">Coolers</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=70">Farrier Supply</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=164">Foal</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=72">Fly Control</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=61">Grooming</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=65">Halters</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=68">Hoof Care</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=67">Leads & Lunges</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=71">Leg Care</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=73">Name Plates</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=60">Race Horse</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=29">Saddle Pads</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=63">Saddles</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=147">Shampoos &amp; Conditioners</a></li>');
	}  else if (theCat=='rider') {
		document.write('<h3>Rider</h3>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=118">Chaps</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=78">Coolers</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=119">Gloves</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=120">Health &amp; Beauty</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=115">Helmets</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=114">Jockey</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=117">Spurs</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=116">Whips</a></li>');
	}   else if (theCat=='tack') {
		document.write('<h3>Tack</h3>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=81">Bits</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=79">Bridles</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=86">Girths</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=80">Halters</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=90">Hoof Care</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=82">Leads</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=91">Leg Care</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=88">Martingales</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=87">Race Horse</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=84">Saddle Pads</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=83">Stirrups</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=85">Tack Hooks</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=89">Whips</a></li>');
	}   else if (theCat=='health') {
		document.write('<h3>Health</h3>');
		document.write('<li><a title="Anti-Fungal" href="index.asp?PageAction=VIEWCATS&amp;Category=104">Anti-Fungal</a></li>');
		document.write('<li><a title="Bandages" href="index.asp?PageAction=VIEWCATS&amp;Category=102">Bandages</a></li>');
		document.write('<li><a title="Blisters" href="index.asp?PageAction=VIEWCATS&amp;Category=105">Blisters</a></li>');
		document.write('<li><a title="Calming" href="index.asp?PageAction=VIEWCATS&amp;Category=133">Calming</a></li>');
		document.write('<li><a title="Coat" href="index.asp?PageAction=VIEWCATS&amp;Category=97">Coat</a></li>');
		document.write('<li><a title="Cribbing" href="index.asp?PageAction=VIEWCATS&amp;Category=134">Cribbing</a></li>');
		document.write('<li><a title="Digestive" href="index.asp?PageAction=VIEWCATS&amp;Category=135">Digestive</a></li>');
		document.write('<li><a title="Electrolyte" href="index.asp?PageAction=VIEWCATS&amp;Category=100">Electrolyte</a></li>');
		document.write('<li><a title="Hoof Care" href="index.asp?PageAction=VIEWCATS&amp;Category=144">Hoof Care</a></li>');
		document.write('<li><a title="Hoof Supliments" href="index.asp?PageAction=VIEWCATS&amp;Category=136">Hoof Supliments</a></li>');
		document.write('<li><a title="Joint" href="index.asp?PageAction=VIEWCATS&amp;Category=93">Joint</a></li>');
		document.write('<li><a title="Leg Paints" href="index.asp?PageAction=VIEWCATS&amp;Category=106">Leg Paints</a></li>');
		document.write('<li><a title="Leg Poltice" href="index.asp?PageAction=VIEWCATS&amp;Category=137">Leg Poltice</a></li>');
		document.write('<li><a title="Liniments" href="index.asp?PageAction=VIEWCATS&amp;Category=101">Liniments</a></li>');
		document.write('<li><a title="Respiratory" href="index.asp?PageAction=VIEWCATS&amp;Category=138">Respiratory</a></li>');
		document.write('<li><a title="Sheath Cleaners" href="index.asp?PageAction=VIEWCATS&amp;Category=143">Sheath Cleaners</a></li>');
		document.write('<li><a title="Thrush Treatment" href="index.asp?PageAction=VIEWCATS&amp;Category=139">Thrush Treatment</a></li>');
		document.write('<li><a title="Topicals" href="index.asp?PageAction=VIEWCATS&amp;Category=103">Topicals</a></li>');
		document.write('<li><a title="Vitamins - Liquid" href="index.asp?PageAction=VIEWCATS&amp;Category=94">Vitamins - Liquid</a></li>');
		document.write('<li><a title="Vitamins - Oral Paste" href="index.asp?PageAction=VIEWCATS&amp;Category=140">Vitamins - Oral Paste</a></li>');
		document.write('<li><a title="Vitamins - Pellets" href="index.asp?PageAction=VIEWCATS&amp;Category=96">Vitamins - Pellets</a></li>');
		document.write('<li><a title="Vitamins - Powder" href="index.asp?PageAction=VIEWCATS&amp;Category=95">Vitamins - Powder</a></li>');
		document.write('<li><a title="Vitamins - Syringe" href="index.asp?PageAction=VIEWCATS&amp;Category=99">Vitamins - Syringe</a></li>');
		document.write('<li><a title="Weight" href="index.asp?PageAction=VIEWCATS&amp;Category=141">Weight</a></li>');
		document.write('<li><a title="Wormers" href="index.asp?PageAction=VIEWCATS&amp;Category=98">Wormers</a></li>');

}   else if (theCat=='small animal') {
		document.write('<h3>Small Animal</h3>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=109">Cat</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=113">Cattle</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=112">Chicken</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=108">Dog</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=111">Goat</a></li>');
		document.write('<li><a href="index.asp?PageAction=VIEWCATS&amp;Category=110">Rabbitt</a></li>');

	} 
	document.write('</ul></div>');
	document.write('</div>');
	}
}
// Burlingham Tack Trunk Embroidery Code =====================================================================================
	var pageType="";

	var theElements;
	var indEmbroidery=-1;
	var indEmbrColor=-1;
	var indEmbrStyle=-1;
	var indEmbrNumLetters=-1;
    var indTimeZone=-1;

	var rrEmbroideryCost=-1;
	var rrPriceObj;

function initializeEmbroidery() {

	if (pageType=="BS-Tack Trunk") {
		theElements = document.body.getElementsByTagName("select");
		for (ii=0; ii<theElements.length; ii++) {
			if (theElements[ii].name == "PQ-Embroidery Color") {
				indEmbrColor = ii;
			} else if (theElements[ii].options[0].innerHTML == "--- Select Style ---") {  // hidden style
				indEmbrStyle = ii;
			} else if (theElements[ii].options[0].innerHTML == "-- Used for Styles 1 - 4 --") {
				indEmbrNumLetters = ii;
			} else if (theElements[ii].name == "PQ-Embroidery on Seat") {
				indEmbroidery = ii;
			} 
		}
		
		if (indEmbroidery > -1) {
			addEvent ( theElements[indEmbroidery], 'change',  function () { updateEnable(); } );
			theElements[indEmbrStyle].style.display = "none";
			addEvent ( document.forms[1]["PQ-Embroidery Style"], 'change',  function () { updateEnable(); } );
			
			//alert(document.forms[1]["PQ-Embroidery Text"].name);
			theText = document.forms[1]["PQ-Embroidery Text"];
			addEvent ( theText, 'keyup',  function () { updateCharacterCount(); } );
			addEvent ( theText, 'change',  function () { updateCharacterCount(); } );
			
			theText.style.width = "100%";
			theText.style.backgroundColor = "#ece9d8";
		}
	}

	if (pageType=="RR-Blanket") {
		theElements = document.body.getElementsByTagName("select");
		document.forms[1]["PQ-<!--save embroidery-->"].style.display = "none";

		
		for (ii=0; ii<theElements.length; ii++) {
			if (theElements[ii].options[1].innerHTML == "charge for embroidery") {
				// comeback - trying moving "charge for embroidery" to the 2nd choice so that it is not displayed in the shopping cart
				rrEmbroideryCost=ii;
				theElements[ii].style.display = "none";
				theID="PriceMod"+theElements[ii].options[0].value;
				//alert(theID);
				rrPriceObj=document.forms[1][theID];
			}

		}
	}


    var theZone = document.forms[1]["PQ-Your Time Zone"];
    if (theZone!=null) {
        addEvent ( theZone, 'change',  function () { updateTimeZone(); } );
       // find it's match
        theElements = document.body.getElementsByTagName("select");
        for (ii=0; ii<theElements.length; ii++) {
            if (theElements[ii].options[0].innerHTML == "-- select your time zone --") {
                indTimeZone = ii;
                theElements[indTimeZone].style.display = "none";
            }
        }
    }

}

function addEvent( obj, type, fn ) {
   if ( obj.attachEvent ) {
     obj['e'+type+fn] = fn;
     obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
     obj.attachEvent( 'on'+type, obj[type+fn] );
   } else
     obj.addEventListener( type, fn, false );
}

function updateTimeZone () {
    if (indTimeZone > -1) {
        theElements[indTimeZone].selectedIndex = document.forms[1]["PQ-Your Time Zone"].selectedIndex;
        changePriceValue();  // this is a monster function
    }
}

function updateEnable() {

//	if (document.getElementById("PQ-Embroidery on Seat")) {
	if (indEmbroidery > -1) {

		var theStyle = document.forms[1]["PQ-Embroidery Style"];
		var theText = document.forms[1]["PQ-Embroidery Text"];
		var embHelp = document.getElementById("embHelp");
		var embTextHelp = document.getElementById("embTextHelp");

		var embTextHelp12 = document.getElementById("embTextHelp12");
		var embTextHelp34 = document.getElementById("embTextHelp34");
		var embTextHelp59 = document.getElementById("embTextHelp59");

		theElements[indEmbrStyle].selectedIndex = theStyle.selectedIndex;

		if (theElements[indEmbroidery].selectedIndex == 0) {
			theElements[indEmbrColor].disabled=true;
			theElements[indEmbrStyle].disabled=true;
			theStyle.disabled=true;
			theElements[indEmbrNumLetters].disabled=true;
			theText.disabled=true;
			theText.style.backgroundColor = "#ece9d8";
			theText.value="";
			theElements[indEmbrColor].selectedIndex = 0;
			theElements[indEmbrStyle].selectedIndex = 0;
			theStyle.selectedIndex = 0;
			theElements[indEmbrNumLetters].selectedIndex = 0;
			embHelp.style.display = "none";

		} else {
			theElements[indEmbrColor].disabled=false;
			theElements[indEmbrStyle].disabled=false;
			theStyle.disabled=false;
			theElements[indEmbrNumLetters].disabled=true;
			embHelp.visible=true;
			embHelp.style.display = "";
		}

		//alert(theElements[indEmbrStyle].selectedIndex);
		//if ((theElements[indEmbrStyle].selectedIndex < 10) && (theElements[indEmbrStyle].selectedIndex > 0)) {
		if ((theStyle.selectedIndex < 10) && (theStyle.selectedIndex > 0)) {
			embTextHelp.style.display = "";
			embTextHelp12.style.display = "none";
			embTextHelp34.style.display = "none";
			embTextHelp59.style.display = "none";
			theText.disabled=false;
			theText.style.backgroundColor = "#ffffcc";
			theElements[indEmbrNumLetters].disabled=true;

			//switch(theElements[indEmbrStyle].selectedIndex) {
			switch(theStyle.selectedIndex) {
			  case 1:
			  case 2:
				embTextHelp12.style.display = "";
				break;
			  case 3:
			  case 4:
				embTextHelp34.style.display = "";
				break;
			  case 5:
			  case 6:
			  case 7:
			  case 8:
			  case 9:
				embTextHelp59.style.display = "";
				updateCharacterCount();
				break;
			  default:
			}
		} else {
			embTextHelp.style.display = "none";
			theText.disabled=true;
			theText.value="";
			theText.style.backgroundColor = "#ece9d8";
			theElements[indEmbrNumLetters].disabled=true;
		}
			
		changePriceValue();  // this is a monster function


	}

}

function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


function trimString2 (str) {
  while (str.charAt(0) == ' ')
    str = str.substring(1);
  while (str.charAt(str.length - 1) == ' ')
    str = str.substring(0, str.length - 1);
  return str;
}

function updateCharacterCount () {
	var theTextObj = document.forms[1]["PQ-Embroidery Text"];
	var theStyle = document.forms[1]["PQ-Embroidery Style"];
	var theText = theTextObj.value;
	var theStrippedText = "";
	theStrippedText = theText.replace(" ","", "gi");
	
	//if ((theElements[indEmbrStyle].selectedIndex >=5) && (theElements[indEmbrStyle].selectedIndex <= 9)) {
	if ((theStyle.selectedIndex >=5) && (theStyle.selectedIndex <= 9)) {
		if (theStrippedText.length > 3) {
			document.forms[1]["PQ-Embroidery Text"].value = theStrippedText.substring(0,3);
			theElements[indEmbrNumLetters].selectedIndex=0;
			alert("Only 3 letters are allowed for monograms.");	
			theTextObj.style.backgroundColor = "#ffffff";
		}
		if (theStrippedText.length < 3) {
			theTextObj.style.backgroundColor = "#ffffcc";
		}
		if (theStrippedText.length == 3) {
			theTextObj.style.backgroundColor = "#ffffff";
		}
		
	} else {
		if (theStrippedText.length == 0) {
			theTextObj.style.backgroundColor = "#ffffcc";
			theElements[indEmbrNumLetters].selectedIndex=0;
		} else {
			theTextObj.style.backgroundColor = "#ffffff";
			if ((theStrippedText.length >= 1) && (theStrippedText.length <= 3)) {
					theElements[indEmbrNumLetters].selectedIndex=1;
			} else  if ((theStrippedText.length >= 4) && (theStrippedText.length <= 10)) {
					theElements[indEmbrNumLetters].selectedIndex=2;
			} else 	if ((theStrippedText.length >= 11) && (theStrippedText.length <= 15)) {
					theElements[indEmbrNumLetters].selectedIndex=3;
			} else 	if ((theStrippedText.length >= 16) && (theStrippedText.length <= 20)) {
					theElements[indEmbrNumLetters].selectedIndex=4;
			} else 	if ((theStrippedText.length >= 21) && (theStrippedText.length <= 25)) {
					theElements[indEmbrNumLetters].selectedIndex=5;

			} else 	if ((theStrippedText.length >= 26) && (theStrippedText.length <= 30)) {
					theElements[indEmbrNumLetters].selectedIndex=6;
			} else 	if ((theStrippedText.length >= 31) && (theStrippedText.length <= 35)) {
					theElements[indEmbrNumLetters].selectedIndex=7;
			} else 	if ((theStrippedText.length >= 36) && (theStrippedText.length <= 40)) {
					theElements[indEmbrNumLetters].selectedIndex=8;
			} else 	if (theStrippedText.length >= 41){
					document.forms[1]["PQ-Embroidery Text"].value = theStrippedText.substring(0,40);
					alert("Text must be 40 characters or less.  Please call us for custom orders.");	
					theElements[indEmbrNumLetters].selectedIndex=7;
			}
		}
	}
	changePriceValue();  // this is a monster function
}
// ===========================================================================================

function getRRCharacterCost ()  {
	var theCost = 0;
	
	var theStyle = document.forms[1]["PQ-Style"];
	var theText1 = document.forms[1]["PQ-Line1"].value;
	var theText2 = document.forms[1]["PQ-Line2"].value;
	var theText3 = document.forms[1]["PQ-Line3"].value;
	var theStrippedText = "";
	var tmpText = "";

	if (theText1.length > 16){
			theText1 = theText1.substring(0,16);
			document.forms[1]["PQ-Line1"].value = theText1;
			alert("Each line of text can be only up to 16 characters wide. Please call us for custom orders.");	
	}
	if (theText2.length > 16){
			theText2 = theText2.substring(0,16);
			document.forms[1]["PQ-Line2"].value = theText2;
			alert("Each line of text can be only up to 16 characters wide. Please call us for custom orders.");	
	}
	if (theText3.length > 16){
			theText3 = theText3.substring(0,16);
			document.forms[1]["PQ-Line3"].value = theText3;
			alert("Each line of text can be only up to 16 characters wide. Please call us for custom orders.");	
	}

	theStrippedText1 = theText1.replace(" ","", "gi");
	theStrippedText2 = theText2.replace(" ","", "gi");
	theStrippedText3 = theText3.replace(" ","", "gi");
	theStrippedText=theStrippedText1+theStrippedText2+theStrippedText3;
	

	if ((theStyle.selectedIndex >=0) && (theStyle.selectedIndex <= 5)) {
		if (theStrippedText.length > 3) {
			document.forms[1]["PQ-Line1"].value = theStrippedText.substring(0,3);
			document.forms[1]["PQ-Line2"].value = "";
			document.forms[1]["PQ-Line3"].value = "";	
			alert("Only 3 letters are allowed for monograms.");	
			//theTextObj.style.backgroundColor = "#ffffff";
		}
		if (theStrippedText.length < 3) {
			//theTextObj.style.backgroundColor = "#ffffcc";
		}
		if (theStrippedText.length == 3) {
			//theTextObj.style.backgroundColor = "#ffffff";
		}
		
	} else {
		if (theStrippedText.length == 0) {
			//theTextObj.style.backgroundColor = "#ffffcc";
		} else {
			//theTextObj.style.backgroundColor = "#ffffff";

			if ((theStrippedText.length >= 1) && (theStrippedText.length <= 6)) {
					theCost = 0;
			} else 	{
					extraLetters=theStrippedText.length-6;
					if (document.forms[1]["PQ-Shadow"].selectedIndex>0) {
						theCost=extraLetters*4;
					} else {
						theCost=extraLetters*3;
					}
			} 
		}
	}
	//alert("theCost="+theCost);
	return theCost;
}



function rrUpdateEnable() {

	if (pageType=="RR-Blanket") {

		if (document.forms[1]["addEmb"][0].checked) {
			// if emb OFF 
			rrPriceObj.value=0;			
			document.forms[1]["PQ-<!--save embroidery-->"].value="";
			theElements[rrEmbroideryCost].selectedIndex = 0; 
		} else {
			// if emb ON
			thePrice=0;

			var RR_EmbTextHelp = document.getElementById("RR_EmbTextHelp");
			var RR_EmbTextHelpMonogram = document.getElementById("RR_EmbTextHelpMonogram");
			var RR_EmbTextHelpLetters = document.getElementById("RR_EmbTextHelpLetters");
			var theStyle = document.forms[1]["PQ-Style"];

			RR_EmbTextHelp.style.display = "";
			RR_EmbTextHelpMonogram.style.display = "none";
			RR_EmbTextHelpLetters.style.display = "none";

			if (theStyle.selectedIndex >0 ) {
				if (theStyle.selectedIndex <=5) RR_EmbTextHelpMonogram.style.display = "";
				else RR_EmbTextHelpLetters.style.display = "";
			}
			if (theStyle.selectedIndex >0) document.forms[1]["PQ-Line1"].disabled=false;

			document.forms[1]["PQ-Line2"].disabled=true;
			document.forms[1]["PQ-Line3"].disabled=true;

			// base price for single & drop shadow
			switch(theStyle.selectedIndex) {
			  // monogram	
			  case 1:
			  case 2:
			  case 3:
			  case 4:
			  case 5:
				if (document.forms[1]["PQ-Shadow"].selectedIndex>0) thePrice+=35; else thePrice+=25;
				break;
			  // letters
			  case 6:
			  case 7:
			  case 8:
			  case 9:
			  case 10:
				document.forms[1]["PQ-Line2"].disabled=false;
				document.forms[1]["PQ-Line3"].disabled=false;
				if (document.forms[1]["PQ-Shadow"].selectedIndex>0) thePrice+=28; else thePrice+=22;
				break;
			  default:
			}

			// count characters
			thePrice+=getRRCharacterCost();
			

			if (thePrice>0) {
				document.forms[1]["PQ-Cost"].value=thePrice;	
				//rrPriceObj.value=thePrice;  this was the cool way but it didn't work
				theElements[rrEmbroideryCost].selectedIndex = thePrice - 20; 	// set the big variant list of prices
			} else {
				theElements[rrEmbroideryCost].selectedIndex = 0; 
			}
			
			// save to the PQ-SAVE fields - readable for checkout
			//comeback
			theLocation=document.forms[1]["PQ-Location"].value+" "+" " ;
			theStyle=document.forms[1]["PQ-Style"][document.forms[1]["PQ-Style"].selectedIndex].value;
			theColor=document.forms[1]["PQ-Color"][document.forms[1]["PQ-Color"].selectedIndex].value;
			theShadow=document.forms[1]["PQ-Shadow"][document.forms[1]["PQ-Shadow"].selectedIndex].value;
			theLine1=document.forms[1]["PQ-Line1"].value;
			theLine2=document.forms[1]["PQ-Line2"].value;
			theLine3=document.forms[1]["PQ-Line3"].value;
			document.forms[1]["PQ-<!--save embroidery-->"].value="Embroidery:"+theLocation+ " Color:"+theColor+" Style:"+theStyle+" Shadow:"+theShadow+" Line1:"+theLine1+" Line2:"+theLine2+" Line3:"+theLine3;
			
		}

	}
	changePriceValue();  // this is a monster function

}


function showHide(theValue, theID) {
	theObject = document.getElementById(theID);
	if (theValue) {
		theObject.style.display="block";
		theObject.style.visibility="visible";
	} else {
		theObject.style.display="none";	
		theObject.style.visibility="hidden";
	}
}
function writeSpecialOptions() {
	if (pageType=="RR-Blanket") {

		document.write ('<!--royal riders - start -->');
		document.write ('<table border="0" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse">');
		document.write ('  <tr>');
		document.write ('    <td width="40%"><font class="subtitle2"><b>Custom Embroidery</b></font> </td>');
		document.write ('    <td><input name="addEmb" type="radio" value="false" onClick="showHide(false,customEmbroideryOptions.id);rrUpdateEnable();" checked>');
		document.write ('      None');
		document.write ('      <input name="addEmb" type="radio" value="true" onClick="showHide(true,customEmbroideryOptions.id);rrUpdateEnable();">');
		document.write ('      Add </td>');
		document.write ('  </tr>');
		document.write ('</table>');
		document.write ('<div id="customEmbroideryOptions" style="display:none">');
		document.write ('  <table border="0" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse;margin-left:20px;">');
		document.write ('    <tr>');
		document.write ('      <td width="40%"><font class="subtitle2"> Location</font> </td>');
		document.write ('      <td><select name="PQ-Location" style="font-size: 8pt" onChange="rrUpdateEnable();">');
		document.write ('          <option value="Left Center Barrel" > Left Center Barrel</option>');
		document.write ('          <option value="Left Hip" > Left Hip</option>');
		document.write ('        </select>');
		document.write ('      </td>');
		document.write ('    </tr>');
		document.write ('    <tr>');
		document.write ('      <td width="40%"><font class="subtitle2"> Style</font> </td>');
		document.write ('      <td><select name="PQ-Style" style="font-size: 8pt" onChange="rrUpdateEnable();">');
		document.write ('          <option value="-- Select Style --" >-- Select Style --</option>');
		document.write ('          <option value="1. Monogram - three letters inside diamond ">1. Monogram - three letters inside diamond</option>');
		document.write ('          <option value="2. Monogram - diamond configuration  ">2. Monogram - diamond configuration </option>');
		document.write ('          <option value="3. Monogram - circle configuration ">3. Monogram - circle configuration</option>');
		document.write ('          <option value="4. Monogram - diamond configuration with outline ">4. Monogram - diamond configuration with outline</option>');
		document.write ('          <option value="5. Monogram - circle configuration with outline ">5. Monogram - circle configuration with outline</option>');
		document.write ('          <option value="6. Gothic Letters ">6. Gothic Letters</option>');
		document.write ('          <option value="7. Roman Letters ">7. Roman Letters</option>');
		document.write ('          <option value="8. Old English Letters ">8. Old English Letters</option>');
		document.write ('          <option value="9. Script Letters ">9. Script Letters</option>');
		document.write ('          <option value="10. Diane Script Letters ">10. Diane Script Letters</option>');
		document.write ('        </select>');
		document.write ('      </td>');
		document.write ('    </tr>');
		document.write ('    <tr>');
		document.write ('      <td width="40%"><font class="subtitle2">Color</font> </td>');
		document.write ('      <td><select name="PQ-Color" style="font-size: 8pt" onChange="rrUpdateEnable();">');
		document.write ('          <option value="-" >-</option>');
		document.write ('          <option value="Black">Black</option>');
		document.write ('          <option value="Brown">Brown</option>');
		document.write ('          <option value="Purple">Purple</option>');
		document.write ('          <option value="Burgundy">Burgundy</option>');
		document.write ('          <option value="Navy">Navy</option>');
		document.write ('          <option value="Royal blue">Royal blue</option>');
		document.write ('          <option value="Light blue">Light blue</option>');
		document.write ('          <option value="Hunter green">Hunter green</option>');
		document.write ('          <option value="Kelly green">Kelly green</option>');
		document.write ('          <option value="Grey">Grey</option>');
		document.write ('          <option value="Light grey">Light grey</option>');
		document.write ('          <option value="Red">Red</option>');
		document.write ('          <option value="Light pink">Light pink</option>');
		document.write ('          <option value="Toast">Toast</option>');
		document.write ('          <option value="Cream">Cream</option>');
		document.write ('          <option value="Hite">Hite</option>');
		document.write ('          <option value="Yellow">Yellow</option>');
		document.write ('          <option value="Gold">Gold</option>');
		document.write ('          <option value="Cocoa ">Cocoa </option>');
		document.write ('        </select> <font class="subtitle2"> (Required) </font>');
		document.write ('      </td>');
		document.write ('    </tr>');
		document.write ('    <tr>');
		document.write ('      <td width="40%"><font class="subtitle2">Shadow Color</font> </td>');
		document.write ('      <td><select name="PQ-Shadow" style="font-size: 8pt"  onChange="rrUpdateEnable();">');
		document.write ('          <option value="No Shadow" >No Shadow</option>');
		document.write ('          <option value="Black">Black</option>');
		document.write ('          <option value="Brown">Brown</option>');
		document.write ('          <option value="Purple">Purple</option>');
		document.write ('          <option value="Burgundy">Burgundy</option>');
		document.write ('          <option value="Navy">Navy</option>');
		document.write ('          <option value="Royal blue">Royal blue</option>');
		document.write ('          <option value="Light blue">Light blue</option>');
		document.write ('          <option value="Hunter green">Hunter green</option>');
		document.write ('          <option value="Kelly green">Kelly green</option>');
		document.write ('          <option value="Grey">Grey</option>');
		document.write ('          <option value="Light grey">Light grey</option>');
		document.write ('          <option value="Red">Red</option>');
		document.write ('          <option value="Light pink">Light pink</option>');
		document.write ('          <option value="Toast">Toast</option>');
		document.write ('          <option value="Cream">Cream</option>');
		document.write ('          <option value="Hite">Hite</option>');
		document.write ('          <option value="Yellow">Yellow</option>');
		document.write ('          <option value="Gold">Gold</option>');
		document.write ('          <option value="Cocoa ">Cocoa </option>');
		document.write ('        </select>');
		document.write ('        </td>');
		document.write ('    </tr>');
		document.write ('    <tr>');
		document.write ('      <td width="40%"><font class="subtitle2"> Text (line 1)</font> </td>');
		document.write ('      <td><input name="PQ-Line1" value="" size="20" style="font-size: 8pt;width:100%;" disabled="disabled" onKeyUp="rrUpdateEnable();" onChange="rrUpdateEnable();">');
		document.write ('      </td>');
		document.write ('    </tr>');
		document.write ('    <tr>');
		document.write ('      <td width="40%"><font class="subtitle2"> Text (line 2)</font> </td>');
		document.write ('      <td><input name="PQ-Line2" value="" size="20" style="font-size: 8pt;width:100%;" disabled="disabled" onKeyUp="rrUpdateEnable();" onChange="rrUpdateEnable();">');
		document.write ('      </td>');
		document.write ('    </tr>');
		document.write ('    <tr>');
		document.write ('      <td width="40%"><font class="subtitle2"> Text (line 3)</font> </td>');
		document.write ('      <td><input name="PQ-Line3" value="" size="20" style="font-size: 8pt;width:100%;" disabled="disabled" onKeyUp="rrUpdateEnable();" onChange="rrUpdateEnable();">');
		document.write ('      </td>');
		document.write ('    </tr>');
		document.write ('    <tr>');
		document.write ('      <td width="40%"><font class="subtitle2"> Embroidery Cost</font> </td>');
		document.write ('      <td><input name="PQ-Cost" value="" size="20" style="font-size: 8pt;width:50px;" disabled="disabled">');
		document.write ('        $ </td>');
		document.write ('    </tr>');
		document.write ('  </table>');
		document.write ('  <br>');
		document.write ('  <div id="embHelp" class="subtitle2" style="margin-left:60px">');
		document.write ('    <div id=RR_EmbTextHelp>');
		document.write ('      <div id=RR_EmbTextHelpMonogram style="display:none;"> <b>Note:</b> Please use the <span class="embroideryText">Text</span> box above to enter initials ');
		document.write ('        in the correct order as they are to be embroidered. <br>');
		document.write ('        For the Monogram style, ');
		document.write ('        your last initial <b>must</b> be entered in the center as shown in this ');
		document.write ('        example: <b>J</b>ennifer <b>A</b>nne <b>S</b>mith  = <b>JSA</b> </div>');
		document.write ('      <div id=RR_EmbTextHelpLetters> <b>Note:</b> Please use the <span class="embroideryText">Text</span> boxes to enter text ');
		document.write ('        as it is to be embroidered. Type text exactly as you want to see it on the blanket, including upper and lower case letters.');
		document.write ('        Notice that cost changes based the number of characters entered.</div>');
		document.write ('      <br>');
		document.write ('    </div>');
		document.write ('  </div>');
		document.write ('</div>');
		document.write ('<!--royal riders - end -->');




	}
	if (pageType=="BS-Tack Trunk") {

		document.write ('<!-- move this to script burlingham  ----------------------------------------------->');
		document.write ('<div id="embHelp" class="subtitle2" style="display:none; margin-left:60px">');
		document.write ('  <div id=embTextHelp>');
		document.write ('    <div id=embTextHelp12><b>Note:</b> Please use the <span class="embroideryText">Embroidery Text</span> box above to enter text as it is to be embroidered.');
		document.write ('      Embroidery will be UPPER CASE letters only. ');
		document.write ('      Notice that cost changes based the number of characters entered.</div>');
		document.write ('    <div id=embTextHelp34><b>Note:</b>Please use the <span class="embroideryText">Embroidery Text</span> box above to enter text ');
		document.write ('      as it is to be embroidered. Embroidery will show First Letter Of Each Word Capitalized. ');
		document.write ('      Notice that cost changes based the number of characters entered.</div>');
		document.write ('    <div id=embTextHelp59><b>Note:</b>Please use the <span class="embroideryText">Embroidery Text</span> box above to enter initials ');
		document.write ('      in the correct order as they are to be embroidered. <br>');
		document.write ('      For the Monogram style, ');
		document.write ('      your last initial <b>must</b> be entered in the center as shown in this ');
		document.write ('      example: <b>J</b>ennifer <b>A</b>nne <b>S</b>mith  = <b>JSA</b> </div>');
		document.write ('    <br>');
		document.write ('  </div>');
		document.write ('</div>');
		document.write ('<!-- end of burlingham stuff ---------------------------------------------------------------->');
		
	}
}


function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function NewBrowser(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=yes,location=yes,status=yes,resizable, menubar=yes'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
