var d = document;
var config = {
		facebox: {},
		actions: {
			alertHTML: '<div class="ui-state-highlight ui-corner-all" style="padding: 0pt 0.7em; margin-top: 20px;"><p style="margin-top: 8px;"><span class="ui-icon ui-icon-info" style="float: left; margin-right: 0.3em;"></span><strong>Notice: </strong>%message%</p></div><br/>',
			errorHTML: '<div class="ui-state-error ui-corner-all" style="padding: 0pt 0.7em;"><p style="margin-top: 8px;"><span class="ui-icon ui-icon-alert" style="float: left; margin-right: 0.3em;"></span><strong>Error: </strong>%message%</p></div><br/>'
		}
};

$(document).ready(function() {
	if ($.browser.msie && $.browser.version == '6.0') $(document).pngFix();
	$('a[rel*=facebox]').facebox();
	$('form[class*=facebox]').submit(function(){
		$.ajax({url: this.getAttribute('action'),
			cache: false,
			type: this.getAttribute('method'),
			data: $(this).serialize(),
			dataType: 'html',
			success: function(response) {$.facebox(response);}
		});
		return false;
	});
	$('input[class*=disabled]').keypress(function(e){e.preventDefault();});
	$('dl.exp dt').toggle(function(){$('dd', $(this).parent()).slideDown(400);}, function(){$('dd', $(this).parent()).slideUp(250);});
	$('tbody tr:odd').css('background-color', '#f5f5f5');
});

/* facebook share */
function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');}

/* form validation */
var validationFilters = {
	email: /([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+/,
	phone1: /([0-9]{3})+\-([0-9]{3})+\-([0-9]{4})/,
	phone2: /([0-9]{3})+\.([0-9]{3})+\.([0-9]{4})/,
	name: /([a-zA-Z]{2,64})/,
	age: /([0-9]{1,3})/
};
function validate(fieldName, value) {
	switch (fieldName) {
		case 'name':
			return (value.search(validationFilters.name) == -1) ? false : true;
			break;
		case 'email':
			return (value.search(validationFilters.email) == -1) ? false : true;
			break;
		case 'phone':
			var validPhone = (value.search(validationFilters.phone1) == -1) ? false : true;
			if (!validPhone) return (value.search(validationFilters.phone2) == -1) ? false : true;
			return true;
			break;
		default:
			return true;
	}
}