/**
 * Replaces content of all the Tags with ID='ir-X' with image at 'images/X.png'
 */
function replaceTitles()
{
	// Check for DOM support
	if (!(document && document.implementation && document.implementation.hasFeature))	return;

	// Check for image support
	if (!document.images)	return;
	
	var pattern = new RegExp('ir-\w?');
	var els = document.getElementsByTagName('*');
	var elsLen = els.length;
	var tags = new Array();	

	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].id) ) {
			tags[j] = els[i];
			j++;
		}
	}	

	for (var i = 0; i < tags.length; i++)	{
		if (tags[i].id) {
			var image = document.createElement('img');
			image.src = 'images/' + tags[i].id.replace('ir-','') + '.png';
			image.alt = tags[i].firstChild.nodeValue;
			image.title = tags[i].firstChild.nodeValue;
			tags[i].replaceChild(image,tags[i].firstChild);
		}
	}
}


$(document).ready(
	function()
	{
		$("#home_3_decor_img").toggle(
				function()
				{
					var o = $(this).offset();
					$(this).appendTo("body");
					$(this).css(
							{
								position: "absolute",
								left: o.left + "px",
								top: o.top + "px"
							}
						);
					$(this).animate({
							width: "250px", 
							height: "250px",
							left: o.left - 140 + "px",
							top: o.top - 140 + "px"
							},
							100,
							function()
							{
								$(this).attr('src', 'images/home_decor_statuette_max.gif');
							}
						);
				},
				function()
				{
					var o = $(this).offset();
					$(this).animate({
							width: "110px", 
							height: "110px",
							left: o.left + 140 + "px",
							top: o.top + 140 + "px"
							},
							100,
							function()
							{
								$(this).attr('src', 'images/home_decor_statuette.gif');
								$(this).appendTo("#home_3_decor");
								$(this).css(
										{
											position: "absolute",
											left: "196px",
											top: "62px"
										}
									);
							}
						);
				}
			);
	}
);

$(document).ready(
		function()
		{
			$("#home_3_decor_img2").toggle(
					function()
					{
						var o = $(this).offset();
						$(this).appendTo("body");
						$(this).css(
								{
									position: "absolute",
									left: o.left + "px",
									top: o.top + "px"
								}
							);
						$(this).animate({
								width: "250px", 
								height: "250px",
								left: o.left - 140 + "px",
								top: o.top - 140 + "px"
								},
								100,
								function()
								{
									$(this).attr('src', 'images/home_decor_statuette2009_max.gif');
								}
							);
					},
					function()
					{
						var o = $(this).offset();
						$(this).animate({
								width: "110px", 
								height: "110px",
								left: o.left + 140 + "px",
								top: o.top + 140 + "px"
								},
								100,
								function()
								{
									$(this).attr('src', 'images/home_decor_statuette2009.gif');
									$(this).appendTo("#home_3_decor");
									$(this).css(
											{
												position: "absolute",
												left: "316px",
												top: "62px"
											}
										);
								}
							);
					}
				);
		}
	);