$(document).ready(function(){
	/*if this is the home page*/
	if ($('body').attr("id") == "home")
		{
		swapAndCall();
		colorboxer();
		}
		
	/*if this is the contact page*/
	if ($('body').attr("id") == "contact")
		{
		$('#submit').click(function(){
			$('div#contactform form').submit();
			});
		$('div#contactform form').submit(function(){
			$(this).validate(
				{
				rules: 	{
						name: "required",
						email: { required:true, email:true },
						text: "required"
						},
				submitHandler: function(){
					
					$.post('submit.php', $('div#contactform form').serialize(), function(data){
						$('div#contactform').append(data);
						});
					}
				});
			return false;
			});
		}
		
	$('#tweet1').tweet(
		{
		avatar_size:22,
		count:1,
		username: "smashingmag",
		loading_text: ""
		});
	$('#tweet2').tweet(
		{
		avatar_size:22,
		count:1,
		username: "alistapart",
		loading_text: ""
		});
	$('#tweet3').tweet(
		{
		avatar_size:22,
		count:1,
		username: "nettuts",
		loading_text: ""
		});
	$('#tweet4').tweet(
		{
		avatar_size:22,
		count:1,
		username: "wordpress",
		loading_text: "loading tweets..."
		});
	
	function swapAndCall(callback){
			/*change destination on gallery link to first page of HTML content; add colorbox class*/
			$('div#wrap div#gallery a#overlay').attr(
				{
				href: "gall/sro.html",
				rel: "colorbox"
				})
			.addClass("gall");
			}
			
		function colorboxer(callback){
			/*call colorbox plugin on gallery links*/
			$('a.gall').colorbox(
				{
				transition: "fade",
				scrolling: false,
				slideshow: true,
				slideshowAuto: false,
				height: "750px",
				innerWidth:"700px",
				slideshowStart: "play slideshow"
				});
			}
			
});