$(document).ready(function() 
{
	$("#frm-cnt").submit
	(
		function()
		{
			strURL = $("#surl").val() + "/sendmail.php";
			$(".msg").html('<p><span class="msg-stat">Sending Message, Please wait.</span></p>');
			var str = $(this).serialize();
			$.ajax(
			{
				type: "POST",
				url: strURL,
				data: str,
				success: 
				function(msgStatus)
				{
					$(".msg").ajaxComplete(function(event, request, settings)
					{
						$(this).html(msgStatus);
					});
				}
			});
			$("#securecode").attr("src", $("#surl").val()+"/securecode.php?" +  Math.floor(Math.random()*100));
			return false;
		}
	);
	
	if($("a[rel=gallery]").length)
	{
		$("a[rel=gallery]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});
	}
	
	if($('#slider').length)
	{
		$("#pagenos").show();
		$("#pagenos a:first").addClass("active");
		var imageWidth = 1000;
		var imageReelWidth = imageWidth * $(".image_reel img").length;
		var triggerID; var image_reelPosition; var anispeed = 500;
		$(".image_reel").css({'width' : imageReelWidth});
		rotate = function(){ triggerID = $active.attr("rel") - 1; image_reelPosition = triggerID * imageWidth; $("#pagenos a").removeClass('active'); $active.addClass('active'); $(".image_reel").animate({left: -image_reelPosition}, anispeed ); };
		rotateSwitch = function(){ play = setInterval(function(){ $active = $('#pagenos a.active').next(); if ( $active.length === 0) { $active = $('#pagenos a:first'); } rotate(); }, 5000); };
		rotateSwitch();
	}
	
});
