function helpPop(id)
{
	var popurl="/help.jsp?id=" + id 
	winpops=window.open(popurl,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=500");
}

function open_window(newwin, width, height) {	
	flyout=window.open(newwin, "popup_sizing", "width=" + width + ",height=" + height + ",menubar=no,toolbar=no,resizeable=no,status=no,scrollbars=yes,center=1");
	flyout.focus();
}

var clicked = false;

function postPage(form, page){	
	
	if (clicked != true){
		form.action = page;
		clicked = true;		
		form.submit();				
	}
}

function processSubmit(form){	
	document["subImg"].src = "i/processing.gif"; ;
	document.getElementById("subHref").href = "#submit";	
   	form.submit();
}

function postMulti(form,page){	
	document["subImg"].src = "i/processing.gif"; ;
	document.getElementById("subHref").href = "#submit";	
	form.encoding = "multipart/form-data";
	form.action = page;
   	form.submit();
}

function setSelectedItem(svalue){		
	document.ItemForm.o.options[svalue].selected = true;	
}

function calcPrice(){
	var selectedItem = document.ItemForm.PriceBox.selectedIndex;
	var qty = document.ItemForm.PriceBox.options[selectedItem].text;
	var unitPrice = document.ItemForm.PriceBox.options[selectedItem].value;	
	var totalPrice = qty * unitPrice;
	totalPrice = totalPrice.toFixed(2);
	document.ItemForm.itemPrice.value = totalPrice;
	document.ItemForm.itemQty.value = qty;

}

function formatCurrency(price){
	var fPrice = 0.00;	
	fPrice = price.toFixed(2);
	document.write(fPrice);
}

function reSort(qs,obj){	
	var sortId;	
	sortId = obj.value;			
	qs = qs + sortId
	document.ItemForm.action = qs;		
	document.ItemForm.submit();				
	
}

function refresh(page){
	window.location = page;		
}

function changePicture(picture,altText){	
	document["itemImage"].src = picture;
	document.getElementById("itemLink").href = picture;		
	document["itemImage"].title = altText;
}

function getCheckedRadio(radioObj) {
	if(!radioObj)		
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked){			
			return radioObj;
		}else{		
			radioObj.checked = true;	
			return radioObj;
		}
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i];
		}
	}
	radioObj[0].checked = true;	
	return radioObj[0];
}

function highlightTerm(){
	var anchorID = location.hash;
	if (anchorID != ""){
		anchorID = anchorID.replace(/(#)/g,"");	
		document.getElementById(anchorID).style.color = "#FF0000";	
	}
}

function sizeValidate(){		
	checkfield = document.ItemForm.size;	
	if (checkfield.value == 0) {
  		checkfield.focus();
  		alert("Please select a size.");
  		return false;
  	}  	  	
  	return true;
}

function addToCart(){	
	if (sizeValidate()){
		postPage(ItemForm, '/addtocart.jsp');
	}	
}

function updateQty(dropdown, item){
	var minQty = dropdown.value;
	document.ItemForm.itemQty.value = minQty;
	document.ItemForm.ordertype.value = dropdown.id;
	getPrice(item,minQty);
}

function setScreenWidth(id){
	var screenW = 640, screenH = 480;
	if (parseInt(navigator.appVersion)>3) {
 		screenW = screen.width; 		
 	}
 	if (screenW == "" || screenW == null) screenW = 640;
 	
 	if (screenW >= 1024){
 		document.getElementById(id).width="1000";
 	} else {
 		document.getElementById(id).width="780";
 	}
}

function protectmail(name,address,style,subject) {
	document.write('<a class="' + style + '" href=mailto:' + name + '@' + address + '?subject=' + subject + '>' + name + '@' + address + '</a>');
}