
// load facebook likes via ajax
$(window).bind("load", function() {	
	$.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1");	
	$("div[fb]").each(function() {
		$(this).html("<fb:like href='"+$(this).attr('url')+"' layout='button_count' show_faces='false' width='80' font='' class='facebooklike'></fb:like>");
	});
	
	/* doesn't work on live site 
	$.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1");
	$("div[fb]").each(function() {
		var url = escape($(this).attr('url'));
		var div = $(this);
		$.ajax({
			url: "index.php?page=fblike&url="+url,
			async: true,
			cache: false,
			dataType: "html",
			success: function(data) {
				div.html(data);
			}
		});
	});
	*/
});



$(document).ready(function(){

	$.preloadCssImages();

	$(document).pngFix(); 

	
	// overlay
	$("img[rel]").overlay({
		effect:'apple',
		closeOnClick:false,
		closeOnEsc:false,
		onBeforeLoad:  function() {
			this.getOverlay().appendTo('body');
        },
		mask: { 
			color:'#333'
		}
	});
	
	$(".show_overlay").overlay({
		effect:'apple',
		closeOnClick:true,
		closeOnEsc:true,
		onBeforeLoad:  function() {
			this.getOverlay().appendTo('body');
        },
		onClose: function() {
			$('#show_info').html('');
	},
		mask: { 
			color:'#333'
		}	
	});
	
	$("#aboutus_overlay").overlay({
		effect:'apple',
		closeOnClick:true,
		closeOnEsc:true,
		onBeforeLoad:  function() {
			this.getOverlay().appendTo('body');
        },
		mask: { 
			color:'#333'
		}	
	});	
	$("#mailing_overlay").overlay({
		effect:'apple',
		closeOnClick:true,
		closeOnEsc:true,
		onBeforeLoad:  function() {
			this.getOverlay().appendTo('body');
        },
		mask: { 
			color:'#333'
		}	
	});		
	// mouseover
	$("img.a").hover(
		function() {
			$(this).stop().animate({"opacity": "0"}, "fast");
		},
		function() {
			$(this).stop().animate({"opacity": "1"}, "fast");
		});

	$(".clipart").hover(function(){
		$(this).toggleClass('enabled');
	});

	// mailing list submit
	$("#mailing_submit").click(function() {
		var emailaddress = $("#mail_email").val();
		var testresult = false;
		$.ajax({
			url: 'index.php?page=checkmailing',
			data: ({email: emailaddress}),
			async: false,
			dataType: 'json',
			success: function(json) {
				testresult = json.result;
				message = json.msg;
			}
		});
		if (testresult === false) { $("#mail_error").html(message); }
		if (testresult === true) { 
			$(this).overlay().close();
		}
		
	});	

	
 });
 
 
 

