// Form fields validation
function showContent(){
	$('#loading').hide();	
	$('#content').show().css('visibility','visible');
} 

function validateOnSubmit() {

	var emailFilter=/^.+@.+\..{2,3}$/;
	$(".validationresponse:visible").hide();

	if (jQuery.trim(document.formdata.txtFullname.value) == "") {
		document.formdata.txtFullname.value="";
		document.formdata.txtFullname.focus();
		addResponse("txtFullname",'Your full name is required');
		return false;
	}
	if (jQuery.trim(document.formdata.txtEmail.value) == "") {
		document.formdata.txtEmail.value="";
		document.formdata.txtEmail.focus();
		addResponse("txtEmail",'Email address is required');
		return false;
	}
	if (!(emailFilter.test(document.formdata.txtEmail.value))) {
		document.formdata.txtEmail.focus();
		addResponse("txtEmail",'Please enter a valid email address');
		return false;
	}
	if (jQuery.trim(document.formdata.txtBusinessTel.value) == "") {
		document.formdata.txtBusinessTel.value="";
		document.formdata.txtBusinessTel.focus();
		addResponse("txtBusinessTel",'Your Business Telephone required');
		return false;
	}
	if (jQuery.trim(document.formdata.txtMobile.value) == "") {
		document.formdata.txtMobile.value="";
		document.formdata.txtMobile.focus();
		addResponse("txtMobile",'Your mobile required');
		return false;
	}
	if (jQuery.trim(document.formdata.txtSubject.value) == "") {
		document.formdata.txtSubject.value="";
		document.formdata.txtSubject.focus();
		addResponse("txtSubject",'Subject is required');
		return false;
	}

	if (jQuery.trim(document.formdata.txtMessage.value) == "") {
		document.formdata.txtMessage.value="";
		document.formdata.txtMessage.focus();
		addResponse("txtMessage",'Your message required','textarea');
		return false;
	}

	if(jQuery.trim(document.formdata.captcha_code.value) == '') {
			document.formdata.captcha_code.value="";
			document.formdata.captcha_code.focus();
			addResponsenew("captcha_code",'Please enter the captcha code');
			return false;
	}
//	var capt =document.formdata.getElementById('captcha_code');


	return true;
}


function isAlphaNumeric(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8 && unicode!=13 && unicode!=9){
		str=String.fromCharCode(unicode);
		var re = /^[a-z A-Z]+$/;
		 // validation fails if the input doesn't match the regular expression
		if(!re.test(str)){
			return false;
		}
	}
	return true;
}

function addResponse(name,msg,type) {
	if(type==null) { type="input" }
	$(type+"[name="+name+"]").next(".validationresponse").html(msg);
	$(type+"[name="+name+"]").next(".validationresponse").show('slow');
	return false;
}

function addResponsenew(name,msg){
	$("[name="+name+"]").parent().children(".validationresponse").html(msg);
	$("[name="+name+"]").parent().children(".validationresponse").show('slow');
	return false;
}

function addResponseCustom(id,msg) {
	$("#"+id).html(msg);
	$("#"+id).show('slow');
	return false;
}

$(function() {	
	$(".image").click(function() {
		var image = $(this).attr("rel");
		$('#image').hide();
		$('#image').fadeIn('slow');
		$('#image').html('<img src="' + image + '"/>');
		return false;
	});
});

$(function() {
	$(".leftnavmenu-list a").each(function(){
		$(this).click(function(){
			id=this.id;
			arr=id.split("_");
			ident=arr[arr.length-1];
			//content=$('#about_content_'+ident).html();
			$('.y-content').each(function(){
				$(this).show();
			});
			$('.y-content').each(function(){
				if(this.id!='content_'+ident){
					$(this).hide();
				}else{
					$(this).hide().fadeIn();
				}
			});
		});
	});
});

$(document).ready(function() { 
	
	$('a#link1_content_2, a#link1_content_3, a#link1_content_4, a#link1_content_5 ').click(function(){$('.y-range-bg').css('background','none').fadeIn('slow');});

	//$('#gallery a').lightBox( {
	//	fixedNavigation:true
	//});

});




