/* $File: utils.js $
   $Date: 2009-09-25 $
   $Modify date: 2010-02-10 $
   $Author: Sébastien Millart (sebastien@greenerweb.be) $
   $Version: 0.0.11 $
*/

var $jQuery = jQuery.noConflict(); // Avoid jQuery conflicts with another library

$jQuery(document).ready(
	function ()
	{
		// Applies opacity on the side navigation
		$jQuery("#sidenav").children(".box").fadeTo("fast",  0.80);
		$jQuery("#sidenav").children(".boxbottom").fadeTo("fast",  0.80);
		
		// Customizes the presentation of the horizontal rule (<hr /> tag)
		var count = 0;
		$jQuery("hr").each(
			function ()
			{
				if (count == 0) $jQuery(this).wrap('<div class="hr first"></div>');
				else $jQuery(this).wrap('<div class="hr"></div>');
				count++;
			}
		);
		
		// Show/Hide the "detail" element with a sliding motion.
		$jQuery('.show').click(
			function ()
			{
				$jQuery('div.hidden').slideToggle('slow');
			}
		);
		
		// Gets the attribut value "id" of the body element
		var bodyId = $jQuery("body").attr("id");
		
		if (bodyId != "Project")
		{
			// Customizes the pictures included in the "Content" and "FreeHTML" template
			$jQuery('#' + bodyId).find('.g660').find('img').each(
				function ()
				{
					var className = $jQuery(this).attr('class');
					if (className == null || className == '' || className == 'undefined') className = 'left';
					if (bodyId == 'Content')
					{
						var imgSrc = $jQuery(this).attr('src');
						var orientation = $jQuery(this).attr('usemap');
						if (orientation == null || orientation == '' || orientation == 'undefined') orientation = 'horizontal';
						if (orientation == 'vertical')
						{
							$jQuery(this).attr(
								{
									width:	'128',
									height:	'170',
									longdesc: imgSrc
								}
							);
							$jQuery(this).removeAttr('usemap');
						}
						else
						{
							$jQuery(this).attr(
								{
									width:	'170',
									height:	'128',
									longdesc: imgSrc
								}
							);
						}
						$jQuery(this).wrap('<div class="img_content shadow ' + className + '"><div class="border"></div></div>');
						$jQuery(this).removeAttr('class');
						$jQuery(this).fullsize();
					}
					else
					{
						$jQuery(this).wrap('<div class="img_content shadow ' + className + '"><div class="border"></div></div>');
						$jQuery(this).removeAttr('class');
					}
				}
			);
		}
		else
		{
			// Gets the path to the Paginator Element
			var sPath = $jQuery('#project_gallery').html();
			
			// Load of the "Eco-construction" or "Eco-rénovation" project gallery using AJAX (Asynchronous JavaScript & XML)
			$jQuery('#project_gallery').load(sPath + '.php',
				function ()
				{
					$jQuery(this).show();
				}
			);
		}
	}
);

