

function testIsBlank(strValue)
{
	for(i = 0; i < strValue.length; i++)
 		{
		var c = strValue.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t'))
			return false;
	}
	return true;
}	

function validateForm()
{
	try
	{
		// Replicate the following for each field to validate and change the field name and message
		///////////////////////////////////////////////////////////////////////////////////////////
		if (testIsBlank(document.frmContact.first_name.value) == true)
		{
			alert("You must enter your First Name");
			document.frmContact.first_name.focus();
			return false;
		}
		///////////////////////////////////////////////////////////////////////////////////////////
		
		// Replicate the following for each field to validate and change the field name and message
		///////////////////////////////////////////////////////////////////////////////////////////
		if (testIsBlank(document.frmContact.last_name.value) == true)
		{
			alert("You must enter your Last Name");
			document.frmContact.last_name.focus();
			return false;
		}
		///////////////////////////////////////////////////////////////////////////////////////////
		
		// Replicate the following for each field to validate and change the field name and message
		///////////////////////////////////////////////////////////////////////////////////////////
		if (testIsBlank(document.frmContact.company.value) == true)
		{
			alert("You must enter your Organisation");
			document.frmContact.company.focus();
			return false;
		}
		///////////////////////////////////////////////////////////////////////////////////////////
		
		if (testIsBlank(document.frmContact.phone.value) == true)
		{
			alert("You must enter your Telephone");
			document.frmContact.phone.focus();
			return false;
		}
		///////////////////////////////////////////////////////////////////////////////////////////
		
		// Replicate the following for each field to validate and change the field name and message
		///////////////////////////////////////////////////////////////////////////////////////////
		if (testIsBlank(document.frmContact.email.value) == true)
		{
			alert("You must enter your Email");
			document.frmContact.email.focus();
			return false;
		}
		///////////////////////////////////////////////////////////////////////////////////////////
		// Replicate the following for each field to validate and change the field name and message
		///////////////////////////////////////////////////////////////////////////////////////////
		if (testIsBlank(document.frmContact.RepeatEmail.value) == true)
		{
			alert("You must enter your Email again");
			document.frmContact.RepeatEmail.focus();
			return false;
		}
		
		if (document.frmContact.email.value != document.frmContact.RepeatEmail.value)
		{
			alert("Email addresses must match");
			document.frmContact.RepeatEmail.focus();
			return false;
		}
		///////////////////////////////////////////////////////////////////////////////////////////
		
		// Replicate the following for each field to validate and change the field name and message
		///////////////////////////////////////////////////////////////////////////////////////////
		//if (testIsBlank(document.frmContact.00N20000000rQoz.value) == true)
		//{
			//alert("You must enter a Subject");
			//document.frmContact.00N20000000rQoz.focus();
			//return false;
		//}
		///////////////////////////////////////////////////////////////////////////////////////////
		
		// Replicate the following for each field to validate and change the field name and message
		///////////////////////////////////////////////////////////////////////////////////////////
		if (testIsBlank(document.frmContact.description.value) == true)
		{
			alert("You must enter a Message");
			document.frmContact.description.focus();
			return false;
		}
		///////////////////////////////////////////////////////////////////////////////////////////
		
		// Replicate the following for each field to validate and change the field name and message
		///////////////////////////////////////////////////////////////////////////////////////////
		//if (document.frmContact.Consent.checked == false)
		//{
			//alert("You must consent to our privacy policy - please tick the box");
			//return false;
		//}
		///////////////////////////////////////////////////////////////////////////////////////////

		document.frmContact.submit();
	}
	catch(e)
	{
		alert("Sorry, an error occurred.\nPlease check that you have JavaScript enabled.")
	}
}


var anewURL = unescape(this.location.search.substring(1));
//alert(location.search.substring(1)+"2");
var amp=0

if(anewURL.charAt(0)!='')
{
	amp=2
}
	
function Runer()
{
	var newURL = unescape(this.location.search.substring(1));
	//alert(location.search.substring(1)+"2");
	//alert(newoption)
	
	if(newURL.charAt(0)!='')
	{
		newoption = new Option(newURL, newURL, true, true);
		window.document.frmForm1.SourceCode.options[0] = newoption;
	}
}

var	g_success = null;

function redirectLoginLink()
{
	document.getElementById("login").href = "https://confirmations.swapswire.com"; 
}

function timedOut()
{
	if (g_success == null)
	{
		g_success = false;
	}		
}

function imageLoadSuccess()
{
	if (g_success == null) 
	{
		g_success = true;
		redirectLoginLink();
	}
}
function imageLoadFailure()
{
	if (g_success == null)
	{
		g_success = false;
		redirectLoginLink();
	}		
}

function probeAuthority()
{
	window.setTimeout(timedOut, 5000);
	var	img = document.createElement("img");
	img.onerror = imageLoadFailure;
	img.onload = imageLoadSuccess;
	img.src = "https://confirmations.swapswire.com/images/swapswire.gif";
}

function ShowDate()
{
	d = new Date();
	dateText = "";
	dayValue = d.getDay();
	if (dayValue == 0)
		dateText += "Sunday";
	else if (dayValue == 1)
		dateText += "Monday";
	else if (dayValue == 2)
		dateText += "Tuesday";
	else if (dayValue == 3)
		dateText += "Wednesday";
	else if (dayValue == 4)
		dateText += "Thursday";
	else if (dayValue == 5)
		dateText += "Friday";
	else if (dayValue == 6)
		dateText += "Saturday";

	monthValue = d.getMonth();
	dateText += " "
	if (monthValue == 0)
		dateText += "January";
	if (monthValue == 1)
		dateText += "February";
	if (monthValue == 2)
		dateText += "March";
	if (monthValue == 3)
		dateText += "April";
	if (monthValue == 4)
		dateText += "May";
	if (monthValue == 5)
		dateText += "June";
	if (monthValue == 6)
		dateText += "July";
	if (monthValue == 7)
		dateText += "August";
	if (monthValue == 8)
		dateText += "September";
	if (monthValue == 9)
		dateText += "October";
	if (monthValue == 10)
		dateText += "November";
	if (monthValue == 11)
		dateText += "December";

	if (navigator.appName.indexOf('Microsoft') != -1)
		dateText += " " + d.getDate() + ", " + (0000 + d.getYear());
	else if (navigator.appName.indexOf('Netscape') != -1)
		dateText += " " + d.getDate() + ", " + (1900 + d.getYear());

	minuteValue = d.getMinutes();
	if (minuteValue < 10)
		minuteValue = "0" + minuteValue
	
	hourValue = d.getHours();
	if (hourValue < 12)
	{
		greeting = " ";
		timeText = " " + hourValue + ":" + minuteValue + 
		" AM";
	}
	else if (hourValue == 12)
	{
		greeting = " ";
		timeText = " " + hourValue + ":" + minuteValue + 
		" PM";
	}
	else if (hourValue < 17)
	{
		greeting = " ";
		timeText = " " + (hourValue-12) + ":" + minuteValue +
		" PM";
	}
	else
	{
		greeting = " ";
		timeText = " " + (hourValue-12) + ":" + minuteValue + 
		" PM";
	}
	document.open();
	document.write(greeting + " " + dateText + timeText);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
