/* ::: thirdwave llc 
   :x: file: paragon.custom.functions.js
   ::: originally written june/july '99
*/


/* Browser type */
browver = parseInt(navigator.appVersion);
browvend = navigator.appName;


/* 1 and 2 no longer used  --PWK, 11/16/01 */


/* ::: Creates dynamic alphabet bar 
   :3: For use on anypage -dynamics
   ::: werk in IE4+ only.
*/


function changeAlpha(idTag, switcher) {
 if (switcher) {
  document.all[idTag].style.color="#E89810";
  document.all[idTag].style.fontWeight="bold";
  } else { 
  document.all[idTag].style.color="#502048";
  document.all[idTag].style.fontWeight="";
 }
}


function clickLink(fileid, regionid, subjectid, id) {
	if (regionid == null && subjectid == null) {
		document.location=fileid +"group=1&letter=" + id;
	} else {
		document.location=fileid +"group=1&letter=" + id + "&regionid=" + regionid + "&subjectid=" + subjectid;
	}
}



/* ::: Focuses the cursor on the Quick Search input box.
   :4: If this doesn't work across all browsers, nothing will.
   ::: Last modified 11/16/01 by PWK
*/


// Invoked by <body onLoad>, this tag sends the cursor to the Quick Search box.
function focusQuickSearch() {
	document.searchForm.searchkeyword.focus();
}  // focusQuickSearch


// Does not allow the form to be submitted unless a search term is typed.
function ignoreEmptyQuickSearch() {
	if ("" == document.searchForm.searchkeyword.value) {
		window.location = "../../html/powersearch/index.cfm";
		return false;
	} else {
		return true;
	}
}  // ignoreEmptyQuickSearch



/* ::: Adds an item to the shopping bag (possibly Used/Hurt, possibly with discounts.)
   :5: Browser-independent.
   ::: Last modified 11/13/01 by PWK
*/


// Regular items
function addItem(itemid, urlrefer) {
	//alert('This is the additem function');
	var url = "/html/youraccnt/additempopup.cfm?itemid=" + itemid +
		"&urlrefer=" + escape(urlrefer, 1);
	//alert(url);	
	var addItem = window.open(url, "addItem",
		"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=400");
}  // addItem


// Used/Hurt items
function addHurtItem(itemid, hurtcopyid, urlrefer) {
	var url = "/html/youraccnt/additempopup.cfm?itemid=" + itemid +
		"&hurtcopyid=" + hurtcopyid +
		"&urlrefer=" + escape(urlrefer, 1);
	var addItem = window.open(url, "addItem",
		"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=400");
}  // addHurtItem


// Discounted (regular) items
function addItemWithBonus(itemid, urlrefer, bonustype, discountcontingencyid, otheritemid) {
	//alert('This is the additemWith Bonus function');
	var url = "/html/youraccnt/additempopup.cfm?itemid=" + itemid +
		"&bonustype=" + bonustype +
		"&discountcontingencyid=" + discountcontingencyid +
		"&otheritemid=" + otheritemid +
		"&urlrefer=" + escape(urlrefer, 1);
	var addItem = window.open(url, "addItem",
		"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=400,height=300");
}  // addItemWithBonus


function cloneAddress(form) {
	var prefix = "bl_",
	e = form.elements;
	for(var i=0;i<e.length;i++) {
	var thisItem = e[i].name;
	var anotherItem = e[i].name; //these form values won't be shortened
	thisItem = thisItem.replace(/sp_/,"" );
	if(e[prefix + thisItem]) {
		e[i].value = e[prefix + thisItem].value;
		}
		//account for items that do not have the 'bl_' prefix that need to be cloned
	else {
		if (e[anotherItem.replace(/sp_/,"" )]){
			e[i].value = e[anotherItem.replace(/sp_/,"" )].value;
			}
		}
	}
} // cloneAddress


// toggle 'shipping same as billing' radio button when user begins to type in the shipping address section
function resetAddressSelect() {
	document.CFForm_1.sp_eq_bl[1].checked = true; 
} // resetAddressSelect






