// JavaScript Document

function showHide(id) {
	var displayed = $('#menu-'+id).css('display');
	$('.menucategory').each(function() {
		var linkhtml = $(this).html();
		$(this).html(linkhtml.replace('[-]', '[+]'));	
	});
	$('.menublock').each(function() {
		if($(this).css('display') == 'block') {
			$(this).css('display', 'none');
		}
	});
	if(displayed == 'none') {
		$('#menu-'+id).css('display', 'block');
		var linkhtml = $('#menucategory-'+id).html();
		$('#menucategory-'+id).html(linkhtml.replace('[+]', '[-]'));
	} else {
		$('#menu-'+id).css('display', 'none');
		var linkhtml = $('#menucategory-'+id).html();
		$('#menucategory-'+id).html(linkhtml.replace('[-]', '[+]'));
	}
	$(document).scrollTop(0);
}

jQuery.fn.center = function () {
	this.css("position","absolute");
	this.css("top", $(window).height() * .5 - this.height() * .5 + "px");
	this.css("left", $(window).width() * .5 - this.width() * .5 + "px");
	return this;
}

$(document).ready(function() {
	$('#left').css("height", $(window).height() + "px");
	$('#right').css("height", $(window).height() + "px");

	$(window).scroll(function() {
		$('#left').css("height", $(document).height() + "px");
		$('#right').css("height", $(document).height() + "px");
	});

	$('.menublock:first').css('display', 'block');
	
	$("#createaccount").validate({
		errorClass: "invalid",
		rules: {
			firstname: {
				required: true,
				minlength: 2,
			},
			lastname: {
				required: true,
				minlength: 2,
			},
			email: {
				required: true,
				email: true,
			},
			phone: {
				required: true,
				digits: true,
				minlength: 10,
    			},
			password: {
				required: true,
				minlength: 5,
			}
		},
		messages: {
			firstname: "* Required",
			lastname: "* Required",
			email: "* Required",
			phone: "* 10 digits",
			password: "* 5 character min"
		}
	});

	$("#emailform").validate({
		errorClass: "invalid",
		rules: {
			fullname: {
				required: true,
				minlength: 2,
			},
			email: {
				required: true,
				email: true,
			},
			phone: {
				digits: true,
				minlength: 10,
    			},
			body: {
				required: true,
				minlength: 2,
			}
		},
		messages: {
			fullname: "* Required",
			email: "* Required",
			phone: "* 10 digits",
			body: "* Required"
		}
	});

	
});

