// JavaScript Document


/* ================================================================================= */	
/* Validate Email Address */

function validEmail(email)
	{
	invalidChars = "/:;,";
	if(email == "")
		{
		return false;
		}
	for(i=0; i<invalidChars.length; i++)
		{
		badChar=invalidChars.charAt(i);
		if (email.indexOf(badChar,0) != -1)
			{
			return false;
			}
		}
	atPos = email.indexOf("@",1);
	if(atPos == -1)
		{
		return false;
		}
	if (email.indexOf("@", atPos+1) != -1)
		{
		return false;
		}
	periodPos = email.indexOf(".",atPos);
	if(periodPos == -1)
		{
		return false;
		}
	if(periodPos+3>email.length)
		{
		return false;
		}
	return true;
	}

function validateEmail(email)
	{	
		if (!validEmail(email.value))
		{
		alert("Invalid Email Address");
		email.focus();
		email.select();
		return false;
		}
	else
		{
		return true;
		}
	}

/* ================================================================================= */	
/* Add to Favourites */

function bookmark(url,title)
	{
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) 
		{
		window.external.AddFavorite(url,title)
		}
	else
		{
		var msg = "Don't forget to bookmark us!";
		if(navigator.appName == "Netscape") msg += " (CTRL+D)";
		alert(msg);
		}
	}

/* ================================================================================= */	
/* popUp window */

function popUp(url,w,h,l,t)
	{
	newWindow = window.open (url,'newWin','scrollbars=no,width='+w+',height='+h+',left='+l+',top='+t);
	}
	
function popFNF(url)
	{
	newWindow = window.open (url,'newWin','scrollbars=no,width=350,height=400,left=150,top=300');
	}
	
  
// Contact Us form validation
function contact_us(form)
{
	if(form.name.value == "") { alert("Please enter your name."); form.name.focus(); return false; } 
	if(!form.email.value == "") 
	{ 
		if (!validEmail(form.email.value))
		{
			alert("Please enter a valid email address."); 
			form.email.focus(); 
			return false; 
		}
	} else {
		alert("Please enter your email address."); 
		form.email.focus(); 
		return false; 
	}
	if(form.phone.value == "") { alert("Please enter your phone number."); form.phone.focus(); return false; } 
	if(form.message.value == "") { alert("Please enter a message."); form.message.focus(); return false; } 

	return true;
}

