// FIX BG IMAGE HEIGHT

	$(document).ready(function(){
		interval = setInterval(function() {
			$('#bg-image-wrapper').css({'height':$(document).height() });
		}, 100);		
	});		

// FIX SIDEBAR HEIGHT

	$(document).ready(function(){
		$('#sidebar-wrapper').css({	'height':($('#content').height() + 50) });
	});		

// SETUP SUPERFISH

	$(document).ready(function(){
		if(!$.browser.msie){
			var anim = "opacity:'show',height:'show'";
		} else { 
			var anim = "opacity:'no',height:'show'";
		}
		$("ul.sf-menu").superfish({
			delay:       0,                               // mouseout delay in milliseconds
			animation:	 anim,
			speed:       'fast',                          // faster animation speed
			autoArrows:  true,                            // disable generation of arrow mark-up
			dropShadows: false                            // disable drop shadows
			});
	});
		
// SETUP PRETTY PHOTO

	$(document).ready(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto({
			default_width:960
		});
	});		

// TOOLS TABS

// perform JavaScript after the document is scriptable.
$(document).ready(function(){
	// setup ul.tabs to work as tabs for each div directly under div.panes
	$("ul.tabs").tabs("div.panes > div");
});
	
// SETUP CUSTOM SCRIPT

	$(document).ready(function(){
	
		$(function() {	
		//SEARCH ROLLOUT
			$('#grabber').hover(function() {
			//SEARCH GRABBER HOVER OVER
				$('#search-area').hover(function() {
					//ACTUAL SEARCH HOVER OVER					
						if($(this).css('top') == '-58px') {
							$(this).animate({'top':'-55px'}, {duration: 100, easing: 'swing'});
						}
				}, function() {
					//ACTUAL SEARCH HOVER OFF
					if($(this).css('top') == '-55px') {
						$(this).animate({'top':'-58px'}, {duration: 100, easing: 'swing'});					
					}
					$(this).unbind('mouseenter mouseleave');
				});
				
			}, function() {
			//SEARCH GRABBER HOVER OFF
			}), $('#search-area').click(function() {
			//SEARCH GRABBER CLICK
				
					if($(this).css('top') != '0px') {
						$(this).animate({'top':'0px'}, {duration: 'fast', easing: 'linear'});
						$('#s').focus();						
					} else {
						$(this).animate({'top':'-58px'}, {duration: 'fast', easing: 'linear'});		
						
					}	 
				
			});
		});

		// TESTIMONIAL NAVIGATION
		$(function() {
		var $i = 1;
			$(".t-next").click(function(){
				var $next = $i + 1;
				$('#tid-'+$i).css({'display':'none'});
				$('#tid-'+$next).css({'display':'block'});		
				$i = $i + 1;
			});
			$(".t-prev").click(function(){
				var $prev = $i - 1;
				$('#tid-'+$i).css({'display':'none'});
				$('#tid-'+$prev).css({'display':'block'});			
				$i = $i - 1;
			});				
		});
		
		//IMAGE ROLLOVERS
		$("a.image").hover(function(){
			$(this).children("span").fadeIn(150);
		},function(){
			$(this).children("span").fadeOut(150);
		});

	});

// CSS TOOLTIPS
$(document).ready(function(){

	function addLoadEvent(func) {
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
	  } else {
		window.onload = function() {
		  oldonload();
		  func();
		}
	  }
	}

	function prepareInputsForHints() {
	  var inputs = document.getElementsByTagName("input");
	  for (var i=0; i<inputs.length; i++){
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
		  inputs[i].onfocus = function () {
			this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
		  }
		  inputs[i].onblur = function () {
			this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		  }
		}
	  }
	  var selects = document.getElementsByTagName("select");
	  for (var k=0; k<selects.length; k++){
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
		  selects[k].onfocus = function () {
			this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
		  }
		  selects[k].onblur = function () {
			this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		  }
		}
	  }
	  var textareas = document.getElementsByTagName("textarea");
	  for (var z=0; z<textareas.length; z++){
		if (textareas[z].parentNode.getElementsByTagName("span")[0]) {
		  textareas[z].onfocus = function () {
			this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
		  }
		  textareas[z].onblur = function () {
			this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		  }
		}
	  }	  
	}
	addLoadEvent(prepareInputsForHints);
});
