jQuery(document).ready(function($)
{
$validform = 0;
$validname = 0;
$validmsg = 0;

	$('#fmsubmit').click(function() {
		if ( $validform == 0  || $validname == 0 || $validmsg == 0 )
		{
			$('#EMAIL').css({'backgroundPosition':'0px 24px'});
			$('#NAME').css({'backgroundPosition':'0px 24px'});
			$('#MSG').css({'backgroundPosition':'0px 124px'});
			return false;
		}
	});
	$('#EMAIL').keyup(function() {
		var email = $("#EMAIL").val();
		if(email != 0)
		{
			if(isValidEmailAddress(email))
			{$validform = 1;
				$("#EMAIL").css({'backgroundPosition':'0px 0px'});
			}
			else
			{$validform = 0;
				$("#EMAIL").css({'backgroundPosition':'0px 24px'});
			}
		}
	});
	$('#NAME').keyup(function() {
		var text = $("#NAME").val();
		if(text != '')
		{
			$validname = 1;
			$("#NAME").css({'backgroundPosition':'0px 0px'});
		}
		else
		{	$validname = 0;
			$("#NAME").css({'backgroundPosition':'0px 24px'});
		}
	});
	$('#MSG').keyup(function() {
		var te2xt = $("#MSG").val();
		if(te2xt != '')
		{
			$validmsg = 1;
			$("#MSG").css({'backgroundPosition':'0px 0px'});
		}
		else
		{	$validmsg = 0;
			$("#MSG").css({'backgroundPosition':'0px 124px'});
		}
	});


	//$(document).pngFix();

	$('.menuitem').click(function(){
		if ($(this).children().html() == '/portfolio.html' )
		{
			$('#bublegumwrap').slideToggle();
			$('#bublegum').slideToggle('slow');
			//$(this).find('.strelka').toggle();
			return false;
		}
	});

	$('#prevarr').mouseover(function(){ $(this).attr({'src':'/assets/templates/fresh/images/arrow_la.png'});	});
	$('#prevarr').mouseleave(function(){ $(this).attr({'src':'/assets/templates/fresh/images/arrow_l.png'});	});
	$('#nextarr').mouseover(function(){ $(this).attr({'src':'/assets/templates/fresh/images/arrow_ra.png'});	});
	$('#nextarr').mouseleave(function(){ $(this).attr({'src':'/assets/templates/fresh/images/arrow_r.png'});	});

	$('#fmsubmit').mouseenter(function(){
		$(this).stop().animate({opacity: 0}, 500, function() {});
	});
	$('#fmsubmit').mouseleave(function(){
		$(this).stop().animate({opacity: 1}, 300, function() {});
	});




});



function isValidEmailAddress(emailAddress)
{
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function testKey(e)
{
  var key = (typeof e.charCode == 'undefined' ? e.keyCode : e.charCode);
  if (e.ctrlKey || e.altKey || key < 32)
    return true;
  key = String.fromCharCode(key);
  return /\w/.test(key);
}
function testKeyD(e)
{
  var key = (typeof e.charCode == 'undefined' ? e.keyCode : e.charCode);
  if (e.ctrlKey || e.altKey || key < 32)
    return true;
  key = String.fromCharCode(key);
 return /[\d\.]/.test(key);
}
function testKeyTel(e)
{
  var key = (typeof e.charCode == 'undefined' ? e.keyCode : e.charCode);
  if (e.ctrlKey || e.altKey || key < 32)
    return true;
  key = String.fromCharCode(key);
 return /[0+ .123456789 ()-]/.test(key);
}


