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=500,width=635,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,pid)
{
	var aDivs = document.body.getElementsByTagName("DIV");
	
	// first hide all divs (only required div's not all)
	for(var i=pid ; 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 showSelectedDiv(psec,pdivid)
{
	if(document.frm1.hdnSection.value==psec)
	{
	document.frm1.action = psec + ".asp"
	document.frm1.submit();
	document.getElementById(pdivid).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 validateNewsletter()
{
	var doc = document.frm1;

	if(doc.txtname.value == "")
	{
		alert("Please enter your name.");
		doc.txtname.focus();
		return false;
	}
	
	if (doc.txtemail.value == "")
	{
		alert("Please enter a valid email.");
		doc.txtemail.focus();
		return false;
	}
	
	if (!IsEmail(doc.txtemail.value))
		{
			alert ('Please check the email address is valid.');
			doc.txtemail.focus();
			return false;
		}
	
}

