$(document).ready(function() {
	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'all') {
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$('ul#portfolio li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});
});
function showDiv(ID)
{

	if(ID=='Dorcas')
	{
		$('#Dorcas').show();
		$('#Church').hide();
		$('#GSASC').hide();
		$('#HLMYW').hide();
		$('#CUNITY').hide();
	}
	if(ID=='Church')
	{
		$('#Dorcas').hide();
		$('#Church').show();
		$('#GSASC').hide();
		$('#HLMYW').hide();
		$('#CUNITY').hide();
	}
	if(ID=='GSASC')
	{
		$('#Dorcas').hide();
		$('#Church').hide();
		$('#GSASC').show();
		$('#HLMYW').hide();
		$('#CUNITY').hide();
	}
	if(ID=='HLMYW')
	{
		$('#Dorcas').hide();
		$('#Church').hide();
		$('#GSASC').hide();
		$('#CUNITY').hide();
		$('#HLMYW').show();
	}
	if(ID=='CUNITY'){
		$('#Dorcas').hide();
		$('#Church').hide();
		$('#GSASC').hide();
		$('#HLMYW').hide();
		$('#CUNITY').show();
		
	}
}
function formCheck()
{
	if(document.getElementById('author').value=='')
	{
		alert('Please enter your name.');
		document.getElementById('author').focus();
		return false;
	}
	if(document.getElementById('email').value=='')
	{
		alert('Please enter your email.');
		document.getElementById('email').focus();
		return false;
	}
	else if(document.getElementById('email').value!='')
			{
				var ret = validEmail('email');
					if( ret == false ){
					document.getElementById('email').focus();
						return false;
					}
			}
	
	if(document.getElementById('url').value!='')
	{
		var ret = url_validate(document.getElementById('url').value);
					if( ret == false ){
					document.getElementById('url').focus();
						return false;
					}
	}
	if(document.getElementById('comment').value=='')
	{
		alert('Please enter your comment.');
		document.getElementById('comment').focus();
		return false;
	}
	
}
//----------------- validate Email Id function ---------------//
function validEmail(emailId){
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   	var address = document.getElementById(emailId).value;
   	if(reg.test(address) == false) {
      	alert("Invalid Email Address");
	  document.getElementById(emailId).focus();
		i=1;
      return false;
   }
   return true;
}

function url_validate(userUrl)
{

var regUrl = /^(((ht|f){1}(tp:[/][/]){1})|((www.){1}))[-a-zA-Z0-9@:%_\+.~#?&//=]+$/;

if(regUrl.test(userUrl) == false)
{

alert("Website URL is not valid yet.");
document.getElementById('url').focus();
return false;
}

}

