// Load after document
$(document).ready(function() {
	
	// slideshow
	var sstimer;
	function ssload() {
		clearTimeout(sstimer);
		var stfun = function() { ssbutton(2); };
		sstimer = setTimeout(stfun,"6000");
	}
	function ssbutton(id) {
		var nssid = (id==3) ? 1:id+1;
		var stfun = function() { ssbutton(nssid); };
		$("li", ".slides").css("visibility","hidden");
		$("#image"+id).css("visibility","visible");
		$("#image"+id).css("opacity","0");
		$("#image"+id).animate({"opacity":1}, 1000, "linear", null);
		clearTimeout(sstimer);
		sstimer = setTimeout(stfun,"6000");
	}
	ssload();
	
	// home sub hover
	$("a", "#services .sub").mouseenter(function() {
		var rel = $(this).attr("rel");
		$("div", "#services .primary").hide();
		$("#"+rel).fadeIn();
	});
	$("ul", "#services .sub").mouseleave(function() {
		$("div", "#services .primary").hide();
		$("#usweb").fadeIn();
	});
	
	// search box
	$("#sbox").focus(function() {
		if($(this).val()=='Search this website ...') {
			$(this).val('');
			$(this).addClass('wtext');
		}
	});
	$("#sbox").blur(function() {
		if($(this).val()=='') {
			$(this).val('Search this website ...');
			$(this).removeClass('wtext');
		}
	});
	
	// contact button
	$("#contactbutton").click(function(e) {
		e.preventDefault();
		$("#contactform").slideToggle("slow");
	});
	
	// client login
	$("#clientlogin").click(function(){
		window.location = "http://usweb.projectpath.com";
	});

});