$(function(){
	//dropdown menu
	$('.mainNav .items > li > a').hover(function(){
		$subNav = $(this).next();
		$subNav.stop().show().fadeTo('fast', 1);
	}, function(){
		$subNav = $(this).next();
		$subNav.stop().fadeOut('fast');
	});
	$('.mainNav .items li ul').hover(function(e){
		$(this).stop().fadeTo('fast', 1);
	}, function(e){
		var node = e.relatedTarget;
		if (this != node) {
			while (node = node.parentNode) {
				if (this == node) return;
			}
			$(this).fadeOut('slow');
		}
	});


	//add mask
	$('div.casesBlock .name').mouseover(function(){
		$(this).next().animate({
			height: '128px'
		});
	});

	$('div.casesBlock .detail').mouseout(function(e){
		var node = e.relatedTarget;
		if (this != node) {
			while (node = node.parentNode) {
				if (this == node) return;
			}
			$(this).animate({
				height: '22px'
			}, function(){
				$(this).hide();
			});
		}
	});

	//results filter effect
	$('#resultsFilter .results .name').mouseover(function(){
		$(this).next().fadeIn();
		$(this).prev().addClass('hover');
	});
	$('#resultsFilter .results .detail').mouseout(function(e){
		var node = e.relatedTarget;
		if (this != node) {
			while (node = node.parentNode) {
				if (this == node) return;
			}
			$(this).fadeOut();
			$(this).prev().prev().removeClass('hover');
		}
	});

	//hide results filter
	$('#resultsFilterHandler a.op').click(function(){
		var $this = $(this);
		$('#resultsFilter').slideToggle('fast', function(){
			$this.toggleClass('down');
		});
		return false;
	}).focus(function(){
		this.blur();
	});
});

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function isEmail(val){
	var email=val.replace(/^\s+|\s+$/g, '');
	
	if ((email==null)||(email=="")){
		return false
	}
	if (echeck(email)==false){
		return false
	}
	return true
 }
