function secureLogin(ID)
	{
		var openNewWindow = true;
		
		if (document.getElementById("OPENINNEWWINDOW").checked == false)
		{
				openNewWindow = false;
		}

		if ((document.getElementById(ID).value == "Member ID") || (document.getElementById(ID).value == ""))
			{
			window.alert("Please enter a valid member ID.");
			}
		else if (parseInt(document.getElementById(ID).value.length) > 8)
			{
			window.alert("Member ID entered is too short.\nPlease check your Member ID and try again.");
			}
		else
			{
			document.getElementById(ID).value = document.getElementById(ID).value.toUpperCase();
			
			if (openNewWindow == true)
				{
				var h = 560;
				var w = 880;
				var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
				var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
				var urlR = "https://www.silverpay.co.uk/SilverClub/Default.aspx?MEMBERID=" + document.getElementById(ID).value;
				window.open(urlR,"CL_Window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", left=" + LeftPosition + ", top=" + TopPosition);
				document.getElementById(ID).value = "Member ID";
				}
			else
				{
				var urlR = "https://www.silverpay.co.uk/SilverClub/Default.aspx?MEMBERID=" + document.getElementById(ID).value;
				window.location = urlR;
				}
			}
	}

function selectLogin(ID)
	{
	var mNum = document.getElementById(ID).value;
	
	if (mNum == "Member ID")
		{
		document.getElementById(ID).value="";
		}
	document.getElementById(ID).select();
	}
	
function unSelectLogin(ID)
	{
	var mNum = document.getElementById(ID).value;
	
	if (mNum == "")
		{
		document.getElementById(ID).value="Member ID";
		}
	}
	

function ChangeLocation(url,sec)
{
	try {
		eval("window." + sec + ".location=\"" + url + "\"");
	} catch (e)
	{
		alert(e.description);
	}
} //End function

function PrivacyStatement()
	{
		var h = 560;
		var w = 400;
		var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		var urlR = "PrivacyStatement.htm";
		window.open(urlR,"PS_Window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + w + ", height=" + h + ", left=" + LeftPosition + ", top=" + TopPosition);
	} //End function
	
function contact()
	{
		var name,email,telephone,source;
		name = document.getElementById("NAME").value;
		email = document.getElementById("EMAIL").value;
		telephone = document.getElementById("TELEPHONE").value;
		source = document.getElementById("SOURCE").options[document.getElementById("SOURCE").selectedIndex].value;
		
		var status = 1;
		var message = "Please check you have supplied the following details:\n\n";
		
		if (name == "")
		{
			status = 0
			message += "- your name\n";
		}
		
		if ((email == "") && (telephone == ""))
		{
			status = 0;
			message += "- email address OR telephone number\n";
		}

		if (source == "--")
		{
			status = 0;
			message += "- Source (how you found out about SilverPay)";
		}
		
		if (status == 1)
		{
			document.getElementById("form1").submit();
		}
		else
		{
			window.alert(message);
		}

	} //End function


function OpenSilverServiceTutorial()
{
	var h = 472;
	var w = 640;
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	var url = "SilverServiceTutorial.htm";
	window.open(url,"SilverServiceTutorial","toolbar=no,resizable=no,scrollbars=no,status=no,menubar=no,height=" + h + ",width=" + w + ",left=" + LeftPosition + ",top=" + TopPosition);
} //End Function


function sendCallBack()
{
		var name = document.getElementById("NAME").value.replace(" ","");
		var phone = document.getElementById("PHONE").value.replace(" ","");
		var phone_type = document.getElementById("PHONE_TYPE").value;
		var callBack = document.getElementById("CALLBACK").value;

		var errNum = 0;
		var message = "The following is required to send a callback request:\n\n";

		if (name == "")
		{
			errNum++;
			message += "- Your name\n"
		}
		
		if (phone.length < 10)
		{
			errNum++;
			message += "- Phone number\n"
		}
		else
		{
			
			var pNum = false;
			for (var i = 0; i < phone.length; i++)
			{
				if ((phone.charCodeAt(i) < 48) || (phone.charCodeAt(i) > 58)) //less than 0 or more than 9
				{
					if (phone.charCodeAt(i) != 32) //Space
					{
						pNum = true;
						errNum++;
					}
				}
			}
			
			if (pNum == true)
			{
				message += "- Invalid phone number (must only contain numbers)\n";
			}
			
		}
		
		if (errNum == 0)
		{
			document.frmCallBack.submit();
		}
		else
		{
			window.alert(message);
		}
}
