function filmTypePanelObject () {
	this.x = -1;
	this.y = -1;
	this.request = undefined;
	this.modelID = '';
	this.modelSKUStem = '';
	this.modelSKU = '';
	this.isBulk = false; // is ignored for the moment
	this.dayvueSwapStem = undefined;
	this.description = '';
	this.baseCost = 0.00;
	this.quantity = 1;
	this.shipping = '.05';
	this.interval = 3;
	this.frames = 10;
	this.panel = undefined;
	this.intervalID = -1;
	this.step = 0;
	this.width = -1;
	this.height = -1;
	this.isIE = false;
	this.filmTypeDescriptions = undefined;
	this.action = undefined;
	this.lastURL = undefined;
	this.filmTypeXMLURL = '/ajax/filmTypes.xml';
	this.modelFilmTypeBaseURL = '/ajax/filmTypes_xml.php';

	this.loadXMLDoc = function (url, action, context, stateChangeFunction) {
		context.lastURL = url;
		context.action = action;
		this.isIE = navigator.appName == 'Microsoft Internet Explorer' ? true : false;

		// branch for native XMLHttpRequest object
		var req;
		if (window.XMLHttpRequest)
			req = new XMLHttpRequest()
		else {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if (req) {
			context.req = req;
			req.onreadystatechange = stateChangeFunction;
			req.open("GET", url, true);
			req.setRequestHeader( "Content-type", "text/xml" );
			req.send(null);
		}
	};

	this.processReqChange = function () {
		// This in the context of this function is the XMLHttpRequest
		var that = filmTypePanel;
		var action = that.action;
		if (that.req === undefined) {
			alert('AJAX Request is undefined.');
			return;
		}
		// only if req shows "loaded"
		if (0) {
			var debug = that.req.responseText;
			var loc1 = document.getElementById('detail');
			var loc = document.getElementById('detail2');
			if (loc)
			loc1.removeChild(loc);
			loc = document.createElement('div');
			loc1.appendChild(loc);
			loc.id = 'detail2';
			var pre = document.createElement('pre');
			pre.appendChild(document.createTextNode(debug));
			loc.appendChild(pre);
		}
		if (that.req.readyState === 4) {
			if (that.req.status === 200 || that.req.status === 304)
				action(that, that.req);
			else
				alert("XML Error:\n" + that.req.statusText + '\nStatus: ' + that.req.status + '\n' + "URL: " + that.lastURL);
		}
	};

	this.show = function () {
		this.makePanel();
	};
	
	this.hide = function () {
		//this.makePanel();
		if (this.panel === undefined)
			return;
		if (this.intervalID != -1) {
			window.clearInterval(this.intervalID);
			this.intervalID = -1;
		}
		this.step = 1;
		var that = this;
		var rootElement = document.getElementById('filmTypePanelAnchor');
		if (!rootElement)
			rootElement = document.getElementsByTagName('body')[0];
		var currentOpacity = that.panel.style.opacity ? that.panel.style.opacity : (that.panel.style.filter && that.panel.style.filter !== '' ? that.panel.style.filter.match(/alpha\(opacity=([0-9]+)\)/)[1]/100.0 : 1.0);
		if (currentOpacity > 0) {
			var shadowCSSCode = '';
			with (that.panel.style) {
				oBoxShadow = shadowCSSCode;
				icabBoxShadow = shadowCSSCode;
				khtmlBoxShadow = shadowCSSCode;
				MozBoxShadow = shadowCSSCode;
				webkitBoxShaow = shadowCSSCode;
				boxShadow = shadowCSSCode;
			}
			this.intervalID = window.setInterval(function () {
				try {
					var opacity = 1.0 - 1.0/that.frames * that.step++;
					// Check for IE
					if (that.panel.style.opacity)
						that.panel.style.opacity = opacity;
//					else {
//						// IE uses filter = 'alpha(opacity = x%)'
//						var ieOpacity = opacity*100;
//						that.panel.style.filter = 'alpha(opacity=' + ieOpacity + ')';
//					}
				}
				finally {
					if (that.step === that.frames+1) {
						window.clearInterval(that.intervalID);
						that.intervalID = -1;
						rootElement.removeChild(that.panel);
						that.panel = undefined;
					}
				}	
			}, this.interval);
		}
			
	};
	// Creates a default panel for debugging.
	this.makePanel = function () {
		var i,j;
		var getY = function ( oElement ) {
			var iReturnValue = 0;
			while( oElement != null ) {
				iReturnValue += oElement.offsetTop;
				oElement = oElement.offsetParent;
			}
			return iReturnValue;
		};
		
		var getX = function ( oElement ) {
			var iReturnValue = 0;
			while( oElement != null ) {
				iReturnValue += oElement.offsetLeft;
				oElement = oElement.offsetParent;
			}
			return iReturnValue;
		};

		var text = function(x,y) {
			var txt = document.createTextNode(y);
			if (x) x.appendChild(txt);
			return txt;
		};
		var italic = function (x) {
			var tn = text(null, x);
			var i = document.createElement('i');
			i.appendChild(tn);
			return i;
		};
		var br = function(x) {
			var br = document.createElement('br');
			if (x)
				x.appendChild(br);
			return br;
		};
		var hr = function() {
			var hr = document.createElement('hr');
			hr.width = '100%';
			return hr;
		};
		var p = function(x,y) {
			var i;
			var para = document.createElement('p');
			if (y) {
				for (i=0; i<y.length; i++)
					para.appendChild(y[i]);
			}
			if (x) x.appendChild(para);
			return para;
		};
		var strong = function(x,y) {
			var strong = document.createElement('strong');
			text(strong, y);
			if (x)
				x.appendChild(strong);
			return strong;
		};
		var td = function(x, y) {
			var td = document.createElement('td');
			if (y) {
				var i;
				for(i=0; i<y.length; i++)
					td.appendChild(y[i]);
			}
			if (x)
				x.appendChild(td);
			return td;
		};
		var bold = function(x) {
			var b = document.createElement('b');
			b.appendChild(document.createTextNode(x));
			return b;
		};
		var thCol = function(x,y) {
			var elem = document.createElement('th');
			p(elem, [text(null, x)]);
			elem.width = y;
			elem.valign = 'top';
			return elem;
		};
		var thCol2 = function(x, y, z) {
			var elem = document.createElement('th');
			var para = p(elem, [text(null, x), br(null), text(null, y)]);
			elem.width = z;
			elem.valign = 'top';
			return elem;
		};
		// For IE 7 compat.
		var tbody = function (table) {
			var tb = document.createElement('tbody');
			table.appendChild(tb);
			return tb;
		}
		var thead = function (table) {
			var thead = document.createElement('thead');
			table.appendChild(thead);
			return thead;
		}
		// -- end
		var that = this;
		
		if (this.panel === undefined) {
			// Generate Element
			var documentFragment = document.createDocumentFragment();
			that.panel = document.createElement('div');
			documentFragment.appendChild(that.panel);
			var rootElement = document.getElementById('filmTypePanelAnchor');
			if (!rootElement)
				rootElement = document.getElementsByTagName('body')[0];
			else
				that.y = -2;
			that.panel.id = 'filmTypePanel';
			that.panel.className = 'shadowed';
			var windowWidth = typeof(window.outerWidth) == 'number' ? window.outerWidth : document.body.clientWidth;
			var windowHeight = typeof(window.innerHeight) == 'number' ? window.innerHeight : document.body.clientHeight
			with (that.panel.style) {
				backgroundColor = '#F8F9F5';
				border = '1px solid black';
				//padding = '5px 0 5px 0';
				position = 'absolute';
				display = 'block';
				zIndex = 15;
				top = '0px';
				right = 'auto';
				bottom = 'auto';
				left = 'auto';
				fontFamily = 'Verdana';
				fontSize = '11px';
				fontStyle = 'normal';
				fontVariant = 'normal';
				lineHeight = 'normal';

				if (that.width === -1) {
					that.width = windowWidth * .9;
					that.x = windowWidth * .025;
				}
				if (that.height === -1) {
					var perH = .90;
					if (that.y !== -1)
						perH -= that.y/windowHeight;
					//maxHeight =  (perH * 100) + '%';
					//height = 'auto';
					//overflow = 'auto';
				} else
					height = that.height + 'px';
				if (that.y >= 0)
					top = that.y + 'px';
				else if (that.y === -2) {
					if (rootElement)
						top = getY(rootElement) + 'px';
				}

				if (that.x === -1)
					left = (windowWidth - that.width)/2 + 'px';
				else
					left = that.x + 'px';
				width = that.width + 'px';
			}
			try {
				var scrOfY = 0;
				if (that.y === -1) {
					if( typeof( window.pageYOffset ) == 'number' ) {
						//Netscape compliant
						scrOfY = window.pageYOffset;
					} else if( document.body
							 && ( document.body.scrollLeft 
								 || document.body.scrollTop ) ) {
						//DOM compliant
						scrOfY = document.body.scrollTop;
					} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
						//IE6 standards compliant mode
						scrOfY = document.documentElement.scrollTop;
					}
					that.panel.style.top = scrOfY + 10 + 'px';
				}
				if (that.panel.style.opacity !== undefined)
					that.panel.style.opacity = 0;
				window.scrollTo(getX(rootElement),getY(rootElement));
			}
			finally {
				//rootElement.appendChild(documentFragment);
				rootElement.insertBefore(documentFragment, rootElement.firstChild);
			}
		}

		// filmTypeDescriptions
		if (that.modelID !== undefined) {
			var defaultSet = false;
			snsCartInterface.clear();
			var form = snsCartInterface.form();
			var processFunction = function(that, request) {
					request = that.req;
				var typeSelectorRow = function(name, displayName, code, scratch, solvent, clarity, glare, surcharge, cost, sku, films) {
					var row = document.createElement('tr');
					var radio;
					// option1|NAME OF OPTION
					var snsEncodedName = 'option2|Film Type';
					var snsEncodedValue = name.replace(/(&(#8482|trade);)|™/, '(tm)') + '|' + (surcharge === '0' ? '0.00' : surcharge.toFixed(2));
					var cmName = 'ignore';
					if (that.isIE) {
						radio = document.createElement("<INPUT type=\"radio\" name=\"" + cmName + "\">");
					}
					else {
						radio = document.createElement('input');
						radio.type = 'radio';
						radio.name = cmName;
					}
					radio.id = code;
					radio.value = snsEncodedValue;
					var destField = document.getElementById('filmTypeValue');
					radio.onclick = function () {
						that.modelSKU = sku;
						var oldValue = destField.value
						destField.value = snsEncodedValue;
//						alert(destField + ' ' + oldValue + '->' + snsEncodedValue);
					}
					if (!defaultSet) {
						radio.checked = true;
						radio.defaultChecked = true;
						that.modelSKU = sku;
						destField.value = snsEncodedValue; 
					}
					// Set name and value for SNSCart later
					row.appendChild(td(null, [radio, text(null, displayName)]));
					td(row, [text(null, scratch)]).align = 'center';
					td(row, [text(null, solvent)]).align = 'center';
					td(row, [text(null, clarity)]).align = 'center';
					td(row, [text(null, glare)]).align = 'center';
					td(row, [text(null, films + ' for $' + Number(cost).toFixed(2))]).align = 'center';
					return row;
				};
				var panel = that.panel;
				panel.appendChild(form);
	
				if (request.responseXML === null) {
					that.panel.appendChild(document.createTextNode(request.responseText));
					that.panel.style.textColor = 'red';
					return;
				}
	
				var table = document.createElement('table');
	
				var xmlReply = request.responseXML.documentElement;
				var filmTypes = xmlReply.getElementsByTagName('type');
				form.appendChild(table);
	
				table.border = '0';
				table.cellpadding = '0';
				table.cellspacing = '0';
				table.style.paddingLeft = '1em';
				table.style.paddingRight = '1em';
//				table.style.paddingBottom = '1em';
				table.width = '100%';
				var tableBody = tbody(table);
				var row = document.createElement('tr');
				tableBody.appendChild(row);
				var col1 = document.createElement('td');
				row.appendChild(col1);
	
				var rowChart = document.createElement('tr');
				tableBody.appendChild(rowChart);
				var chartHeader = document.createElement('td');
				rowChart.appendChild(chartHeader);
	
				p(chartHeader, [br(null), strong(null, 'NuShield™ Film Selector Chart'), br(null), text(null, 'Select your film type:')]);

				var table2 = document.createElement('table');
				chartHeader.appendChild(table2);
	
				with (table2) {
					border = '1';
					cellspacing = '3';
					cellpadding = '0';
					style.border = 'thin';
					style.borderWidth = 'thin';
				}

				var table2Head = thead(table2);
				var table2Body = tbody(table2);

				var TSRow = document.createElement('tr');
				table2Head.appendChild(TSRow);
				with (TSRow) {
					align = 'center';
					appendChild(thCol('NuShield™ Film', '200'));
					appendChild(thCol2('Scratch', 'Resistance', '100'));
					appendChild(thCol2('Solvent', 'Resistance', '100'));
					appendChild(thCol('Clarity', '100'));
					appendChild(thCol2('Glare', 'Protection', '100'));
					appendChild(thCol('Cost (each)', '183'));
				}
				var filmTypeField;
				var filmTypeFieldSNSEncodedName = 'option2|Film Type';

				if (that.isIE) {
					filmTypeField = document.createElement("<INPUT type=\"hidden\" name=\"" + filmTypeFieldSNSEncodedName + "\" " + "id=\"filmTypeValue\"" + ">");
				}
				else {
					filmTypeField = document.createElement('input');
					filmTypeField.type = 'hidden';
					filmTypeField.name = filmTypeFieldSNSEncodedName;
					filmTypeField.id = 'filmTypeValue';
				}
				form.appendChild(filmTypeField);

				var i;
				for (i=0; i<filmTypes.length; i++) {
					var type = filmTypes[i];
					var para;
					var attrs = type.attributes
					var code;
					var typeSKU;
					var baseCost;
					var filmsQuantity;
					for (j=0; j<attrs.length; j++) {
						var attr = attrs[j];
						if (attr.name === 'code')
							code = attr.value;
						else if (attr.name === 'snsSKU')
							typeSKU = attr.value;
						else if (attr.name === 'snsSKU')
							typeSKU = attr.value;
						else if (attr.name === 'basePrice')
							baseCost = Number(attr.value) + 0.002;
						else if (attr.name === 'filmsQuantity')
							filmsQuantity = Number(attr.value);
					}
					var lookup = that.filmTypeDescriptions[code];
					if (lookup.description && lookup['description'] !== '') {
						para = p(null, [strong(null, lookup['displayName'])]);
						para.innerHTML = para.innerHTML + ' ' + lookup['description'];
					}
					var pm = Number(lookup.priceModifier);
					var cost = baseCost * pm;
					var surcharge = baseCost * (pm - 1);
					table2Body.appendChild(
					//name, displayName, code, scratch, solvent, clarity, glare, surcharge, cost
						typeSelectorRow(lookup.snsname,
							lookup.displayName,
							code,
							lookup.scratch,
							lookup.solvent,
							lookup.clarity,
							lookup.glare,
							surcharge,
							cost,
							typeSKU,
							filmsQuantity)
					);
					defaultSet = true;
					if (para)
						col1.appendChild(para);
				}
				
				that.isIE = false;

				var buttonFontSize = "bold 150% 'trebuchet ms',helvetica,sans-serif";
				var submitButton = function () {
				var submit = document.createElement('input');				
				var addToCartFunction = function () {
						// Validate:
						var inputs = that.panel.getElementsByTagName('input');
						var filmTypeSelected = false;
						var i;
						for (i=0; i<inputs.length; i++) {
							var input = inputs[i];
							if (input.type == 'radio' && input.checked == true) {
								filmTypeSelected = true;
								break;
							}
						}
						
						var nameField = document.getElementById('sku');
						nameField.value = that.modelSKU;
						if (filmTypeSelected)
							form.submit();
						else
							alert('No Film Type has been selected. Please select a film type.');
					};
					
					if (that.isIE)
						submit = document.createElement('<input type="button" name="addToCart" value="Add to Cart">');
					else {
						submit.type = 'button';
						submit.name = 'addToCart';
						submit.value = 'Add to Cart';
					}
					submit.style.font = buttonFontSize;
					submit.onclick = addToCartFunction;
					return submit;
				};
				
				var cancelButton = function () {
					var cancel;
					
					if (that.isIE)
						cancel = document.createElement('<input type="button" name="cancel" value="Cancel"');
					else {
						cancel = document.createElement('input');
						cancel.type = 'button';
						cancel.name = 'cancel';
						cancel.value = 'Cancel';
					}
					cancel.onclick = function () {filmTypePanel.hide(); return false; };
					cancel.style.font = buttonFontSize;
					return cancel;
				};

				var topMatter = document.createElement('div');
				topMatter.appendChild(submitButton());
				topMatter.appendChild(cancelButton());
				topMatter.style.paddingLeft = '1em';
				topMatter.style.paddingTop = '1em';
				panel.insertBefore(topMatter, panel.firstChild);
				p(chartHeader, [text(null, 'Not all films types are available or recommended for all applications'), br(null), text(null, 'Higher numbers means a higher amount of that property.'), form.quantity(that.quantity), hr(), bold('Klear Screen '), text(null, 'NuShield recommends that you clean the LCD screen of your device before installing the screen protector. Klear Screen wiping pads will remove any dirt or grit from the LCD screen. NuShield offers 3 wiping pads and a chamois cloth for $1.99 when purchasing screen protectors.'), that.isIE?form.KSIE('checkbox'):form.KS('checkbox'), /* br(),*/ submitButton(), cancelButton()]);
				form.addItem('add', '1');
				form.addItem('sku', that.modelSKU);


				//form.addItem('description', that.description);
				//form.addItem('shipping', that.shipping);
				//form.addItem('price', that.baseCost);
				// Show

				if (that.intervalID != -1) {
					window.clearInterval(that.intervalID);
					that.intervalID = -1;
				}
				that.step = 1;
				var currentOpacity = that.panel.style.opacity ? that.panel.style.opacity : (that.panel.style.filter && that.panel.style.filter !== '' ? that.panel.style.filter.match(/alpha\(opacity=([0-9]+)\)/)[1]/100.0 : 0.0);
				if (currentOpacity < 1) {
					that.intervalID = window.setInterval(function () {
						try {
							var opacity = 1.0/that.frames* that.step++;
							if (that.panel.style.opacity)
								that.panel.style.opacity = opacity;
							else
								that.step = that.frames+1;
						}
						finally {
							if (that.step === that.frames+1) {
								window.clearInterval(that.intervalID);
								that.intervalID = -1;
								var shadowCSSCode = '5px 5px 15px #222';
								with (that.panel.style) {
									oBoxShadow = shadowCSSCode;
									icabBoxShadow = shadowCSSCode;
									khtmlBoxShadow = shadowCSSCode;
									MozBoxShadow = shadowCSSCode;
									webkitBoxShaow = shadowCSSCode;
									boxShadow = shadowCSSCode;
								}
							}
						}	
					}, that.interval);
				}
			};

			var filmTypeRetrievalFunction = function(that, request) {
				var xmlReply = request.responseXML.documentElement;
				var filmTypes = xmlReply.getElementsByTagName('film');
				that.filmTypeDescriptions = new Object();
				for (i=0; i<filmTypes.length; i++) {
					var record = new Object();
					var desc = filmTypes[i].textContent ? filmTypes[i].textContent : filmTypes[i].text;
					if (desc === undefined)
						desc = "N/A";
					record['description'] = desc;
					var attrs = filmTypes[i].attributes;
					for (j = 0; j < attrs.length; j++) {
						var attr = attrs[j];
						if (attr.name === 'name')
							record['name'] = attr.value;
						else if (attr.name === 'display')
							record['displayName'] = attr.value;
						else if (attr.name === 'scratch')
							record['scratch'] = attr.value;
						else if (attr.name === 'solvent')
							record['solvent'] = attr.value;
						else if (attr.name === 'clarity')
							record['clarity'] = attr.value;
						else if (attr.name === 'glare')
							record['glare'] = attr.value;
						else if (attr.name === 'priceModifier') {
							var pm =  1.0 + Number(attr.value);
							var sur = Number(that.baseCost) * Number(attr.value);
							record['priceModifier'] = pm;
						}
						else if (attr.name === 'snsname')
							record['snsname'] = attr.value;
					}
					that.filmTypeDescriptions[record['name']] = record;
					/*
					record['name'] = attrs.name.value;
					record['displayName'] = attrs.display.value;
					record['scratch'] = attrs.scratch.value;
					record['solvent'] = attrs.solvent.value;
					record['clarity'] = attrs.clarity.value;
					record['glare'] = attrs.glare.value;
					var pm =  1.0 + Number(attrs.priceModifier.value);
					var sur = Number(that.baseCost) * Number(attrs.priceModifier.value);
					record['priceModifier'] = pm;
					record['snsname'] = attrs.snsname.value;
					that.filmTypeDescriptions[record['name']] = record;
					*/
				}	
				that.makePanel();
			};
			
			if (that.filmTypeDescriptions === undefined)
				that.loadXMLDoc(that.filmTypeXMLURL, filmTypeRetrievalFunction, that, that.processReqChange);
			else
				that.loadXMLDoc(that.modelFilmTypeBaseURL + '?p=' + that.modelID, processFunction, that, that.processReqChange);
		}
		
	};
}

function snsCartInterfaceObject () {
	this.name = undefined;
	this.description = undefined;
	this.price = undefined;
	this.shipping = undefined;
	this.quantity = 0;
	this.merchant = '404';
	
	this.omitship = false;
	this.ship = true;
	this.promo = true;
	this.volume = true;
	this.free = false;
	this.minQty = 0;
	this.maxQty = 0;
	this.flat = undefined;
	
	this.hasKS = false;
	
	this.filmType = 'Antiglare';
	this.filmPrice = '0.00';
	
	this.snsForm = null;
	
	this.form = function () {		
		var that = this;
		
		if (this.snsForm)
			this.snsForm.parentNode.removeChild(this.snsForm);
		this.snsForm = document.createElement('form');
		this.snsForm.addItem = addItem;
		
		var addItem = function (name, value) {
			var input = document.createElement('input');
			input.type = 'hidden';
			input.name = name;
			input.value = value;
			input.id = name;
			that.snsForm.appendChild(input);
			return input;
		};
		
		var addItemIE = function (name, value) {
			var input = document.createElement('<input type="hidden" name="' + name + '" value="' + value + '" id="' + name + '">');
			that.snsForm.appendChild(input);
			return input;
		};
		
		var quantity = function (x) {
			var input = document.createElement('input');
			input.type = 'text';
			input.name = 'quantity';
			input.value = x;
			input.maxlength = '4';
			input.size = '4';
			var para = document.createElement('p');
			para.appendChild(document.createTextNode('Quantity: '));
			para.appendChild(input);
			return para;
		};
		
		var quantityIE = function (x) {
			var input = document.createElement('<input type="text" name="quantity" value="' + x + '" maxlength="4" size="4">');
			var para = document.createElement('p');
			para.appendChild(document.createTextNode('Quantity: '));
			para.appendChild(input);
			return para;
		};


		var _KS = function (type, isIE) {
			var input;
			var bu = function(x) {
				var span = document.createElement('span');
				span.style.textDecoration = 'underline';
				span.style.fontWeight = 'bold';
				span.appendChild(document.createTextNode(x));
				return span;
			};
			if (type === 'checkbox' || type === 'radio') {
				var para = document.createElement('p');
				var boldSpan = document.createElement('b');
				boldSpan.appendChild(document.createTextNode('Special offer:'));
				para.appendChild(boldSpan);
				para.appendChild(document.createTextNode(' Get '));
				para.appendChild(bu('Klear Screen at 33% off'));
				para.appendChild(document.createTextNode(' when you purchase NuShield screen protectors!'));
				para.appendChild(document.createElement('br'));
				if (!isIE) {
					input = document.createElement('input');
					input.type = type;
					input.name = 'option1|Special Offer';
					input.value = 'Klear Screen|1.99|.06';
					input.checked = false;
					input.id = 'KlearScreen';
				}
				else
					input = document.createElement('<input type="' + type + '" name="option1|Special Offer" value="Klear Screen|1.99|.06" checked="false" id="KlearScreen"');
				var label = document.createTextNode('3 Klear Screen wipes - $1.99');
				para.appendChild(input);
				para.appendChild(label);
				return para;
			}
			else
				that.snsForm.appendChild(input);
		};

		var KS = function (type) {
			return _KS(type, false);
		};
		
		var KSIE = function (type) {
			return _KS(type, true);
		};
		
		this.snsForm.addItem = addItem;
		this.snsForm.addItemIE = addItemIE;
		this.snsForm.KS = KS;
		this.snsForm.KSIE = KSIE;
		this.snsForm.quantity = quantity;
		this.snsForm.method = 'POST';
		this.snsForm.action = 'http://www.ewebcart.com/~' + this.merchant + '/cgi-bin/cart.cgi';
		if (this.hasKS)
			addKS('hidden');
	
		with (this) {
			if (name && description && price && quantity && quantity > 0 && merchant) {
				var itmModifiers = '';
				if (omitship) itmModifiers += '[#OMITSHIP#]';
				if (!ship) itmModifiers += '[#NOSHIP#]';
				if (!promo) itmModifiers += '[#NOPROMO#]';
				if (!volume) itmModifiers += '[#NOVOL#]';
				if (free) itmModifiers += '[#FREE#]';
				if (minQty > 0) itmModifiers += '[#MINQTY:' + minQty + '#]';
				if (maxQty > 0) itmModifiers += '[#MAXQTY:' + maxQty + '#]';
				if (flat) shipping = 'FLAT:' + flat;
				
				name += itmModifiers;
				addItem('name', name);
				addItem('description', description);
				addItem('price', price);
				addItem('shipping', shipping);
				addItem('add', '1');
			}
		}
		return this.snsForm;
	};
	
	this.clear = function () {
		with (this) {
			name = undefined;
			description = undefined;
			price = undefined;
			shipping = undefined;
			quantity = 0;
			merchant = '404';
			omitship = false;
			ship = true;
			promo = true;
			volume = true;
			free = false;
			minQty = 0;
			maxQty = 0;
			flat = undefined;
			if (snsForm) {
				if (snsForm.parentNode)
					snsForm.parentNode.removeChild(this.snsForm);
				snsForm = null;
			}
		}
	};
	
	this.addToCart = function () {
		if (this.snsForm)
			this.snsForm.submit();
	};
}

var snsCartInterface = new snsCartInterfaceObject();
var filmTypePanel = new filmTypePanelObject();
