<!--
function DelRecord(TheID, DelType) {

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 = "../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;
	
	memnews = new Array("tbl11Heading", "tbl11IntroText", "tbl11Text");
	addcasting = new Array("tbl10SubsectionID", "tbl10Name", "tbl10ContactNumber");
	add_image = new Array("tbl6GalleryID");
	add_gal = new Array("tbl5Name");
	add_artiste = new Array("tbl7Heading", "tbl7IntroText", "tbl7Text");
	add_link = new Array("tbl3Name", "tbl3Description", "tbl3URL");
	homepage = new Array("tbl4Text");
	adddoc = new Array("tbl1Heading");
	adduser = new Array("tbl0CompanyName", "tbl0UserName", "tbl0UserPass");

	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") && $TypeBit[1] == "URL") {
				TestStr = obj.value;
				var URL = /\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/i
				Valid = URL.test(TestStr);

  				if(!Valid) {
					message = message + "- " + obj.id + " must be a valid URL ie http://www.my-site.com\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 true;
	}
	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";
	}
}
//-->