<!--
/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

function getFrameByName(parentFrame, targetFrameName) {

	var frame = parentFrame.frames;
	var targetFrame = parentFrame;
	for (var i = 0; i < frame.length; i++) {
			
		if (frame[i].name == targetFrameName) {
			targetFrame = frame[i];
			return frame[i]; 
		}
		
		if (frame[i].frames.length > 0) {
			targetFrame = getFrameByName(frame[i],targetFrameName);
			if (frame[i].name == targetFrameName)
				return targetFrame;
		}
	}

	return targetFrame;
}

// Highlighting HTML Access Keys by Christian Schmidt
// This code may be freely used, copied, modified, distributed etc.

// Iterates through all elements that support the ACCESSKEY attribute.
function highlightAccessKeys() {
    //don't do anything in old browsers
    if (!document.getElementsByTagName) return;

    var labels = document.getElementsByTagName('LABEL');
    for (var i = 0; i < labels.length; i++) {
        var control = document.getElementById(labels[i].htmlFor);
        if (control && control.accessKey) {
            highlightAccessKey(labels[i], control.accessKey);
        } else if (labels[i].accessKey) {
            highlightAccessKey(labels[i], labels[i].accessKey);
        }
    }

    var tagNames = new Array('A', 'BUTTON', 'LEGEND');
    for (var j = 0; j < tagNames.length; j++) {
        var elements = document.getElementsByTagName(tagNames[j]);
        for (var i = 0; i < elements.length; i++) {
            if (elements[i].accessKey) {
                highlightAccessKey(elements[i], elements[i].accessKey);
            }
        }
    }
}

// Highlights the specified character in the specified element
function highlightAccessKey(e, accessKey) {
    if (e.hasChildNodes()) {
        var childNode, txt;
        
        //find the first text node that contains the access character
        for (var i = 0; i < e.childNodes.length; i++) {
            txt = e.childNodes[i].nodeValue;
            if (e.childNodes[i].nodeType == 3 &&
                txt.toLowerCase().indexOf(accessKey.toLowerCase()) != -1) {
            
                childNode = e.childNodes[i];
                break;
            }
        }
        
        if (!childNode) {
            //access character was not found
            return;
        }

        var pos = txt.toLowerCase().indexOf(accessKey.toLowerCase());
        var span = document.createElement('SPAN');
        var spanText = document.createTextNode(txt.substr(pos, 1));
        span.className = 'accesskey';
        span.appendChild(spanText);

        //the text before the access key
        var text1 = document.createTextNode(txt.substr(0, pos));
        //the text after the access key
        var text2 = document.createTextNode(txt.substr(pos + 1));
        
        if (text1.length > 0) e.insertBefore(text1, childNode);
        e.insertBefore(span, childNode);
        if (text2.length > 0) e.insertBefore(text2, childNode);

        e.removeChild(childNode);
    }
}

function popWindow (action, winwidth, winheight) {
    var pw = null;
    pw =  window.open ("", "", "toolbar=no,width="+winwidth+",height="+winheight+",directories=no,status=no,scrollbars=no,resize=no,menubar=no");
    if (pw != null) {
           if (pw.opener == null) {
           pw.opener = self;
           }
           pw.location.href = action;
    }   
}

function popScrollWindow (action, winwidth, winheight) {
    var pw = null;
    pw =  window.open ("", "", "toolbar=no,width="+winwidth+",height="+winheight+",directories=no,status=no,scrollbars=yes,resize=no,menubar=no");
    if (pw != null) {
           if (pw.opener == null) {
           pw.opener = self;
           }
           pw.location.href = action;
    }   
}

function popScrollWindowMax (action, winwidth, winheight) {
    var pw = null;
    pw =  window.open ("", "", "toolbar=no,width="+winwidth+",height="+winheight+",directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
    if (pw != null) {
           if (pw.opener == null) {
           pw.opener = self;
           }
           pw.location.href = action;
    }   
}
      // function for changing stylesheets using
      // document.getElementsByTagName("link")
      function setLinkedStyleSheet(title) {
        var linkNodes = document.getElementsByTagName("link");
        for ( i = 0; i < linkNodes.length; i++ ) {
          linkNode = linkNodes[i];
          relAttr = linkNode.getAttribute('rel');
          if ( relAttr && ( relAttr.indexOf("style") != -1 ) && linkNode.getAttribute("title") ) {
            linkNode.disabled = true;
            if ( linkNode.getAttribute("title") == title )
              linkNode.disabled = false;
          }
        }
      }

      // function for changing stylesheets using document.styleSheets
      function setStyleSheet(theme) {
        for ( i = 0; i < document.styleSheets.length; i++ ) {
          if ( document.styleSheets[i].title ) {
            document.styleSheets[i].disabled = true;
            if ( document.styleSheets[i].title == theme )
              document.styleSheets[i].disabled = false;
          }
        }
      }


function setCookie(name, value) {
  document.cookie = name + "=" + escape(value);
}

function setPermCookie(name, value) {
  document.cookie  = name+"="+escape(value)+"; EXPIRES=Tuesday, 01-Jun-32 11:21:30 GMT; PATH=/; DOMAIN=.webedoctor.com";
}

function getCookie(name) {
  var find = name + "=";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(find);
    if (offset >= 0) {
      offset += find.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end));
    }
  }
}
/**
 * Function that could be used to round a number to a given decimal points. Returns the answer
 * Arguments :  number - The number that must be rounded
 *				decimal_points - The number of decimal points that should appear in the result
 */
function roundNumber(number,decimal_points) {
	if(!decimal_points) return Math.round(number);
	if(number == 0) {
		var decimals = "";
		for(var i=0;i<decimal_points;i++) decimals += "0";
		return "0."+decimals;
	}

	var exponent = Math.pow(10,decimal_points);
	var num = Math.round((number * exponent)).toString();
	return num.slice(0,-1*decimal_points) + "." + num.slice(-1*decimal_points)
}


//-->
