function pricingService(kit, sku, imgWI, imgHI, LL, mat, matBorder, kitCall)
{
	this._kit = kit;
	this._sku = sku;
	this._imgWI = imgWI;
	this._imgHI = imgHI;
	this._LL = LL;
	this._mat = mat;
	this._matBorder = matBorder;
	this._kitCall = kitCall;
}

pricingService.prototype.Kit = function(kit)
{
	this._kit = kit;
}

pricingService.prototype.Sku = function(sku)
{
	this._sku = sku;
}

pricingService.prototype.ImgWI = function(imgWI)
{
	this._imgWI = imgWI;
}

pricingService.prototype.ImgHI = function(imgHI)
{
	this._imgHI = imgHI;
}
pricingService.prototype.Mat = function(mat)
{
	this._mat = mat;
}
pricingService.prototype.MatBorder = function(matBorder)
{
	this._matBorder = matBorder;
}
pricingService.prototype.kitCost = function(func)
{
	this.priceCall('kit', func);
}
pricingService.prototype.matCost = function(func)
{
        this.priceCall('mat', func);
}
pricingService.prototype.linerCost = function(func)
{
        this.priceCall('liner', func);
}

pricingService.prototype.frameCost = function(func)
{
	this.priceCall('frame', func);
}
pricingService.prototype.frameOnlyCost = function(func)
{
	this.priceCall('frameOnly', func);
}



pricingService.prototype.priceCall = function(cost, func)
{
	var self = this;
	if (self._kitCall && self._kit == 'cclips') {  func(self._kit, 0.95); return;}
	new Ajax.Request(this.buildURL(),
		{
			method: 'get',
			onSuccess: function(transport){
				switch(cost)
				{
				case 'kit':
					if(self._kit == 'cclips')
						func(self._kit, 0.95);
					else
						func(self._kit, self.getCostKit(transport.responseText));
					break;
				case 'frame':
					func(self.getCost(transport.responseText)); 
					break;
				case 'liner':
					func(self.getCostLiner(transport.responseText)); 
					break;
				case 'frameOnly':
					func(self.getCostFrame(transport.responseText));
					break;
				case 'mat':
				func(self.getCostMat(transport.responseText));
					break;
				}				
			},
			onFailure: function() {  }
		});
}

pricingService.prototype.newxtr = function() {
	var request = false;
	var ua = navigator.userAgent.toLowerCase();
	if (!window.ActiveXObject)
	     request = new XMLHttpRequest();
	else if (ua.indexOf('msie 5') == -1)
	     request = new ActiveXObject("Msxml2.XMLHTTP");
	else
	     request = new ActiveXObject("Microsoft.XMLHTTP");
	return request;
}

pricingService.prototype.getCostLiner = function(data) {
return this.getFloat(data, "liner-cost");
}

pricingService.prototype.getCostKit = function(data) {
	return this.getFloat(data, "framing-kit-cost");
}

pricingService.prototype.getCostFrame = function(data) {
 return this.getFloat(data, "frame-cost");
}

pricingService.prototype.getCostMat = function(data) {
 return this.getFloat(data, "bottom-mat-cost");
}

pricingService.prototype.getCost = function(data) {
	if ( this.getCostLiner(data) > 0) {
	return (this.getFloat(data, "framing-project-cost") - this.getCostKit(data));
	} else {
	return this.getCostKit(data) + this.getCostFrame(data) + this.getCostLiner(data) + this.getCostMat(data);
	}
}

pricingService.prototype.getFloat  = function(data, str) {
	 var doc = xmlParser(data);
        if (doc.getElementsByTagName(str)[0] != null) {
        return parseFloat(doc.getElementsByTagName(str)[0].childNodes[0].nodeValue);
        } else {
        return 0;
        }
}

pricingService.prototype.buildURL = function() {	
	var url = "/cgi-bin/cobraProx.pl/cgi-bin/WebObjects/Pricing.woa/wa/FramedArtPrice/framedArtPrice?";
	url += "testing=true&com.pictureframes.pfs.core.authSkipEnforced=3053&AffID=12345678&returnformat=xml&";
	url += "quantity=1";	
	
	if(this._kit == "cclips")
		url += "&canvClips=true";
	else
	{
		if( this._kit != "")
			url += "&finish=" + this._kit;
	}
	if (this._kitCall) {
		url += "&kitCache=true";
	}
	url += "&mat1="+this._mat+"&t="+this._matBorder+"&r="+this._matBorder+"&b="+this._matBorder+"&l="+this._matBorder+"&LL="+this._LL+"&sku="+this._sku+"&imgWI="+this._imgWI+"&imgHI="+this._imgHI;
	//document.getElementById("matWithKitMessage").innerHTML = url;
	return url;
};
