//var strMenu = "";

function openPopUp( strFileName, strWinName, intWidth, intHieght )
{	
	// Work out the central horizontal position
	var intScreenX = Math.round( ( ( window.screen.availWidth - intWidth ) / 2 ) );
	// Work out the central vertical position
	var intScreenY = Math.round( ( ( window.screen.availHeight - intHieght ) / 2 ) );
	
	// Open the new window and set it to focus
	var popupref = window.open( strFileName, strWinName, 'scrollbars=yes,width=' + intWidth + ',height=' + intHieght + ',screenx=' + intScreenX + ',screeny=' + intScreenY + ',top=' + intScreenY + ',left=' + intScreenX + ',resizable=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,copyhistory=no' );
	popupref.focus( );
}

function setTreeVisibility( objTableObject, objImg )
{
	if( objTableObject.style.display == "none" )
	{
		objTableObject.style.display = "";
		objImg.src = "../images/minus.gif";
	}
	else
	{
		objTableObject.style.display  = "none";
		objImg.src = "../images/plus.gif";
	}
}

function setDivVisiblity( objTableObject )
{
	if( objTableObject.style.display == "none" )
	{
		objTableObject.style.display = "";
	}
	else
	{
		objTableObject.style.display  = "none";
	}
	
	// strMenu += "setDivVisiblity( " + objTableObject.name + " )";
}

function changeTreeImage( objImg )
{
	var strImage = objImg.src;
	strImage = strImage.toString();
	
	if( strImage.indexOf("minus.gif") == -1 )
	{
		objImg.src = "../images/minus.gif";
	}
	else
	{
		objImg.src = "../images/plus.gif";
	}
	
	// strMenu += "changeTreeImage( " + objImg.name + " );";
}

function openLargeImage( objImage )
{
	var strImagePath = objImage.src;
	strImagePath = strImagePath.toString();
	strImagePath = strImagePath.replace( "thumbmid", "thumblarge" );
		
	openPopUp( strImagePath, "EnlargeImage", 400, 300 );
}

function changeMainImageName( strImageDesc )
{

	var objImageName = document.getElementById("objImageName");
	objImageName.innerHTML = strImageDesc + " - click to enlarge";
}

function regValidation()
{
	var strMSG = "";
	
	if( frmReg.WebFirstName.value == "" )
	{
		strMSG += "You must enter a first name.\n";
	}

	if( frmReg.WebSurname.value == "" )
	{
		strMSG += "You must enter a surname.\n";
	}
	
	if( frmReg.WebUserName.value == "" )
	{
		strMSG += "You must enter a user name.\n";
	}
	
	if( frmReg.WebPassword.value == "" )
	{
		strMSG += "You must enter a password.\n";
	}

	if( frmReg.WebUserEmail.value == "" )
	{
		strMSG += "You must enter an email address.\n";
	}
	
	var strEmail = frmReg.WebUserEmail.value;
	
	if( strEmail.indexOf("@") == -1 && strEmail .indexOf(".") == -1 )
	{
		strMSG += "You must enter a valid email address.\n";	
	}

	if( frmReg.WebTelephone.value == "" && frmReg.WebMobile.value == "" )
	{
		strMSG += "You must enter at least 1 telephone number.\n";
	}

	if( frmReg.WebAddr1.value == "" )
	{
		strMSG += "You must enter an address.\n";
	}

	if( frmReg.WebPostCode.value == "" )
	{
		strMSG += "You must enter a post code.\n";
	}	

	if( frmReg.WebPassword.value != frmReg.WebPassword1.value )	
	{
		strMSG += "Your passwords do not match.\n";
	}
	
	if( strMSG == "" )
	{
		return true;
	}
	else
	{
		alert(strMSG);
		return false;
	}
	
}

function validateDelivery()
{
	var strMSG = "";
	
	if( frmBasket.WebFirstName.value == "" )
	{
		strMSG += "You must enter a first name.\n";
	}

	if( frmBasket.WebSurname.value == "" )
	{
		strMSG += "You must enter a surname.\n";
	}
	

	if( frmBasket.WebUserEmail.value == "" )
	{
		strMSG += "You must enter an email address.\n";
	}
	
	var strEmail = frmBasket.WebUserEmail.value;
	
	if( strEmail.indexOf("@") == -1 && strEmail .indexOf(".") == -1 )
	{
		strMSG += "You must enter a valid email address.\n";	
	}

	if( frmBasket.WebTelephone.value == "" )
	{
		strMSG += "You must enter a contact telephone number.\n";
	}

	if( frmBasket.WebAddr1.value == "" )
	{
		strMSG += "You must enter an address.\n";
	}

	if( frmBasket.WebPostCode.value == "" )

	{
		strMSG += "You must enter a post code.\n";
	}	

	if( strMSG == "" )
	{
		return true;
	}
	else
	{
		alert(strMSG);
		return false;
	}
	
}

function breakOutOfFrameset()
{
	if (parent.frames.length > 0) 
	{
		parent.location.href = location.href;
	}
}
