window.onload = function(){
//	highlightLink();
};

try{
//Cufon.replace('#header #topRed .white a, #header #topRed .shadow', {fontFamily: 'Arial', hover:'true'});
}catch(e){}

function validZip(zipInput){
	if(zipInput.value.indexOf('PO')==0 || zipInput.value.indexOf('po')==0){
		alert('Please enter a street address for shipping, we can not ship to PO Boxes');
		zipInput.value = '';
	}
}

// JavaScript Document

function formData2QueryString(docForm) {
	var submitContent = '';
	var formElem;
	var lastElemName = '';
	for (i = 0; i < docForm.elements.length; i++) {
		formElem = docForm.elements[i];
		if(formElem.disabled) continue;
		switch (formElem.type) {

			// Text fields, hidden form elements
			case 'text':
			case 'hidden':
			case 'password':
			case 'textarea':
			case 'submit':
			case 'select-one':
			submitContent += formElem.name + '=' + escape(formElem.value) + '&'
			break;
			// Radio buttons
			case 'radio':
			if (formElem.checked) {
				submitContent += formElem.name + '=' + escape(formElem.value) + '&'
			}
			break;
			// Checkboxes
			case 'checkbox':
			if (formElem.checked) {
				// Continuing multiple, same-name checkboxes
				if (formElem.name == lastElemName) {
					// Strip of end ampersand if there is one
					if (submitContent.lastIndexOf('&') == submitContent.length-1) {
						submitContent = submitContent.substr(0, submitContent.length - 1);
					}
					// Append value as comma-delimited string
					submitContent += ',' + escape(formElem.value);
				}
				else {
					submitContent += formElem.name + '=' + escape(formElem.value);
				}
				submitContent += '&';
				lastElemName = formElem.name;
			}
			break;
		}
	}

	// Remove trailing separator

	submitContent = submitContent.substr(0, submitContent.length - 1);

	return submitContent;

}

var responseText;

function xmlhttpGet(strURL, strSubmit, strResultFunc,id, refreshNeeded) {
	var xmlHttpReq = false;
	// IE
	if (window.ActiveXObject) {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	// Mozilla/Safari
	else if (window.XMLHttpRequest) {
		xmlHttpReq = new XMLHttpRequest();
		xmlHttpReq.overrideMimeType('text/xml');
	}
	xmlHttpReq.open('POST', strURL, true);
	xmlHttpReq.setRequestHeader('Content-Type',
	'application/x-www-form-urlencoded');
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			//performing our things
			responseText=xmlHttpReq.responseText;
			eval(strResultFunc+"(responseText,'"+id+"','"+refreshNeeded+"')")
		}

	}
	xmlHttpReq.send(strSubmit);
}


function callbackWrapper(responseText,obj,refreshNeeded){
	//checking response for the presence of error tags/markups
	cell=document.getElementById(obj);
	cell.innerHTML=responseText;
	//alert(responseText);
}


function formatPrice(price){
	var v=Math.round(price*100)/100;
	return v.toFixed(2);
}

function roundBy25(v){
	if(v!=''&&v!='0'){
		v=parseFloat(v);
		v+=(v%25!=0)?25-v%25:0;
	}
	return v;
}


function getBaseURL(){
	return document.getElementsByTag('base')[0].href;
}

function highlightLink(){
	//Get filename from the URL
	thisPage = document.URL.substring(document.URL.lastIndexOf("/")+1 ,document.URL.length);
	//Loop through all the links
	for (i=0; i<document.links.length; i++ ){
		//Get only the filename from the href of navigation link
		pageLink = document.links[i].href.substring(document.links[i].href.lastIndexOf("/")+1 ,document.links[i].href.length);
		//if the current filename &amp; the link-ed file name are the same, change the background color of that link

		if (thisPage == pageLink){
			//BG is the name of a class that I have defined, that sets background color to grey
			document.links[i].className += " highlight";
		}
	}
}
