$(function(){
	
	$("li#pulltop a").hover(
		function(){
			$("li#pulltop ul").css("display","block");
		},
		function(){
			$("li#pulltop ul").css("display","none");
		}
	);
	
	$("li#pull a").hover(
		function(){
			$("li#pull ul").css("display","block");
			$("#contents").css("z-index","-1");
		},
		function(){
			$("li#pull ul").css("display","none");
			$("#contents").css("z-index","1");
		}
	);
	
	
	
	$("#second").append('<div class="img"><hr /></div>');
	
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
	
	function rollover() {
		if (!document.getElementsByTagName) return false;
		var image = document.getElementsByTagName("img");
		for (i=0; i<image.length; i++) {
			if (image[i].getAttribute("src").match(/_off\./)){
		 		image[i].onmouseover = function() {
		 			this.setAttribute("src", this.getAttribute("src").replace("_off.","_ov."));
		 		}
		 		image[i].onmouseout = function() {
		 			this.setAttribute("src", this.getAttribute("src").replace("_ov.","_off."));
		 		}
			}
		}
		var inpt = document.getElementsByTagName("input");
		for (i=0; i<inpt.length; i++) {
			if (inpt[i].type == 'image') {
				if (inpt[i].getAttribute("src").match(/_off\./)){
			 		inpt[i].onmouseover = function() {
			 			this.setAttribute("src", this.getAttribute("src").replace("_off.","_ov."));
			 		}
			 		inpt[i].onmouseout = function() {
			 			this.setAttribute("src", this.getAttribute("src").replace("_ov.","_off."));
			 		}
				}
			}
			
		}
	}
	
	function popUp() {
		if (!document.getElementsByTagName) return false;
		var links = document.getElementsByTagName("a");
		
		for (i=0; i<links.length; i++) {
			
			if (links[i].className.match("popup")) {
				links[i].onclick=(function(obj, num){
				return function(){
					var newWindow =window.open(obj.href, num, "width=600,height=750,menubar=1,scrollbars=1,resizable=1");
					newWindow.focus();
					return false;
				};})(links[i],i);
			}
		}
	}
	
	rollover();
	popUp();
	
});
