function NavigateMemorialSignup(aBase){
  document.location.href = aBase+'signup.asp?service=memorial';
}

function NavigateLink(aURL){
  document.location.href = aURL;
}

function NavigateHeavensMailSignup(aBase){
  document.location.href = aBase+'signup.asp?service=heavensmail';
}

function NavigateOnlineMemorial(aBase, aId){
  document.location.href = aBase+'memorials/show.asp?id='+aId;
}

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit) {
    field.value = field.value.substring(0, maxlimit);
  } else {
    countfield.value = maxlimit - field.value.length;
  }
}

// ##### MOUSEOVER FOR BUTTONS #####
function button_over(eButton){
  eButton.style.backgroundColor 	= "#C1D2EE";
  eButton.style.borderColor 		= "darkblue darkblue darkblue darkblue";
  eButton = null;
}
function button_out(eButton){
  eButton.style.backgroundColor 	= "#DEE6EE";
  eButton.style.borderColor 		= "#DDDDDD #DDDDDD #DDDDDD #DDDDDD";
}
function button_down(eButton){
  eButton.style.backgroundColor 	= "#98B5E2";
  eButton.style.borderColor 		= "darkblue darkblue darkblue darkblue";
}
function button_up(eButton){
  eButton.style.backgroundColor 	= "#C1D2EE";
  eButton.style.borderColor 		= "darkblue darkblue darkblue darkblue";
  eButton.style.cursor 			= "hand";
}

function IsCorrectFileExt(file, extlist){
  //Get a file extension
  var ext = file.substr(file.lastIndexOf('.')).toLowerCase()

  //Check extension to xx types.

  return extlist.indexOf(ext+',') >= 0
}

function FormBadInput(aInput, aCaption) {
  if (aInput.value==""){
    alert("Please enter a "+aCaption);
    aInput.focus();
    return true;
  }
  return false;
}

function openFullScreen(page, title)
{
	var yes = 1;
	var no = 0;
	
	var menubar = yes;
	var scrollbars = yes;
	var locationbar = yes;
	var directories = yes;
	var resizable = yes;
	var statusbar = yes;
	var toolbar = yes;
	
	windowprops = "width=" + (window.width) + ",height=" + (window.width)
	+
	",top=0,left=0";
	
	windowprops += (menubar ? ",menubars" : "") +
	(scrollbars ? ",scrollbars" : "") +
	(locationbar ? ",location" : "") +
	(directories ? ",directories" : "") +
	(resizable ? ",resizable" : "") +
	(statusbar ? ",status" : "") +
	(toolbar ? ",toolbar" : "");
	
	window.open(page, title, windowprops);
}

WebBase = "/twma/"

function submitonce(theform)
{
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById)
	{
		//screen thru every element in the form, and hunt down "submit" and "reset"
		for (i=0;i<theform.length;i++)
		{
			var tempobj=theform.elements[i]
			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
			//disable em
			tempobj.disabled=true
		}
	}
}

function copyToClipBoard(copy, hold)
{
	if (!copy)
	{
		return;
	}
	
	hold.innerText = copy.innerText;
	Copied = hold.createTextRange();
	Copied.execCommand("RemoveFormat");
	Copied.execCommand("Copy");
}

function delconfirm()
{
	var con= confirm("Are you sure you want to delete this message?");
	if (con== true){
                return true;
	} else {
                return false;
	}
}

function delphotoconfirm() {
	var con = confirm("Are you sure you want to delete this memorial photo?");
	if (con == true){
                return true;
	} else {
                return false;
	}
}

function deltripconfirm()
{
	var con= confirm("Are you sure you want to cancel this booking?");
	if (con== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function deleteconfirm(text)
{
	var con= confirm(text);
	if (con== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function paidconfirm()
{
	var con= confirm("Are you sure this invoice has been paid?");
	if (con== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
	win=window.open(mypage,myname,settings);}
	
function confirmDocumentDelete(formIdentifier, message) {
	var confirmation = confirm(message);
	if (confirmation == true)
	{
		var formID = document.getElementById(formIdentifier);
		formID.submit(this);
	}
	return false;
}