//used for better business bureau link
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
function replace(string) {
    var text = ' ', by = '';
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
//following 2 functions used for linking letters
function findPrice(toChange,what,input){
  var nameString
  var thePrice
  var index
  var sSelect,temp
  sSelect = document.getElementById(toChange);
  if (sSelect.options[sSelect.selectedIndex].value != '1523')
	temp=1;
  else {
    nameString = replace(input.value);
    thePrice=nameString.length * .95;
    sSelect.options[sSelect.selectedIndex].text ='Letters "A" Add $' + thePrice.toFixed(2);
  }
}
function letterPrice(what,input){
  var nameString
  var thePrice
  nameString = replace(input.value);
  thePrice=nameString.length * .95;
  what.answer.value ="$" + thePrice.toFixed(2);
}
function bookmarksite(title, url){
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}
//following two used to toggle info on shopcustomer.asp
function toggle(obj,obj2) {
	var el = document.getElementById(obj);			//display this
	var el2 = document.getElementById(obj2);		//hide this
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	} else {
		el.style.display = '';
		el2.style.visibility = 'hidden';
	}
}
function removeRow(selectS,obj,obj2) {
	if (document.getElementById) {
	  var el = document.getElementById(obj);
	  var el2 = document.getElementById(obj2);
	  document.getElementById(selectS).selectedIndex = 0; 
	  document.getElementById(selectS + 'text').value = '';
	  el.style.display = 'none';
	  el2.style.visibility = 'visible';
	} else if (document.all) {
	  var el = document.all[obj];
	  var el2 = doclument.all[obj2];
	  document.all[selectS].selectIndex = 0;
	  document.all[selectS + 'text'].value = '';a
	  el.style.display = 'none';
	  el2.style.visibility = 'visible';
	} else if (document.layers) {
	  var el = document.layers[obj];
	  var el2 = document.layers[obj2];
	  document.layers[selectS].selectIndex = 0;
	  document.layers[selectS + 'text'].value = '';
	  el.style.display = 'none';
	  el2.style.visibility = 'visible';
	}
}
//Used in print pages
function toggleLayer(whichLayer)
{
	if (document.getElementById) {
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	} else if (document.all) {
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";		
	} else if (document.layers) {
		var style3 = document.layers[whichLayer].style;
		style3.display = style3.display? "":"block";
	}
}
function getElementByClass(theClass) {
	var allHTMLTags = new Array();
	var matchingHTMLTags = new Array();
	var allHTMLTags=document.getElementsByTagName("*");

    for (i=0; i<allHTMLTags.length+0; i++) {
		if (allHTMLTags[i].className==theClass) {
			matchingHTMLTags.push(allHTMLTags[i]);
		}
	}
	return matchingHTMLTags;
}
function updateCountries(selectValue) {
	var x,y;
	var usTags = new Array();
	usTags = getElementByClass('usa');
	var caTags = new Array();
	caTags = getElementByClass('canada');
	
	if (selectValue.value == "US" || selectValue.value == "PR") {
		for (x in usTags) {
			usTags[x].style.display="block";
		}
		for (y in caTags) {
			caTags[y].style.display="none";
		}
		if (document.getElementById('radio2').checked !== true) {
			document.getElementById('radio1').checked=true;
		}
	} else if (selectValue.value == "CA") {
		for (x in caTags) {
			caTags[x].style.display="block";
		}
		for (y in usTags) {
			usTags[y].style.display="none";
		}
		if ((document.getElementById('radio4').checked !== true) && (document.getElementById('radio5').checked !== true)) {
			document.getElementById('radio3').checked=true;
		}
	} else	{
		for (x in caTags) {
			caTags[x].style.display="block";
		}
		for (y in usTags) {
			usTags[y].style.display="block";
		}
	}
}
function updaterecipient(form,thisselect,id,oid,i) {
	var addressid = thisselect.options[thisselect.selectedIndex].value;
	var itemid = id;
	window.location = "shoplinkaddress.asp?addressid=" + addressid + "&itemid=" + itemid + "&oid=" + oid + "&i=" + i;
}
function updateshipmethod(addressid,sselect) {
	var shipmethod = sselect.options[sselect.selectedIndex].value;
	var fullmethod = shipmethod;
	window.location = "shoplinkshipmethod.asp?addressid=" + addressid + "&fulltext=" + fullmethod;
}

function launchWindow(theForm) {
	//remove onsubmit action here in case there is an error in the JS
	
	document.getElementById('popup_container').style.display = "block";
	document.getElementById('popup_window').style.display = "block";
	document.getElementsByTagName('html')[0].style.overflow = "hidden";
	
	document.getElementById('skipbutton').onclick = submitForm;
								   
	return false;
}

function submitForm() {
	
	document.getElementById('popup_container').style.display = "none";
	document.getElementById('popup_window').style.display = "none";
	document.getElementsByTagName('html')[0].style.overflow = "auto";
	
	document.getElementById('form1').submit();
	
	
	return false;
}


function changeExtraInfo(tabname){
  var directions;
  var numTabs = 5;
  //if (document.images){
  //  document['map'].src = 'images/' + cityname + '.jpg';
  //}
	for(i = 1; i <= numTabs;i++) {
		if (tabname == 'tab' + i) {
			document.getElementById(tabname + '_content').style.display = 'block';
			document.getElementById(tabname).style.borderBottom = '2px solid #FFFFFF';
			document.getElementById(tabname).style.backgroundColor = '#FFFFFF';			
		} else {
			document.getElementById('tab' + i + '_content').style.display = 'none';
			document.getElementById('tab' + i).style.borderBottom = 'none';
			document.getElementById('tab' + i).style.backgroundColor = '#EEEEEE';
		}
	}
}