/*
Class: BannerGenerator, 2008 Dec 26

It handles the auto-generation of product banners. For instance,
"10 pices" and "7 colors".
*/
var BannerGenerator=function()
{
	//Properties
	this.processorUrl = null;
	
	var getProductBanner_success=function(o)
	{
		var element=o.argument.element;
		element.innerHTML=o.responseText;
	}
	
	var getProductBanner_failure=function(o)
	{
		if(o.statusText != 'communication failure'){
		alert("failure: getProductBanner");
		}
		else;
	}
		
	/*
	Function: init
	it plays the roles of the constructor, but you have to call it explicity.
	*/
	this.init=function()
	{
		/*
		Note: important, 2008 Dec 26
		Due to the rewrites modes which build links like the following
		http://dev4.wheretobuyroses.com/flowers/collections/WeddingFlowersWeddingFlowerCollectionsHydrangeaWeddingFlowersDesignedForYou_23697.htm
		
		we have to use the proper realtive path.
		*/
		this.processorUrl =	"../../model/cart_products_collections_MDL.php";
		
		//var items=YAHOO.util.Selector.query('div.item div.itemPicture a div.productBanner','container_right');
		var items=YAHOO.util.Selector.query('div.item div.itemPicture div.productBanner','container_right');

		var l=items.length;
		for(i=0;i<l;i++)
		{
			var myText=items[i].innerHTML;
			var postData="action=getProductBanner&text="+myText;
			var args=
			{
				element:items[i]
			};
			var callback = 
			{ 
				success:getProductBanner_success, 
				failure:getProductBanner_failure, 
				scope:this,
				argument:args
			}; 
		
			YAHOO.util.Connect.asyncRequest('POST', this.processorUrl, callback, postData);
			//alert(""+myText);
		}
		
		
		//alert("I am ready!!");	
	}
}