
/*TTP 1980 (start)*/
// used to hilight inputs on error 

/*
TTP 2128 - start 
*/
	hilightCol = "pink"
	hilightBorderCol = "red"
	lowlightcolor = "white"
	bgColor = "#E8F2F9"
/*
TTP 2128 - end 
*/
	

	function hilight(e)
	{
			
	// TTP 2128 
	if(e == null)
		{
		return false
		}
			
	if((e.length != null) && (e.type != "select-one")) //  non standard api thank you M$
		{
		for(var n=0 ; n < e.length ; n++) // loop over checkboxes + radios, putting a nice border on em 
			{
			e[n].style.backgroundColor = hilightCol
			e[n].style.borderColor = hilightBorderCol
			e[n].style.borderWidth = 1
			e[n].style.borderStyle = 'solid'
			}
		}
	else
		{
		e.style.borderColor = hilightBorderCol
		e.style.backgroundColor = hilightCol
		}
	
	}
	
	function lowlight(frm)
	{
	
	for( var n = 0 ; n < frm.length ; n++)
		{
		e = frm[n]
		// TTP 2128 
		if( e != null )
		{
		e.style.backgroundColor = ''
		e.style.borderColor = ''
		}
		
		}
	}
/*TTP 1980 (end)*/

	
/*
TTP 2173 - start 
*/
function getErrorDiv()
{

var e = document.getElementById("LMSalert")
if( e == null )
	{
	var d = document.getElementById("mainContent")
	d.innerHTML = ' <div ID="LMSalert" ></div>' + d.innerHTML
	}
e = document.getElementById("LMSalert")
return e
}

function splitError(str)
{

var ar = str.split("\n")

// remove unwanted elements
if( ar.length > 1) 
	{
	ar = ar.reverse() 
	ar.pop()
	ar.pop()
	ar = ar.reverse() 
	ar.pop()
	}
return ar 
}

function LMSalert(str)
{

if( str == null )
	{
	str = "" 
	}

var d = getErrorDiv()	
if( d == null )
	{
	confirm( str )
	return false 
	}

arError = splitError(str)	

MAX_ERRORS = 4 
bShowErrorStack = false  // TTP 2173

errList = ""
if( arError.length == 0)
	{
	errList = ""
	}
else if( arError.length < MAX_ERRORS )
	{
	errList = '<ul type="square">'
	
	for( var n = 0 ; n <arError.length ; n++ )
		{
		errList = errList + "<li>"+arError[n]+"</li>"
		}
	
	errList = errList + "</ul>"
	
	} 
else
	{
	errList = '<ul type="square">'
	
	for( var n = 0 ; n < MAX_ERRORS-2 ; n++ )
		{
		errList = errList + "<li>"+arError[n]+"</li>"
		}
	

	
	errList = errList + "<li><i>Other errors have occured</i></li>"
	errList = errList + "</ul>"
	
	}

// TTP 2173	- start 
if( bShowErrorStack )	
	{
	//d.innerHTML = '<div title="'+str+'" style="color: red" class="errorMsg">Please correct the fields highlighted in red.'+errList+'</div>'		
	d.innerHTML = '<div title="'+str+'" class="errorMsg_box">Please correct the fields highlighted in red.'+errList+'</div>'		
	}
else
	{
	//d.innerHTML = '<div style="color: red" class="errorMsg">Please correct the fields highlighted in red.</div>'	
	d.innerHTML = '<div class="errorMsg_box">Please correct the fields highlighted in red.</div>'	
	}		
// TTP 2173 - end

}

window.LMSalert = LMSalert

// TTP 3356 DJS 06/11/07 start
function trim(str)
{
 	return str.replace(/^\s*|\s*$/g,"");
}
// TTP 3356 DJS 06/11/07 END
/*
TTP 2173 - end 
*/	
	

function getValue(e)
{



if(e != null)
	{
	// get the elment type 
	type = e.type
	
	if(type == null) // must be a radio or checkbox
		{
		type = e[0].type
		}
		
	if( type =="text" || type =="textarea" || type == "password"|| type == "hidden")
		{
// TTP 3356 DJS 06/11/07 START		
		return trim(e.value)
// TTP 3356 DJS 06/11/07 END		
		}
	
	if( type =="select-one" )
		{
		return e[e.selectedIndex].value		 
		 }
	
	if( type =="select-multiple" )
		{
		rtn = new Array() 
			
			for(n=0 ; n < e.length ; n++)
				{
				
				if( e[n].selected == true )
					{
					rtn[rtn.length] =  e[n].value
					}
				}
								
				return rtn
			 
		 }
	
	
	if( type =="radio" || type =="checkbox" )
		{
		
		if( e.length != null )
			{
			rtn = ""
			for(n=0 ; n < e.length ; n++)
					{
					if( e[n].checked == true )
						{
						rtn = rtn  + e[n].value + ','
						}
					}
				
				rtn = rtn.substring( 0 , rtn.length - 1 ) // chop off the last comma
				return rtn
				}
			else
				{
				if( e.checked == true )
					{return e.value}
				}	
		
		 }		
	}		
	return false 
}
