
function ValidateDataSmall(theForm)
{
	debugger;
	if (theForm.contactDate.value != "")
	{
		return false;
	}

	if ((theForm.Name.value == "") || (theForm.Name.value == 'Name'))
	{
		alert('Please, enter your full name.');
		theForm.Name.focus();
		return false;
	}
	
	if ((theForm.Email.value == "") || (theForm.Email.value == 'Email'))
	{
		alert('Please, enter your email.');
		theForm.Email.focus();
		return false;
	}
	else
	{
		if(!ValidateEmail(theForm.Email.value))
		{
			alert("Please check the emails address");
			theForm.Email.focus();
			return false;
		}
	}
		
	if ((theForm.Comment.value == "") || (theForm.Comment.value == 'Comments'))
	{
		alert('Please, enter your comments.');
		theForm.Comment.focus();
		return false;
	}
	
	createCookie('smallContactName',theForm.Name.value,1);
	createCookie('smallContactEmail',theForm.Email.value,1);
	createCookie('smallContactComment',theForm.Comment.value,1);
	createCookie('smallContactNewsletter',theForm.Newsletter.checked,1);
	openShowModal('',580,750);
}

function ValidateEmail(incoming) 
{
	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
	// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
	// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
	// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
	// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));
	//var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/ 
	// index of -1 means "not found"
	
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) //&&
		//(email_regex.test(emailstring))
		) 
	{
		return true;
	} 
	else {
		return false;
	}
}

function openShowModal(pageName,width,height)
{
	LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	window.open(pageName,"DisplayWindow","height="+height+",width="+width+",scroll=yes,scrollbars=1,top="+TopPosition+",left="+LeftPosition+",resizable=no,noresize=yes,toolbar=no,location=no,directories=0,status=0,menubar=0");
}

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}		