
/* 	provides animations and ajax loaded content */
/* 	powered by jquery */


function isDefined (variable) {
    return (typeof(window[variable]) == "undefined") ?  false : true;
}

function validateContact () {
	var item = $('#contacts-form');
	var response = $('#contact_response');
	
	var email = item.find('input[name=email]').val();
	var name = item.find('input[name=name]').val();
	var msg = item.find('textarea').val();
	
	if (email == "E-mail:" || name == "Name:" || msg == "Message:")
		response.html("<span class='errmsg'>The submitted form was incomplete. Fill all the fields.</span>");
	else {
		response.html("<span>Please Wait. Sending...</span>");
		item.submit();
	}
}
	
function ajaxPage (pageId) {

/*	requires variable currentPageId must be defined */
	//if (!isDefined(currentPageId)) alert ("Error: currentPageId not defined");
	
	var loadLink = "content/page" + pageId + ".php";
	
	$('#ajaxContainer').load(loadLink, function (responseText, textStatus, XMLHttpRequest) {
		var id = pageId;
		var test = $('#ajaxFooterList').children().removeClass('active');
		var cornerPoints = new Array (0, 500, 1130, 1800, 2350, 3070);
		var e = test.eq(id).addClass('active');
		
		$('body').attr('id', 'page' + id);		
		$('#headerMain').stop().animate({
			backgroundPosition : "(-" + cornerPoints[id] + " 0)"
		}, {
			queue : false,
			duration : 300
		});
		
		$("a[rel='gallery']").colorbox();
		CufonReplace();
	});
	
}
