<!--
function DelRecord(TheID, DelType, From)
{
var message = "";
if(DelType.indexOf("Del", 0) >= 0)
{
var DelOrDisoc = "Delete";
}
if(DelType.indexOf("Disoc", 0) >= 0)
{
var DelOrDisoc = "Dissociate";
}
if(DelType.indexOf("DelCat", 0) >= 0)
{
message = "\n\nAll related sub categories will also be deleted. \nProducts, Discounts and Category recommended products will loose their associations.\n(Meaning the system will become unstable)\nFirst re-associate related categories and products then delete this category.\n\n Proceed with delete?";
}
	if(confirm(DelOrDisoc + " record?\n ID: " + TheID + message))
	{
		if(confirm("Last warning!\n\n" + DelOrDisoc + " record?\n ID: " + TheID))
		{
		location.href = From+"PHP-API/API_Main.php?API_CallFirst=" + DelType + "/" + TheID;
		}
	}
}
function SetObjFocus(obj)
{
obj.style.cssText = "background-color: #FFFF99"; 
}
function LooseObjFocus(obj)
{
obj.style.cssText = "background-color: #FFFFFF"; 
}

function MM_findObj(n, d) 
{ 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function ValidateForm(FieldRange, FormName)
{
var message = "";
var message2 = "";
var TestCondition = false;

checkout1 = new Array("Title", "Firstname" , "Lastname" , "Address1" , "Country" , 
 "CountyState" , "PostcodeZIP" , "Phone|PHONE" , "Email_address" ,
  "MATCHPREVIOUS", "CONDITION");

UploadNewsletter = new Array("tbl17Heading", "tbl17file"); 
AddReferral = new Array("tbl4Title", "tbl4Description");
AddReferralCat = new Array("tbl5CatName", "tbl5Description");
AddClassified = new Array("tbl6Title", "tbl6Description", "tbl6Price");
SendMessage = new Array("tbl16Subject", "tbl16Message");
VotePoll = new Array("tbl10PollOptID");
UserAdd = new Array("tbl1UserName", "tbl1PASSWORD", "tbl1Name", "tbl1LastName");
UserEdit = new Array("tbl1Name", "tbl1LastName");
ProfileEdit = new Array("tbl1UserName", "tbl1PASSWORD", "tbl1Name", "tbl1LastName");					 
AddNews = new Array("tbl2Title", "tbl2Description");
AddAnnouncement = new Array("tbl3Title");
AddPoll = new Array("tbl9Title", "Option1", "Option2", "Option3");
AddEvent = new Array("tbl12Title", "tbl12Description");
AddFAQItem = new Array("tbl14Title", "tbl14Description");
AddFAQCat = new Array("tbl15CatName");
AddClassifiedCat = new Array("tbl7CatName");
AddClassifiedSubcat = new Array("tbl8SubCatName");
PropAdd = new Array("tbl11ErfNumber|NUM", "tbl11Address1", "tbl11Address2", "tbl11Address3")

ThisArray = eval(FieldRange)

	//LOOK FOR A CONDITION ELEMENT THEN APPEND THE 2 ARRAYS e.g. Personal detail then Personal details2 when CONDITION checkbox on
	for(x=0; x<ThisArray.length; x++) 
	{
	$TypeBit = ThisArray[x].split("|");	
	
		if($TypeBit[0].indexOf("CONDITION", 0) >= 0)
		{
		obj = MM_findObj($TypeBit[0]);
		testobj = eval("document." + FormName + "." + obj.value);//THE CONDITION FORM OBJECT
			if(testobj.checked == true)
			{
			TestCondition = true;
			ConditionalArray = eval(FieldRange + "ALT");
			ThisArray = ThisArray.concat(ConditionalArray); //MAKE ONE ARRAY
			break;
			}
		}
	}

	for(x=0; x<ThisArray.length; x++)
	{

	$TypeBit = ThisArray[x].split("|");	
	obj = MM_findObj($TypeBit[0]);
		//alert(obj.type);
		LooseObjFocus(obj)
		if($TypeBit[0].indexOf("MATCHPREVIOUS", 0) >= 0)
		{
			if(CurrentVal != obj.value)
			{
			message2 = "\n" + obj.id + " does not match " + CurrentVal + "\n\n";
			SetObjFocus(obj);
			}
			
		}
		
		if(obj)
		{
		CurrentVal = obj.value;
			if((obj.type == "text" || obj.type == "textarea") && obj.value == "")
			{
			message = message + "- " + obj.id + "\n";
			SetObjFocus(obj);
			}

			if((obj.type == "text" || obj.type == "textarea") && obj.value != "" && $TypeBit[1] == "NUM")
			{
			TestStr = obj.value;
			var NonNumbers = /\D+/
			Numbers = NonNumbers.test(TestStr);
			
  				if(Numbers)
				{
				message = message + "- " + obj.id + " may only contain numbers\n";
				SetObjFocus(obj);
				}
			}
			
			if((obj.type == "text" || obj.type == "textarea") && obj.value != "" && $TypeBit[1] == "PHONE")
			{
			TestStr = obj.value;
			var Numbers = /\d+/
			Numbers = Numbers.test(TestStr);
			var AllowedChars = /[a-zA-Z]+/
			AllowedChars = AllowedChars.test(TestStr);
			
  				if(!Numbers || AllowedChars)
				{
				message = message + "- " + obj.id + " may only contain 0-9, - + and ()\n";
				SetObjFocus(obj);
				}
				
			}
			//alert(obj.value);
			teststr = obj.name.toUpperCase();
			if(teststr.indexOf("EMAIL", 0) >= 0 && (obj.value.indexOf("@") < 0 || obj.value.indexOf("\.") < 0))
			{
			message = message + "- " + obj.id + " must be a valid e-mail address\n";
			SetObjFocus(obj);
			}
		
			if((obj.type == "select" || obj.type == "select-one" || obj.type == "select-multiple") && 
			(obj.options.value == "" || obj.options.value == "0000:" 
			|| obj.options.value == "00:" || obj.options.value == "00" 
			|| obj.options.value == "00-" || obj.options.value == "0000-"))
			{
			message = message + "- " + obj.id + "\n";
			SetObjFocus(obj);
			}
			
			if((obj.type == "checkbox" || obj.type == "radio") && obj.checked == false)
			{
			message = message + "- " + obj.id + "\n";
			SetObjFocus(obj);
			}
		}

	}
		if(message == "" && message2 == "")
		{
		obj = eval("document." + FormName);
		obj.submit();
		return false
		}
		if(message != "" || message2 != "")
		{
		alert("Please fill in the following fields:\n\n" + message + " " + message2);
		return false;
		}
}
function ShowColours(Obj) {
features = "status=yes,width=150,height=150";
theURL = "/PHP-API/API_ColourPicker.htm?FillObj=" + Obj;
ColWin = window.open(theURL,"Popup",features);
ColWin.focus();
//ColWin.moveTo(200, 200);
}
function OpenWindow(theURL)
{
features = "status=yes,scrollbars=yes,width=600,height=400";
ContentWin = window.open(theURL,"ContPopup",features);
ContentWin.focus();
//ContentWin.moveTo(200, 200);
}

function OpenSpecWindow(theURL, features)
{
SpecWin = window.open(theURL,"SpecPopup",features);
SpecWin.focus();
}

function AddToWishOrCart(obj, WishCartAction)
{
//alert(obj);
	obj = eval("document." + obj);
	if(obj)
	{
	//alert(obj.name);
	obj.action = "PHP-API/API_AddWishOrCart.php?Action=" + WishCartAction;
	obj.submit();
	return false;
	}
	else
	{
	location.href = "PHP-API/API_AddWishOrCart.php?Action=" + WishCartAction; 
	}
}

function ShowHideLayer(objname)
{
//alert(objname);
LayerObj = objname;
//LayerObj = MM_findObj(obj);
//alert(LayerObj);
	if(LayerObj.style.visibility == "visible")
	{
	LayerObj.style.visibility = "hidden";
	}
	else
	{
	LayerObj.style.visibility = "visible";
	}
}
//-->