$(document).ready(function() {

	$('#btnSearch').click(function() {
		if ($("#mySearch").valid()) {
			return true;
		}
		return false;
	});

	$('#login').click(function() {
		$('#member-login').slideToggle(400);
		$('#login-username').focus();
	});

	$('#logout').click(function() {
		$.post('/resources/vb/post-member-login.asp',
		function(result) {
			if (result == '') {
				window.location = "/"
			}
		});
	});

	$('#login-submit').click(function() {
		if ($("#myLogin").valid()) {
			var username = $('#login-username').val();
			var password = $('#login-password').val();
			$.post('/resources/vb/post-member-login.asp',{username:username,password:password},
				function(result) {
				if (result == '') {
					window.location = "/members/members-home"
				} else {
					$('#login-response').empty();
					$('#login-response').css("color","red");
					$('#login-response').append(result);
					Cufon.replace('h2');
				}
			});
		}
		return false;
	});

	// Bookmark site
	if(window.opera) {
		if ($("a.bookmark").attr("rel") != ""){
			$("a.bookmark").attr("rel","sidebar");
		} 
	}

	$("a.bookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;

		if (window.sidebar) { 
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { 
			window.external.AddFavorite( url, title);
		} else if(window.opera) { 
			return false; 
		} else { 
			 alert('Sorry, your browser does not support the requested action,'
			 + ' please add this page manually to your bookmarks.');
		}
	});

	$('.search').focus(function() {
		if (this.value == 'Search') { this.value=''; };
	});

	if ($('#blog-panel').length) {
		$('#panel').empty();
		$('#blog-panel').prependTo($('#panel'));
	}

	ddsmoothmenu.init({
		mainmenuid: "smoothmenu1", 
		orientation: 'h', 
		classname: 'ddsmoothmenu', 
		contentsource: "markup" 
	});
	
});

