StaticData = {
	Templates: {
		imgConfTpl: new Template("\
				<?xml version='1.0' encoding='UTF-8' ?>\
				<config>\
					<textmap>\
					<field id='description_txt'>#{description}</field>\
				</textmap>\
				<imagemap>\
					<image id='polaroid.src_img' src='#{image}'/>\
				</imagemap>\
				</config>\
		"),
		
		hdrConfTpl: new Template("\
			<?xml version='1.0' encoding='UTF-8' ?>\
			<config>\
				<textmap>\
					<field id='postLink_mc' handlerName='links'>#{postLink}</field>\
					<field id='catLink_mc' handlerName='links'>#{catLink}</field>\
					<field id='writtenBy_mc.authorLink_mc' handlerName='links'>#{authorLink}</field>\
					<field id='heading_txt'>#{heading}</field>\
					<field id='subheading_txt'>#{subheading}</field>\
					<field id='cat_txt'>#{category}</field>\
					<field id='writtenBy_mc.author_txt'>#{author}</field>\
					<field id='writtenBy_mc.writtenBy_txt' handlerName='writtenBy'>#{writtenBy}</field>\
					<field id='day_txt'>#{day}</field>\
					<field id='mon_txt'>#{month}</field>\
					<field id='year_txt'>#{year}</field>\
					<field id='commentsamount_txt'>#{commentsamount}</field>\
				</textmap>\
				<imagemap>\
					<image id='smallpolaroid.src_img' src='#{image}'/>\
				</imagemap>\
			</config>\
		"),

		redHdrConfTpl: new Template("\
			<config>\
				<textmap>\
					<field id='postLink_mc' handlerName='links'>#{postLink}</field>\
					<field id='heading_txt'>#{heading}</field>\
					<field id='author_txt'>#{author}</field>\
					<field id='day_txt'>#{day}</field>\
					<field id='mon_txt'>#{month}</field>\
					<field id='year_txt'>#{year}</field>\
				</textmap>\
			</config>\
		"),
		
		smallHdrConfTpl: new Template("\
			<config>\
				<textmap>\
					<field id='heading_txt'>#{heading}</field>\
				</textmap>\
			</config>\
		"),		
			
		commConfTpl: new Template("\
			<config>\
				<textmap>\
					<field id='comments_txt'>#{heading}</field>\
				</textmap>\
			</config>\
		")
	}};
	
FlashReplacement = Class.create({
	
	initialize: function() {
	},
	
	replace: function(argObj) {
		switch(argObj.type) {
			case 'image': 	argObj.nodes.each(this.replaceImages);
							break;
			case 'header':	argObj.nodes.each(this.replaceHeader);
							break;
			case 'commentsHeader':	argObj.nodes.each(this.replaceCommentsHeader);
									break;
			case 'smallHeader':	argObj.nodes.each(this.replaceSmallHeader);
								break;
			case 'redHeader':	argObj.nodes.each(this.replaceRedHeader);
								break;								
		}
	},
	
	replaceImages: function(el) {
		id=el.identify();
		config={ description: el.down().readAttribute("title"),  image: el.down().readAttribute("src")};
		fv=StaticData.Templates.imgConfTpl.evaluate(config);
		var FO = { movie: $cnf.flashURL+"/image.swf", width:"450", height:"400", majorversion:"7", build:"0", flashvars:"confVar="+fv };
    	UFO.create(FO, id);
	},
	
	replaceCommentsHeader: function(el) {
		id=el.identify();
		config={ heading: el.down('h3 span.amount').innerHTML };
		fv=StaticData.Templates.commConfTpl.evaluate(config);
		var FO = { movie: $cnf.flashURL+"/comments.swf", width:"540", height:"50", majorversion:"7", build:"0", flashvars:"confVar="+fv, wmode:"transparent" };
    	UFO.create(FO, id);
	},
	
	replaceRedHeader: function(el) {
		id=el.identify();
		subheading = (el.down('h2').innerHTML!="") ? el.down('h2').innerHTML:" ";
		
		config = { 	heading: el.down('h1 a').innerHTML,
					postLink: el.down('h1 a').readAttribute('href'),
					author: el.down('a.heading-author span').innerHTML,
					day: el.down('span.heading-date span.day').innerHTML,
					month: el.down('span.heading-date span.month').innerHTML.toUpperCase(),
					year: el.down('span.heading-date span.year').innerHTML				
		};
    	fv=StaticData.Templates.redHdrConfTpl.evaluate(config);
		var FO = { movie: $cnf.flashURL+"/header_red.swf", width:"585", height:"80", majorversion:"7", build:"0", flashvars:"confVar="+fv, wmode:"transparent" };
    	UFO.create(FO, id);	
	},
	
	replaceSmallHeader: function(el) {
		id=el.identify();
		config = { 	heading: el.down('h1 a').innerHTML.strip()};
    	fv=StaticData.Templates.smallHdrConfTpl.evaluate(config);
		var FO = { movie: $cnf.flashURL+"/header_small.swf", width:"510", height:"90", majorversion:"7", build:"0", flashvars:"confVar="+fv, wmode:"transparent" };
    	UFO.create(FO, id);	
	},
	
	
	replaceHeader: function(el) {
		id=el.identify();
		config={ 	
					heading: el.down('h1 a').innerHTML,
					postLink: el.down('h1 a').readAttribute('href'),
					catLink: el.down('a.heading-cat').readAttribute('href'),
					authorLink: el.down('a.heading-author').readAttribute('href'),
					subheading: el.down('h2').innerHTML,
					category: el.down('a.heading-cat span').innerHTML,
					writtenBy: (el.down('a.heading-author span').readAttribute('rel')) ? el.down('a.heading-author span').readAttribute('rel'):'nap�sal(a)',
					author: el.down('a.heading-author span').innerHTML,
					day: el.down('span.heading-date span.day').innerHTML,
					month: el.down('span.heading-date span.month').innerHTML.toUpperCase(),
					year: el.down('span.heading-date span.year').innerHTML,
					image: (el.down('div.clipper img') != undefined) ? el.down('div.clipper img').readAttribute('src'):'__NOTHUMB__',
					commentsamount: el.down('span.comments-amount').innerHTML.strip()
		};
		fv=StaticData.Templates.hdrConfTpl.evaluate(config);
		var FO = { movie: $cnf.flashURL+"/header.swf", width:"585", height:"140", majorversion:"7", build:"0", flashvars:"confVar="+fv, wmode:"transparent" };
    	UFO.create(FO, id);	
	}
});


	
document.observe("dom:loaded",function() {
	
	fr=new FlashReplacement();
	fr.replace(
		{	
			type: "image",
			nodes: $$(".flash-image")
		}	
	);
	
	fr.replace(
		{	
			type: "header",
			nodes: $$(".header-html")
		}
	);
	fr.replace(
		{	
			type: "commentsHeader",
			nodes: $$(".comments-header")
		}
		
	);
	
	fr.replace(
		{	
			type: "smallHeader",
			nodes: $$(".header-small")
		}
		
	);

	fr.replace(
		{	
			type: "redHeader",
			nodes: $$(".header-html-red")
		}
		
	);	
	 
});



