
/* SUB MENU  */

var SUBtimeout	= 500;
var SUBclosetimer	= 0;
var SUBmenuitem	= 0;


function subNavOpen(name){
	
	if(SUBmenuitem) SUBmenuitem.style.display = 'none';
	
	SUBmenuitem = document.getElementById( name );
	SUBmenuitem.style.display = 'block';
	
	
	document.getElementById( name + 'A' ).style.backgroundColor = '#ffffff'; //#3399cc
	document.getElementById( name + 'A' ).style.color = '#3382cc'	
}
function SUBclose()
{
	
}
function subNavClose(name){
	if(SUBmenuitem) SUBmenuitem.style.display = 'none';
	document.getElementById( name + 'A' ).style.backgroundColor = ''; //#3382cc
	document.getElementById( name + 'A' ).style.color = '#ffffff';
	$('#'+name+'A').css({borderRadius: 4});
}

function SUBclosetime()
{
	closetimer = window.setTimeout(mclose, SUBtimeout);
}

/* END SUB MENU */

$(".tooltipbox a[title]").tooltip();


function nl2br (str, is_xhtml) {
  
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';

    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}

$.fn.insertAtCaret = function(text) {
    return this.each(function() {
        if (document.selection && this.tagName == 'TEXTAREA') {
            //IE textarea support
            this.focus();
            sel = document.selection.createRange();
            sel.text = text;
            this.focus();
        } else if (this.selectionStart || this.selectionStart == '0') {
            //MOZILLA/NETSCAPE support
            startPos = this.selectionStart;
            endPos = this.selectionEnd;
            scrollTop = this.scrollTop;
            this.value = this.value.substring(0, startPos) + text + this.value.substring(endPos, this.value.length);
            this.focus();
            this.selectionStart = startPos + text.length;
            this.selectionEnd = startPos + text.length;
            this.scrollTop = scrollTop;
        } else {
            // IE input[type=text] and other browsers
            this.value += text;
            this.focus();
            this.value = this.value;    // forces cursor to end
        }
    });
};

