function ClearContent(pItem)
{
	if(pItem.value==pItem.defaultValue)
	{	
		pItem.value="";	
	}
}
	
function FillContent(pItem)
{
	if(pItem.value=="")
		pItem.value=pItem.defaultValue;
}

function printWindow()
{
	window.open(document.frmSearch.hdnprint.value+"?print=1",null,"top=0,left=0,height=550,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");
}

function gopage(ppage,pstr)
{
	var doc = document.frmSearchResults;
	doc.searchbox.value = pstr;
	doc.page.value = ppage;
	doc.action = "search_results.asp";
	doc.submit();
}

// Dynamic hide/showdivs
function showdiv(pdivid)
{
	var aDivs = document.body.getElementsByTagName("DIV");
	
	// first hide all divs (only required div's not all)
	for(var i=0 ; i< aDivs.length; i++)
	{
		if (aDivs[i].id.substring(0,4) == 'div_')
		{
			aDivs[i].style.display = 'none';
		}
	} 
	
	if (document.layers) 	//IS NETSCAPE 4 or below 
	{ 
		document.layers[pdivid].display = 'block'; 
	}
	else			//IS IE
	{
		// show the wanted one
		var showItem = document.getElementById(pdivid); 
		showItem.style.display = 'block'; 
	}
}

function showdefaultdiv()
{
	showdiv('div_0');
}

function IsEmail(str) 
{
	// are regular expressions supported?
  	var supported = 0;
  	if (window.RegExp) 
	{
  			var tempStr = "a";
  			var tempReg = new RegExp(tempStr);
    	if (tempReg.test(tempStr)) supported = 1;
  	}
  	if (!supported) 
  			return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	  	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	  	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	  	return (!r1.test(str) && r2.test(str));
}

function validateform()
{
	var doc = document.contactForm;

	if (doc.name.value == "")
	{
		alert("Please enter your name.");
		doc.name.focus();
		return false;		
	}
	
	if (doc.company.value == "")
	{
		alert("Please enter a your company.");
		doc.company.focus();
		return false;
	}
	
	if (doc.telephone.value == "")
	{
		alert("Please enter telephone number.");
		doc.telephone.focus();
		return false;
	}
	
	if (doc.email.value == "")
	{
		alert("Please enter a valid email.");
		doc.email.focus();
		return false;
	}
	
	if (!IsEmail(doc.email.value))
		{
			alert ('Please check that the email address is valid.');
			doc.email.focus();
			return false;
		}
	
	if (doc.website.value == "")
	{
		alert("Please enter your website.");
		doc.website.focus();
		return false;		
	}
	
	if (doc.aboutus.value == "")
	{
		alert("Please select How did you find out about Twice Creative.");
		doc.aboutus.focus();
		return false;
	}
	
	if (doc.descp.value == "")
	{
		alert("Please enter a description.");
		doc.descp.focus();
		return false;
	}

	return true;
}

function validateSurvey()
{
	if (document.frmSurvey.radiosurvey[0].checked == false && document.frmSurvey.radiosurvey[1].checked == false && document.frmSurvey.radiosurvey[2].checked == false)
	{
		alert("Please select one of the answers before submitting.");
		return false;
	}
	else
	{
		alert("Thank you for your feedback.");
		document.frmSurvey.submit();
	}
}

function popupExternalLink(pExtLink)
{
	if (pExtLink != "")
	{
		alert("Thank you for viewing the Tribal Group plc Half Year Results 2008 online.\n\rThis link has been provided to give you additional information. Clicking on it will give you access to material that is not part of the Half Year Results.");
		window.open(pExtLink,null,"top=150,left=200,height=500,width=803,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");
	}
}