// Search Wizards js file
function displayDiv(id)
{
	if(currentItem == id)
	{
		document.getElementById(id).style.visibility = "hidden";
		document.getElementById(id).style.display = "none";
		currentItem = false;
	}
	else
	{
		document.getElementById(id).style.visibility = "visible";
		document.getElementById(id).style.display = "block";
		currentItem = id;
	}
}
function doSize(id, size)
{
	var totalWidth = document.getElementById(id).width;
	if(isNaN(size))
	{
		var newHeight = Math.round(document.getElementById(id).height*200/totalWidth, 2);
		document.getElementById(id).style.width = '200px';
	}
	else
	{	
		var newHeight = Math.round(document.getElementById(id).height*size/totalWidth, 2);
		document.getElementById(id).style.width = size+'px';
	}
	document.getElementById(id).style.height = newHeight+"px";
	document.getElementById(id).alt = "Height: "+newHeight+"px";	
}
function switchImage(target, img)
{
	document.getElementById(target).src = img;
}
function subNavOver(id)
{
	document.getElementById(id).style.backgroundColor = '#eff1f4';
	document.getElementById(id).style.color = '#000000';
	document.getElementById(id+"_img").src = '../images/subNav_over.jpg';
}
function subNavRestore(id)
{
	document.getElementById(id).style.backgroundColor = '#c9c9c9';
	document.getElementById(id).style.color = '#363636';
	document.getElementById(id+"_img").src = '../images/subNav.jpg';
}
function navOver(id)
{
	document.getElementById(id).style.backgroundColor = '#6f6f6f';
	document.getElementById(id).style.color = '#FFFFFF';
	document.getElementById(id).style.fontSize = '13px';
	document.getElementById(id).style.fontWeight = 'bold';
}
function navRestore(id)
{
	document.getElementById(id).style.backgroundColor = '#600f0f';
	document.getElementById(id).style.color = '#d9dee7';
	document.getElementById(id).style.fontSize = '12px';
	document.getElementById(id).style.fontWeight = 'bold';
}
function newsDisplay(id)
{
	var num = id.split('_')
	
	if(document.getElementById(id).name == 'all')
	{
		document.getElementById('newsStory_'+num[1]).style.visibility = "hidden";
		document.getElementById('newsStory_'+num[1]).style.display = "none";
		document.getElementById(id).name = 'none';
		document.getElementById(id).src = '../backend/images/maximize_lg.jpg';
		if(isopen == id)
		{
			isopen = 'none';
		}
	}
	else
	{
		if(isopen != id && isopen != 'none')
		{
			var num2 = isopen.split('_');
			document.getElementById('newsStory_'+num2[1]).style.visibility = "hidden";
			document.getElementById('newsStory_'+num2[1]).style.display = "none";
			document.getElementById('news_'+num2[1]).style.backgroundColor = '';
			document.getElementById(isopen).name = 'none';
			document.getElementById(isopen).src = '../backend/images/maximize_lg.jpg';
		}
		document.getElementById('newsStory_'+num[1]).style.visibility = "visible";
		document.getElementById('newsStory_'+num[1]).style.display = "block";
		document.getElementById(id).name = 'all';
		document.getElementById(id).src = '../backend/images/minimize_lg.jpg';
		isopen = id
	}	
}
function highlightDiv(id)
{
	var obj = document.getElementById(id);
	obj.style.backgroundColor = '#6f101c';
	obj.style.cursor = 'pointer';
	var img = obj.id.split('_');
	var currentWidth = document.getElementById(img[1]).width;
	obj.style.width = (currentWidth-4)+'px';
	//document.getElementById(img[1]).style.width = (currentWidth-4)+'px';
	obj.style.borderRightWidth = '2px';
	obj.style.borderRightStyle = 'solid';
	obj.style.borderRightColor = '#4d050e';
	obj.style.borderLeftWidth = '2px';
	obj.style.borderLeftStyle = 'solid';
	obj.style.borderLeftColor = '#4d050e';
}
function unhighlightDiv(id)
{
	var obj = document.getElementById(id);
	obj.style.backgroundColor = '';
	obj.style.cursor = 'default';
	var img = obj.id.split('_');
	var currentWidth = document.getElementById(img[1]).width;
	obj.style.width = (currentWidth)+'px';
	//document.getElementById(img[1]).style.width = (currentWidth+4)+'px';
	obj.style.borderRightWidth = '';
	obj.style.borderRightStyle = '';
	obj.style.borderRightColor = '';
	obj.style.borderLeftWidth = '';
	obj.style.borderLeftStyle = '';
	obj.style.borderLeftColor = '';
}
function checkEmpty(str)
{
	return (str != '');
}
function isValidEmail(str) 
{
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
function checkForm()
{
	var fName = checkEmpty(document.getElementById('fName').value);
	if(!fName)
	{
		alert('Please enter your First Name.');
		return false;
	}
	var lName = checkEmpty(document.getElementById('lName').value);
	if(!lName)
	{
		alert('Please enter your Last Name.');
		return false;
	}
	var eMail = checkEmpty(document.getElementById('eMail').value);
	if(eMail)
	{
		eMail = isValidEmail(document.getElementById('eMail').value);
	}
	else
	{
		alert('Please enter an E-Mail address');
		return false;
	}
	if(!eMail)
	{
		alert('Please enter a valid E-Mail address.');
		return false;
	}
	var pPhone = isNaN(document.getElementById('pPhone').value);
	if(pPhone)
	{
		alert('Please enter a phone number in the correct format. e.g. 4566543489');
		return false;
	}
}