function shipTest()
{

document.getElementById("calcresults").innerHTML = "<div align='center'><img id='ajaxLoader' src='http://worf.tchmachines.com/~vmyjbfx/overLord/images/ajax-loader.gif'/></div>";
url = "http://worf.tchmachines.com/~vmyjbfx/overLord/php/shipCalculation.php?";

params = "Item-Count=1"; 
params += "&Item-Code-1="+document.getElementById("nTc").innerHTML;  
temp = document.getElementsByName("vwquantity");
if(temp.length > 0 )
{
	params += "&Item-Quantity-1="+temp[0].value;
}
else
{
	params += "&Item-Quantity-1=1";
}


selects = document.getElementById("cartForm").getElementsByTagName("select");
temp = "";
for(x=0; x < selects.length; x++)
{
	params += "&Item-Option-1-"+selects[x].name+"="+selects[x].options[selects[x].selectedIndex].value; 
}


spans = document.getElementById("cartForm").getElementsByTagName("span");
for(x=0; x < spans.length;x++)
{
	if(spans[x].className == "multiLineOption")
	{
		inputs = spans[x].getElementsByTagName("input");
		if(inputs.length > 0)
		{
			name = inputs[0].previousElementSibling.innerHTML;
			name = name.trim();
			name = name.replace(":","");
			temp += "&Item-Option-1-"+name+"="+inputs[0].value; 
		}
	}
}


params += "&Ship-Zip="+document.getElementById("calc_zip").value;

temp = temp.replace(/"/g,"");
temp = temp.replace(/'/g,"");

var req  = url+params+'&output=json&callback=ws_results&cart=no'+temp; 
bObj = new JSONscriptRequest(req); 
bObj.buildScriptTag(); 
bObj.addScriptTag();
}

function ws_results(obj)
{
var test1=document.getElementById("calcresults");

if(obj.Error == "" && obj.Usps == "" && obj.FedEx == "" && obj.FreightBusiness == "")
{
	test1.innerHTML = "OOOPS! There seems to be an error with the shipping calculation.<br><br>";
	test1.innerHTML += "How to fix:";
	test1.innerHTML += "<ol>";
	test1.innerHTML += "<li>Click 'Add to Cart' and use the Shopping Carts calculation. It often times works when this one doesn't.</li>";
	test1.innerHTML += "<li>If that doesn't work, call us at 800-979-2647</li>";
	test1.innerHTML += "</ol>";
}
else
{
	if(obj.Error != "")
	{
	test1.innerHTML = obj.Error;
	}
	else
	{
		 test1.innerHTML ='<div id="calcresults" style="">';
		 test1.innerHTML +='<div id="ajax_results">';
		 
		 test1.innerHTML +='<div id="ajax_rates">Price:</div>';
		 test1.innerHTML +='<div id="ajax_methods">Method</div>';
		 test1.innerHTML +='<div id="ajax_dates">Transit Time</div>';
		 test1.innerHTML +='<div style="clear: both;"></div>';
		 
		 if(obj.Usps != "")
		 {
		 test1.innerHTML +='<div id="ajax_rates">$'+obj.Usps+'</div>';
		 test1.innerHTML +='<div id="ajax_methods">USPS Priority Mail</div>';
		 test1.innerHTML +='<div id="ajax_dates">'+obj.UspsTransit+' Days</div>';
		 test1.innerHTML +='<div style="clear: both;"></div>';
		 }
		 
		  if(obj.FedEx != "")
		 {
		 test1.innerHTML +='<div id="ajax_rates">$'+obj.FedEx+'</div>';
		 test1.innerHTML +='<div id="ajax_methods">FedEx Ground</div>';
		 test1.innerHTML +='<div id="ajax_dates">'+obj.FedExTransit+' Days</div>';
		 test1.innerHTML +='<div style="clear: both;"></div>';
		 }
		 
		  if(obj.FreightBusiness != "" && obj.FreightBusiness != "0")
		 {
		 test1.innerHTML +='<div id="ajax_rates">$'+obj.FreightBusiness+'</div>';
		 test1.innerHTML +='<div id="ajax_methods">Freight-Business</div>';
		 test1.innerHTML +='<div id="ajax_dates">'+obj.FreightBusinessTransit+' Days</div>';
		 test1.innerHTML +='<div style="clear: both;"></div>';
		 test1.innerHTML +='<div id="ajax_rates">$'+obj.FreightResidential+'</div>';
		 test1.innerHTML +='<div id="ajax_methods">Freight-Residential</div>';
		 test1.innerHTML +='<div id="ajax_dates">'+obj.FreightResidentialTransit+' Days</div>';
		 test1.innerHTML +='<div style="clear: both;"></div>';
		 test1.innerHTML +='</div></div>';
		 }
		 else
		 {
		 /*
		 test1.innerHTML +='<div id="ajax_rates">0</div>';
		 test1.innerHTML +='<div id="ajax_methods">Freight Error With System. Call for Quote!</div>';
		 test1.innerHTML +='<div id="ajax_dates"> </div>';
		 test1.innerHTML +='<div style="clear: both;"></div>';
		 test1.innerHTML +='</div></div>';
		 */
		 }
	}
}
}

function JSONscriptRequest(fullUrl) {
    this.fullUrl = fullUrl; 
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    this.headLoc = document.getElementsByTagName("head").item(0);
    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
}

JSONscriptRequest.scriptCounter = 1;

JSONscriptRequest.prototype.buildScriptTag = function () {
    this.scriptObj = document.createElement("script");
    
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("charset", "utf-8");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}
 
JSONscriptRequest.prototype.removeScriptTag = function () {
    this.headLoc.removeChild(this.scriptObj);  
}

JSONscriptRequest.prototype.addScriptTag = function () {
    this.headLoc.appendChild(this.scriptObj);
}

