///////////////////////////////////////////////////////////
//////////////////////JAVASCRIPT.JS///////////////////////
/////////////////////////////////////////////////////////

function notNumeric( fieldString )
{
if ( String(fieldString * 1) == "NaN")
return true;
else
return false;
}

function check(obj)
{
	//var error = "";

if (obj == null)
return;
if (obj.value == "")
	{
alert("Please enter age for all passengers");
//error +="\nPlease enter age for all passengers";
obj.style.backgroundColor = '#FFD8D8';
obj.SailingSelection.focus();
}
else if (isNaN(obj.value))
{
alert("The age of passengers must be a numeric value");
//error +="\nThe age of passengers must be a numeric value";
obj.style.backgroundColor = '#FFD8D8';
}
}

function validate(SailingSelection)
{

// at this point no invalid fields have been encountered
var error = "";

if (SailingSelection.company_name.value == "")
{
error +="\nPlease enter an title for your site";
document.SailingSelection.company_name.style.backgroundColor = '#FFD8D8';
}
else {
document.SailingSelection.company_name.style.backgroundColor = '#FFFFFF';
}

 if (SailingSelection.website.value == "")
{
error +="\nPlease enter the URL of your site";
document.SailingSelection.website.style.backgroundColor = '#FFD8D8';
}
else {
document.SailingSelection.website.style.backgroundColor = '#FFFFFF';
}

if (SailingSelection.linkpage.value == "")
{
error +="\nPlease enter the URL of page you are going to list our site";
document.SailingSelection.linkpage.style.backgroundColor = '#FFD8D8';
}
else {
document.SailingSelection.linkpage.style.backgroundColor = '#FFFFFF';
}

if (SailingSelection.category.value == "")
{
error +="\nPlease choose a category for your site name";
document.SailingSelection.category.style.backgroundColor = '#FFD8D8';
}
else {
document.SailingSelection.category.style.backgroundColor = '#FFFFFF';
}

if (SailingSelection.description.value == "")
{
error +="\nPlease enter a description for your site";
document.SailingSelection.description.style.backgroundColor = '#FFD8D8';
}
else {
document.SailingSelection.description.style.backgroundColor = '#FFFFFF';
}


///////////////////////////////////////////////////////////////
//////-------EMAIL VALIDATION STARTS HERE ------------////////
/////////////////////////////////////////////////////////////

var x=document.SailingSelection.email.value

var mail=document.SailingSelection.email.value.indexOf('@')

if (SailingSelection.email.value == "")
{
error +="\nYou did not enter an email address.";
document.SailingSelection.email.style.backgroundColor = '#FFD8D8';
}
else if (mail==-1)
{
error += "\nYou did not enter a valid email address.";
document.SailingSelection.email.style.backgroundColor = '#FFD8D8';
}
else {
document.SailingSelection.email.style.backgroundColor = '#FFFFFF';
}


//////////////////////////////////////////////////////////
////////------E-MAIL VALIDATION ENDS HERE ------/////////
////////////////////////////////////////////////////////


if (error != "")
  {
    alert(error);
    return (false);
	
  } else {
    return (true);
 
 
  }
}

