$(document).ready(function(){
	//FADE
	$('#fade').innerfade({
		speed: 1500,
		timeout: 4000,
		type: 'sequence',
		containerwidth: '500px',
		containerheight: '297px'
	});
	
	if($.browser.msie){
		$('#fade').css('margin-top', '10px');
	}

	//INPUT ELEMENTS	
		var st = '#4c4c4c';
		var en = '#9a9a9a';
		
		$('input[type=hidden]').each(function(){
			$(this).css('display', 'none');
		});
			
		$(':input').focus(function(){
			if($(this).val() == $(this).attr('rel')){
				$(this).css('color', en);
				$(this).keydown(function(){
					if($(this).val() == $(this).attr('rel')){					
						$(this).val('');
						$(this).css('color', st);
					}
				});
			}
		}).blur(function(){
			if($(this).val() == '' || $(this).val() == $(this).attr('rel')){
				var atty = $(this).attr('rel');
				$(this).val(atty).css('color', st);
			}
		});
		
		//CHECKBOX
		$('input[type=checkbox]').each(function(){
			$(this).css({'display' : 'inline', 'width' : 'auto', 'padding' : '0px', 'margin-right' : '5px'});
		});
	//INPUT ELEMENTS
	
	//DROPDOWN MENU
	$('#nav li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown(300);
		},function(){
			//hide its submenu
			$('ul', this).slideUp(100);
		}
	);

	
	//FIND LOGO
	$('#logo').css('cursor', 'pointer').bind({
		click: function(){
			window.location = './?page=home';	
		},
		mouseenter: function(){
			$(this).fadeTo(500, 0.5);
		},
		mouseleave: function(){
			$(this).fadeTo(500, 1.0);
		}
	});
	
	$('#foot_logo').css('cursor', 'pointer').bind({
		click: function(){
			window.location = './?page=home';	
		},
		mouseenter: function(){
			$(this).fadeTo(500, 0.5);
		},
		mouseleave: function(){
			$(this).fadeTo(500, 1.0);
		}
	});
	
	//GET FUNCTION
		function GET(name){
			name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regexS = "[\\?&]"+name+"=([^&#]*)";
			var regex = new RegExp( regexS );
			var results = regex.exec( window.location.href );
			if(results == null){
				return "";
			}else{
				return decodeURIComponent(results[1].replace(/\+/g, " "));
			}
		}
		
		var $Page = GET('page');
		if($Page == ''){
			if($('input[name=page]').attr('value') == undefined){
				var $Page = 'home';
			}else{
				var $Page = $('input[name=page]').attr('home');
			}
		}
		if($Page == ''){
			var $Page = 'home';
		}
	//GET FUNCTION
	
	//CLEANING UP MARGINS AND JUNK
	$('.cal:last').css('margin-right', '0%');
	$('#inner a:last').css({'margin-bottom' : '0px', 'padding-bottom' : '0px', 'border-bottom' : 'none'});
	
	//CAL OVER
	$('.cal').bind({
		click: function(){
			window.location = './?page=calendar&'+$(this).attr('rel');	
		},
		mouseenter: function(){
			$(this).children('span').css('background-color', '#575c61');
			$(this).children().next().css('color', '#4b4b4b');
		},
		mouseleave: function(){
			$(this).children('span').css('background-color', '#6e747a');
			$(this).children().next().css('color', '#696969');
		}
	});
	
	//PLAYLIST
	$('.playlist li a').click(function(){
		var inner = $(this).html();
		
		if(inner == 'play'){
			$(this).html('playing');
		}else{
			if(inner == 'playing'){
				$(this).html('paused (click to play)');
			}else{
				$(this).html('playing');
			}
		}
	});
	
	//CALENDAR SHOW
	$('.showDescription').toggle(function(){
		$(this).next().show(1000);
		$(this).css('font-weight', 'bold');
	},function(){
		$(this).next().hide('slow');
		$(this).css('font-weight', 'normal');
	});

	//BUTTON	
	$('.button').css('cursor', 'pointer').bind({
		mouseenter: function(){
			$(this).fadeTo(500, 0.5);
		},
		mouseleave: function(){
			$(this).fadeTo(500, 1.0);
		}
	});
});
