/**
 * Description for file
 *
 * JS version $version
 *
 * @author      Remo Häusler <internet@promacx.ch>
 * @copyright   PROMACX AG / Wasserwerkgasse 20 / 3011 CH-Bern
 * @link        www.promacx.ch
 * @licence     http://www.opensource.org/licenses/mit-license.php The MIT License
 * @version     0.0.1
 */

jQuery.ImageAvec =
{
	count:0,
	
	build: function ()
	{
		var source = 'fileadmin/templates/avec/images/fce/fceimageavec.swf';
		var id = jQuery(this).attr('id');
		if (id == null || id == ''){
			id = 'imageavec' + (++jQuery.ImageAvec.count);
			jQuery(this).attr('id', id);
		}
		
		var width = 695;
		// {{{ Build XML
		var xml = '';
		xml += '<imageavec>';
		var childs = this.children('*');
		childs.each(function (i){
			if (jQuery(this).is('img')){
				var $link = '';
				var $source = jQuery(this).attr('src');
				var legend = '';
			} else {
				var $link = jQuery(this).attr('href');
				var $source = jQuery(this).children('img').attr('src');
				var legend = jQuery(this).attr('title');
			}	
			xml += '<item source="' + $source + '" link="' + $link + '" legend="' + legend + '" />';
		});
		xml += '</imageavec>';
		// }}}
		
		//alert(id)
		var so = new SWFObject(source, "so" + id, width, 150, "8", '#FFFFFF');
		so.addParam("wmode", "transparent");
		so.addVariable("xml", encodeURIComponent(xml));
		so.write(id);	
		//this.empty();
		//this.append(so.getSWFHTML());
	}
}

jQuery.fn.ImageAvec = jQuery.ImageAvec.build;

jQuery(document).ready(function(){
	jQuery('.fce-imageavec-container').ImageAvec();							
});

