	$("#Search_Field").hide();
	
	$("#Search_Field_Display").focus( function () {
		if (searching == false) {
			$("#Search_Field_Display").hide();
			$("#Search_Field").show();
			$("#Search_Field").focus();
			searching = true;	
		}
	});
	
	$(".design_button").click( function() {
		$(this).css('background','#224472');
		var temp = this;
		setTimeout(function() {
			$(temp).css('background','');
		},200);
	});
	
	$(".web_button").click( function() {
		$(this).css('background','#71215e');
		var temp = this;
		setTimeout(function() {
			$(temp).css('background','');
		},200);
	});
	
	$(".back_button").click( function() {
		$(this).css('background','#151617');
		var temp = this;
		setTimeout(function() {
			$(temp).css('background','');
		},200);
	});
	
	$(".print_button").click( function() {
		$(this).css('background','#2d7625');
		var temp = this;
		setTimeout(function() {
			$(temp).css('background','');
		},200);
	});
	
	$("#Search_Button").click( function() {
		$(this).css('margin-top','-29px');
		var temp = this;
		setTimeout(function() {
			$(temp).css('margin-top','0px');
		},200);
	});
	
	$("#Search_Field").focus();
	
	$("#Login_Sel_Button").click(function () {
		clearflag = true;
		$('#Login_Message').hide();
		$('#Login_Info').show();
		CenterPopup ('#Login_Box');
		LoadPopup ('#Login_Box');
		setTimeout(function() {
			$("#Login_Sel_Button").css('margin-top','0px');
		},250);
		$("#User").focus();
	});
	
	$("#Logout_Sel_Button").click(function () {
		$.cookie("DigiplicityLoginCookie", '', { expires: 604800 });
		window.location = ('index.php');	
	});
	
	$("#User").keyup( function (e) {
		if (e.keyCode == 13) {
			$("#Password").focus();	
		}
	});
	
	$("#Password").keyup( function (e) {
		if (e.keyCode == 13) {
			Login (); 
		}
	});
	
	$("#Login_Button").click( function () {
		Login (); 
	});
	
	$("#Reset_Button").click( function () {
		Reset_Login (); 
	});
	
	$("#background_fade").click(function () {
		$("#background_fade").fadeOut("slow");
		$(".popup").fadeOut("slow");
	});
	
	function Login () {
		var p = $('#Password').val();
		p = calcMD5(p);
		var u = $('#User').val();
		u = calcMD5(u);
		$.post("update.php", { action: "Login", 
							   user: u,
							   password: p }, function(data){
			var temp = data.split('confirm|');
			var temp2;
			if (temp.length > 1) {
				temp2 = temp[1].split('||');
				$("#Login_Message").html('Thanks '+temp2[0]+', you will be transfered momentarily.');
				$.cookie("DigiplicityLoginCookie", temp2[1], { expires: 0.083 });
			}
			else {
				temp = data.split('reset|');
				if (temp.length > 1) {
					CenterPopup ('#Reset_Box');
					LoadPopup ('#Reset_Box');
					$("#New_User").focus();
				}
				else {
					$("#Login_Message").html('We\'re sorry either the username or password you entered was incorrect. Please try again.');
					$('#User').val('');
					$('#Password').val('');
				}
			}
			$('#Login_Info').hide();
			$('#Login_Message').fadeIn('slow');
			setTimeout(function() {
				$('#Login_Message').hide();
				$('#Login_Info').fadeIn('slow');
			},4000);
			if (temp2[2] == 'Client') {
				window.location = ('client_side.php');	
			}
			if (temp2[2] == 'Staff') {
				window.location = ('staff_side.php');	
			}
		}); 	
	}
	
	function Reset_Login () {
		var pu = $('#User').val();
		pu = calcMD5(pu);
		var u = $('#New_User').val();
		var ulen = u.length;
		var p = $('#New_Password').val();
		var plen = p.length;
		p = calcMD5(p);
		var vp = $('#Verify_Password').val();
		vp = calcMD5(vp);
		if (plen >= 8 && ulen >=5) {
			$.post("update.php", { action: "New_Login", 
								   prev_user: pu,
								   user: u,
								   password: p,
								   verify: vp }, function(data){
				var temp = data.split('user|');
				var temp2;
				if (temp.length > 1) {
					$("#Reset_Message").html('We\'re sorry that user name is already taken. Please try again.');
				}
				else {
					temp = data.split('pass|');
					if (temp.length > 1) {
						$("#Reset_Message").html('We\'re sorry it seems the passwords did not match. Please try again.');
					}
					else {
						temp = data.split('confirm|');
						if (temp.length > 1) {
							temp2 = temp[1].split('||');
							$("#Reset_Message").html('Thanks '+temp2[0]+', you will be transfered momentarily.');
							$.cookie("DigiplicityLoginCookie", temp2[1], { expires: 0.083 });
						}
					}
				}
				$('#Reset_Info').hide();
				$('#Reset_Message').fadeIn('slow');
				setTimeout(function() {
					$('#Reset_Message').hide();
					$('#Reset_Info').fadeIn('slow');
				},4000);
				if (temp2[2] == 'Client') {
					window.location = ('client_side.php');	
				}
				if (temp2[2] == 'Staff') {
					window.location = ('staff_side.php');	
				}
			});
		}
		else {
			$("#Reset_Message").html('We\'re sorry passwords must be at least 8 characters and user names 5 characters. Please try again.');
			$('#Reset_Info').hide();
			$('#Reset_Message').fadeIn('slow');
			setTimeout(function() {
				$('#Reset_Message').hide();
				$('#Reset_Info').fadeIn('slow');
			},4000);
		}
	}
	
	function LoadPopup (windowid) {
		$("#background_fade").css({
			"opacity": "0.7"
		});
		$("#background_fade").fadeIn("slow");
		$(windowid).fadeIn("slow");
	}
	
	function ClosePopup (windowid) {
		$("#background_fade").fadeOut("slow");
		$(windowid).fadeOut("slow");
	}
	
	function GetPageScroll () {
  	  var xScroll, yScroll;
	    if (self.pageYOffset) {
	      yScroll = self.pageYOffset;
	      xScroll = self.pageXOffset;
	    } else if (document.documentElement && document.documentElement.scrollTop) {
	      yScroll = document.documentElement.scrollTop;
	      xScroll = document.documentElement.scrollLeft;
	    } else if (document.body) {// all other Explorers
	      yScroll = document.body.scrollTop;
	      xScroll = document.body.scrollLeft;
	    }
	    return new Array(xScroll,yScroll)
	}
	
	//centering popup
	function CenterPopup (windowid){
	//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $(windowid).height();
		var popupWidth = $(windowid).width();
		//centering
		var temp = GetPageScroll();
		$(windowid).css({
			"position": "absolute",
			"top": windowHeight/2-popupHeight/2+temp[1],
			"left": windowWidth/2-popupWidth/2+temp[0]
		});
	}
	
	function Gsitesearch(curobj){
		curobj.q.value="site:www.digiplicity.com "+curobj.Search_Field.value
	}
