// JavaScript Document
var prefix ="_ctl0__ctl0_m_ctrlMainContentPlaceHolder_m_ctrlMainContentPlaceHolder_BookingMgrCtrl_BookingMotifEditCtrl_CustAttrMotifClfBaseCtrl_";	
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie4up  = (is_ie && (is_major >= 4));
var is_gecko = (agt.indexOf('gecko') != -1);

function insertSymbol(Symbol, fieldId) {

	Symbol = ' '+Symbol+' ';
	front = '';
    uni_tag('', Symbol, fieldId);

}

function uni_tag(front, end, fieldId) {
  	textBox = document.getElementById(prefix + fieldId);
    textBox.focus();
     if (is_ie4up && textBox.caretPos) 	
	 {
    		    textBox.caretPos.text = front + textBox.caretPos.text + end;
 	 }  else if (is_gecko) {
         // edit = document.send.text;
         textBox.value = textBox.value.substring(0, textBox.selectionStart) + front + textBox.value.substring(textBox.selectionStart, textBox.selectionEnd) + end +
             textBox.value.substring(textBox.selectionEnd, textBox.value.length);
 
        }
        else textBox.value += front + end;
         
}

function storeCaret(textElement) {
     if (textElement.createTextRange) textElement.caretPos = document.selection.createRange().duplicate();
}

function openWindow(url) {
	url = url.replace('~','http://' + location.host);
	w=window.open(url,'w','width=460,height=480,scrollbars=yes,scrolling=yes,resizable=yes');
}


function takeMeHome()
{
	var foo = document.location.toString().split("/");
	var slashes = foo.length;
	var backHome = '';
	if (slashes == 6)
	{
		backHome = '../../';
	}
	if (slashes == 5)
	{
		backHome = '../';
	}
	document.location.href=backHome;
}

function toggleElement(e, state)
{
	if (state == true)
	{
	e.style.backgroundColor='#ccc';
	e.style.color='#000';
	}
	else if (state == false)
	{
	e.style.backgroundColor='#01497F';
	e.style.color='#fff';
	}
}

