// ===================================================================
// newImage(arg)
// New Image Object
// ------------------------------------------------------------------
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// ------------------------------------------------------------------
// changeImages()
// Image swap function
// ------------------------------------------------------------------
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

// ------------------------------------------------------------------
// function preloadImages()
// Preload these images on page load
// ------------------------------------------------------------------
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		nav_home_over = newImage("img/bds/nav_home_over.gif");
		nav_about_over = newImage("img/bds/nav_about_over.gif");
		nav_services_over = newImage("img/bds/nav_services_over.gif");
		nav_products_over = newImage("img/bds/nav_products_over.gif");
		nav_resources_over = newImage("img/bds/nav_resources_over.gif");
		preloadFlag = true;
	}
}

// ------------------------------------------------------------------
// function PopUpWindow(strTitle, strBegin, strEnd, strDesc)
// Window Popup
// ------------------------------------------------------------------
function PopUpWindow(strTitle, strBegin, strEnd, strDesc) {
    spcWindow = window.open('','PopUp','height=500,width=400,toolbar=no,resizable=no,scrollbars=no');
    spcWindow.document.write('<html><head><title>Burkhart Dental</title></head>');
    spcWindow.document.write('<body onload=focus("PopUp"); bgcolor="#ffffff" text="#333333" background="img/bds/background/popup_background.jpg" leftmargin="0" bottommargin="0" rightmargin="0" topmargin="0" marginheight="0" marginwidth="0">');
    spcWindow.document.write('<font face="Arial, Helvetica, Verdana, Geneva">');
    spcWindow.document.write('<table width="400" height="400" cellspacing="4" cellpadding="4" border="0">');
    spcWindow.document.write('<tr height="78"><td colspan="2">&nbsp;</td></tr>');
    spcWindow.document.write('<tr height="20"><th align="center" colspan="2">** ' + strTitle + ' **</th></tr>');
    spcWindow.document.write('<tr height="15"><th align="right">Begins:</th><td align="left">' + strBegin + '</td></tr>');
    spcWindow.document.write('<tr height="15"><th align="right">Ends:</th><td align="left">' + strEnd + '</td></tr>');
    spcWindow.document.write('<tr><td align="center" valign="top" colspan="2"><br />' + strDesc + '</td></tr>');
    spcWindow.document.write('</table></font>');
    spcWindow.document.write('</body></html>');
    spcWindow.document.close('');
}

// ------------------------------------------------------------------
// CheckAllRows(pattern)
// Checks all CheckBoxes in form[0] with an ID that matches the given pattern.
// ------------------------------------------------------------------
function CheckAllRows(pattern)
{
 re = new RegExp(pattern)

   for (var iCount=0; iCount < document.forms[0].elements.length; iCount++)  {
   elm = document.forms[0].elements[iCount]

    if (elm.type == 'checkbox') {

     if (re.test(elm.id)) {
      elm.checked = true;
     }
    }

  }
 }

// ------------------------------------------------------------------
// ClearAllRows(pattern)
// Un-Checks all CheckBoxes in form[0] with an ID that matches the given pattern.
// ------------------------------------------------------------------
function ClearAllRows(pattern)
{
 re = new RegExp(pattern)

   for (var iCount=0; iCount < document.forms[0].elements.length; iCount++)  {
   elm = document.forms[0].elements[iCount]

    if (elm.type == 'checkbox') {

     if (re.test(elm.id)) {
      elm.checked = false;
     }
    }

  }
 }

// ------------------------------------------------------------------
// ClickControl(id)
// Issues the click event for a given control id.
// ------------------------------------------------------------------
function ClickControl(id)
{
 var control = document.getElementById(id);
 if( control != null )
 {
  control.focus();
  control.click()
 }
}

// ------------------------------------------------------------------
// doClearText(id)
// Clears the default text from a text box.
// ------------------------------------------------------------------
function doClearText(txtBox)
{
 if (txtBox.value == txtBox.defaultValue)
 {
  txtBox.value = ""
 }
}

