// JavaScript Document

//Controls the text inside the search box onblur and onfocus
function searchblur(element) {
	if(element.value == '') {
		element.value = 'Search TheMaxExp ...';
	}
}
function searchfocus(element) {
	if(element.value == 'Search TheMaxExp ...') {
		element.value = '';
	}
}

 $(document).ready(function(){
	//
	//Generate Boxs
	var anibox = '<div class="animatebox"></div>';
	for(var i=0;i<150;i++)
	{
		anibox+='<div class="animatebox"></div>';

	}
	$('div#holder_box').append(anibox);
	
	//Pretty Thing
	$('div.animatebox').bind("mouseenter", function(e)
	{
			$(this).animate({
			opacity: 1
			}, 250 )
		
	}).bind("mouseleave", function()
	{
		$(this).animate({
			opacity: 0.1
			}, 250 );
	});

	//Scroll to top Button
	$('a#totop').click( function() {
		var targetOffset = $("div#top").offset().top;
		$('html,body')
  			.animate({scrollTop: targetOffset}, 250, "linear");
	});
	
	var contract = false;
	//Expand the Hidden footer, or shrink it.
	$('a#expand_footer').click( function(){
		var targetOffset = $("a#expand_footer").offset().top;
		$('html,body')
  			.animate({scrollTop: targetOffset}, 1000);
		
		if(contract)
		{$('a#expand_footer').text('Expand')}
		else
		{$('a#expand_footer').text('Contract')}
		contract = !contract;
		
		$('div#hidden_footer').animate({ 
			height: "toggle",
     	}, 1000 );
	});
   
	//Hide the sub Menus
	$("div#sub_menus div").hide();
	$("#submenu_t1").fadeIn('slow');
	
	var has = false; 
	
	
	//Sub Menu roll Over code
    $("div.navigationbar a").hover(
      function () {
		$("div#sub_menus div").hide();  
		if(!$(this).hasClass('current')) 
		{
			$(this).stop().animate({ backgroundPosition: "0px -34px", color: "#000000"}, 300 );
		}
		
		  var section = this.id;
		  $("div#sub_menus div").hide();
		  $("#submenu_"+section).fadeIn(800);
      }, 
      function () {

		if(!$(this).hasClass('current')) 
		{
			$(this).stop().animate({ backgroundPosition: "0px 0px", color: "#dddddd"}, 200 );
		}

      }
    );



	var x = location.href.split("/");
	var num = 4;
	
	if(x[num] == null){$('a#t1').addClass('current');}
	if(x[num] === "portfolio"){$('a#t2').addClass('current');}
	if(x[num] === "about"){$('a#t3').addClass('current');}
	if(x[num] === "contact"){$('a#t4').addClass('current');}
	if(x[num] === "random"){$('a#t5').addClass('current');}







  });