$(document).ready(function(){
	if(_root_lightbox) {
			$("a[rel^='prettyPhoto']").prettyPhoto();
			$(".next").click(function(e) {e.blur();});
			$(".previous").click(function(e) {e.blur();});
	}
/*jQuery(window).load(function(){*/
//-------------------- body fadeing -------------------------//	
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1])
//		$("#main_body").fadeIn('slow');				

	if(version >= 5.5) {
//		$("#main_body").css({display:'block'});
		$("#main_body").fadeIn('fast');
	} else
		$("#main_body").fadeIn('slow');		/**/

	$(".main_link").click(function () {
		if( this.blur )
				this.blur();//remove the awful outline
		$("#main_body").fadeOut('slow');
	});
	
	//prepend span tag
//	$(".ovalbutton").prepend("<span></span>");	
	
//-------------------- png fix start ----------------------------//
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
		  var img = document.images[i]
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.id) ? "id='" + img.id + "' " : ""
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;" + img.style.cssText 
			 if (img.align == "left") imgStyle = "float:left;" + imgStyle
			 if (img.align == "right") imgStyle = "float:right;" + imgStyle
			 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			 img.outerHTML = strNewHTML
			 i = i-1
		  }
	   }
	}	
//-------------------- png fix end -------------------------//
	if(_root_validation)
	{
		$("#contactForm").validate({errorPlacement: function(error, element) {
					error.appendTo( element.next() );
		}});
	}

	setTimeout("animate_home()",3000);	
});

var animate_toggle = 1;

function animate_home()
{
	if(animate_toggle == 1)	
	{
	   $("#logo_cont").fadeOut('slow');
	   $("#matter_cont").fadeIn('slow');
		animate_toggle = 0;
	}
}

//-------------------- CONTENT START ----------------------------//
jQuery(function( $ ){
	/**
	 * THIS BLOCK IS SPECIFICALLY FOR THE DEMO
	 * Binding of the section links, to load other sections inside the content div
	 */
	var $content = $('#content'),//the container, that is scrolled each time.
		$sections = $('#navigation a'),//links on the left
		last = null;//last section
	
	$sections.click(function(){
		if( last != this ){ // let's avoid needless requests
			// I use the extension .ahah for a speicific reason, you use .html or .php or w/e you want.
			$content.html( '<p class="loading">Loading...</p>' ).load( this.hash.slice(1) + '.php', function(){
				$content[0].scrollLeft = 0;//scroll back to the left
			});
		}
		last = this;
		this.blur();//r emove the awful outline
		return false;
	});
	
	$sections.eq(0).click();//load the first section	
	
	/**
	 * Actual call to jQuery.localScroll.
	 * Most jQuery.LocalScroll's defaults, belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.webs.com/jQuery.ScrollTo/
	 */
	
	$('#content').localScroll({// only the links inside that jquery object will be affected
		lazy:false, // this is the KEY setting here, makes the links work even after an Ajax load.
		target: '#content', // the element that gets scrolled
		axis:'x', // horizontal scrolling
		duration:500,
		onBefore:function( e, subsec, $cont ){//'this' is the clicked link
			if( this.blur )
				this.blur();//remove the awful outline
		}
	});
});	
//-------------------- CONTENT END ----------------------------//	