/*
Default value for text input fields. Looks for the 'defval' attribute.
*/
$(function() {
    $('input[type="text"]').each(function() {
        if ( $(this).attr('defval') ) {
            var defVal = $(this).attr('defval');
        } else {
            var defVal = '';
        }

        if( this.value == '') {
            this.value = defVal;
        }

        $(this).focus(function() {
            if (this.value == defVal){
                this.value = '';
            }
            if(this.value != defVal){
                this.select();
            }
        });

        $(this).blur(function() {
            if ($.trim(this.value) == ''){
                this.value = (defVal ? defVal : '');
            }
        });
    });
});

/*
CLCP v2.1 Clear Links to Current Page
Jonathan Snook
This code is offered unto the public domain
http://www.snook.ca/jonathan/
*/

function clearCurrentLink(){
    if (document.getElementById("navMenus") !=null ) {
      var a = document.getElementById("navMenus").getElementsByTagName("a");
      for(var i=0;i<a.length;i++) {
            if(a[i].href == window.location.href.split("#")[0]) {
                highlightNode(a[i]);
            }

            a[i].parentNode.oldClass = a[i].parentNode.className;

            a[i].onmouseover = function() {
                this.parentNode.className = this.parentNode.oldClass + " navItemOver";
            };
            a[i].onmouseout = function() {
                this.parentNode.className = this.parentNode.oldClass;
            };
      }
    }
}

/* Removes <a> tag around menu item text */
function removeNode(n){
    if(n.hasChildNodes())
        for(var i=0;i<n.childNodes.length;i++)
            n.parentNode.insertBefore(n.childNodes[i].cloneNode(true),n);
    n.parentNode.removeChild(n);
}

/* sets class on current menu item */
function highlightNode(n) {
    n.parentNode.className = n.parentNode.className+" current";
}


