$(document).ready(function() {
	$('.mycarousel').jcarousel();
	$('.blog-date-box,.jcarousel-container').corners();
	$('input[name=keywords]').DefaultValue("search");
	$('#page-search input').DefaultValue("search");
	$('.contact-number').DefaultValue("contact number");
	$(".contact-name,#comment-name").DefaultValue("name");
	$(".contact-email").DefaultValue("you@youremailaddress.com");
	$("#message,#comment-message").DefaultValue("message");
	$("#top-tab").click(function(){$.scrollTo("#top",800); return false;});
	
	workpageload();
	sifrs();

	$("#contact-estimate").selectbox();

	$("#project-detailed").bind("ajaxComplete", function(){
   		workpageload();
		sifrs();
 	});


	$("form").submit(function(){
		var result = true;
		$(".required", this).each(function (i) {
			$(this).removeClass("badvalue");
			if (this.value === "") {
				$(this).addClass("badvalue");
				result = false;
			}
		});
		if (!checkemail($("input[name='email']").val())) {
			$("input[name='email']").addClass("badvalue");
			result = false;
		}
		if (result === false) 
			$(".error", this).css("visibility", "visible");
		return result;
	});

	$("#home-recent a").click(function(){
		name = $(this).attr("id");
		$(".featured-info,.featured-slideshow").addClass("feat-off");
		$("."+name).removeClass("feat-off");
		//$("#home-recent a").removeClass("feat-off");
		//$(this).addClass("feat-off");
		return false;
	});
});

// WORK DETAIL PAGE EVENTS
function workpageload () {

	$("#next,#previous").click(function(){
		$("#project-detailed").load($(this).attr('href'));
		return false;
	});
	$("#more-work").click(function(){
		$("#project-thumbs").show('slow');
		$(this).css("display","none");
		return false;
	});
	$("#more-work-").click(function(){
		$("#project-thumbs").hide('fast');
		$("#more-work").css("display","block");
		return false;
	});
	$("#case-study-close").click(function(){
		$("#case-study").addClass("hide");
		return false;
	});
	$("#case-study-available").click(function(){
		$("#case-study").removeClass("hide");
		return false;
	});

}

// EMAIL FILTER
function checkemail(str){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=true
	else{testresults=false}
	return (testresults)
}
