function validateContact(form1)
{
	var valid = true;

	if (form1.email.value == "")
	{
		alert('Please enter your email address');
		valid = false;
		form1.email.focus();
	}

	if (form1.message.value == "" && valid)
	{
		alert('Please enter a message');
		valid = false;
		form1.message.focus();
	}

	if (valid)
	{
		form1.submit()
	}
}

function validateSurvey(form1)
{
	var valid = true;
	
	if (form1.name.value == "")
	{
		alert('Please enter your name');
		valid = false;
		form1.name.focus();
	}

	if (form1.email.value == "" && valid)
	{
		alert('Please enter the email you used to register on sparjobs.co.uk');
		valid = false;
		form1.email.focus();
	}

	if (form1.os_1.selectedIndex < 1 && valid)
	{
		alert('Please select an option for how you found sparjobs.co.uk site');
		valid = false;
		form1.os_1.focus();
	}

	if (form1.os_1.options[form1.os_1.selectedIndex].value == 'other' && valid && form1.os_1_other.value == "")
	{
		alert('Please enter how you found sparjobs.co.uk in the box provided');
		valid = false;
		form1.os_1_other.focus();
	}

	if (form1.os_2.selectedIndex < 1 && valid) 
	{
		alert('Please select an option for Question 4');
		valid = false;
		form1.os_2.focus();
	}
	
	if (form1.os_2.selectedIndex > 0 && valid && form1.os_2_reason.value == "")
	{
		alert('Please give a reason for your answer to Question 4');
		valid = false;
		form1.os_2_reason.focus();
	}

	if (form1.os_3.selectedIndex < 1 && valid)
	{
		alert('Please select an option for Question 5');
		valid = false;
		form1.os_3.focus();
	}

	if (form1.os_3.options[form1.os_3.selectedIndex].value == 'no' && valid)
	{
		alert('Please explain why you would not use sparjobs.co.uk again');
		valid = false;
		form1.os_3_explain.focus();
	}

	if (valid)
		form1.submit();

}

function validateMemberSurvey(form1)
{
	valid = true;

	if (form1.code.value == "")
	{
		valid = false;
		alert('Please enter your store code');
		form1.code.focus();
	}

	if (form1.os_2.selectedIndex < 1 && valid)
	{
		valid = false;
		alert('Please select an option for Question 2');
		form1.os_2.focus();
	}

	if (form1.os_2.selectedIndex > 4 && form1.os_2_reason.value == "" && valid)
	{
		valid = false;
		alert('Please enter a reason why you found using the system difficult');
		form1.os_2_reason.focus();
	}

	if (form1.os_3.selectedIndex < 1 && valid)
	{
		valid = false;
		alert('Please select an option for Question 3');
		form1.os_3.focus();
	}
	
	if (form1.os_3.value == 'no' && valid && form1.os_3_reason.value == "")
	{
		valid = false;
		alert('Please give reason why you think the system did not save you time');
		form1.os_3_reason.focus();
	}

	if (form1.os_4.value == "" && valid)
	{
		valid = false;
		alert('Please give a short description in your opinion of how the system has helped you\nor also how it has not helped you');
		form1.os_4.focus();
	}

	if (form1.os_5.selectedIndex < 1 && valid)
	{
		valid = false;
		alert('Please select an option for Question 5');
		form1.os_5.focus();
	}

	if (form1.os_5.selectedIndex > 2 && valid && form1.os_5_reason.value == "")
	{
		valid = false;
		alert('Please give reasons why you would not continue to use the system');
		form1.os_5_reason.focus();
	}

	if (valid)
		form1.submit();
}

function validateSignup(form1)
{
	var valid = true;

	if (form1.name.value == "")
	{
		alert('Please enter your name');
		valid = false;
		form1.name.focus();
	}

	if (form1.email.value == "")
	{
		alert('Please enter your email address');
		valid = false;
		form1.email.focus();
	}

	if (form1.pcode.value == "")
	{
		alert('Please enter your post code');
		valid = false;
		form1.pcode.focus();
	}

	if (form1.scode.value == "")
	{
		alert('Please enter your store code');
		valid = false;
		form1.scode.focus();
	}

	if (valid)
	{
		form1.submit()
	}
}

function setSearchRegion(rid)
{
	// get the region element and set it to correct place
	var e = document.getElementById('sregion');
	var eLen = e.length;
	for (i = 0; i < eLen; i++) {
		if (e.options[i].value == rid)
			e.options[i].selected = true;
	}
}

function confirmDeleteEmail(frm)
{
	if (confirm('Are you sure you wish to delete the selected item(s)?'))
	{
		frm.submit();
	}
}

function checkSearch(theform)
{
	var fm = document.forms['searchfrm'];
	var res = false;
	if (fm.kw.value != '')
	{
		res = true;
	}
	if (fm.cat.selectedIndex > 0 && !res)
	{
		res = true;
	}
	if (fm.region.selectedIndex > 0 && !res)
	{
		res = true;
	}
	if (fm.loc.value != '' && !res)
	{
		res = true;
	}
	if (fm.pc.value != '' && !res)
	{
		res = true;
	}
	if (fm.hours.selectedIndex > 0 && !res)
	{
		res = true;
	}

	if (!res)
	{
		alert('Please select at least one criteria to search on');
	}

	return res;
}

function miniHelp(anchor,filetype)
{
	var w = 0;
	var h = 0;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	} else {
		w = screen.width;
		h = screen.height;
	}

	var popW = 260, popH = 300;

	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	var url = "/help?id="+filetype+"&amp;t="+anchor;
	var win = window.open(url,'minihelp','width=260,height=300,toolbar=no,scrollbars=yes,resizable=yes,menubar=no,location=no,left='+leftPos+',top='+topPos);
	if (!win)
	{
		alert('A popup blocker may have blocked this link, please allow popups on this site');
	} else {
		win.moveTo(leftPos,topPos);
	}
}

function miniPane(url,width,height)
{
	var w = 0;
	var h = 0;
	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	} else {
		w = screen.width;
		h = screen.height;
	}

	var popW = width, popH = height;

	var leftPos = (w-popW)/2, topPos = (h-popH)/2;

	var win = window.open(url,'smallwindow','width='+width+',height='+height+',toolbar=no,scrollbars=yes,resizable=yes,menubar=no,location=no');
	if (!win)
	{
		alert('A popup blocker may have blocked this link, please allow popups on this site');
	} else {
		win.moveTo(leftPos,topPos);
	}
}

function layerShow(layerId)
{
	document.getElementById(layerId).style.display = (document.getElementById(layerId).style.display == "none") ? "" : "none";
}

function showAddress(ext,domain,name,title,_class,addtxt)
{
	var add = name + '@' + domain + '.' + ext;
	if (addtxt == "")
		addtxt = add;
	var str = '<a href="mail' + 'to:' + add + '"';
	if (title != "")
		str += ' title="'+title+'"';

	if (_class != "")
		str += ' class="'+_class+'"';
	str += '>' + addtxt + '</a>';
	document.write(str);
}

function confirmURL(url,txt)
{
	if (confirm(txt))
	{
		document.location = url;
	}
}