//------------------------------------checkForm Validate Form Fields------------------------------------------------
//Member Array
var gvstrArrayMbr= Array("FirstName","LastName", "AddressLine1", "Suburb", "City", "Country",  "Email", "UserName", "UserPassword");
//Room Array
var gvstrArrayRoom = Array("RoomName")
//Thread Array
var gvstrArrayThread = Array("ThreadName", "MessageContent")
//Page Array
var gvstrArrayPage = Array("PageURL", "PageHTMLTitle", "TextContent")
//Image Array
var gvstrArrayImage = Array("ImageName", "ImageLocation")
//ProductArray
var gvstrArrayPrd = Array("ProductName", "ProductLocation", "ProductDesc")
//Product Key Array
var gvstrArrayPrdKey = Array("ProductID", "MemberID")

function checkForm(pcobjForm, pcstrFields)
{
	var lvobjForm=document.all[pcobjForm];
	for(i=0; i<pcstrFields.length; i++)
	{
		if(lvobjForm[pcstrFields[i]].value=="")
		{
			alert("You must enter a value in the " + pcstrFields[i] + " field");
			lvobjForm[pcstrFields[i]].focus;
			return false;
		}
	}
	//return true;
}



//-------------------------------------------- isNumeric ------------------------------------------------------------

function isNumeric(pcvntSource)
{
	var lvintNumber ="0123456789.";			//declare valid numbers
	for(i=0; i<pcvntSource.length; i++)			
	{
		if (lvintNumber.indexOf(pcvntSource.charAt(i))==-1)	//find out if anything other than numeric exists
		{
			alert(pcvntSource.charAt(i) + " is not a valid number.");  //alert user where problem exists
			return false;
		}
	}
	return true;
}

//------------------------------------- isAddress ------------------------------------------------------------------

function isAddress(pcvntSource)
{
	//ensure the value has both numbers and or characters
	for(i=0; i<pcvntSource.length; i++)
	{
	var lvstrChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/\ ,'-1234567890";	//declare valid characters
		
		if (lvstrChar.indexOf(pcvntSource.charAt(i))==-1)
		{
			alert("You must enter a valid address");
			return false;
		}
	}
	return true;
}

//-------------------------------------- isName ---------------------------------------------------------------------

function isName(pcvntSource)
{
	// returns true if string has stated characters in it
	var lvstrChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ,'-";		//declare valid characters
	for(i=0; i<pcvntSource.length; i++)			
	{
		if (lvstrChar.indexOf(pcvntSource.charAt(i))==-1)	//find out if anything other than chars exists
		{
			alert(pcvntSource.charAt(i) + " is not a valid english letter.");  //alert user where problem exists
			return false;
		}
	}
	return true;
}

//-------------------------------------- isEmail ---------------------------------------------------------------------

function isEmail(pcvntSource)
{
	//returns true if email is valid ie: has an @ symbol, a decimal place after it and is longer than the last decimal point value + 1
	var lvstrSource = pcvntSource;
	var lvintAtSym = lvstrSource.indexOf("@");
	if(lvintAtSym >0)
	{
		var lvintDecimal = lvstrSource.indexOf(".", lvintAtSym)
		if((lvintDecimal > lvintAtSym + 1) && (lvstrSource.length > lvintDecimal +1))
			return true;
	}
	alert("You must enter a valid email address eg: yourname@yourname.com");
	return false;
}
//-------------------------------------- isAlphaNumeric ---------------------------------------------------------------------

function isAlphaNumeric(pcvntSource)
{
	//ensure the value has both numbers and or characters
	for(i=0; i<pcvntSource.length; i++)
	{
	var lvstrChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 .";	//declare valid characters
		
		if (lvstrChar.indexOf(pcvntSource.charAt(i))==-1)
		{
			alert("You must enter a valid Name");
			return false;
		}
	}
	return true;
}

//--------------------------------------------Open New Window ----------------------------------
function newwindow(pctsrURL) 
{ 
var lvstrURL = pctsrURL;
var lvstrTitle
window.open(lvstrURL,lvstrTitle,'width=600,height=500,resizable=yes,scrollbars=yes'); 
//window.open(lvstrURL,'width=500,height=500,resizable=yes,scrollbars=yes'); 
} 
