/*
PROJECT: POP-OLOGY
AUTHOR: DREW DAHLMAN
*/

$(function(){
	var inp = document.getElementsByTagName('input');for(var i=0;i<inp.length;i++){if(inp[i].type=='text'){inp[i].setAttribute('rel',inp[i].defaultValue);inp[i].onfocus=function(){if(this.value==this.getAttribute('rel')){this.value='';}else{return false;}};inp[i].onblur=function(){if(this.value==''){this.value=this.getAttribute('rel');}else{return false;}};inp[i].ondblclick=function(){this.value=this.getAttribute('rel')}}};
});
$(window).scroll(function(e){ 
	$el = $('#header'); // element you want to scroll
	$scrolling = -90; // Position you want element to assume during scroll
	$bounds = 90; // boundary of when to change element to fixed and scroll
	
	if ($(this).scrollTop() > $bounds && $el.css('position') != 'fixed'){ 
		$($el).css({'position': 'fixed', 'top': $scrolling}); 
		$("#logo").animate({'margin-top':'73px'},500);
		$($el).hover(
			function(){
				$($el).stop().animate({'top':'0px'},500);
				$("#logo").animate({'margin-top':'0px'},500);	
			},
			function(){
				$($el).stop().animate({'top':'-90px'},500);	
				$("#logo").animate({'margin-top':'73px'},500);
			}
		);
		
	} 
	if ($(this).scrollTop() < $bounds && $el.css('position') != 'absolute'){ 
		$($el).css({'position': 'absolute', 'top': '0px'}); 
		$("#logo").animate({'margin-top':'0px'},500);
		$($el).unbind('mouseenter mouseleave');
	} 
});
