function show (elmName,msg) {
	$("#"+elmName).fadeIn(500);
	$("#"+elmName).find("select,textarea,input").each(function(){
		$(this).attr("required",msg);
	});
}
function hide (elmName) {
	$("#"+elmName).fadeOut(500);

	$("#"+elmName).find("textarea,input").each(function(){
		$(this).attr("required","").val("");
	});


// may need this later
/*
	$("#"+elmName).find("select").each(function(){
		$(this).attr("required","").get(0).selectedIndex = 0;
	});
*/


}

$(document).ready(function(){

	$(this).find(".popup.show input, .popup.show select, .popup.show textarea").each(function(){

		$(this).attr("required","please fill in required field");

	});

	$("input[name='clear']").click(function(){ 
		$(this).parents("form").clearForm();
		$(".popup").each(function(){ $(this).hide(); });
	});

});

$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form') return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea') this.value = '';
		else if (type == 'checkbox' || type == 'radio') this.checked = false;
		else if (tag == 'select') this.selectedIndex = -1;
	});
};

