﻿// JavaScript Document

	var slider = "";

	if(typeof parkside == "undefined") var parkside = new Object();
	if(typeof parkside.feature_slide == "undefined") parkside.feature_slide = new Object();
	
	// Constructor
	parkside.feature_slide = function() {
	}
	
	/// Class members
	parkside.feature_slide.prototype = {
	/// Properties
		feature_slide_results: null,
		
	/// Methods
		request: function(params) 
		{			
			if( typeof http == "undefined" )
			{
				alert("JSMX not included!");
				return;
			}	
						
			http("POST", "custom/big_feature.cfc?method=getFeaturesAjax", this.response, params); //notice the third argument = list_response. This is the callback function below.
		}
		,
		response: function(obj) //callback functions always take one argument. This is the result passed back from the server.
		{ 	
			if(obj !== "undefined") 
			{
				var list = document.getElementById("feature_list");
				for(var i = 0; i < fs.length; i++)
				{
					list.innerHTML += fs[i];
				}
			}	
		}
	}
	
	parkside.feature_slide = new parkside.feature_slide();
	
	function slide()
	{	
		if(slider != "")
		{
			window.clearInterval(slider);
			slider = "";
		}
		slider = window.setInterval(slideitem, 1);
	}
	
	function slideitem()
	{
		var list = document.getElementById("feature_list");
		if(list.getElementsByTagName("li").length > 0)
		{
			var listitem = list.getElementsByTagName("li").item(0);
			var itemwidth = listitem.style.width.substring(0, listitem.style.width.length-2);
			var itemmargin = listitem.style.marginLeft.substring(0, listitem.style.marginLeft.length-2);
			
			var lastitem = list.getElementsByTagName("li").item(list.getElementsByTagName("li").length - 1);
			
			if(itemmargin >= itemwidth*(-1))
			{
				listitem.style.marginLeft = itemmargin-10 + "px";
			}
			else
			{
				list.removeChild(listitem);	
				var params = new Object();
				params.last_order_nr = lastitem.getAttribute("id");
				params.first_item_width = itemwidth;
				parkside.feature_slide.request(params);
				window.clearInterval(slider);
			}
		}
		else
		{
			window.clearInterval(slider);
		}
	}

