//Internet Explorer?
isIE = (document.all) ? true:false;

// Function to allow replacement of target="_blank" with XHTML compliant rel="external"
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

// Function to allow replacement of target="_blank" with XHTML compliant rel="external" in form tags
function externalLinksForms() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("form");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

//Function to style abbr tags in IE
function styleAbbr() {
  var oldBodyText, newBodyText, reg
  if (isIE) {
    oldBodyText = document.body.innerHTML;
    reg = /<ABBR([^>]*)>([^<]*)<\/ABBR>/g;
    //newBodyText = oldBodyText.replace(reg, '<ABBR $1><SPAN class=\"abbr\" $1>$2</SPAN></ABBR>');
    //document.body.innerHTML = newBodyText;
    document.body.innerHTML.replace(reg, '<ABBR $1><SPAN class=\"abbr\" $1>$2</SPAN></ABBR>')
  }
}

window.onload = function() { 
  externalLinks();
  externalLinksForms();
  styleAbbr();
  //fixHeight();
}

// Date change function for Calendar view of Meetings
function calendarDateChange() {
	document.location='calendar.asp?year=' + calendar.year.options[calendar.year.selectedIndex].value + '&month=' + calendar.month.options[calendar.month.selectedIndex].value;
}

function normalpage() {
	strURL = new String(window.location)
	window.location = strURL.substr(0, strURL.length - 6);
}

function strReplace(str1, str2, str3) { 
  while(str1.indexOf(str2) != -1) {
   str1 = str1.replace(str2, str3);
 } 
  return str1;     
}

function printPage() 
{
	if (window.print) 
	{
        	window.print();
        } 
	else 
	{
                alert("Sorry, your browser doesn't support this feature.\n" +
                      "Please use your browser's print button");
        }
}

function copyAddress()
{

document.forms['mainform'].c_add_1.value=document.forms['mainform'].add_1.value;
document.forms['mainform'].c_add_2.value=document.forms['mainform'].add_2.value;
document.forms['mainform'].c_add_3.value=document.forms['mainform'].add_3.value;
document.forms['mainform'].c_add_4.value=document.forms['mainform'].add_4.value;
document.forms['mainform'].c_post_code.value=document.forms['mainform'].post_code.value;

}

function fixHeight()
{
	if(document.getElementById)
	{
		var newHeight = 0;

		var left = document.getElementById("left").offsetHeight;
		var centre = document.getElementById("centre").offsetHeight;

		if(left > centre)
			newHeight = left;
		else
			newHeight = centre;

		newHeight = newHeight + "px";

		document.getElementById("left").style.height = newHeight;
		document.getElementById("centre").style.height = newHeight;
	}
	return true;
}

//**************************************************************
// This function clears a given text box if it contains specific 
// text. This is useful for search or username boxes where if 
// the user places the cursor in the box, text such as 
// 'search...' or 'username...' should disappear, but not text 
// that the user has typed
//
// Usage : <input type="text" value="search..." onfocus="clearSingleLineEditText(this, 'search...');" />
//**************************************************************
function clearSingleLineEditText(theSingleLineEdit, textToClear)
{
	if (theSingleLineEdit.value == textToClear)
	{
		theSingleLineEdit.value = '';
	}
}