// *********************************************************************
// Function to create pop-up windows at a custom size.
// w = width
// h = height
// d = directories
// l = location
// m = menubar
// r = resizeable
// sc = scrollbars
// st = status
// t = toolbar
// EXAMPLE CALL: <a href="javascript:popUp('[URL]','[WINDOW NAME]',400,300,1,1,0,0,0,0,0);">LINK</a>
// *********************************************************************
function popUp(URL,name,w,h,d,l,m,r,sc,st,t) {
	var featureStr = "";
	featureStr = "width=" + w + ",height=" + h + ",directories=" + d + ",location=" + l + ",menubar=" + m + ",resizable=" + r + ",scrollbars=" + sc + ",status=" + st + ",toolbar=" + t;
	window.open(URL,name,featureStr);
}

// determines the keyboard key that was pressed
function whatsTheKey(e) {
 var keycode;
 if (window.event) {
  return window.event.keyCode; 
 } else if (e) {
  return e.which; 
 } else {
  return '';
 }
}

// user clicks the Enter key to submit a form with defined action
function enterSubmit(field,e)
{
 whatsTheKey(e);
 
 if (keycode == 13) {
  field.form.submit();
  return false;
 } else {
  return true;
 }
}

function siteSearch() {
 var searchValue = self.document.getElementById("SearchValue").value;
 if (searchValue == "") {
  alert("Please enter a value in the search field before clicking the \"Go\" button.");
 } else {
  self.location.href = "/search.aspx?searchtext=" + searchValue;
 }
}

// user clicks the Enter key to submit an html form as a get with action passed as parameter
function enterSubmitUri(field,e,uri) {
 var keycode = whatsTheKey(e);
 
 if (keycode==13) {
  window.location.href=uri;
  return true;
 } else {
  return false;
 }
}

function enterSubmitJS(field,e,functionName) {

 var keycode = whatsTheKey(e);
 if (keycode==13) {
  functionName();
 } else {
  return false;
 }
}

function emailThisPage() {
   var pagetitle = self.document.forms[0].pageTitle.value;
   var pageURL = "/EmailThisPage.aspx?pageUrl="+self.location+"&pageTitle="+pagetitle;
   popUp(pageURL,'emailthispage',590,530,0,0,0,0,0,0,0);
}

function replaceText(name) {
 var inputObj = document.getElementById(name);
	if (inputObj.value == "Search") {
	document.getElementById(name).value = "";
 }
}
