
var jspageprocessrule = 0;
var jssessionkey = 0;
var jscustomerkey = 0;
var jscustsitekey = 0;
var jscustsitename= '';
var jscustadminkey = 0;
var jscustsitecoordkey = 0;
var jscustsitegroupkey = 0;
var jsreferringuserkey = 0;
var jsproductkey = 0;
var jsuserkey = 0;
var jspagekey = 0;
var jsdatabase = '';
var jsstudydatabase = '';
var jshtmlversion = 0;
var jspatientkey =0;
var jspatientid ='';
var jspatientsessionkey =0;
var jsadminproduct ='false';
var jspageformlist ='';
var jserrorsw = '';
var jserrormsg = '';
var jscriticalcareid = 0;
var jsfirstname = '';
var jslastname = '';
var jsemail = '';
var jsnotes = '';
var jsprovider = '';
// close windows 
function closeme() 
{
 
  if ((window.parent.parent) && window.parent.parent != window) {
      window.parent.parent.close();
      return;
  }
  if ((window.top) && window.top != window) {
      window.top.close();
      return;
  }
  window.close();
  self.close()
  if ((window.parent.opener) && window.parent.opener != window) {
      window.parent.opener.close();
      return;
  }
  if ((window.parent) && window.parent != window) {
      window.parent.close();
      return;
  }
  if ((window.opener) && window.opener != window) {
      window.opener.close();
      return;
  }

}


// enable / disable formfields depending on whether or not another form field is selected
function EnableFormfield(disableList, enableList) 
{


var disablearray = disableList.split(',');
var enablearray  = enableList.split(',');
var formname="";
if (disableList != 'none' && disableList != '') 
{

    for (var i=0; i< disablearray.length; i++)
        {
          formname = disablearray[i];
        if (document.getElementById(formname))
        {
        document.getElementById(formname).disabled= true;
        }
        else
        {
        document.all(formname).disabled= true;
        }
     }
}

if (enableList != 'none' && enableList != '') 
{

    for (var j=0; j< enablearray.length; j++)
        {
        formname = enablearray[j];
     
        if (document.getElementById(formname))
        {
             document.getElementById(formname).disabled= false;
        }
        else
        {
            document.all(formname).disabled= false;
        }
     
       }
}
}

function cbEnableFormfield(disableList, enableList, unseldisableList, unselenableList, thisform ) 
{
var disablearray;
var enablearray;
if (thisform.checked == true)
{

    disablearray = disableList.split(',');
    enablearray  = enableList.split(',');
}
else
{

    disablearray = unseldisableList.split(',');
    enablearray  = unselenableList.split(',');

}
   

if (disablearray.length > 0 && disablearray[0] != '') 
{
    for (var i=0; i< disablearray.length; i++)
        {
          formname = disablearray[i];
          document.all(formname).disabled= true;
          document.all(formname).value='';
          document.getElementById(formname).disabled= true;
          document.getElementById(formname).value='';
       }
       return;
}

if (enablearray.length > 0 && enablearray[0] != '') 
{

    for (var j=0; j< enablearray.length; j++)
        {
         formname = enablearray[j];

         document.all(formname).disabled= false;
         document.getElementById(formname).disabled= false; 
       }
}
}

// Swap chapter image for module mouseover
//----------------------------------
function modmousout(bImage,bItem,bExt,bCurmoditem,bCurmodImage) {
bItem.src=bImage+bExt;
if (bCurmoditem!="0") {
    bCurmoditem.src=bCurmodImage+"-down"+bExt;
}
}
function submodmousout(bImage,bItem,bExt,bCurmoditem,bCurmodImage) {
bItem.src=bImage+bExt;
if (bCurmoditem!="0") {
    bCurmoditem.src=bCurmodImage+"-sel"+bExt;
}
}
function modmousover(bImage,bItem,bExt,bCurmoditem,bCurmodImage) {

if (bCurmoditem!="0") {
    bCurmoditem.src=bCurmodImage+bExt;
}
bItem.src=bImage+"-over"+bExt;
bItem.style.cursor="pointer";
window.status='';
}

function chapmousover(bmod, bImageLoc) {
nextform.talariachaptertitlebutton.src=bImageLoc + "chaptertitle-mod"+bmod+"_over.gif"
}
function chapmousout(bmod, bImageLoc) {
nextform.talariachaptertitlebutton.src=bImageLoc + "chaptertitle-mod" + bmod + "_over.gif";
}

// PopupWindow Scripts (URL and for page number)
//----------------------------------

day = new Date();
id = day.getTime();
var winHt
var winWth
var winAS
var winFS
var winopts
var SAWdth, SAHt
winHt = ",height=480"
winWth = ",width=640"
var URL
var bookmark="";


//----------URL-popup--------------------------
//-----------------------------------------
function popUpURL(oURL, ht, wth, fs, as, bm) {
winHt = ",height=480";
winWth = ",width=640";
winFS = "";
if (ht > "0") {
	winHt = ", height=" + ht;
}
if (wth > "0") {
	winWth = ", width=" + wth;
}
if (as > "0" || fs > "0") {
	SAHt = screen.availHeight-60;
	winHt = ", height=" + SAHt + ", top=0, left=0";
	SAWdth = screen.availWidth-10;
	winWth = ", width=" + SAWdth;
	winFS = "";
}
bookmark = ""

if (bm > "0") bookmark = "#"+bm;
eval("page" + id + " = window.open(oURL+bookmark, '" + id + "', 'toolbar=0,scrollbars=1,location=0,menubar=0,resizable=1,directories=0" + winWth + winHt + ", copyhistory=0" + winFS + "');");
}


// Script for expanding module menu
//----------------------------------


function modmenumousover(bImage,bItem,bExt,bCurmoditem,bCurmodImage,bMenuItem, bMenuItemPrev) {
bCurmoditem.src=bCurmodImage+bExt;
bItem.src=bImage+"-over"+bExt;
bItem.style.cursor="pointer";
if (bMenuItemPrev.style.visibility='visible') {
	bMenuItemPrev.style.visibility = 'hidden';
}
if (navigator.appName=="Microsoft Internet Explorer") {
    bMenuItem.style.visibility = 'visible';
    
}
}
function modmenulinkmousover(src,clrOver,bMenuItem, bMenuItemPrev, sItem) {
if (navigator.appName=="Microsoft Internet Explorer") {
    if (!src.contains(event.fromElement)){
	    src.style.cursor = 'pointer';
	    src.bgColor = clrOver;
    }
 }
 else
 {
bMenuItem.style.width = 300;
 }
var x = bMenuItemPrev.id
var y = bMenuItem.id
if (bMenuItemPrev.style.visibility='visible') {
	bMenuItemPrev.style.visibility = 'hidden';
}
bMenuItem.style.visibility = 'visible';
bMenuItem.style.zIndex = 10000;
}
function menumouseout(bItem,bMenuItem) {
	if(window.event.x+0 < bItem.offsetLeft+10) {
		bItem.style.visibility = 'hidden';
	}
	if(window.event.y+0 < bItem.offsetTop+5) {
		bItem.style.visibility = 'hidden';
	}
}
function modmenumousout(bImage,bItem,bExt,bCurmoditem,bCurmodImage,bMenuItem) {

bItem.src=bImage+bExt;
bCurmoditem.src=bCurmodImage+"-over"+bExt;
if (navigator.appName=="Microsoft Internet Explorer") {	
	if (window.event.y+0 < bMenuItem.offsetTop - bItem.offsetHeight+3) {
		bMenuItem.style.visibility='hidden';
		bItem.src=bImage+bExt;
		bCurmoditem.src=bCurmodImage+"-over"+bExt;	
	}
	if (window.event.x+0 < bMenuItem.offsetLeft+3) {
		bMenuItem.style.visibility='hidden';
		bItem.src=bImage+bExt;
		bCurmoditem.src=bCurmodImage+"-over"+bExt;
	}
	if (window.event.x+0>bMenuItem.offsetLeft+bItem.offsetWidth-3) {
		bMenuItem.style.visibility='hidden';
		bItem.src=bImage+bExt;
		bCurmoditem.src=bCurmodImage+"-over"+bExt;
	}
}
else
{
		bMenuItem.style.visibility='hidden';
		bItem.src=bImage+bExt;
		bCurmoditem.src=bCurmodImage+"-over"+bExt;
}
}

function modmenulinkmousout(bItem,clrIn,bMenuItem) {

if (navigator.appName=="Microsoft Internet Explorer") {		
	if (window.event.y+0 < bMenuItem.offsetTop - bItem.offsetHeight+3) {
		bMenuItem.style.visibility='hidden';
		bItem.style.cursor = 'default'; 
	}
	if (window.event.x+0 < bMenuItem.offsetLeft+3) {
		bMenuItem.style.visibility='hidden';
		bItem.style.cursor = 'default'; 
	}
	if (window.event.x+0 > bMenuItem.offsetLeft+bItem.offsetWidth-3) {
		bMenuItem.style.visibility='hidden';
		bItem.style.cursor = 'default'; 
	}
}
else
{
		bMenuItem.style.visibility='hidden';
		bItem.style.cursor = 'default'; 

}
if (clrIn != ' ' && clrIn != '')
{
    bItem.bgColor = clrIn;
}
else
{
    bItem.bgColor = '';
}

}

function submenumouseout(bItem, bSubItem, bMenuItem, bMenuctr) {
	if(window.event.y+0>bItem.offsetParent.offsetTop+bItem.offsetTop+bItem.offsetHeight-5) {
		bSubItem.style.visibility='hidden';
	}
	if (bMenuctr==1) {
		if(window.event.y+0 < bItem.offsetParent.offsetTop+bItem.offsetTop+5) {
			bSubItem.style.visibility='hidden';
		}
	}
	if (window.event.x+0 < bMenuItem.offsetLeft+7) {
		bMenuItem.style.visibility='hidden';
		bSubItem.style.visibility='hidden';
	}
	if(window.event.y+0 < bMenuItem.offsetTop) {
		bMenuItem.style.visibility = 'hidden';
		bSubItem.style.visibility='hidden';
	}
	if (bMenuctr==999) {
		if(window.event.y+0>bMenuItem.offsetTop+bMenuItem.offsetHeight-7) {
			bMenuItem.style.visibility = 'hidden';
		}
	}
}
function submenuout(bsubItem, bMenuItem, bMenuLine, bclassname) {
if (navigator.appName=="Microsoft Internet Explorer") {	
	if(window.event.x+0>bMenuItem.offsetLeft+bMenuItem.offsetWidth+bsubItem.offsetWidth-5) {
		bMenuItem.style.visibility='hidden';
		bsubItem.style.visibility='hidden';
	}
	if(window.event.x+0 < bMenuItem.offsetLeft+bMenuItem.offsetWidth+10) {
		bsubItem.style.visibility='hidden';
		bMenuLine.className=bclassname;
	}
	if(window.event.y+0 < bMenuItem.offsetTop+bsubItem.offsetTop+10) {
		bsubItem.style.visibility='hidden';
		bMenuLine.className=bclassname;
		if (window.event.x+0>bMenuItem.offsetLeft+bMenuItem.offsetWidth) {
			bMenuItem.style.visibility='hidden';
		}
	}
	if(window.event.y+0>bMenuItem.offsetTop+bsubItem.offsetTop+bsubItem.offsetHeight-5) {
		bsubItem.style.visibility='hidden';
		bMenuLine.className=bclassname;
		if (window.event.x+0>bMenuItem.offsetLeft+bMenuItem.offsetWidth) {
			bMenuItem.style.visibility='hidden';
		}
	}
}
else
{
		bsubItem.style.visibility='hidden';
		bMenuLine.className=bclassname;
}
}
function Nosubmenumousout(bLineItem, bMenuItem, bMenuctr, thisevent) {
if (navigator.appName=="Microsoft Internet Explorer") {	
	if (event.x+0< bMenuItem.offsetLeft+7) {
		bMenuItem.style.visibility='hidden';
	}
	if (window.event.x+0>bMenuItem.offsetLeft+bMenuItem.offsetWidth-3) {
		bMenuItem.style.visibility='hidden';
	}
	if (bMenuctr==1) {
		if(window.event.y+0 < bMenuItem.offsetTop+5) {
			bMenuItem.style.visibility = 'hidden';
		}
	}
	if (bMenuctr==999) {
		if(window.event.y+0 > bMenuItem.offsetTop+bMenuItem.offsetHeight-7) {
			bMenuItem.style.visibility = 'hidden';
		}
	}
}
else
{
bMenuItem.style.visibility = 'hidden';
}
}

function bulletmenumouseout(bItem, bSubItem, bMenuItem) {
if (navigator.appName=="Microsoft Internet Explorer") {	
	if(window.event.y+0>bItem.offsetParent.offsetTop+bItem.offsetTop+bItem.offsetHeight-5) {
		bSubItem.style.visibility='hidden';
	}
	if(window.event.y+0 < bItem.offsetParent.offsetTop+bItem.offsetTop+5) {
		bSubItem.style.visibility='hidden';
	}
	if (window.event.x+0< bMenuItem.offsetLeft+7) {
		bMenuItem.style.visibility='hidden';
		bSubItem.style.visibility='hidden';
	}
	if(window.event.y+0 < bMenuItem.offsetTop) {
		bMenuItem.style.visibility = 'hidden';
		bSubItem.style.visibility='hidden';
	}
	if(window.event.y+0>bMenuItem.offsetTop+bMenuItem.offsetHeight-7) {
		bMenuItem.style.visibility = 'hidden';
		bSubItem.style.visibility='hidden';
	}
}
else
{
		bMenuItem.style.visibility = 'hidden';
		bSubItem.style.visibility='hidden';
}
}

// Script for mouse events for non expanding module menus
//----------------------------------

function modmenumousdown(bImage,bItem,bExt, bPage, bUser, bSession, bProd) {
bItem.src=bImage+"-down"+bExt;
	if (navigator.appName=="Microsoft Internet Explorer") {
		window.navigate("buildcontent.aspx?pagekey="+bPage+"&userkey="+bUser+"&sessionkey="+bSession+"&tut="+bProd);
	}
	else
	{
		document.location="buildcontent.aspx?pagekey="+bPage+"&userkey="+bUser+"&sessionkey="+bSession+"&tut="+bProd;
	}
}


// Script for module menus where chapter image swaps on mouse overs
//----------------------------------

function modchapmousout(bImage,bItem,bExt,bCurmoditem,bCurmodImage, bChapterImage, bChapterImageItem) {
bItem.src=bImage+bExt;
if (bCurmoditem!="0") {
    bCurmoditem.src=bCurmodImage+"-over"+bExt;
}
bChapterImageItem.src=bChapterImage + "_over"+bExt
}
function modchapmousover(bImage,bItem,bExt,bCurmoditem,bCurmodImage, bChapterImage, bChapterImageItem) {
if (bCurmoditem!="0") {
    bCurmoditem.src=bCurmodImage+bExt;
}
bItem.src=bImage+"-over"+bExt;
bItem.style.cursor="pointer";
bChapterImageItem.src=bChapterImage + "_over"+bExt
}
function mouspointer(oItems) {
oItems.style.cursor = "pointer";
}
var time = 3000;
var menumax = 0;
var menumin = 9999999;
var menuLeft = 0;
//menu constructor
function menu(allitems,thisitem,startstate){ 
  callname= "gl"+thisitem;
  divname="subglobal"+thisitem;
  this.numberofmenuitems = numofitems;
  this.caller = document.getElementById(callname);
  this.thediv = document.getElementById(divname);
  this.thediv.style.visibility = startstate;
}
//menu methods
//menu methods
function ehandlerright(event,theobj,theParenObj, theSubGlobal){
  menuLeft=event.clientX;
  if (event.clientY > menumax){
     menumax=event.clientY;
  }
  if (event.clientY < menumin){
     menumin=event.clientY;
  }
  for (var i=1; i<= theobj.numberofmenuitems; i++){
    var shutdiv =eval( "menuitem"+i+".thediv");
   shutdiv.style.visibility="hidden";
  }
  theobj.thediv.style.visibility="visible";
  theSubGlobal.style.posLeft=theParenObj.clientLeft +  theParenObj.clientWidth;
}
function closesubnavright(event,loY,hiY){
  if ((event.clientY < loY)||(event.clientY > hiY)){
    for (var i=1; i<= numofitems; i++){
      var shutdiv =eval('menuitem'+i+'.thediv');
            shutdiv.style.visibility='hidden';
    }
  }
}
function closesubnav2right(event,loY2,hiY2){
  if ((event.clientY < loY2)||(event.clientY > hiY2)){
    for (var i=1; i<= numofitems; i++){
      var shutdiv =eval('menuitem'+i+'.thediv');
            shutdiv.style.visibility='hidden';
    }
  }
}
function ehandlerunder(event,theobj,oSrcObj,oDestObj){
  menuLeft=event.clientX;
  if (event.clientY > menumax){
     menumax=event.clientY;
  }
  if (event.clientY < menumin){
     menumin=event.clientY;
  }
  for (var i=1; i<= theobj.numberofmenuitems; i++){
    var shutdiv =eval( "menuitem"+i+".thediv");
   shutdiv.style.visibility="hidden";
  }
  theobj.thediv.style.visibility="visible";
oDestObj.style.left =oSrcObj.offsetLeft + oDestObj.offsetParent.offsetLeft + subglobal1.offsetLeft


}
function closesubnavUnder(event){
if (((event.clientY<menumin-2))||(event.clientX < (menuLeft))||(event.clientX > (menuLeft + 10))){
    for (var i=1; i<= numofitems; i++){
      var shutdiv =eval('menuitem'+i+'.thediv');
            shutdiv.style.visibility='hidden';
    }
}
}
function closesubnavunder_border(){
    for (var i=1; i<= numofitems; i++){
      var shutdiv =eval('menuitem'+i+'.thediv');
            shutdiv.style.visibility='hidden';
    }

}
function closesubnavunder2(oNum,oMaxNum){
if (oNum < oMaxNum) {
}
else
{
    for (var i=1; i<= numofitems; i++){
      var shutdiv =eval('menuitem'+i+'.thediv');
            shutdiv.style.visibility='hidden';
    }
}

}
// Mouse event catchers
//--------------------------------------------
function mousclick(bItem) {
if (navigator.appName=="Microsoft Internet Explorer") {
window.nextform.submit();
}
else
{
document.nextform.submit();
}
}
function mousout(bImage,bItem,bExt) {

bItem.src=bImage+bExt;
}
function mousdown(bImage,bItem,bExt) {
bItem.src=bImage+"-down"+bExt;
}
function mousover(bImage,bItem,bExt) {
bItem.src=bImage+"-over"+bExt;
bItem.style.cursor="pointer";

}


function mOvr(src,clrOver){
	if (!src.contains(event.fromElement)){
		src.style.cursor = 'pointer';
		src.bgColor = clrOver;
	}
}

function mOut(src,clrIn){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	} 
} 


function mClk(src){  


if (typeof window.event!= "undefined" )
 {

  if (event.srcElement.tagName=='TD') 
  {
    src.children.tags('A')[0].click(); 
  }
 } 
else
 {
 
  //src.children.tags('A')[0].click(); 
 } 


} 


function mDwn(src,clrDn){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.bgColor = clrDn; 
	} 
}
//roll over text script
//-------------------------------------
function setroll(hotwtext){

var x0, y0;
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}


	var popupwidth = eval(hotwtext).style.width;

	popupwidth = popupwidth.replace(/px/i, "")
if (navigator.appName=="Microsoft Internet Explorer") {
	x0 = window.event.x;
	y0 = window.event.y;

	if (1*x0 + 1*popupwidth > window_width)
	{
	x0 = 1*window_width - 1*popupwidth - 50;
	
	}
    eval(hotwtext).style.left = x0;
	
    eval(hotwtext).style.top = y0;

    eval(hotwtext).style.display = 'block';  
  }
else
{
	eval(hotwtext).style.left = 400
	eval(hotwtext).style.top = 300
	eval(hotwtext).style.display='block';
}
}
function endroll(hotwtext){
    eval(hotwtext).style.display = 'none';
} 
//


//---------------------------------+
//  CARPE  S l i d e r        1.5  |
//  2006 - 01 - 03                 |
//  By Tom Hermansson Snickars     |
//  Copyright CARPE Design         |
//  http://carpe.ambiprospect.com/ |
//  Contact for custom scripts     |
//  or implementation help.        |
//---------------------------------+
// Global vars. You don't need to make changes here to change your sliders.
// Changing the attributes in your (X)HTML file is enough.
var carpeDefaultSliderLength      = 100
var carpeSliderDefaultOrientation = 'horizontal'
var carpeSliderClassName          = 'carpe_slider'
var carpeSliderDisplayClassName   = 'carpe_slider_display'
var carpeslideruserkey = ''
var carpeslidersessionkey = ''
var carpesliderpagekey = ''
var carpesliderdb = ''
var carpeslidertestanswerkey = ''
var carpesliderpatientkey = ''
var carpesliderpatientsessionkey = ''
var carpecalbeforesliderid = ''
var carpecalaftersliderid = ''
var carpecalweekly1sliderid = ''
var carpecalweekly2sliderid = ''
var carpesliderhandleleft = 0;
// carpeGetElementsByClass: Cross-browser function that returns
// an array with all elements that have a class attribute that
// contains className
function carpeGetElementsByClass(className)
{
	var classElements = new Array()
	var els = document.getElementsByTagName("*")
	var elsLen = els.length
	var pattern = new RegExp("\\b" + className + "\\b")
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i]
			j++
		}
	}
	return classElements;
}
// carpeLeft: Cross-browser version of "element.style.left"
// Returns or sets the horizontal position of an element.
function carpeLeft(elmnt, pos)
{

	if (!(elmnt = document.getElementById(elmnt))) return 0;
	if (elmnt.style && (typeof(elmnt.style.left) == 'string')) {
		if (typeof(pos) == 'number') elmnt.style.left = pos + 'px';
		else {
			pos = parseInt(elmnt.style.left);
			if (isNaN(pos)) pos = 0;
		}
	}
	else if (elmnt.style && elmnt.style.pixelLeft) {
		if (typeof(pos) == 'number') elmnt.style.pixelLeft = pos;
		else pos = elmnt.style.pixelLeft;
	}
	return pos;
}
// carpeTop: Cross-browser version of "element.style.top"
// Returns or sets the vertical position of an element.
function carpeTop(elmnt, pos)
{

	if (!(elmnt = document.getElementById(elmnt))) return 0;
	if (elmnt.style && (typeof(elmnt.style.top) == 'string')) {
		if (typeof(pos) == 'number') {
		    elmnt.style.top = pos + 'px';
		   }
		else {
			pos = parseInt(elmnt.style.top);
			if (isNaN(pos)) pos = 0;
		}
	}
	else if (elmnt.style && elmnt.style.pixelTop) {
		if (typeof(pos) == 'number') elmnt.style.pixelTop = pos;
		else pos = elmnt.style.pixelTop;
	}
	return pos;
}
// moveSlider: Handles slider and display while dragging
function moveSlider(evnt)
{
	var evnt = (!evnt) ? window.event : evnt; // The mousemove event
	if (mouseover) { // Only if slider is dragged
		x = slider.startOffsetX + evnt.screenX // Horizontal mouse position relative to allowed slider positions
		y = slider.startOffsetY + evnt.screenY // Horizontal mouse position relative to allowed slider positions
		if (x > slider.xMax) x = slider.xMax // Limit horizontal movement
		if (x < 0) x = 0 // Limit horizontal movement
		if (y > slider.yMax) y = slider.yMax // Limit vertical movement
		if (y < 0) y = 0 // Limit vertical movement
		carpeLeft(slider.id, x)  // move slider to new horizontal position
		carpeTop(slider.id, y) // move slider to new vertical position
		sliderVal = x + y // pixel value of slider regardless of orientation
		sliderPos = (slider.distance / display.valuecount) * 
			Math.round(display.valuecount * sliderVal / slider.distance)
		v = Math.round((sliderPos * slider.scale + slider.from) * // calculate display value
			Math.pow(10, display.decimals)) / Math.pow(10, display.decimals)
		display.value = v // put the new value in the slider display element
		return false
	}
	return
}
// slide: Handles the start of a slider move.
function slide(evnt)
{

	if (!evnt) evnt = window.event; // Get the mouse event causing the slider activation.
	slider = (evnt.target) ? evnt.target : evnt.srcElement; // Get the activated slider element.
	dist = parseInt(slider.getAttribute('distance')) // The allowed slider movement in pixels.
	slider.distance = dist ? dist : carpeDefaultSliderLength // Deafault distance from global var.
	ori = slider.getAttribute('orientation') // Slider orientation: 'horizontal' or 'vertical'.
	orientation = ((ori == 'horizontal') || (ori == 'vertical')) ? ori : carpeSliderDefaultOrientation
		// Default orientation from global variable.
	displayId = slider.getAttribute('display') // ID of associated display element.
	display = document.getElementById(displayId) // Get the associated display element.
	display.sliderId = slider.id // Associate the display with the correct slider.
	dec = parseInt(display.getAttribute('decimals')) // Number of decimals to be displayed.
	display.decimals = dec ? dec : 0 // Default number of decimals: 0.
	val = parseInt(display.getAttribute('valuecount'))  // Allowed number of values in the interval.
	display.valuecount = val ? val : slider.distance + 1 // Default number of values: the sliding distance.
	from = parseFloat(display.getAttribute('from')) // Min/start value for the display.
	from = from ? from : 0 // Default min/start value: 0.
	to = parseFloat(display.getAttribute('to')) // Max value for the display.
	to = to ? to : slider.distance // Default number of values: the sliding distance.
	slider.scale = (to - from) / slider.distance // Slider-display scale [value-change per pixel of movement].
	if (orientation == 'vertical') { // Set limits and scale for vertical sliders.
		slider.from = to // Invert for vertical sliders. "Higher is more."
		slider.xMax = 0
		slider.yMax = slider.distance
		slider.scale = -slider.scale // Invert scale for vertical sliders. "Higher is more."
	}
	else { // Set limits for horizontal sliders.
		slider.from = from
		slider.xMax = slider.distance
		slider.yMax = 0
	}
	slider.startOffsetX = carpeLeft(slider.id) - evnt.screenX  // Slider-mouse horizontal offset at start of slide.
	slider.startOffsetY = carpeTop(slider.id) - evnt.screenY  // Slider-mouse vertical offset at start of slide.
	mouseover = true
	document.onmousemove = moveSlider // Start the action if the mouse is dragged.
	document.onmouseup = sliderMouseUp // Stop sliding.
	return false
}
// sliderMouseUp: Handles the mouseup event after moving a slider.
// Snaps the slider position to allowed/displayed value. 
function sliderMouseUp()
{

	if (mouseover) {
		v = (display.value) ? display.value : 0 // Find last display value.
		pos = (v - slider.from)/(slider.scale) // Calculate slider position (regardless of orientation).
		if (slider.yMax == 0) {
			pos = (pos > slider.xMax) ? slider.xMax : pos
			pos = (pos < 0) ? 0 : pos
			carpeLeft(slider.id, pos) // Snap horizontal slider to corresponding display position.
		}
		if (slider.xMax == 0) {
			pos = (pos > slider.yMax) ? slider.yMax : pos
			pos = (pos < 0) ? 0 : pos
			carpeTop(slider.id, pos) // Snap vertical slider to corresponding display position.
		}
		if (document.removeEventListener) { // Remove event listeners from 'document' (W3C).
			document.removeEventListener('mousemove', moveSlider, false)
			document.removeEventListener('mouseup', sliderMouseUp, false)
		}
		else if (document.detachEvent) { // Remove event listeners from 'document' (IE).
			document.detachEvent('onmousemove', moveSlider)
			document.detachEvent('onmouseup', sliderMouseUp)
		}
	}
	var sliderid = slider.id
	var sliderarray= sliderid.split("_");
	var formkey = sliderarray[1];
	
	if (carpecalbeforesliderid == formkey || carpecalaftersliderid == formkey || carpecalweekly1sliderid == formkey || carpecalweekly2sliderid == formkey)
	{
	    var beforevalue = '';
	    var aftervalue = '';
	    var weekly1 = '';
	    var weekly2 = '';
        if (lastcellclicked)
        {
	       
	        var lastclickedhtml = lastcellclicked.innerHTML.replace(/<br>/gim, "<BR>");
	        var thiscellvalues = lastclickedhtml.split("<BR><BR>");
	        var thisdaynum = thiscellvalues[0];
	        if (thisdaynum.indexOf("Week ") > -1)
	        {
	            thisdaynum = cleanitup(thisdaynum);
	            if (thiscellvalues.length > 1)
	            {
    	            if (cleanitup(thiscellvalues[1]) != '')
    	            {
	                    weekly1 = weektrack1val + ' ' + cleanitup(thiscellvalues[1]);
	                }
	            }
	            if (thiscellvalues.length > 1)
	            {
    	            if (cleanitup(thiscellvalues[2]) != '')
    	            {
	                    weekly2 = weektrack2val + ' ' + cleanitup(thiscellvalues[2]);
	                }
	            }
	        }
	        else
	        {
	            if (thiscellvalues.length > 0)
	            {
	                beforevalue = thiscellvalues[1];
	            }
	            if (thiscellvalues.length > 1)
	            {
	                aftervalue = thiscellvalues[2];
	            }
            }
	        if (carpecalbeforesliderid == formkey) 
	        {
	            updatecalendarholdervalues(calbeforeholderid,'calbeforeholder',display.value);
	            if (display.value != '')
	            {
	                beforevalue = "B: " + display.value;
	            }
	        }
	        else
	        {
	            if (carpecalaftersliderid == formkey)
	            {
	                updatecalendarholdervalues(calafterholderid,'calafterholder',display.value);
	                if (display.value != '')
	                {
	                    aftervalue = "A: " + display.value;
	                }
	            }
	            else
	            {
	        	     if (carpecalweekly1sliderid == formkey)
	                {
                        updatecalendarholdervalues(calweekly1id,'calweekly1',display.value) == 1;
	 	                 weekly1= weektrack1val + ' ' + display.value;
    	              
	                }
	                else
	                {
	                    if (carpecalweekly2sliderid == formkey)
	                    {
	                        updatecalendarholdervalues(calweekly2id,'calweekly2',display.value) == 1;
	                        weekly2 = weektrack2val + ' ' + display.value;
    	                    
	                    }
    	            
	                }
    	              
	            }
	       }
    	   
	        if (lastcellclicked.innerHTML.indexOf("Week") ==-1)
	        {
	        lastcellclicked.innerHTML = thisdaynum + "<br><br>" + beforevalue + '<br><br>' + aftervalue;
	        
	        }
	        else
	        {
	        lastcellclicked.innerHTML = "<b>Week " + thisdaynum + "</b><br><br>" + weekly1 + '<br><br>' + weekly2;
	        }
	    }
	}
	else
	{
//alert(display.value + ' ' + carpeslideruserkey + ' ' +  formkey + ' ' +  carpesliderpagekey + ' ' +  carpeslidersessionkey + ' ' +  carpesliderdb + ' ' + carpeslidertestanswerkey + ' ' + carpesliderpatientkey + ' ' + carpesliderpatientsessionkey);
	    if (jshtmlversion == 0)
	    {PostformResponse(display.value,carpeslideruserkey, formkey, carpesliderpagekey, carpeslidersessionkey, carpesliderdb,carpeslidertestanswerkey,carpesliderpatientkey,carpesliderpatientsessionkey,5,0,0,0,0,0,'False');}
	    else
	    {document.cookie= usecarpesliderpagekey + '-' + formkey + '-5='+ escape(display.value);if (jshtmlversion == 2){updateform(display.value, formkey, carpesliderpagekey);};
	    if (jspatientkey !=0 && jsadminproduct == true && jspageprocessrule == 0){document.cookie= usecarpesliderpagekey + '-' + formkey + '-5-' + jspatientkey + '='+ escape(display.value);};}
	}
	mouseover = false // Stop the sliding.

}
function focusDisplay(evnt)
{
	if (!evnt) evnt = window.event; // Get the mouse event causing the display activation.
	display = (evnt.target) ? evnt.target : evnt.srcElement; // Get the activated display element.
	lock = display.getAttribute('typelock') // Is the user allowed to type into the display?
	if (lock == 'on') {
		display.blur()
	}
	return
}
window.onload = function() // Set up the sliders and the displays.
{
	sliders = carpeGetElementsByClass(carpeSliderClassName) // Find the horizontal sliders.
	for (i = 0; i < sliders.length; i++) {
		sliders[i].onmousedown = slide // Attach event listener.
	}
	displays = carpeGetElementsByClass(carpeSliderDisplayClassName) // Find the displays.
	for (i = 0; i < displays.length; i++) {
		displays[i].onfocus = focusDisplay // Attach event listener.
	}
}
	
	//fontsizer
//
var tags = new Array( 'div','td','tr','p','b','table','strong','emphasis','a','h1','h2','h3','pre','sub','sup','i','th','cp','ul','ol','li','dt','dd','span');
var pixelArray =  new Array('10','12','14','16','18','20','22');
var emArray =  new Array('0.7','0.9','1.0','1.5','2.0','2.5','3');
var initSize = 2;
var p;
var clickcounter=0;

function readCookie1(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return 2;
}
	



function setSkinCookie(name, value, expires, path, domain, secure) {

  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
	  
  document.cookie = curCookie;
}

function fontSizer(inc,unit) {

var size =2
	if (clickcounter == 0) {
		clickcounter = 1
		size = 2
	}
	else
	{

		if (!document.getElementById) 
			return;
			var s1=readCookie1('size');
			size = Number(s1);
	}
	size += inc;
	
	if (size < 0 ) {
		size = 0;
	}
	if (size > 6 ) {
		size = 6;
}
if(size==11)
{
size = 1;

}

		initSize = size;
		getBody = document.getElementsByTagName('body')[0];
	for (i = 0 ; i < tags.length ; i++ ) {
		getallTags = getBody.getElementsByTagName(tags[i]);
	for (k = 0 ; k < getallTags.length ; k++) 
	{
		getallTags[k].style.fontSize = (unit=='px') ? pixelArray[size]+unit: emArray[size]+unit;
		fontSize=(unit=='px') ? pixelArray[size]+unit: emArray[size]+unit;
		
	}
		
	}
	 setSkinCookie("size",size, new Date("December 31, 2010 23:59:59"),"/");

	
}
function jpwriteapplet(text) {
  document.write(text);
}
// activewidget stuff for dashboard
function PostCellData(text, thiscol, thisrow)
   {

   ///obj.getCellTemplate(thiscol, thisrow).setStyle('background', 'white');
  obj.getCellTemplate(thiscol, thisrow).setStyle('color', 'black');
   var thispatientkey = obj.getCellText(0, thisrow);

   //var invalue = text.replace(/'/g, "")
    var dataval = "";
   var invalue = text.replace(/"/g, "");
   obj.setCellData(invalue, thiscol, thisrow);
   obj.setCellText(invalue, thiscol, thisrow);
   var dayspermonth = 31;
   var thisURL = "postcelldata.aspx?tut=" + prodkey + "&col=" + thiscol + "&pid=" + thispatientkey + "&val=" +escape(invalue) + "&fn=" + escape(jsfirstname) + "&ln=" + escape(jslastname) + "&email=" + escape(jsemail) + "&notes=" + escape(jsnotes) + "&group=" + jsprovider + "&custsitekey=" + jscustsitekey + "&customerkey=" + jscustomerkey;

 // alert(thisURL);

       var r = new AW.HTTP.Request;
       r.setURL(thisURL);
       r.setRequestMethod("POST");
       r.request();

        r.response = function(data){
//alert(data)

       }  
}


function setselectedrow(thiscol, thisrow, colcount)
{

obj.getRowTemplate(thisrow).setStyle('background', '#316ac5');
obj.getRowTemplate(thisrow).setStyle('color', 'white');
for (var i = 0; i < colcount; i++)
    {
       obj.getCellTemplate(i, thisrow).setStyle('background', '#316ac5');
       obj.getCellTemplate(i, thisrow).setStyle('color', 'white');   
    }
  
if (obj.getCellData(6, thisrow) != 0)
 {
    obj.getCellTemplate(6, thisrow).setStyle('visibility','visible');
    obj.getCellTemplate(6, row).setStyle('color','black');
    obj.setCellTemplate(rowCombo, 5);
    document.all('patientvisit').value =0;
    document.all('patientprod').value=obj.getCellData(6, thisrow);
 }
}
  

function clearAllRows(Oobj, clearvalcol, hidevalcol, colcount)
{


var rowctr = Oobj.getRowCount()

var i;
// clear any previous selections in the grid
  for (i=0; i< rowctr; i++)
       {
       Oobj.getRowTemplate(i).setStyle("background", "white");
       Oobj.getRowTemplate(i).setStyle("color", "black");
       if (clearvalcol != 0)
       {
    
         //  obj.setCellText('', clearvalcol, i) ;
       }
       if (hidevalcol != 0)
       {
           obj.getCellTemplate(hidevalcol, i).setStyle('visibility','hidden'); 
       }        
       for (var j = 0; j < colcount; j++)
            {
                obj.getCellTemplate(j, i).setStyle('background', 'white');
                obj.getCellTemplate(j, i).setStyle('color', 'black');               
            }

       }
       return true;
}
// for patient report / list



function changeselectedvalue(ivalue, Oobj, iformname, irowhite, clearvalcol, hidevalcol, colcount,iformID)
{
var testvalue = ivalue;
var comparevalue = '';
var listvalue = '';
var rowctr = Oobj.getRowCount()
var valuearray = ivalue.split('');
var n = valuearray.length;
var i;

// clear any previous selections in the grid
//var resp =clearAllRows(Oobj, clearvalcol, hidevalcol, colcount);

//select row in grid


    for (i=0; i< rowctr; i++)
        {
            listvalue = Oobj.getCellText(1, i);
            comparevalue = '';
	        comparevalue=listvalue.substring(0,n);
        
           if (comparevalue == testvalue)
           {
             //  setselectedrow(1, i, colcount)
               Oobj.setSelectedRows(i);

               lastselrow = i;
             //  getRowPosition(i)+1

             Oobj.setScrollTop(irowhite*(obj.getSelectorText(i) - 1));
             document.all(iformname).value = Oobj.getCellText(0, i);
             document.getElementById(iformID).value = Oobj.getCellText(0, i);
              // lastselvalue = document.all(iformname)(i).text;
             
                return;
           }
       }

       alert("patientid not found");
}
/*****************************************************************

	ActiveWidgets 2.5.3
	Copyright (C) 2003-2008 ActiveWidgets SARL. All Rights Reserved. 
	http://www.activewidgets.com/

	WARNING: This software program is protected by copyright law 
	and international treaties. Unauthorized reproduction or
	distribution of this program, or any portion of it, may result
	in severe civil and criminal penalties, and will be prosecuted
	to the maximum extent possible under the law.

*****************************************************************/

 if(!window.AW){var AW=function(a,b){return AW.dispatch(a,b)};AW.version=253;AW.toString=function(){return "ActiveWidgets 2.5.3"}}if(!AW.System){AW.System={}}if(!AW.HTML){AW.HTML={}}if(!AW.Templates){AW.Templates={}}if(!AW.Scroll){AW.Scroll={}}if(!AW.Panels){AW.Panels={}}if(!AW.Formats){AW.Formats={}}if(!AW.HTTP){AW.HTTP={}}if(!AW.CSV){AW.CSV={}}if(!AW.XML){AW.XML={}}if(!AW.UI){AW.UI={}}if(!AW.Grid){AW.Grid={}}if(!AW.Tree){AW.Tree={}}if(!AW.UI.Controllers){AW.UI.Controllers={}}if(!AW.Grid.Controllers){AW.Grid.Controllers={}}
(function(){AW.all={id:0};AW.docs=[document];AW.log=function(level,arg){try{var i,s="";for(i=0;i<arg.length;i++){s+=arg[i]+" "}window.status=s}catch(error){window.status=error.message}};AW.debug=function(){AW.log("debug",arguments)};AW.info=function(){AW.log("info",arguments)};AW.warn=function(){AW.log("warn",arguments)};AW.error=function(){AW.log("error",arguments)};AW.fatal=function(){AW.log("fatal",arguments)};AW.forEach=function(array,handler){var i,custom={};for(i in array){if(!custom[i]){handler(i,array[i])}}};AW.element=function(id){if(!id || typeof(id)!="string"){return}var i,e,docs=AW.docs;for(i=0;i<docs.length;i++){e=docs[i].getElementById(id);if(e){return e}}};AW.object=function(id,skipContent){var parts=id.split("-");var tag=parts[0];var obj=AW.all[tag];if(!obj){return}for(var i=1;i<parts.length;i++){var name=parts[i];if(obj["_"+name+"Content"]){if(!skipContent){for(var j=i;j<parts.length;j++){obj=obj.getContent(parts[j])}}return obj}tag+="-"+name;if(AW.element(tag)){obj=obj.getTemplate(name);continue}var index1=parts[++i];tag+="-"+index1;if(AW.element(tag)){obj=obj.getTemplate(name,index1);continue}var index2=parts[++i];tag+="-"+index2;if(AW.element(tag)){obj=obj.getTemplate(name,index1,index2);continue}var index3=parts[++i];tag+="-"+index3;if(AW.element(tag)){obj=obj.getTemplate(name,index1,index2,index3);continue}}return obj};var events={"DOMFocusIn":"focus"};AW.dispatch=function(element,event){var type="_on"+(events[event.type] || event.type)+"Event";var target=AW.object(element.id);var obj=target;while(obj._parent){obj=obj._parent}return target[type].call(obj,event)};AW.camelCase=function(){var i,s=arguments[0];for(i=1;i<arguments.length;i++){s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1)}return s};AW.textPattern=/(\"|&|<|>)/gm;AW.textTable={"\"":"&quot;","&":"&amp;","<":"&lt;",">":"&gt;"};AW.textReplace=function(c){return AW.textTable[c] || ""};AW.htmlPattern=/(&quot;|&amp;|&lt;|&gt;|<[^<>]*>)/gm;AW.htmlTable={"&quot;":"\"","&amp;":"&","&lt;":"<","&gt;":">"};AW.htmlReplace=function(e){return AW.htmlTable[e] || ""};AW.valueToText=function(v){return v?String(v).replace(AW.textPattern,AW.textReplace):""};AW.textToValue=function(t){return t?String(t).replace(AW.htmlPattern,AW.htmlReplace):""}})();
(function(){var ua=navigator.userAgent || "";AW.browser="";if(document.recalc){AW.browser="ie"}if(window.XULElement){AW.browser="gecko"}if(window.opera){AW.browser="opera"}if(ua.match("WebKit")){AW.browser="webkit"}if(ua.match("Konqueror")){AW.browser="konqueror"}if(AW.browser){AW[AW.browser]=true}if(AW.webkit){if(ua.match("Chrome")){AW.chrome=true}else if(ua.match("Safari")){AW.safari=true}}if(AW.safari && !document.evaluate){AW.safari2=true}if(!ua.match("Windows")){AW.unix=true}AW.theme="classic";if(ua.match("Windows NT 6")){AW.theme="vista"}if(ua.match("Windows NT 5.1")){AW.theme="xp"}if(AW.safari || ua.match("Mac OS")){AW.theme="aqua"}AW.strict=(""+document.compatMode).match("CSS");if(AW.safari2 ||(AW.safari && !document.compatMode && document.doctype &&(document.doctype.systemId || !(""+document.doctype.publicId).match(/(Transitional|Final)/)))){AW.strict=true}if(!AW.strict){AW.quirks=true}var htmlc=" aw-all";if(AW.strict){htmlc+=" aw-strict"}if(AW.quirks){htmlc+=" aw-quirks"}if(AW.browser){htmlc+=" aw-"+AW.browser}if(AW.safari){htmlc+=" aw-safari"}if(AW.chrome){htmlc+=" aw-chrome"}if(AW.unix){htmlc+=" aw-unix"}if(AW.theme){htmlc+=" aw-"+AW.theme}if(AW.theme && AW.strict){htmlc+=" aw-"+AW.theme+"-strict"}if(AW.ie){var s=document.documentElement.currentStyle;if(s.outlineStyle){AW.ie8=true;htmlc+=" aw-ie8"}else if(s.maxWidth){AW.ie7=true;htmlc+=" aw-ie7"}else if(s.textOverflow){AW.ie6=true;htmlc+=" aw-ie6"}else if(s.writingMode){AW.ie5=true;htmlc+=" aw-ie5"}s=null;if(document.documentMode >=8){AW.ms8=true;htmlc+=" aw-ms8"}else if(document.documentMode==7 ||(AW.ie7 && AW.strict)){AW.ms7=true;htmlc+=" aw-ms7"}else if(AW.ie6 && AW.strict){AW.ms6=true;htmlc+=" aw-ms6"}else{AW.ms5=true;htmlc+=" aw-ms5"}}if(AW.gecko){if(document.elementFromPoint){AW.ff3=true;htmlc+=" aw-ff3"}else if(window.globalStorage){AW.ff2=true;htmlc+=" aw-ff2"}else if(window.XPCNativeWrapper){AW.ff15=true;htmlc+=" aw-ff15"}else{AW.ff1=true;htmlc+=" aw-ff1"}if(!AW.ff3){AW.ffx=true;htmlc+=" aw-ffx"}}if(AW.ie5 || AW.ie6){htmlc+=" aw-png1 aw-"+AW.theme+"-png1"}else{htmlc+=" aw-png2"}AW._htmlClasses=htmlc;if(AW.strict){AW.dx=8;AW.dy=4}else{AW.dx=0;AW.dy=0}AW.sx=20;AW.sy=20})();
(function(){if(AW.ie){try{document.execCommand("BackgroundImageCache",false,true)}catch(err){}AW.attachEvent=function(element,name,handler){return element.attachEvent(name,handler)};AW.detachEvent=function(element,name,handler){return element.detachEvent(name,handler)};AW.srcElement=function(event){if(event){return event.srcElement}};AW.toElement=function(event){if(event){return event.toElement}};AW.setReturnValue=function(event,value){if(event){event.returnValue=value}};AW.setCapture=function(element){return element.setCapture()};AW.releaseCapture=function(element){return element.releaseCapture()};AW.addRule=function(stylesheet,selector,rule){return stylesheet.addRule(selector,rule)};AW.getRules=function(stylesheet){return stylesheet.rules};AW.setOuterHTML=function(element,html){element.outerHTML=html};AW.createXMLHttpRequest=function(){try{return new ActiveXObject("MSXML2.XMLHTTP")}catch(err){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(err){}try{return new XMLHttpRequest}catch(err){}};AW.getLeft=function(element){return element.getBoundingClientRect().left};AW.getTop=function(element){return element.getBoundingClientRect().top};AW.contains=function(parent,child){return parent.contains(child)}}})();
(function(){if(!AW.ie){var capture;AW.attachEvent=function(target,name,handler){if(capture){handler[name]=function(event){return handler.call(target,event)};window.addEventListener(name.replace(/^on/,""),handler[name],true)}else{target.addEventListener(name.replace(/^on/,""),handler,false)}};AW.detachEvent=function(target,name,handler){if(capture){window.removeEventListener(name.replace(/^on/,""),handler[name],true);handler[name]=null}else{target.removeEventListener(name.replace(/^on/,""),handler,false)}};AW.srcElement=function(event){try{return(event.target && event.target.nodeType==3)?event.target.parentNode:event.target}catch(e){return event.target}};AW.toElement=function(event){try{return(event.relatedTarget && event.relatedTarget.nodeType==3)?event.relatedTarget.parentNode:event.relatedTarget}catch(e){return event.relatedTarget}};AW.setReturnValue=function(event,value){if(event && event.preventDefault && !value){event.preventDefault()}};AW.setCapture=function(element){capture=element};AW.releaseCapture=function(element){capture=null};AW.addRule=function(stylesheet,selector,rule){var i=stylesheet.cssRules.length;stylesheet.insertRule(selector+"{"+rule+"}",i);stylesheet.cssRules[i].style.cssText=rule};AW.getRules=function(stylesheet){return stylesheet.cssRules};AW.setOuterHTML=function(element,html){var range=element.ownerDocument.createRange();range.setStartBefore(element);var fragment=range.createContextualFragment(html);element.parentNode.replaceChild(fragment,element)};AW.createXMLHttpRequest=function(){return new XMLHttpRequest};AW.getLeft=function(element){return getRectangle(element).left};AW.getTop=function(element){return getRectangle(element).top};var getRectangle=function(e){var t=e,x=0,y=0;function getPos(el){if(!el){return{x:0,y:0}}if(el==document.body.parentNode){return{x:0,y:0}}if(el==document.body){return{x:el.offsetLeft,y:el.offsetTop}}var p=el.offsetParent;var pp=getPos(p);return{x:el.offsetLeft+pp.x,y:el.offsetTop+pp.y}}var pp=getPos(e);return{left:pp.x,right:pp.x+e.offsetWidth,top:pp.y,bottom:pp.y+e.offsetHeight}};AW.contains=function(parent,child){while(child){if(parent==child){return true}child=child.parentNode}return false}}if(AW.gecko){AW.getLeft=function(element){var doc=document.getBoxObjectFor(document.body);return document.getBoxObjectFor(element).screenX - doc.screenX+doc.x};AW.getTop=function(element){var doc=document.getBoxObjectFor(document.body);return document.getBoxObjectFor(element).screenY - doc.screenY+doc.y}}if(AW.ff3){AW.getLeft=function(element){return element.getBoundingClientRect().left - document.documentElement.getBoundingClientRect().left};AW.getTop=function(element){return element.getBoundingClientRect().top - document.documentElement.getBoundingClientRect().top}}if(AW.webkit || AW.opera){AW.setOuterHTML=function(element,html){element.outerHTML=html}}})();
(function(){AW._addMouseEvents=function(obj,name){function clear(){var e=this.element();if(e){e.className=e.className.replace(/ aw-mouse(over|down)-\w+/g,"")}e=null}if(obj.setController){if(name){obj.setController("highlight",{onControlMouseOver:function(){if(this._controlDisabled){return}var e=this.element();if(e){e.className+=" aw-mouseover-"+name}e=null},onControlMouseDown:function(){if(this._controlDisabled){return}var e=this.element();if(e){e.className+=" aw-mousedown-"+name}e=null},onControlMouseOut:clear,onControlMouseUp:clear})}}else{obj._raiseEvents=true;obj.onMouseOver=function(){if(this.$owner && this.$owner._controlDisabled){return}var e=this.element();if(e){e.className+=" aw-mouseover-"+this.$name+(name?" aw-mouseover-"+name:"");if(AW.ie){var h=e.offsetHeight}}e=null};obj.onMouseDown=function(){if(this.$owner && this.$owner._controlDisabled){return}var e=this.element();if(e){e.className+=" aw-mousedown-"+this.$name+(name?" aw-mousedown-"+name:"");if(AW.ie){var h=e.offsetHeight}}e=null};obj.onMouseOut=clear;obj.onMouseUp=clear}};AW._startEventManager=function(){var keyNames={8:"Backspace",9:"Tab",13:"Enter",27:"Escape",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12"};function keydown(event){var key=keyNames[event.keyCode];if(event.keyCode >=48 && event.keyCode <=90){key=String.fromCharCode(event.keyCode)}if(key){if(event.shiftKey){key="Shift"+key}if(event.altKey){key="Alt"+key}if(event.ctrlKey){key="Ctrl"+key}raiseKbEvent("onKey"+key,event)}}var excludeOperaKeys={35:1,36:1,45:1,46:1};function keypress(event){if((AW.ie ||(AW.opera && event.which &&(event.keyCode > 31 || event.keyCode==13)&& !excludeOperaKeys[event.keyCode])||(event.charCode && event.charCode < 63000))&& !(event.altKey || event.ctrlKey)){raiseKbEvent("onKeyPress",event)}}function keyup(){AW._scrollWait=false}function raiseKbEvent(name,event){try{var target=event.srcElement || event.target;var obj,e=target;while(e){if(e.id && typeof(e.id)=="string"){obj=AW.object(e.id,true);if(obj && obj.setController){obj.raiseEvent(name,event);e=obj.element()}}e=e.parentNode}}catch(err){}}function raiseControlEvent(name,obj,event){var name0,name1;if(obj.setController){if((AW.webkit || AW.opera || AW.konqueror)&& !event.done){if(name.match("MouseDown")&& event.target.tagName !="INPUT" && event.target.tagName !="SELECT" && !AW.safari2){event.preventDefault()}if(name=="Clicking"){if(obj.getId()!=AW._edit){obj.focus()}event.done=true}}if((!obj.$active || AW._edit)&&(name.indexOf("Click")> -1)){return}name1="onControl"+name;return obj.raiseEvent(name1,event,obj.$0,obj.$1,obj.$2)}if(obj.$name && obj.raiseEvent){if((AW.webkit || AW.opera || AW.konqueror)&& !event.done){if(name.match("MouseDown")&& event.target.tagName !="INPUT" && event.target.tagName !="SELECT" && !AW.safari2){event.preventDefault()}if(name=="Clicking"){if(obj.getId()!=AW._edit && obj.$owner.$name !="popup"){obj.$owner.focus()}event.done=true}}if(!obj._raiseEvents){return}if(!AW.$popup &&(!obj.$owner.$active || AW._edit)&&(name.indexOf("Click")> -1)){return}name0="on"+name;if(typeof obj[name0]=="function"){obj[name0](event)}name1=AW.camelCase("on",obj.$name,name);return obj.$owner.raiseEvent(name1,event,obj.$0,obj.$1,obj.$2)}}var targets={};function handleMouse(e,event){try{if(AW.ignoreMouse){return}var i,obj,temp={};while(e){if(e.id && typeof(e.id)=="string"){obj=AW.object(e.id,true);if(obj){e=obj.element();temp[e.id]=true}}e=e.parentNode}for(i in targets){if(!temp[i]){obj=AW.object(i,true);if(obj){raiseControlEvent("MouseOut",obj,event)}}}for(i in temp){if(!targets[i]){obj=AW.object(i,true);if(obj){raiseControlEvent("MouseOver",obj,event)}}}targets=temp}catch(error){}}function copyEvent(e,type){if(AW.ie){return document.createEventObject(e)}else if(AW.webkit || AW.opera || AW.konqueror){return{type:e.type,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,button:e.button,target:e.target,srcElement:e.target}}else{var event=document.createEvent("MouseEvents");event.initMouseEvent(type || e.type,true,true,e.view,1,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,e.button,null);event.srcElement=e.target;return event}}var clickingEvent=null;function raiseClickingEvent(){if(clickingEvent){mouseClicks("Clicking")(clickingEvent);clickingEvent=null}}var mouseDownId="";function mouseClicks(name){return function(event){try{if(name=="MouseUp" && clickingEvent){raiseClickingEvent()}var target=event.srcElement || event.target;var inside=false;var s=(event.ctrlKey?"Ctrl":"")+(event.altKey?"Alt":"")+(event.shiftKey?"Shift":"")+name;var obj,e=target;while(e){if(e.id && typeof(e.id)=="string"){obj=AW.object(e.id,true);if(obj){raiseControlEvent(s,obj,event);e=obj.element();inside=true}}e=e.parentNode}if(name=="MouseDown" && inside){clickingEvent=copyEvent(event);window.setTimeout(raiseClickingEvent,10)}if(name=="MouseDown"){mouseDownId=""}if((name=="MouseDown" || name=="Clicking")&& inside &&(target !==AW.element(target.id))){mouseDownId=target.id}if(name=="MouseUp" && mouseDownId &&(mouseDownId==target.id)){if(AW.ie){event.srcElement.fireEvent("onclick",copyEvent(event))}else{event.target.dispatchEvent(copyEvent(event,"click"))}}e=null;target=null}catch(err){}}}function focusIE(name){return function(event){try{if(event.srcElement.document !==document){return}if(name=="Deactivating" && AW._edit){if(!AW._endEdit()){return false}}var obj,e=AW.srcElement(event);while(e){if(e.id && typeof(e.id)=="string"){obj=AW.object(e.id,true);if(obj && obj.setController){switch(name){case "Deactivating":if(!obj.element().contains(event.toElement)){if(AW.ie5){obj._deactivate=true}if(raiseControlEvent(name,obj,event)){event.returnValue=false}}else if(AW.ie5){obj._deactivate=false}break;case "Activating":if(!obj.$active){if(raiseControlEvent(name,obj,event)){event.returnValue=false}}break;case "Deactivated":if(!obj.element().contains(event.toElement)){if(AW.ie5 && !obj._deactivate){break}obj.$active=false;if(raiseControlEvent(name,obj,event)){event.returnValue=false}}break;case "Activated":if(!obj.$active){obj.$active=true;if(raiseControlEvent(name,obj,event)){event.returnValue=false}}break}e=obj.element()}}e=e.parentNode}}catch(err){}}}var handlers={onkeypress:keypress,onkeydown:keydown,onkeyup:keyup,onmousemove:function(event){handleMouse(AW.srcElement(event),event)},onmouseover:function(event){handleMouse(AW.srcElement(event),event)},onmouseout:function(event){handleMouse(AW.toElement(event),event)},onmousedown:mouseClicks("MouseDown"),onmouseup:mouseClicks("MouseUp"),onclick:mouseClicks("Clicked"),ondblclick:mouseClicks("DoubleClicked"),onbeforeactivate:focusIE("Activating"),onbeforedeactivate:focusIE("Deactivating"),onactivate:focusIE("Activated"),ondeactivate:focusIE("Deactivated")};var activeElements={},blurFlag;function focusemu(event){try{if(AW.opera && event.srcElement===document.body){return}if(AW.opera && event.srcElement===document){return}if(AW.gecko && event.target===document && event.type){return bluremu(event)}blurFlag=false;if(AW.lockFocus){return}var e=event.target;var prevFocus=AW._focus;AW._focus=e.id;var obj,a={};while(e){if(e.id && typeof(e.id)=="string"){obj=AW.object(e.id,true);if(obj && obj.setController && !obj.getControlDisabled()){e=obj.element();a[e.id]=true}}e=e.parentNode}function raiseEvents(a1,a2,name,state){var i,obj,x={};for(i in a1){if(!a2[i] && !x[i]){obj=AW.object(i);if(obj && obj.setController){if(state !==undefined){obj.$active=state}if(raiseControlEvent(name,obj,event)){return true}}}}}obj=AW._focus && AW.object(AW._focus,true);if(AW._edit &&(!obj ||(obj && obj.getId()!=AW._edit))&& !AW._endEdit()){AW.element(prevFocus).focus();return true}if(raiseEvents(activeElements,a,"Deactivating")){AW.element(prevFocus).focus();return}if(raiseEvents(a,activeElements,"Activating")){AW.element(AW._focus).blur();return}raiseEvents(activeElements,a,"Deactivated",false);raiseEvents(a,activeElements,"Activated",true);activeElements=a}catch(err){}}function bluremu(event){if(AW.opera && event.srcElement===document.body){return}if(AW.opera && event.srcElement===document){return}blurFlag=true;window.setTimeout(function(){window.setTimeout(function(){if(blurFlag){focusemu({target:document})}},0)},0)}function mousewheelemu(event){try{var e=event.target;while(e){if(e.getAttribute && e.getAttribute("onDOMMouseScroll")){return AW(e,event)}e=e.parentNode}e=null}catch(err){}}function scrollemu(event){try{var e=event.target;if(e.getAttribute && e.getAttribute("onscroll")){return AW(e,event)}e=null}catch(err){}}AW.register=function(win){if(win !==window){win.AW=AW;AW.docs.push(win.document)}var target=AW.ie?win.document.documentElement:win.document;AW.forEach(handlers,function(name,handler){AW.attachEvent(target,name,handler)});if(!AW.ie){target.addEventListener("focus",focusemu,true)}if(AW.webkit || AW.opera || AW.konqueror){target.addEventListener("blur",bluremu,true)}if(AW.gecko){target.addEventListener("DOMMouseScroll",mousewheelemu,true)}if(AW.konqueror){target.addEventListener("scroll",scrollemu,true)}function unregister(){AW.unregister(win);AW.detachEvent(win,"onunload",unregister);win=null}AW.attachEvent(win,"onunload",unregister)};AW.unregister=function(win){var target=AW.ie?win.document.documentElement:win.document;AW.forEach(handlers,function(name,handler){AW.detachEvent(target,name,handler)});if(!AW.ie){target.removeEventListener("focus",focusemu,true)}if(AW.webkit || AW.opera || AW.konqueror){target.removeEventListener("blur",bluremu,true)}if(AW.gecko){target.removeEventListener("DOMMouseScroll",mousewheelemu,true)}if(AW.konqueror){target.removeEventListener("scroll",scrollemu,true)}if(win !=window){var i,docs=AW.docs;for(i=0;i<docs.length;i++){if(docs[i]===win.document){docs.splice(i,1);return}}win.AW=null}};AW.register(window)}})();
(function(){var obj;var originalText;var originalNode;AW._startEdit=function(target,startText){obj=target;if(!obj.element()|| raiseEvent("editStarting")){return false}originalText=obj.getControlProperty("text");obj.element().className+=" aw-edit-"+(obj.setController?"control":obj.$name);var e=obj.getContent("box/text").element();if(!e || !e.tagName.match(/input/i)){originalNode=e;e=document.createElement("input");e.setAttribute("id",originalNode?originalNode.id:obj.getId()+"-box-edit");e.setAttribute("type","text");e.setAttribute("class",originalNode?originalNode.className:"aw-item-text");e.setAttribute("autocomplete","off");e.setAttribute("value",originalText);e.style.width=calcWidth(originalNode);if(originalNode){if(AW.ie){originalNode.parentNode.insertBefore(e,originalNode);e.focus();e.parentNode.removeChild(originalNode)}else{originalNode.parentNode.replaceChild(e,originalNode);e.focus()}}else{var parent=obj.element();parent.innerHTML="<span class=\"aw-item-ruler\"></span>";parent.appendChild(e);e.focus()}e.parentNode.scrollTop=0}if(AW.ie){if(!AW.ms8){e.setExpression("aw-value","this.value")}e.attachEvent("oncontextmenu",nobubble);e.attachEvent("onselectstart",nobubble);e.attachEvent("onpropertychange",oninput);e.attachEvent("onkeydown",onkeydown);e.attachEvent("onbeforedeactivate",onbeforedeactivate)}else{e.addEventListener("contextmenu",nobubble,false);e.addEventListener("input",oninput,false);e.addEventListener("keydown",onkeydown,false);obj.element().addEventListener("mousedown",onmousedown,true)}if(obj.$owner){obj.$owner.$edit=true}AW._edit=obj.getId();raiseEvent("editStarted");if(typeof(startText)=="string"){obj.setControlProperty("text",startText);e.value=startText}else{e.select()}e=null;return true};AW._endEdit=function(){if(AW._endEditFlag){return false}AW._endEditFlag=true;try{if(originalText !=obj.getControlProperty("text")&& !AW._commitEdit()){return false}if(raiseEvent("editEnding")){return false}if(AW.$popup){AW.$popup.hidePopup()}var e=obj.element().getElementsByTagName("INPUT")[0];if(AW.ie){if(!AW.ms8){e.removeExpression("aw-value")}e.detachEvent("onselectstart",nobubble);e.detachEvent("oncontextmenu",nobubble);e.detachEvent("onpropertychange",oninput);e.detachEvent("onkeydown",onkeydown);e.detachEvent("onbeforedeactivate",onbeforedeactivate)}else{e.removeEventListener("contextmenu",nobubble,false);e.removeEventListener("input",oninput,false);e.removeEventListener("keydown",onkeydown,false);obj.element().removeEventListener("mousedown",onmousedown,true)}e.parentNode.scrollLeft=0;var text=obj.getControlProperty("text");if(originalNode){originalNode.innerHTML=text;if(AW.ie){e.parentNode.insertBefore(originalNode,e);removeElement(e)}else{e.parentNode.replaceChild(originalNode,e)}originalNode=null}else if(!obj.getContent("box/text").element()){if(AW.ie){e.parentNode.removeChild(e.previousSibling);e.insertAdjacentHTML("beforeBegin",text);removeElement(e)}else{e.parentNode.innerHTML=text}}e=null;obj.element().className=obj.element().className.replace(/ aw-edit-\w+/ig,"");if(obj.$owner){obj.$owner.$edit=false}AW._edit="";raiseEvent("editEnded");return true}finally{AW._endEditFlag=false}};AW._commitEdit=function(){if(!AW._edit){return false}if(raiseEvent("validating")){return false}originalText=obj.getControlProperty("text");raiseEvent("validated");return true};AW._cancelEdit=function(){if(!AW._edit){return false}obj.setControlProperty("text",originalText);obj.element().getElementsByTagName("INPUT")[0].value=originalText;return true};AW._updateEdit=function(){obj.refreshClasses();obj.element().className+=" aw-edit-"+obj.$name;var e=obj.element().getElementsByTagName("INPUT")[0];var text=obj.getControlProperty("text");if(e && e.value !=text){if(AW.ie){var r=document.selection.createRange();r.collapse();r.select()}e.value=text}e=null};function raiseEvent(name){var item=obj.setController?"control":obj.$name;var fullname=AW.camelCase("on",item,name);var text=obj.getControlProperty("text");return obj.raiseEvent(fullname,text,obj.$0,obj.$1,obj.$2)}function nobubble(event){if(AW.ie){event.cancelBubble=true}else{event.stopPropagation()}}function oninput(event){var text1=obj.getControlProperty("text");var text2=(event.srcElement||event.target).value;if(text2 !=text1){obj.setControlProperty("text",text2)}var text3=obj.getControlProperty("text");if(text3 !=text2){(event.srcElement||event.target).value=text3}}function onkeydown(event){if(AW.ie){var r=event.srcElement.createTextRange();var s=document.selection.createRange();if((event.keyCode==36 || event.keyCode==37)&&(r.compareEndPoints("StartToEnd",s)||r.compareEndPoints("StartToStart",s))){event.cancelBubble=true;r=null;s=null;return}if((event.keyCode==35 || event.keyCode==39)&&(r.compareEndPoints("EndToEnd",s)|| r.compareEndPoints("EndToStart",s))){event.cancelBubble=true;r=null;s=null;return}}else{if((event.keyCode==36 || event.keyCode==37)&& event.target.selectionEnd > 0){event.stopPropagation();return}if((event.keyCode==35 || event.keyCode==39)&& event.target.selectionStart < event.target.value.length){event.stopPropagation();return}}}function onbeforedeactivate(event){if(obj.element().contains(event.toElement)){event.returnValue=false;event.cancelBubble=true}}function onmousedown(event){if(event.target && event.target.tagName !="INPUT"){event.preventDefault();return}}function calcWidth(e){if(!e){return "100%"}var w=e.offsetWidth+e.parentNode.clientWidth - 5;var i,ee=e.parentNode.childNodes;for(i=0;i<ee.length;i++){w -=(ee[i].offsetWidth+1)}return w+"px"}function removeElement(node){document.selection.empty();node.id="aw-edit";window.setTimeout(function(){try{node.parentElement.removeChild(node)}catch(err){}node=null},0)}})();
 AW.System.Object=function(){};AW.System.Object.subclass=function(){var create=function(cls){cls.created=true;if(cls.superclass && !cls.superclass.created){create(cls.superclass)}cls.create()};var constructor=function(){if(constructor.defer){return}if(!constructor.created){create(constructor)}if(this.init){this.init.apply(this,arguments)}};for(var i in this){constructor[i]=this[i]}this.defer=true;constructor.prototype=new this();this.defer=false;constructor.prototype.constructor=constructor;constructor.superclass=this;constructor.created=false;return constructor};AW.System.Object.handle=function(error){throw(error);};AW.System.Object.create=function(){var obj=this.prototype;obj.clone=function(){if(this._clone.prototype!==this){this._clone=function(){this.init()};this._clone.prototype=this}return new this._clone()};obj._clone=function(){};obj.init=function(){};obj.handle=function(error){throw(error);};obj.setTimeout=function(handler,delay){var self=this;var wrapper=function(){handler.call(self)};return window.setTimeout(wrapper,delay?delay:0)};obj.timeout=obj.setTimeout;obj.toString=function(){return ""}};AW.System.Object.create();
 AW.System.Model=AW.System.Object.subclass();AW.System.Model.create=function(){var obj=this.prototype;var join=function(){var i,s=arguments[0];for(i=1;i<arguments.length;i++){s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1)}return s};obj.defineProperty=function(name,value){var _getProperty=join("get",name);var _setProperty=join("set",name);var _property="_"+name;var getProperty=function(){return this[_property]};this[_setProperty]=function(value){if(typeof value=="function"){this[_getProperty]=value}else{this[_getProperty]=getProperty;this[_property]=value}};this[_setProperty](value)};var get={};var set={};obj.getProperty=function(name,a,b,c){if(!get[name]){get[name]=join("get",name)}return this[get[name]](a,b,c)};obj.setProperty=function(name,value,a,b,c){if(!set[name]){set[name]=join("set",name)}return this[set[name]](value,a,b,c)};obj.isReady=function(){return true}};
 AW.System.Format=AW.System.Object.subclass();AW.System.Format.create=function(){var obj=this.prototype;obj.valueToText=function(value){return value};obj.dataToValue=function(data){return data};obj.dataToText=function(data){var value=this.dataToValue(data);return this.valueToText(value)};obj.setErrorText=function(text){this._textError=text};obj.setErrorValue=function(value){this._valueError=value};obj.setErrorText("#ERR");obj.setErrorValue(NaN);obj.textToValue=function(text){return text};obj.textToData=function(text){return text};obj.valueToData=function(value){return value};obj.comparator=function(values,greater,less,equal,error){return function(i,j){try{var a=values[i];var b=values[j];if(a > b){return greater}if(a < b){return less}return equal(i,j)}catch(e){return error(i,j,e)}}}};
 AW.System.HTML=AW.System.Object.subclass();AW.System.HTML.create=function(){var obj=this.prototype;obj.setTag=function(tag){this._tag=tag;resetHTMLCache(this)};obj.getTag=function(){return this._tag};obj._tag="span";obj.init=function(){if(this.$owner){return}if(this._parent){return}this._id="aw"+AW.all.id++;AW.all[this._id]=this};obj.getId=function(){return this._id};obj._id="";obj.setId=function(id){AW.all[this._id]=null;this._id=id;AW.all[this._id]=this;resetHTMLCache(this)};obj.element=function(){var i,docs=AW.docs,id=this.getId(),e;if(!id){return}for(i=0;i<docs.length;i++){e=docs[i].getElementById(id);if(e){return e}}};obj.getClass=function(name){var param="_"+name+"Class";var value=this[param];return typeof(value)=="function"?value.call(getParent(this)):value};obj.setClass=function(name,value){var element=this.element();if(element){var v=(typeof(value)=="function")?value.call(getParent(this)):value;var s=v || v===0 || v===false?" aw-"+name+"-"+v+" ":" ";element.className=element.className.replace(new RegExp("(aw-"+name+"-\\w* *| *$)","g"),"")+s}var param="_"+name+"Class";if(this[param]==null){this._classes+=" "+name}this[param]=value;resetHTMLCache(this)};function resetHTMLCache(obj){obj._outerHTML="";while(obj._parent){obj=obj._parent;obj._innerHTML="";obj._outerHTML=""}if(obj.lock){obj.lock()}}obj.refreshClasses=function(){var element=this.element();if(!element){return}var i,name,value,s="";var classes=this._classes.split(" ");for(i=1;i<classes.length;i++){name=classes[i];value=this["_"+name+"Class"];if(typeof(value)=="function"){value=value.call(getParent(this))}if(value || value===0 || value===false){s+="aw-"+name+"-"+value+" "}}element.className=s};obj._classes="";obj.getStyle=function(name){var param="_"+name+"Style";var value=this[param];return typeof(value)=="function"?value.call(getParent(this)):value};obj.setStyle=function(name,value){var param="_"+name+"Style";if(this[param]==null){this._styles+=" "+name}this[param]=value;resetHTMLCache(this);var element=this.element();if(element){if(!styleNames[name]){styleNames[name]=AW.camelCase.apply(AW,name.split("-"))}if(typeof(value)=="function"){value=value.call(getParent(this))}element.style[styleNames[name]]=value}};obj.refreshStyles=function(){var element=this.element();if(!element){return}var i,name,value;var styles=this._styles.split(" ");for(i=1;i<styles.length;i++){name=styles[i];value=this["_"+name+"Style"];if(typeof(value)=="function"){value=value.call(getParent(this));element.style[styleNames[name]]=value}}};obj._styles="";var styleNames={};obj.getAttribute=function(name){try{var param="_"+name+"Attribute";var value=this[param];return typeof(value)=="function"?value.call(getParent(this)):value}catch(error){this.handle(error)}};obj.setAttribute=function(name,value){try{var param="_"+name+"Attribute";if(typeof this[param]=="undefined"){this._attributes+=" "+name}if(specialAttributes[name] &&(typeof value=="function")){this[param]=function(){return value.call(this._parent?getParent(this):this)?true:null}}else{this[param]=value}resetHTMLCache(this);var element=this.element();if(element){if(typeof(value)=="function"){value=value.call(getParent(this))}if(specialAttributes[name] && !value){element.removeAttribute(name)}else{element.setAttribute(name,value)}}}catch(error){this.handle(error)}};obj.refreshAttributes=function(){var element=this.element();if(!element){return}var i,name,value;var attributes=this._attributes.split(" ");for(i=1;i<attributes.length;i++){name=attributes[i];value=this["_"+name+"Attribute"];if(typeof(value)=="function"){value=value.call(getParent(this));if(specialAttributes[name] && !value){element.removeAttribute(name)}else{element.setAttribute(name,value)}}}};obj._attributes="";var specialAttributes={checked:true,disabled:true,hidefocus:true,readonly:true};obj.getEvent=function(name){try{var param="_"+name+"Event";var value=this[param];return value}catch(error){this.handle(error)}};obj.setEvent=function(name,value){try{var param="_"+name+"Event";if(this[param]==null){this._events+=" "+name}this[param]=value;resetHTMLCache(this)}catch(error){this.handle(error)}};obj._events="";obj.getContent=function(name){try{var split=name.match(/^(\w+)\W(.+)$/);if(split){var ref=this.getContent(split[1]);return ref.getContent(split[2])}else{var param="_"+name+"Content";var value=this[param];if((typeof value=="object")&&(value._parent !=this)){value=value.clone();value._parent=this;this[param]=value}if(value && typeof value=="object" && !value.defineModel){value._id=this._id+"-"+name}if(typeof(value)=="function"){value=value.call(getParent(this))}return value}}catch(error){this.handle(error)}};obj.setContent=function(name,value){try{if(arguments.length==1){this._content="";if(typeof name=="object"){for(var i in name){if(typeof(i)=="string"){this.setContent(i,name[i])}}}else{this.setContent("html",name)}}else{var split=name.match(/^(\w+)\W(.+)$/);if(split){var ref=this.getContent(split[1]);ref.setContent(split[2],value)}else{var param="_"+name+"Content";if(this[param]==null){this._content+=" "+name}if(value && typeof value=="object"){value._parent=this;if(!value.defineModel){value._id=this._id+"-"+name}}this[param]=value;this._innerHTML="";resetHTMLCache(this)}}}catch(error){this.handle(error)}};obj.refreshContents=function(){try{var element=this.element();if(!element || element.tagName.match(/input|textarea/i)){return}if(AW._edit && AW.contains(element,AW.element(AW._edit))){return}var i,s="",content=this._content.split(" ");for(i=1;i<content.length;i++){s+=this.getContent(content[i])}try{var focus=AW.element(AW._focus)}catch(err){}element.innerHTML=s;try{if(focus !==AW.element(AW._focus)){AW.element(AW._focus).focus()}}catch(err){}}catch(error){this.handle(error)}};obj._content="";var getParamStr=function(i){return "{#"+i+"}"};var getControlFunc=function(v){return function(){return v}};obj.innerHTML=function(){try{if(this._innerHTML){return this._innerHTML}this._innerParamLength=0;var i,j,name,value,param,param1,param2,html,item,s="";var content=this._content.split(" ");for(i=1;i<content.length;i++){name=content[i];value=this["_"+name+"Content"];if(typeof(value)=="function"){param=getParamStr(this._innerParamLength++);this[param]=value;s+=param}else if(typeof(value)=="object" && value.defineModel){param=getParamStr(this._innerParamLength++);this[param]=getControlFunc(value);s+=param}else if(typeof(value)=="object"){item=value;html=item.outerHTML().replace(/\{id\}/g,"{id}-"+name);for(j=item._outerParamLength-1;j>=0;j--){param1=getParamStr(j);param2=getParamStr(this._innerParamLength+j);if(param1 !=param2){html=html.replace(param1,param2)}this[param2]=item[param1]}this._innerParamLength+=item._outerParamLength;s+=html}else{s+=value}}this._innerHTML=s;return s}catch(error){this.handle(error)}};obj.outerHTML=function(){try{if(this._outerHTML){return this._outerHTML}var innerHTML=this.innerHTML();this._outerParamLength=this._innerParamLength;if(!this._tag){return innerHTML}var i,tmp,name,value,param;var html="<"+this._tag+" id=\"{id}\"";tmp="";var classes=this._classes.split(" ");for(i=1;i<classes.length;i++){name=classes[i];value=this["_"+name+"Class"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param}if(value || value===0 || value===false){tmp+="aw-"+name+"-"+value+" "}}if(tmp){html+=" class=\""+tmp+"\""}tmp="";var styles=this._styles.split(" ");for(i=1;i<styles.length;i++){name=styles[i];value=this["_"+name+"Style"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param}tmp+=name+":"+value+";"}if(tmp){html+=" style=\""+tmp+"\""}tmp="";var attributes=this._attributes.split(" ");for(i=1;i<attributes.length;i++){name=attributes[i];value=this["_"+name+"Attribute"];if(typeof(value)=="function"){param=getParamStr(this._outerParamLength++);this[param]=value;value=param}else if(specialAttributes[name] && !value){value=null}if(value !==null){tmp+=" "+name+"=\""+value+"\""}}html+=tmp;tmp="";var events=this._events.split(" ");for(i=1;i<events.length;i++){name=events[i];value=this["_"+name+"Event"];if(typeof(value)=="function"){value="AW(this,event)"}tmp+=" "+name+"=\""+value+"\""}html+=tmp;html+=">"+innerHTML+"</"+this._tag+">";this._outerHTML=html;return html}catch(error){this.handle(error)}};obj.toString=function(){try{var i,s=this._outerHTML;if(!s){s=this.outerHTML()}s=s.replace(id_pattern,this._id);var max=this._outerParamLength;if(param_cache.length < max){for(i=param_cache.length;i<max;i++){param_cache[i]=getParamStr(i)}}for(i=0;i<max;i++){var param=param_cache[i];var value=this._parent?this[param].call(getParent(this)):this[param]();if(value===null){value="";param=specialParams[i];if(!param){param=getSpecialParamStr(i)}}s=s.replace(param,value)}return s}catch(error){this.handle(error)}};var id_pattern=/\{id\}/g;var param_cache=[];var specialParams=[];function getSpecialParamStr(i){return(specialParams[i]=new RegExp("[\\w\\x2D]*=?:?\\x22?\\{#"+i+"\\}[;\\x22]?"))}function getParent(obj){while(obj){if(!obj._parent || obj.defineModel){return obj}obj=obj._parent}}obj.refresh=function(){try{var element=this.element();if(element){if(AW._edit && AW.contains(element,AW.element(AW._edit))){return}try{var focus=AW.element(AW._focus)}catch(err){}AW.setOuterHTML(element,this.toString());try{if(focus !==AW.element(AW._focus)){AW.element(AW._focus).focus()}}catch(err){}}}catch(error){this.handle(error)}};obj.setSize=function(width,height){if(typeof(width)!="undefined"){this.setStyle("width",width - AW.dx+"px")}if(typeof(height)!="undefined"){this.setStyle("height",height - AW.dy+"px")}};obj.setPosition=function(left,top){this.setStyle("position","absolute");if(typeof(left)!="undefined"){this.setStyle("left",left+"px")}if(typeof(top)!="undefined"){this.setStyle("top",top+"px")}};var errors={101:"non-supported doctype",102:"non-supported browser",103:"non-supported browser"};function hte(i){return function(){return "AW Error:<a href=\"http:\/\/www.activewidgets.com/error."+i+"/\">"+errors[i]+"</a>"}}};
 AW.System.Template=AW.System.HTML.subclass();AW.System.Template.create=function(){var obj=this.prototype;obj.lock=function(){if(!this.$owner){return}this.$owner[AW.camelCase("set",this.$name)](this,this.$0,this.$1,this.$2)};obj.getTemplate=function(name){var i,args=[],get=AW.camelCase("get",name);for(i=1;i<arguments.length;i++){args[i-1]=arguments[i]}return this[get].apply(this,args)};obj.setTemplate=function(name,template,index){var set=AW.camelCase("set",name);this[set](template,index)};obj.raiseEvent=function(name,source,a,b,c){if(typeof source=="undefined"){source=this;a=this.$0;b=this.$1;c=this.$2}var handler=this[name];if(typeof(handler)=="function"){var r=handler.call(this,source,a,b,c);if(r){return r}}if(this.$owner && this.$owner.raiseEvent){return this.$owner.raiseEvent(name,source,a,b,c)}};obj.action=function(name,source,a,b,c){this.raiseEvent(AW.camelCase("on",name),source,a,b,c)};obj.mapTemplate=function(source,target){var get=AW.camelCase("get",source);var get1=AW.camelCase("get",source,"template");if(typeof(target)=="function"){this[get]=target;this[get1]=target}else{var u,m=AW.camelCase("get",target);this[get]=function(a,b,c){if(a===u){return this.$owner[m](this.$0,this.$1,this.$2)}if(b===u){return this.$owner[m](a,this.$0,this.$1)}if(c===u){return this.$owner[m](a,b,this.$0)}return this.$owner[m](a,b,c)};this[get1]=this[get]}this.lock()};obj.mapModel=function(source,target,target2){var get=AW.camelCase("get",source,"property");var set=AW.camelCase("set",source,"property");if(typeof(target)=="function"){this[get]=target;if(typeof(target2)=="function"){this[set]=target2}else{this[set]=function(){}}}else{var _get=AW.camelCase("get",target,"property");var _set=AW.camelCase("set",target,"property");var u;this[get]=function(p,a,b,c){if(a===u){return this.$owner[_get](p,this.$0,this.$1,this.$2)}if(b===u){return this.$owner[_get](p,a,this.$0,this.$1)}if(c===u){return this.$owner[_get](p,a,b,this.$0)}return this.$owner[_get](p,a,b,c)};this[set]=function(p,v,a,b,c){if(a===u){return this.$owner[_set](p,v,this.$0,this.$1,this.$2)}if(b===u){return this.$owner[_set](p,v,a,this.$0,this.$1)}if(c===u){return this.$owner[_set](p,v,a,b,this.$0)}return this.$owner[_set](p,v,a,b,c)}}this.lock()}};
 AW.System.Control=AW.System.HTML.subclass();AW.System.Control.create=function(){AW.System.Template.create.call(this);var obj=this.prototype;var templates=AW.System.Template.prototype;obj.setTag("span");obj.setClass("system","control");obj.setAttribute("tabIndex","-1");obj.setAttribute("hideFocus","true");obj.setEvent("oncontextmenu","return false");obj.setEvent("onselectstart","return false");obj.clear=function(){};obj.mapTemplate=function(){};obj.mapModel=function(){};obj.getModel=function(name){var getModel=AW.camelCase("get",name,"model");return this[getModel]()};obj.setModel=function(name,model){var setModel=AW.camelCase("set",name,"model");return this[setModel](model)};obj.defineModel=function(m,z){var ext="_"+m+"Model";var defineProperty=AW.camelCase("define",m,"property");var getProperty=AW.camelCase("get",m,"property");var setProperty=AW.camelCase("set",m,"property");var getModel=AW.camelCase("get",m,"model");var setModel=AW.camelCase("set",m,"model");var clearModel=AW.camelCase("clear",m,"model");var getInt={};var setInt={};var getExt={};var setExt={};var changing={};var changed={};var error={};var undef;this[defineProperty]=function(p,v,arrayValue){var _p="_"+AW.camelCase(m,p);var _p1=_p+"1";var _p2=_p+"2";var _p3=_p+"3";var _x2=_p+"2x";var get=(getInt[p]=AW.camelCase("get",m,p));var set=(setInt[p]=AW.camelCase("set",m,p));var $get=(getExt[p]=AW.camelCase("get",p));var $set=(setExt[p]=AW.camelCase("set",p));var _changing=(changing[p]=AW.camelCase("on",m,p,"changing"));var _changed=(changed[p]=AW.camelCase("on",m,p,"changed"));var _error=(error[p]=AW.camelCase("on",m,p,"error"));this[get]=function(a,b,c){if(this[ext] && this[ext][$get]){return this[ext][$get](a,b,c)}var r;if(c !==undef && this[_p3] && this[_p3][c] && this[_p3][c][b] && this[_p3][c][b][a] !==undef){r=this[_p3][c][b][a]}else if(b !==undef &&(!this[_x2] || !this[_x2][a] || this[_x2][a][b])&& this[_p2] && this[_p2][b] && this[_p2][b][a] !==undef){r=this[_p2][b][a]}else if(a !==undef && this[_p1] && this[_p1][a] !==undef){r=this[_p1][a]}else{r=this[_p]}return(typeof(r)=="function")?r.call(this,a,b,c):r};function isArray(a){return a && typeof(a)=="object" && !a.constructor.subclass && !arrayValue}var setProp=function(v,a,b,c){var i;if(isArray(v)){for(i in v){if(typeof(v[i])=="function"){continue}if(isArray(v[i])){this[_p2]=v;delete this[_p3];delete this[_x2];return}break}if(a !==undef){if(!this[_p2]){this[_p2]={}}this[_p2][a]=v;delete this[_p3]}else{this[_p1]=v;delete this[_p2];delete this[_p3];delete this[_x2]}return}if(c !==undef){if(!this[_p3]){this[_p3]={}}if(!this[_p3][c]){this[_p3][c]={}}if(!this[_p3][c][b]){this[_p3][c][b]={}}this[_p3][c][b][a]=v}else if(b !==undef){if(!this[_p2]){this[_p2]={}}if(!this[_p2][b]){this[_p2][b]={}}this[_p2][b][a]=v;if(this[_x2] && this[_x2][a]){this[_x2][a][b]=true}}else if(a !==undef){if(!this[_p1]){this[_p1]={$owner:this}}else if(this[_p1].$owner !=this){var r=this[_p1];this[_p1]={};for(i in r){this[_p1][i]=r[i]}this[_p1].$owner=this}this[_p1][a]=v;if(this[_p2]){if(!this[_x2]){this[_x2]={}}this[_x2][a]={}}}else{this[_p]=v;delete this[_p1];delete this[_p2];delete this[_p3];delete this[_x2]}};this[set]=function(v,a,b,c){if(this._groupUpdate){this._groupUpdate.push({f:setProp,e1:_changing,e2:_changed,v:v,a:a,b:b,c:c});return}if(this[ext] && this[ext][$set]){return this[ext][$set](v,a,b,c)}var r=this.raiseEvent(_changing,v,a,b,c);if(r){this.raiseEvent(_error,r,a,b,c);return false}setProp.call(this,v,a,b,c);this.raiseEvent(_changed,v,a,b,c);return true};setProp.call(this,v);var clearPrevious=this[clearModel];this[clearModel]=function(){delete this[_x2];delete this[_p3];delete this[_p2];delete this[_p1];delete this[_p];clearPrevious.call(this);setProp.call(this,v)}};this[getProperty]=function(p,a,b,c){try{if(this[ext] && this[ext][getExt[p]]){return this[ext][getExt[p]](a,b,c)}return this[getInt[p]](a,b,c)}catch(error){return this.handle(error)}};this[setProperty]=function(p,v,a,b,c){try{if(this[ext] && this[ext][setExt[p]]){return this[ext][setExt[p]](v,a,b,c)}return this[setInt[p]](v,a,b,c)}catch(error){return this.handle(error)}};templates[getProperty]=function(p,a,b,c){if(a===undef){return this.$owner[getProperty](p,this.$0,this.$1,this.$2)}if(b===undef){return this.$owner[getProperty](p,a,this.$0,this.$1)}if(c===undef){return this.$owner[getProperty](p,a,b,this.$0)}return this.$owner[getProperty](p,a,b,c)};templates[setProperty]=function(p,v,a,b,c){if(a===undef){return this.$owner[setProperty](p,v,this.$0,this.$1,this.$2)}if(b===undef){return this.$owner[setProperty](p,v,a,this.$0,this.$1)}if(c===undef){return this.$owner[setProperty](p,v,a,b,this.$0)}return this.$owner[setProperty](p,v,a,b,c)};this[getModel]=function(){return this[ext]};this[setModel]=function(model){this[ext]=model;if(model){model.$owner=this}};this[clearModel]=function(){if(this[ext] && this[ext].$owner){delete this[ext].$owner}delete this[ext]};var clear=this.clear;this.clear=function(){clear.call(this);this[clearModel]()};var i,zz={};for(i in z){if(!zz[i]){this[defineProperty](i,z[i])}}};obj._startUpdate=function(){this._groupUpdate=[]};obj._endUpdate=function(){var i,r,u=this._groupUpdate;this._groupUpdate=null;for(i=0;i<u.length;i++){r=u[i];this.raiseEvent(r.e1,r.v,r.a,r.b,r.c)}for(i=0;i<u.length;i++){r=u[i];r.f.call(this,r.v,r.a,r.b,r.c)}for(i=0;i<u.length;i++){r=u[i];this.raiseEvent(r.e2,r.v,r.a,r.b,r.c)}};obj.defineTemplate=function(name,template){var ref="_"+name+"Template";var ref1=ref+"1",ref2=ref+"2",ref3=ref+"3";var get=AW.camelCase("get",name);var set=AW.camelCase("set",name);var get1=AW.camelCase("get",name,"template");var set1=AW.camelCase("set",name,"template");var name1="-"+name;var name2="-"+name+"-";var undef;this[get]=function(a,b,c){var r,id,clone;if(a===undef){id=this._id+name1;r=this[ref]}else if(b===undef){id=this._id+name2+a;r=this[ref1] && this[ref1][a];if(!r){r=this[ref];clone=true}}else if(c===undef){id=this._id+name2+a+"-"+b;r=this[ref2] && this[ref2][a] && this[ref2][a][b];if(!r){r=(this[ref1] && this[ref1][a])|| this[ref];clone=true}}else{id=this._id+name2+a+"-"+b+"-"+c;r=this[ref3] && this[ref3][a] && this[ref3][a][b] && this[ref3][a][b][c];if(!r){r=(this[ref2] && this[ref2][a] && this[ref2][a][b])||(this[ref1] && this[ref1][a])|| this[ref];clone=true}}if(typeof(r)=="function"){return r.call(this,a,b,c)}if((this.$clone)&&(clone || r.$owner !=this)){r=r.clone()}r.$owner=this;r.$0=a;r.$1=b;r.$2=c;r._id=id;return r};templates[get]=function(a,b,c){if(a===undef){return this.$owner[get](this.$0,this.$1,this.$2)}if(b===undef){return this.$owner[get](a,this.$0,this.$1)}if(c===undef){return this.$owner[get](a,b,this.$0)}return this.$owner[get](a,b,c)};this[set]=function(template,a,b,c){var previous;if(a===undef){previous=this[ref];this[ref]=template}else if(b===undef){if(!this[ref1]){this[ref1]={}}previous=this[ref1][a];this[ref1][a]=template}else if(c===undef){if(!this[ref2]){this[ref2]={}}if(!this[ref2][a]){this[ref2][a]={}}previous=this[ref2][a][b];this[ref2][a][b]=template}else{if(!this[ref3]){this[ref3]={}}if(!this[ref3][a]){this[ref3][a]={}}if(!this[ref3][a][b]){this[ref3][a][b]={}}previous=this[ref3][a][b][c];this[ref3][a][b][c]=template}if(template){template.$name=name;template.$0=a;template.$1=b;template.$2=c;if(template.$owner !==this && template !==previous){template.$owner=this;this.raiseEvent(AW.camelCase("on",name,"templateChanged"),template,a,b,c)}}};this[set](template);this[get1]=this[get];this[set1]=this[set];templates[get1]=templates[get]};obj.$clone=true;function controlValue(){var text=this.getControlText();var format=this.getControlFormat();return format?format.textToValue(text):text}function controlData(){var value=this.getControlValue();var format=this.getControlFormat();return format?format.valueToData(value):value}obj.defineModel("tab",{index:0});obj.defineModel("control",{text:"",image:"",link:"",value:controlValue,data:controlData,format:"",tooltip:"",state:"",visible:true,disabled:false});obj.setControlSize=obj.setSize;obj.setControlPosition=obj.setPosition;obj.onControlVisibleChanged=function(value){this.setClass("visible",value)};obj.focus=function(){};obj.setName=function(name){var hidden=new AW.HTML.INPUT;hidden.setAttribute("type","hidden");hidden.setAttribute("name",name);hidden.setAttribute("value",function(){return AW.valueToText(this.getControlData())});this.setContent("data",hidden)};obj.setController=function(name,controller){var i,n="_"+name+"Controller";this[n]=controller;for(i=0;i<this._controllers.length;i++){if(this._controllers[i]==n){return}}this._controllers=this._controllers.concat();this._controllers.push(n)};obj._controllers=[];obj.raiseEvent=function(name,source,a,b,c){var i,r;var handler=this[name];if(typeof(handler)=="function"){r=handler.call(this,source,a,b,c);if(r){return r}}for(i=0;i<this._controllers.length;i++){handler=this[this._controllers[i]]?this[this._controllers[i]][name]:null;if(typeof(handler)=="function"){r=handler.call(this,source,a,b,c);if(r){return r}}else if(typeof(handler)=="string" && handler !=name){r=this.raiseEvent(handler,source,a,b,c);if(r){return r}}}};obj.action=function(name,source,a,b,c){this.raiseEvent(AW.camelCase("on",name),source,a,b,c)};obj.$active=false;AW._startEventManager()};
 AW.Formats.String=AW.System.Format.subclass();AW.Formats.String.create=function(){var obj=this.prototype;obj.valueToText=function(data){return data?String(data).replace(AW.textPattern,AW.textReplace):""};obj.textToValue=function(text){return text?String(text).replace(AW.htmlPattern,AW.htmlReplace):""};obj.dataToText=obj.valueToText;obj.textToData=obj.textToValue;if("".localeCompare){obj.comparator=function(values,greater,less,equal,error){return function(i,j){try{return greater *(""+values[i]).localeCompare(values[j])|| equal(i,j)}catch(e){return error(i,j,e)}}}}};
 AW.Formats.Number=AW.System.Format.subclass();AW.Formats.Number.create=function(){var obj=this.prototype;obj.dataToValue=function(v){return Number((""+v).replace(numPattern,""))};obj.textToValue=function(v){return Number((""+v).replace(numPattern,""))};var numPattern=/[^0-9.\-+]+/gm;var noFormat=function(value){return ""+value};var doFormat=function(value){var abs=(value<0)?-value:value;var rounded=value.toFixed(this._decimals);if(abs<1000){return rounded.replace(this.p1,this.r1)}if(abs<1000000){return rounded.replace(this.p2,this.r2)}if(abs<1000000000){return rounded.replace(this.p3,this.r3)}return rounded.replace(this.p4,this.r4)};obj.setTextFormat=function(format){var pattern=/^([^0#]*)([0#]*)([ .,]?)([0#]|[0#]{3})([.,])([0#]*)([^0#]*)$/;var f=format.replace(/\$/g,"$$$$").match(pattern);if(!f){this.valueToText=function(value){return ""+value};this.dataToText=function(value){return ""+value};return}this.valueToText=doFormat;this.dataToText=function(v){return doFormat.call(this,Number((""+v).replace(numPattern,"")))};var rs=f[1];var rg=f[3];var rd=f[5];var re=f[7];this._decimals=f[6].length;var ps="^(-?\\d+)",pm="(\\d{3})",pe="\\.(\\d{"+this._decimals+"})$";if(!this._decimals){pe="($)";rd=""}this.p1=new RegExp(ps+pe);this.p2=new RegExp(ps+pm+pe);this.p3=new RegExp(ps+pm+pm+pe);this.p4=new RegExp(ps+pm+pm+pm+pe);this.r1=rs+"$1"+rd+"$2"+re;this.r2=rs+"$1"+rg+"$2"+rd+"$3"+re;this.r3=rs+"$1"+rg+"$2"+rg+"$3"+rd+"$4"+re;this.r4=rs+"$1"+rg+"$2"+rg+"$3"+rg+"$4"+rd+"$5"+re};obj.setTextFormat("")};
 AW.Formats.Date=AW.System.Format.subclass();AW.Formats.Date.create=function(){var obj=this.prototype;obj.date=new Date();var shortMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var longMonths=["January","February","March","April","May","June","July","August","September","October","November","December"];var shortWeekdays=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var longWeekdays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];if(!obj.shortMonths){obj.shortMonths=shortMonths}if(!obj.longMonths){obj.longMonths=longMonths}if(!obj.shortWeekdays){obj.shortWeekdays=shortWeekdays}if(!obj.longWeekdays){obj.longWeekdays=longWeekdays}obj.digits=[];for(var i=0;i<100;i++){obj.digits[i]=i<10?"0"+i:""+i}var tokens={"hh":"this.digits[this.date.getUTCHours()]","h":"this.date.getUTCHours()",":mm":"':'+this.digits[this.date.getUTCMinutes()]","mm:":"this.digits[this.date.getUTCMinutes()]+':'","ss":"this.digits[this.date.getUTCSeconds()]","tt":"(this.date.getUTCHours()>11?'PM':'AM')","dddd":"this.longWeekdays[this.date.getUTCDay()]","ddd":"this.shortWeekdays[this.date.getUTCDay()]","dd":"this.digits[this.date.getUTCDate()]","d":"this.date.getUTCDate()","mmmm":"this.longMonths[this.date.getUTCMonth()]","mmm":"this.shortMonths[this.date.getUTCMonth()]","mm":"this.digits[this.date.getUTCMonth()+1]","m":"(this.date.getUTCMonth()+1)","yyyy":"this.date.getUTCFullYear()","yy":"this.digits[this.date.getUTCFullYear()%100]"};var tokens12={},match="";for(i in tokens){if(typeof(i)=="string"){tokens12[i]=tokens[i];match+="|"+i}}tokens12.hh="this.digits[1+(this.date.getUTCHours()+11)%12]";tokens12.h="(1+(this.date.getUTCHours()+11)%12)";var re=new RegExp(match.replace("|","(")+")","gi");var reverse={"hh":["(\\d{1,2})","a[3]=",";"],"h":["(\\d{1,2})","a[3]=",";"],":mm":[":(\\d{1,2})","a[4]=",";"],"mm:":["(\\d{1,2}):","a[4]=",";"],"ss":["(\\d{1,2})","a[5]=",";"],"tt":["(AM|PM)","a[3]=","=='AM'?a[3]%12:a[3]%12+12;"],"dd":["(\\d{1,2})","a[2]=",";"],"d":["(\\d{1,2})","a[2]=",";"],"mmmm":["([^\\s\\x2c-\\x2f\\x5c;]+)","a[1]=this.rMonths[",".toLowerCase()];"],"mmm":["([^\\s\\x2c-\\x2f\\x5c;]+)","a[1]=this.rMonths[",".toLowerCase()];"],"mm":["(\\d{1,2})","a[1]=Number(",")-1;"],"m":["(\\d{1,2})","a[1]=Number(",")-1;"],"yyyy":["(\\d{1,4})","a[0]=Number(",");if(a[0]<30){a[0]+=2000};"],"yy":["(\\d{1,4})","a[0]=Number(",");if(a[0]<30){a[0]+=2000};"]};var delim=/[\s\x2c-\x2f\x5c;]+/g;obj.setTextFormat=function(format){format=format.replace(/am\/pm/i,"tt");var tok=format.match("tt")?tokens12:tokens;var code=format.replace(re,function(i){return "'+"+tok[i.toLowerCase()]+"+'"});code="if(isNaN(value)||(value===this._valueError))return this._textError;"+"this.date.setTime(value+this._textTimezoneOffset);"+("return '"+code+"'").replace(/(''\+|\+'')/g,"");this.valueToText=new Function("value",code);var num=0;code="var a=[this._year,0,1];if(String(text).match(this._t2v)){\n";function item(i){i=i.toLowerCase();if(reverse[i]){code+=reverse[i][1]+"RegExp.$"+(++num)+reverse[i][2];return reverse[i][0]}else{return "\\w+"}}this._t2v=new RegExp(format.replace(delim,"[\\s\\x2c-\\x2f\\x5c;]+").replace(re,item));code+="\n return Date.UTC.apply(this,a)- this._textTimezoneOffset}else{return this._valueError}";this.textToValue=new Function("text",code);this.rMonths={};for(var m=0;m<12;m++){this.rMonths[m+1]=m;this.rMonths[this.digits[m+1]]=m;this.rMonths[shortMonths[m].toLowerCase()]=m;this.rMonths[longMonths[m].toLowerCase()]=m;this.rMonths[this.shortMonths[m].toLowerCase()]=m;this.rMonths[this.longMonths[m].toLowerCase()]=m}this._year=(new Date).getUTCFullYear()};var xmlExpr=/(\d\d\d\d)-(\d\d)-(\d\d)[T ]?(\d\d)?(:\d\d)?(:\d\d)?(\.\d+)?Z?([+-]\d\d)?:?(\d\d)?/;var xmlOut="$1/$2/$3 $4$5$6 GMT$8$9";var auto=function(data){var value=Date.parse(data+this._dataTimezoneCode);return isNaN(value)?this._valueError:value};var RFC822=function(data){var value=Date.parse(data);return isNaN(value)?this._valueError:value};var ISO8601=function(data){var value=Date.parse(data.replace(xmlExpr,xmlOut));return isNaN(value)?this._valueError:value};obj.setDataFormat=function(format){if(format=="RFC822" || format=="rfc822"){this.dataToValue=RFC822}else if(format=="ISO8601" || format=="iso8601" || format=="ISO8061"){this.dataToValue=ISO8601}else{this.dataToValue=auto}};obj.setTextTimezone=function(value){this._textTimezoneOffset=value};obj.setDataTimezone=function(value){if(!value){this._dataTimezoneCode=" GMT"}else{this._dataTimezoneCode=" GMT"+(value>0?"+":"-")+this.digits[Math.floor(Math.abs(value/3600000))]+this.digits[Math.abs(value/60000)%60]}};var localTimezone=- obj.date.getTimezoneOffset()* 60000;obj.setTextTimezone(localTimezone);obj.setDataTimezone(localTimezone);obj.setTextFormat("m/d/yyyy");obj.setDataFormat("default")};
 AW.Formats.HTML=AW.System.Format.subclass();AW.Formats.HTML.create=function(){var obj=this.prototype;obj.dataToValue=function(data){return data?data.replace(AW.htmlPattern,AW.htmlReplace):""};obj.dataToText=function(data){return data};obj.textToValue=obj.dataToValue;if("".localeCompare){obj.comparator=function(values,greater,less,equal,error){return function(i,j){try{return greater *(""+values[i]).localeCompare(values[j])|| equal(i,j)}catch(e){return error(i,j,e)}}}}};
 AW.HTML.define=function(name,tag,type){if(!tag){tag=name.toLowerCase()}AW.HTML[name]=AW.System.HTML.subclass();AW.HTML[name].create=function(){this.prototype.setTag(tag)}};(function(){var i,tags=["DIV","SPAN","IMG","INPUT","BUTTON","TEXTAREA","TABLE","TR","TD"];for(i=0;i<tags.length;i++){AW.HTML.define(tags[i])}})();
 AW.Templates.ImageText=AW.System.Template.subclass();AW.Templates.ImageText.create=function(){var obj=this.prototype;function _image(){return this.getControlProperty("image")|| "none"}function _text(){return this.getControlProperty("text")}function _tooltip(){return this.getControlProperty("tooltip")}var span=AW.HTML.SPAN;var image=new span;image.setClass("item","image");image.setClass("image",_image);var ruler=new span;ruler.setClass("item","ruler");var text=new span;text.setClass("item","text");text.setContent("html",_text);var box=new span;box.setClass("item","box");box.setContent("sign","");box.setContent("marker","");box.setContent("image",image);box.setContent("ruler",ruler);box.setContent("text",text);obj.setTag("span");obj.setClass("item","template");obj.setClass("templates","imagetext");obj.setAttribute("title",_tooltip);obj.setContent("box",box);obj.refresh=function(){this.refreshStyles();this.getContent("box/image").refreshClasses();if(AW._edit==this.getId()){AW._updateEdit()}else{this.refreshClasses();this.getContent("box/text").refreshContents()}};AW._addMouseEvents(obj);if(AW.gecko){obj.setAttribute("tabIndex","-1")}obj.startEdit=function(text){AW._startEdit(this,text)}};
 AW.Templates.Image=AW.Templates.ImageText.subclass();AW.Templates.Image.create=function(){var obj=this.prototype;obj.setClass("templates","image");obj.getContent("box").setTag("");obj.getContent("box/text").setTag("");obj.setContent("box/text/html","");obj.startEdit=null};
 AW.Templates.Text=AW.Templates.ImageText.subclass();AW.Templates.Text.create=function(){var obj=this.prototype;obj.setClass("templates","text");obj.getContent("box").setTag("");obj.getContent("box/image").setTag("")};
 AW.Templates.Link=AW.Templates.ImageText.subclass();AW.Templates.Link.create=function(){var obj=this.prototype;obj.setTag("a");obj.setClass("templates","link");obj.setAttribute("tabIndex","-1");obj.setAttribute("href",function(){return this.getControlProperty("link")|| null});obj.getContent("box").setTag("");obj.startEdit=null};
 AW.Templates.CheckBox=AW.Templates.ImageText.subclass();AW.Templates.CheckBox.create=function(){var obj=this.prototype;obj.setClass("value",function(){return this.getControlProperty("value")|| false});obj.setClass("toggle","checkbox");obj.setClass("templates","checkbox");var marker=new AW.HTML.SPAN;marker.setClass("item","marker");obj.setContent("box/marker",marker);obj.setEvent("onclick",function(){var value=this.getControlProperty("value");this.setControlProperty("value",!value)});obj.startEdit=null;AW._addMouseEvents(obj,"toggle")};AW.Templates.Checkbox=AW.Templates.CheckBox;
 AW.Templates.CheckedItem=AW.Templates.CheckBox.subclass();AW.Templates.CheckedItem.create=function(){var obj=this.prototype;obj.setClass("templates","checkeditem");obj.setClass("value",function(){return this.getStateProperty("selected")|| false});obj.setEvent("onclick",function(){var selected=this.getStateProperty("selected");this.setStateProperty("selected",!selected)})};
 AW.Templates.Radio=AW.Templates.CheckedItem.subclass();AW.Templates.Radio.create=function(){var obj=this.prototype;obj.setClass("toggle","radio");obj.setClass("templates","radio");obj.setEvent("onclick","")};
 AW.Templates.Popup=AW.System.Template.subclass();AW.Templates.Popup.create=function(){var obj=this.prototype;obj.setClass("popup","normal");obj.showPopup=function(){unregisterPopupDoc();var popup=window.createPopup();this.$popup=popup;AW.$popup=this;var doc=popup.document;doc.open();if(AW.strict){doc.write("<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\" \"http:\/\/www.w3.org/TR/html4/strict.dtd\">")}doc.write("<html class=\"aw-popup-window aw-system-control "+AW._htmlClasses+" aw-popup-"+AW.theme+"\"><head>");AW.register(doc.parentWindow);for(var i=0;i<document.styleSheets.length;i++){doc.write(document.styleSheets[i].owningElement.outerHTML)}doc.write("</head><body onselectstart=\"return false\" oncontextmenu=\"return false\">");doc.write(this.getPopup().toString());doc.write("</body></html>");doc.close();var ref=this.element();var left=0;var top=ref.offsetHeight;var width=ref.offsetWidth;var height=1;popup.show(left,top,width,height,ref);function resizePopup(){try{if(popup.isOpen){var e=doc.body.firstChild;width=e.offsetWidth;height=e.offsetHeight;if(!width || !height){return this.setTimeout(resizePopup,100)}popup.show(left,top,width,height,ref)}ref=null;popup=null;doc=null}catch(err){}}this.setTimeout(resizePopup)};obj.hidePopup=function(){unregisterPopupDoc();if(this.$popup){this.$popup=null}if(AW.$popup){AW.$popup=null}};function unregisterPopupDoc(){try{if(AW.$popup){var popup=AW.$popup.$popup;if(popup && popup.isOpen){popup.hide()}if(popup){var i,docs=AW.docs;for(i=0;i<docs.length;i++){if(docs[i].body==popup.document.body){docs.splice(i,1);break}}}}}catch(err){}}if(!AW.ie){function onmousedown(event){if(event.target){event.preventDefault();return}}obj.showPopup=function(){if(this.$popup){document.body.removeChild(this.$popup);this.$popup=null}var ref=this.element()?this.element():document.body;var left=AW.getLeft(ref);var top=AW.getTop(ref)+ref.offsetHeight;var popup=document.createElement("div");this.$popup=popup;AW.$popup=this;document.body.appendChild(popup);popup.className="aw-popup-window aw-system-control";popup.style.left=left+"px";popup.style.top=top+"px";popup.innerHTML=this.getPopup().toString();popup.addEventListener("mousedown",onmousedown,true)};obj.hidePopup=function(){if(this.$popup){this.$popup.removeEventListener("mousedown",onmousedown,true);this.setTimeout(function(){if(this.$popup){document.body.removeChild(this.$popup);this.$popup=null;AW.$popup=null}})}};obj.onControlDeactivated=function(){this.hidePopup()}}};
 AW.Templates.Frame=AW.System.Template.subclass();AW.Templates.Frame.create=function(){var obj=this.prototype;obj.setClass("frame","template");obj.setClass("flow","vertical");obj.setClass("text","normal");var box=new AW.HTML.SPAN;box.setClass("frame","box");box.setClass("list","box");if(AW.ie && AW.strict){box.setStyle("width","expression(this.parentElement.offsetWidth-4)")}box.setContent("html",function(){return this.getLayout()});obj.setContent("box",box)};
 AW.Templates.List=AW.System.Template.subclass();AW.Templates.List.create=function(){var obj=this.prototype;obj.setTag("span");obj.setClass("templates","list");obj.setContent("start","");obj.setContent("items",function(){var i,ii,a=[];var count=this.getViewProperty("count");var offset=this.getViewProperty("offset");var indices=this.getViewProperty("indices");var clone=this.$owner.$clone;this.$owner.$clone=false;for(i=0;i<count;i++){ii=indices?indices[i+offset]:i+offset;a[i]=this.getItem(ii).toString()}this.$owner.$clone=clone;return a.join("")});obj.setContent("end","")};
 AW.Templates.Input=AW.Templates.ImageText.subclass();AW.Templates.Input.create=function(){var obj=this.prototype;obj.setClass("templates","input");obj.setClass("input","box")};
 AW.Templates.Combo=AW.Templates.ImageText.subclass();AW.Templates.Combo.create=function(){AW.Templates.Popup.create.call(this);var obj=this.prototype;obj.setClass("templates","combo");obj.setClass("combo","box");var button=new AW.HTML.TABLE;button.setClass("combo","button");button.setAttribute("cellspacing","0");button.setEvent("onclick",function(event){if((!this.$owner && !this.$active)||(this.$owner && !this.$owner.$active)){return}if(this.$owner && this.$name=="cell"){this.$owner.startCellEdit()}this.showPopup()});obj.setContent("box/sign",button);obj.setContent("box/sign/html","<tr class=\"aw-cb-1\"><td></td></tr><tr class=\"aw-cb-2\"><td>&nbsp;</td></tr><tr class=\"aw-cb-3\"><td></td></tr>");AW._addMouseEvents(obj,"combo")};
 AW.Templates.Cell=AW.Templates.ImageText.subclass();AW.Templates.Cell.create=function(){var obj=this.prototype;obj.setClass("templates","cell");obj.getContent("box").setTag("");obj.getContent("box/image").setTag("");obj.getContent("box/ruler").setTag("");obj.getContent("box/text").setTag("");obj.refresh=function(){if(AW._edit==this.getId()){AW._updateEdit()}else{this.refreshClasses();this.refreshContents()}}};AW.Templates.HTML=AW.Templates.Cell;
 AW.Scroll.Bars=AW.System.Template.subclass();AW.Scroll.Bars.create=function(){var obj=this.prototype;obj.setClass("scroll","bars");obj.setClass("scrollbars","both");var span=AW.HTML.SPAN;var box=new span;var spacer=new span;var content=new span;if(AW.gecko){box.setAttribute("tabIndex","-1");content.setAttribute("tabIndex","-1")}box.setClass("bars","box");spacer.setClass("bars","spacer");content.setClass("bars","content");obj.setContent("box",box);obj.setContent("box/spacer",spacer);obj.setContent("content",content);obj.setContent("content/html",function(){this.lock();this._initialized=false;this.setTimeout(function(){this._initialized=true},1000);return this.getView()});var serial=0;obj.setEvent("onresize",function(){if(!this._initialized){return}serial=(serial+1)% 1000;var s=serial;this.setTimeout(function(){if(s==serial){if(this.element()){var w=this.element().offsetWidth;if(w !=this.getContentProperty("width","total")){this.setContentProperty("width",w,"total")}var h=this.element().offsetHeight;if(h !=this.getContentProperty("height","total")){this.setContentProperty("height",h,"total")}}}})});box.setEvent("onscroll",function(){if(!this._initialized){return}var e=this.getContent("box").element();var left=this.getScrollProperty("left");var top=this.getScrollProperty("top");if(e.scrollLeft !=left){this.setScrollProperty("left",e.scrollLeft)}if(e.scrollTop !=top){this.setScrollProperty("top",e.scrollTop)}e=null});function mousewheel(event){var top=this.getScrollProperty("top");top -=!AW.gecko?event.wheelDelta/2:event.detail *(-10);var e=this.element();if(e){var max=this.getScrollProperty("height")- e.offsetHeight;var bars=this.getScrollProperty("bars");max+=(bars=="horizontal" || bars=="both")?16:0;top=top > max?max:top}top=top < 0?0:top;this.setScrollProperty("top",top);AW.setReturnValue(event,false)}obj.setEvent(!AW.gecko?"onmousewheel":"onDOMMouseScroll",mousewheel);obj.adjustSize=function(){var e=this.getContent("box").element();var sx=e.offsetWidth - e.clientWidth;var sy=e.offsetHeight - e.clientHeight;e=null;if(sx > 0 && sy > 0 && sx < 50 && sy < 50){AW.sx=sx;AW.sy=sy;if(AW.ie && !AW.strict){this.getContent("content").setStyle("margin-right",sx+"px");this.setStyle("padding-bottom",sy+"px")}else{this.getContent("content").setStyle("right",sx+"px");this.getContent("content").setStyle("bottom",sy+"px")}}}};
 AW.Panels.Horizontal=AW.System.Template.subclass();AW.Panels.Horizontal.create=function(){var obj=this.prototype;obj.setClass("hpanel","template");var span=AW.HTML.SPAN;var box=new span;var top=new span;var middle=new span;var bottom=new span;box.setClass("hpanel","box");top.setClass("hpanel","top");middle.setClass("hpanel","middle");bottom.setClass("hpanel","bottom");if(AW.ms6){middle.setStyle("height","expression(this.parentElement.clientHeight-this.previousSibling.offsetHeight-this.nextSibling.offsetHeight)")}function panel(i){return function(){return this.getPanel(i)}}top.setContent("html",panel("top"));middle.setContent("html",panel("center"));bottom.setContent("html",panel("bottom"));box.setContent("top",top);box.setContent("middle",middle);box.setContent("bottom",bottom);obj.setContent("box",box);obj.changeScrollLeft=function(x){var e1=this.getContent("box/middle").element();var e2=this.getContent("box/top").element();var e3=this.getContent("box/bottom").element();if(AW.gecko){AW.ignoreMouse=true}if(e1){e1.scrollLeft=x}if(e2){e2.scrollLeft=x}if(e3){e3.scrollLeft=x}if(AW.gecko){this.setTimeout(function(){AW.ignoreMouse=false})}};obj.changeScrollTop=function(y){var e=this.getContent("box/middle").element();if(AW.gecko){AW.ignoreMouse=true}if(e){e.scrollTop=y}if(AW.gecko){this.setTimeout(function(){AW.ignoreMouse=false})}};obj.changePanelWidth=function(){};obj.changePanelHeight=function(height,part){var h=height+"px";if(part=="top"){this.getContent("box/top").setStyle("height",h);this.getContent("box/top").setStyle("visibility",height?"inherit":"hidden");if(AW.ie && !AW.strict){this.getContent("box").setStyle("padding-top",h)}else{this.getContent("box/middle").setStyle("top",h)}}else if(part=="bottom"){this.getContent("box/bottom").setStyle("height",h);this.getContent("box/bottom").setStyle("display",height?"block":"none");if(AW.ie && !AW.strict){this.getContent("box").setStyle("padding-bottom",h)}else{this.getContent("box/middle").setStyle("bottom",h)}}};obj.changePanelHeight(20,"top");obj.changePanelHeight(0,"bottom")};
 AW.Panels.Vertical=AW.System.Template.subclass();AW.Panels.Vertical.create=function(){var obj=this.prototype;obj.setClass("vpanel","template");var span=AW.HTML.SPAN;var box=new span;var left=new span;var center=new span;var right=new span;box.setClass("vpanel","box");left.setClass("vpanel","left");center.setClass("vpanel","center");right.setClass("vpanel","right");left.setContent("html",function(){return this.getPanel(0)});center.setContent("html",function(){return this.getPanel(1)});right.setContent("html",function(){return this.getPanel(2)});box.setContent("left",left);box.setContent("center",center);box.setContent("right",right);obj.setContent("box",box)};
 AW.Panels.Grid=AW.System.Template.subclass();AW.Panels.Grid.create=function(){var obj=this.prototype;obj.setClass("gpanel","template");var span=AW.HTML.SPAN;var box=new span;var top=new span;var middle=new span;var bottom=new span;box.setClass("gpanel","box");top.setClass("gpanel","top");middle.setClass("gpanel","middle");bottom.setClass("gpanel","bottom");if(AW.ms6){middle.setStyle("height","expression(this.parentElement.clientHeight-this.previousSibling.offsetHeight-this.nextSibling.offsetHeight)")}function panel(i,j){return function(){return this.getPanel(i,j)}}var i,rows=[top,middle,bottom],names=["top","center","bottom"];for(i=0;i<3;i++){var left=new span;var center=new span;var right=new span;left.setClass("gpanel","left");center.setClass("gpanel","center");right.setClass("gpanel","right");left.setContent("html",panel(names[i],"left"));center.setContent("html",panel(names[i],"center"));right.setContent("html",panel(names[i],"right"));if(AW.ms6){center.setStyle("width","expression(this.parentElement.clientWidth-this.previousSibling.offsetWidth-this.nextSibling.offsetWidth)")}rows[i].setContent("left",left);rows[i].setContent("center",center);rows[i].setContent("right",right)}box.setContent("top",top);box.setContent("middle",middle);box.setContent("bottom",bottom);obj.setContent("box",box);obj.changeScrollLeft=function(x){var e1=this.getContent("box/middle/center").element();var e2=this.getContent("box/top/center").element();var e3=this.getContent("box/bottom/center").element();if(AW.gecko){AW.ignoreMouse=true}if(e1){e1.scrollLeft=x}if(e2){e2.scrollLeft=x}if(e3){e3.scrollLeft=x}if(AW.gecko){this.setTimeout(function(){AW.ignoreMouse=false})}};obj.changeScrollTop=function(y){var e1=this.getContent("box/middle/center").element();var e2=this.getContent("box/middle/left").element();var e3=this.getContent("box/middle/right").element();if(AW.gecko){AW.ignoreMouse=true}if(e1){e1.scrollTop=y}if(e2){e2.scrollTop=y}if(e3){e3.scrollTop=y}if(AW.gecko){this.setTimeout(function(){AW.ignoreMouse=false})}};obj.changePanelWidth=function(width,part){var w=width+"px";var i,r,parts=["box/top","box/middle","box/bottom"];if(part=="left"){for(i=0;i<3;i++){r=this.getContent(parts[i]);r.getContent("left").setStyle("width",w);r.getContent("left").setStyle("display",width?"block":"none");if(AW.ie && !AW.strict){r.setStyle("padding-left",w)}else{r.getContent("center").setStyle("left",w)}}}else if(part=="right"){for(i=0;i<3;i++){r=this.getContent(parts[i]);r.getContent("right").setStyle("width",w);r.getContent("right").setStyle("display",width?"block":"none");if(AW.ie && !AW.strict){r.setStyle("padding-right",w)}else{r.getContent("center").setStyle("right",w)}}}};obj.changePanelHeight=function(height,part){var h=height+"px";if(part=="top"){this.getContent("box/top").setStyle("height",h);this.getContent("box/top").setStyle("visibility",height?"inherit":"hidden");if(AW.ie && !AW.strict){this.getContent("box").setStyle("padding-top",h)}else{this.getContent("box/middle").setStyle("top",h)}}else if(part=="bottom"){this.getContent("box/bottom").setStyle("height",h);this.getContent("box/bottom").setStyle("display",height?"block":"none");if(AW.ie && !AW.strict){this.getContent("box").setStyle("padding-bottom",h)}else{this.getContent("box/middle").setStyle("bottom",h)}}};obj.changePanelWidth(100,"left");obj.changePanelWidth(0,"right");obj.changePanelHeight(20,"top");obj.changePanelHeight(0,"bottom")};
 AW.UI.Controllers.List={onItemTemplateChanged:function(item){item.setClass("list","item");item.setClass("items",function(){return this.getControlProperty("state")|| "normal"});item.mapModel("control","item");item.mapModel("state","item")},onViewTemplateChanged:function(view){view.setClass("list","template")}};
 AW.UI.Controllers.Actions=(function(){function clicked(event,index){return index}function current(){return this.getCurrentItem()}function first(){var p=this.getViewOffset();var a=this.getViewIndices();return a?a[p]:p}function last(){var p=this.getViewOffset()+this.getViewCount()- 1;var a=this.getViewIndices();return a?a[p]:p}function next(){var i=this.getCurrentItem();var p=Math.min(this.getViewPosition(i)+1,this.getViewOffset()+this.getViewCount()- 1);var a=this.getViewIndices();return a?a[p]:p}function previous(){var i=this.getCurrentItem();var p=Math.max(this.getViewPosition(i)- 1,this.getViewOffset());var a=this.getViewIndices();return a?a[p]:p}function go(i){this.setCurrentItem(i)}function select(i){this.setSelectedItems([i]);this.setCurrentItem(i)}function toggle(i){this.setItemSelected(!this.getItemSelected(i),i);if(i !=this.getCurrentItem()){this.setCurrentItem(i)}}function f(action,item){return function(event,index){var i=item.call(this,event,index);AW.setReturnValue(event,false);if(event && event.type=="mousedown"){this.setTimeout(function(){if(this.$active){action.call(this,i)}})}else{if(this.$active){action.call(this,i)}}event=null}}return{gotoClickedItem:f(go,clicked),gotoPreviousItem:f(go,previous),gotoNextItem:f(go,next),gotoFirstItem:f(go,first),gotoLastItem:f(go,last),selectClickedItem:f(select,clicked),selectPreviousItem:f(select,previous),selectNextItem:f(select,next),selectFirstItem:f(select,first),selectLastItem:f(select,last),toggleClickedItem:f(toggle,clicked),toggleCurrentItem:f(toggle,current)}})();
 AW.UI.Controllers.Changes=(function(){function item(v,i){this.getItem(i).refresh()}function view(indices){var pos=[];for(var i=0;i<indices.length;i++){pos[indices[i]]=i}this.setViewPosition(pos);this.refresh()}function selection(mode){switch(mode){case "single":this.setController("selection",AW.UI.Controllers.Single);break;case "multi":this.setController("selection",AW.UI.Controllers.Multi);break}}return{onItemTextChanged:item,onItemImageChanged:item,onItemValueChanged:item,onItemLinkChanged:item,onItemTooltipChanged:item,onItemStateChanged:item,onViewIndicesChanged:view,onSelectionModeChanged:selection}})();
 AW.UI.Controllers.State=(function(){function itemSelected(value,index){this.calculateItemState(index);var i,a=this.getSelectedItems();for(i=0;i<a.length;i++){if(a[i]==index){if(!value){a=a.concat();a.splice(i,1);this.setSelectedItems(a)}return}}if(value){a=a.concat(index);this.setSelectedItems(a)}}var select=[],unselect=[];function selectedItems1(a){var b=this.getSelectedItems();var i,before={},after={};select=[];unselect=[];for(i=0;i<b.length;i++){before[b[i]]=true}for(i=0;i<a.length;i++){after[a[i]]=true}for(i=0;i<b.length;i++){if(!after[b[i]]){unselect.push(b[i])}}for(i=0;i<a.length;i++){if(!before[a[i]]){select.push(a[i])}}}function selectedItems2(){var i;for(i=0;i<unselect.length;i++){if(this.getItemSelected(unselect[i])){this.setItemSelected(false,unselect[i])}}for(i=0;i<select.length;i++){if(!this.getItemSelected(select[i])){this.setItemSelected(true,select[i])}}}var current;function currentItem1(){current=this.getCurrentItem()}function currentItem2(index){this.calculateItemState(current);var e1=this.getItem(current).getContent("box/text").element();if(e1 && index !=current){e1.tabIndex=-1}e1=null;this.calculateItemState(index);var e2=this.getItem(index).getContent("box/text").element();if(e2 && e2.focus && !AW.opera && !AW.$popup){e2.tabIndex=this.getTabIndex();e2.focus()}e2=null}return{onItemSelectedChanged:itemSelected,onCurrentItemChanging:currentItem1,onCurrentItemChanged:currentItem2,onSelectedItemsChanging:selectedItems1,onSelectedItemsChanged:selectedItems2}})();
 AW.UI.Controllers.Single={onKeyHome:"selectFirstItem",onKeyEnd:"selectLastItem",onKeyUp:"selectPreviousItem",onKeyDown:"selectNextItem",onKeyLeft:"selectPreviousItem",onKeyRight:"selectNextItem",onKeyPageUp:"selectPreviousPage",onKeyPageDown:"selectNextPage",onItemClicked:"selectClickedItem"};
 AW.UI.Controllers.Multi={onKeyHome:"selectFirstItem",onKeyEnd:"selectLastItem",onKeyUp:"selectPreviousItem",onKeyDown:"selectNextItem",onKeyPageUp:"selectPreviousPage",onKeyPageDown:"selectNextPage",onKeyCtrlHome:"gotoFirstItem",onKeyCtrlEnd:"gotoLastItem",onKeyCtrlUp:"gotoPreviousItem",onKeyCtrlDown:"gotoNextItem",onKeyCtrlPageUp:"gotoPreviousPage",onKeyCtrlPageDown:"gotoNextPage",onKeyCtrlSpace:"toggleCurrentItem",onKeySpace:"toggleCurrentItem",onItemClicked:"toggleClickedItem"};
 AW.UI.Controllers.Checked={onKeyHome:"gotoFirstItem",onKeyEnd:"gotoLastItem",onKeyUp:"gotoPreviousItem",onKeyDown:"gotoNextItem",onKeySpace:"toggleCurrentItem"};
 AW.UI.ImageText=AW.System.Control.subclass();AW.UI.ImageText.create=function(){AW.Templates.ImageText.create.call(this);var obj=this.prototype;var _super=this.superclass.prototype;obj.setClass("templates","");obj.setClass("ui","imagetext");obj.setClass("item","control");obj.setClass("text","expand");function _tabIndex(){return this.getTabProperty("index")}if(AW.ie || AW.gecko){obj.getContent("box/text").setAttribute("tabIndex",_tabIndex)}obj.refresh=function(){if(this.getContent("box/text").element()){this.refreshClasses();this.refreshStyles();this.refreshAttributes();this.getContent("box/image").refreshClasses();this.getContent("box/text").refreshAttributes();this.getContent("box/text").refreshContents();if(this.getContent("data")){this.getContent("data").refreshAttributes()}}else{_super.refresh.call(this)}};var _refresh=function(){this.refresh()};var itemController={onControlTextChanged:_refresh,onControlImageChanged:_refresh,onControlValueChanged:_refresh,onControlLinkChanged:_refresh,onControlTooltipChanged:_refresh,onControlStateChanged:_refresh};obj.setController("item",itemController);obj.setEvent("onactivate",function(event){var e=this.getContent("box/text").element();if(e && event.srcElement !=e){this.setTimeout(function(){if(this.$active){e.setActive()}})}});if(AW.webkit || AW.opera || AW.konqueror){var focus=new AW.HTML.SPAN;focus.setTag("a");focus.setClass("control","focus");focus.setAttribute("tabIndex",function(){return this.getTabProperty("index")});if(AW.webkit){focus.setAttribute("href","#")}if(AW.opera){focus.setContent("html","&nbsp;")}obj.setContent("focus",focus)}obj.focus=function(){try{if(this.getControlDisabled()){return}if(AW.webkit || AW.opera || AW.konqueror){this.getContent("focus").element().focus();return}this.getContent("box/text").element().focus()}catch(err){}};obj.onControlDisabledChanged=function(value){this.setClass("disabled",value?"control":null);this.setAttribute("disabled",value?true:null);this.getContent("box/text").setAttribute("disabled",value?true:null)};obj.setSize=function(width,height){if(typeof(width)!="undefined"){if(AW.ms5 || AW.ms6 || this._textClass !="expand"){this.setStyle("width",width - AW.dx+"px")}else{if(AW.ff2 || AW.ff15 || AW.ff1){this.setStyle("min-width",width+"px")}else if(AW.opera && opera.version()< 9.5 && this._uiClass=="button"){this.setStyle("min-width",width - 8+"px")}else{this.setStyle("min-width",width - AW.dx+"px")}if(AW.ms7 || AW.ms8){this.getContent("box").setStyle("min-width",width - AW.dx+"px")}}}if(typeof(height)!="undefined"){this.setStyle("height",height - AW.dy+"px")}}};
 AW.UI.Label=AW.UI.ImageText.subclass();AW.UI.Label.create=function(){var obj=this.prototype;obj.setClass("ui","label");obj.setTabIndex(-1)};
 AW.UI.Group=AW.UI.ImageText.subclass();AW.UI.Group.create=function(){var obj=this.prototype;obj.setTag("fieldset");obj.setClass("ui","group");obj.setClass("text","normal");obj.setTabIndex(-1);var box=obj.getContent("box");box.setTag("legend");box.setClass("item","legend")};
 AW.UI.Button=AW.UI.ImageText.subclass();AW.UI.Button.create=function(){var obj=this.prototype;obj.setClass("ui","button");var _click=function(event){if(!this.getControlDisabled()){this.raiseEvent("onClick",event)}};obj.setController("button",{onControlClicked:_click,onKeySpace:_click,onKeyEnter:_click});AW._addMouseEvents(obj,"button")};
 AW.UI.Link=AW.UI.ImageText.subclass();AW.UI.Link.create=function(){AW.Templates.Link.create.call(this);var obj=this.prototype;obj.setClass("ui","link");obj.getContent("box").setTag("span")};
 AW.UI.Input=AW.UI.ImageText.subclass();AW.UI.Input.create=function(){var obj=this.prototype;obj.setClass("ui","input");obj.setClass("input","box");obj.setClass("text","");var text=new AW.HTML.INPUT;text.setClass("item","text");text.setAttribute("type","text");text.setAttribute("value",function(){return this.getControlProperty("text")});text.setAttribute("tabIndex",function(){return this.getTabProperty("index")});obj.setContent("box/text",text);var _edit=function(){this.setTimeout(function(){if(this.$active){this.startEdit()}})};var _validate=function(){AW._commitEdit()};var _cancel=function(event){AW._cancelEdit();AW.setReturnValue(event,false)};var _refresh=function(){this.refresh()};var _text=function(){var e=this.getContent("box/text").element();var text=this.getControlProperty("text");if(e && e.value !=text){if(AW.ie){var r=document.selection.createRange();r.collapse();r.select()}e.value=text}if(this.getContent("data")){e=this.getContent("data").element();if(e){e.value=this.getControlData()}}};var itemController={onKeyEnter:_validate,onKeyEscape:_cancel,onControlActivated:_edit,onControlTextChanged:_text,onControlValueChanged:_text,onControlDataChanged:_text,onControlImageChanged:_refresh,onControlLinkChanged:_refresh,onControlTooltipChanged:_refresh,onControlStateChanged:_refresh};obj.setController("item",itemController);if(AW.webkit || AW.opera || AW.konqueror){obj.setContent("focus","")}obj.focus=function(){try{if(this.getControlDisabled()){return}this.getContent("box/text").element().focus()}catch(err){}}};
 AW.UI.Password=AW.UI.Input.subclass();AW.UI.Password.create=function(){var obj=this.prototype;obj.getContent("box/text").setAttribute("type","password")};
 AW.UI.List=AW.System.Control.subclass();AW.UI.List.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setClass("ui","list");obj.setClass("list","control");obj.setClass("flow","vertical");obj.setClass("text","normal");var box=new AW.HTML.SPAN;box.setClass("list","box");if(AW.gecko){box.setAttribute("tabIndex","-1")}if(AW.ie && AW.strict){box.setStyle("width","expression(this.parentElement.offsetWidth-4)")}box.setContent("html",function(){return this.getLayout()});obj.setContent("box",box);var UI=AW.UI.Controllers;obj.setController("list",UI.List);obj.setController("actions",UI.Actions);obj.setController("changes",UI.Changes);obj.setController("selection",UI.Single);obj.setController("state",UI.State);obj.defineTemplate("layout",function(){return this.getScroll()});obj.defineTemplate("scroll",function(){return this.getView()});obj.defineTemplate("view",new AW.Templates.List);obj.defineTemplate("item",new AW.Templates.ImageText);function value(i){var text=this.getItemText(i);var format=this.getItemFormat(i);return format?format.textToValue(text):text}function count(){return this.getItemCount()}function position(i){return Number(i)}var models={item:{count:0,text:"",image:"",link:"",value:value,format:"",tooltip:"",state:"",selected:false},view:{count:count,position:position,offset:0,expanded:false},selection:{mode:"single"},current:{item:0}};obj.defineModel("item",models.item);obj.defineModel("view",models.view);obj.defineModel("current",models.current);obj.defineModel("selected",{});obj.defineModel("selection",models.selection);obj.defineModel("state",{});obj.defineViewProperty("indices","",true);obj.defineSelectedProperty("items",[],true);obj.calculateItemState=function(i){var state="";if(this.getCurrentItem()==i){state="current"}if(this.getItemSelected(i)){state="selected"}if(this.getItemState(i)!=state){this.setItemState(state,i)}};obj.toString=function(){if(AW.ie || AW.gecko){this.setTimeout(function(){try{var i=this.getCurrentItem();var t=this.getTabIndex();this.getItem(i).getContent("box/text").element().tabIndex=t}catch(err){}})}return _super.toString.call(this)};if(AW.webkit || AW.opera || AW.konqueror){var focus=new AW.HTML.SPAN;focus.setTag("a");focus.setClass("control","focus");focus.setAttribute("tabIndex",function(){return this.getTabProperty("index")});if(AW.webkit){focus.setAttribute("href","#")}if(AW.opera){focus.setContent("html","&nbsp;")}obj.setContent("focus",focus)}obj.focus=function(){try{if(this.getControlDisabled()){return}if(AW.webkit || AW.opera || AW.konqueror){this.getContent("focus").element().focus();return}var i=this.getCurrentItem();this.getItem(i).getContent("box/text").element().focus()}catch(err){}};obj.onControlDisabledChanged=function(value){this.setClass("disabled",value?"control":null);this.setAttribute("disabled",value?true:null)}};
 AW.UI.Tabs=AW.UI.List.subclass();AW.UI.Tabs.create=function(){var obj=this.prototype;obj.setClass("ui","tabs");obj.setClass("text","expand");obj.setClass("flow","horizontal");if(AW.opera){obj.setController("repaint",{onCurrentItemChanged:function(){var n=document.createElement("div");var e=this.element();var p=e.parentNode;p.insertBefore(n,e);p.removeChild(n)}})}};
 AW.UI.Combo=AW.UI.List.subclass();AW.UI.Combo.create=function(){AW.UI.ImageText.create.call(this);AW.UI.Input.create.call(this);AW.Templates.Combo.create.call(this);var obj=this.prototype;obj.setClass("ui","combo");obj.setClass("input","");obj.defineTemplate("popup",new AW.Templates.Frame);obj.onCurrentItemChanged=function(i){var text=this.getItemText(i);this.setControlText(text);this.hidePopup()};obj.setController("selection",{onKeyUp:"selectPreviousItem",onKeyDown:"selectNextItem",onItemClicked:"selectClickedItem"})};
 AW.UI.CheckBox=AW.UI.ImageText.subclass();AW.UI.CheckBox.create=function(){AW.Templates.CheckBox.create.call(this);var obj=this.prototype;obj.setClass("ui","checkbox");obj.setControlProperty("value",false);obj.setEvent("onclick","");var _toggle=function(){if(!this.getControlDisabled()){this.setControlValue(!this.getControlValue())}};obj.setController("checkbox",{onKeySpace:_toggle,onControlClicked:_toggle})};AW.UI.Checkbox=AW.UI.CheckBox;
 AW.UI.CheckedList=AW.UI.List.subclass();AW.UI.CheckedList.create=function(){var obj=this.prototype;obj.setClass("ui","checkedlist");obj.setItem(new AW.Templates.CheckedItem);obj.setController("selection",AW.UI.Controllers.Checked)};
 AW.UI.Radio=AW.UI.CheckedList.subclass();AW.UI.Radio.create=function(){var obj=this.prototype;obj.setClass("ui","radio");obj.setItem(new AW.Templates.Radio);obj.setSelectionMode("single")};
 AW.Grid.Controllers.Size=(function(){var initFlag=false;function init(){initFlag=true;try{var height=this.getContent("box/sample").element().offsetHeight;var i,ii,n=this.getColumnCount(),a=this.getColumnIndices();var hrow=this.$extended?0:undefined;var width=[];for(i=0;i<n;i++){ii=a?a[i]:i;width[ii]=this.getHeader(ii,hrow).element().offsetWidth}var w=this.getScroll().element().offsetWidth;var h=this.getScroll().element().offsetHeight;var left=this.getScrollLeft();var top=this.getScrollTop();this.getScroll().adjustSize();this.getScroll().setStyle("visibility","inherit");this._startUpdate();this.setRowHeight(height);this.setColumnWidth(width);this.setContentWidth(w,"total");this.setContentHeight(h,"total");this.setScrollLeft(left);this.setScrollTop(top);this._endUpdate()}catch(err){}try{this.getScroll().setStyle("visibility","inherit");this.setTimeout(function(){this.getRows().refresh()})}catch(err){}initFlag=false}function setStyle(selector,attribute,value){try{if(AW.webkit && document.styleSheets.length===0){window.setTimeout(function(){setStyle(selector,attribute,value)},100);return}var i,ss=document.styleSheets[document.styleSheets.length-1];var rules=AW.getRules(ss);if(AW.webkit){selector=selector.toLowerCase()}for(i=rules.length-1;i>=0;i--){if(rules[i].selectorText==selector){rules[i].style[attribute]=value;return}}AW.addRule(ss,selector,attribute+":"+value)}catch(err){}}return{paint:init,onColumnWidthChanged:function(width,column){if(initFlag){return}if(typeof(width)=="object"){if(this.element()){this.element().innerHTML=""}var i,a=[];for(i in width){if(!a[i]){setStyle("#"+this.getId()+" .aw-column-"+i,"width",(width[i] - AW.dx)+"px")}}if(this.element()){this.refresh()}return}if(AW.ie && this.getView().element()){this.getView().element().firstChild.className+=""}if(column===undefined){setStyle("#"+this.getId()+" .aw-grid-cell","width",(width - AW.dx)+"px");setStyle("#"+this.getId()+" .aw-grid-header","width",(width - AW.dx)+"px");setStyle("#"+this.getId()+" .aw-grid-footer","width",(width - AW.dx)+"px")}else{setStyle("#"+this.getId()+" .aw-column-"+column,"width",(width - AW.dx)+"px")}},onSelectorWidthChanged:function(width){setStyle("#"+this.getId()+" .aw-row-selector","width",(width - AW.dx)+"px")},onRowHeightChanged:function(height){if(initFlag){return}setStyle("#"+this.getId()+" .aw-grid-row","height",(height - AW.dy)+"px");setStyle("#"+this.getId()+" .aw-grid-row","lineHeight",height+"px")}}})();
 AW.Grid.Controllers.Cell=(function(){function refresh(value,col,row){this.getCell(col,row).refresh()}function refreshClasses(value,col,row){this.getCell(col,row).refreshClasses()}function cellData(val,col,row){function dataToText(i,j){var data=this.getCellData(i,j);var format=this.getCellFormat(i,j);return format?format.dataToText(data):data}function dataToValue(i,j){var data=this.getCellData(i,j);var format=this.getCellFormat(i,j);return format?format.dataToValue(data):data}this.setCellText(dataToText,col,row);this.setCellValue(dataToValue,col,row)}function tooltip(event,col,row){var e=this.getCell(col,row).element();var s=this.getCellTooltip(col,row);if(e){e.setAttribute("title",s)}e=null}function calcState(v,i,j){this.calculateCellState(i,j)}return{onCellMouseOver:tooltip,onCellSelectedChanged:calcState,onCellDataChanged:cellData,onCellTextChanged:refresh,onCellLinkChanged:refresh,onCellImageChanged:refresh,onCellValueChanged:refresh,onCellStateChanged:refreshClasses}})();
 AW.Grid.Controllers.Edit=(function(){function startEdit(event){if(AW._edit){return}var s;if(event && event.type=="keypress"){if(event.keyCode==27 || event.keyCode==13){return}s=String.fromCharCode(event.keyCode || event.charCode)}if(this.startCellEdit(s)){AW.setReturnValue(event,false)}}function startOrEnd(event){if(!AW._edit){this.startCellEdit()}else{this.endCellEdit()}AW.setReturnValue(event,false)}function endEdit(event){this.endCellEdit();AW.setReturnValue(event,false)}function cancelEdit(event){this.cancelCellEdit();this.endCellEdit();AW.setReturnValue(event,false)}return{onKeyF2:startEdit,onCellDoubleClicked:startEdit,onKeyPress:startEdit,onKeyEnter:startOrEnd,onKeyEscape:cancelEdit,editCurrentCell:startEdit}})();
 AW.Grid.Controllers.Row=(function(){function refresh(value,row){this.getRow(row).refreshClasses()}function addRow(row){var count=this.getRowCount();var a=this.getRowIndices();if(count<2){this.refresh();return}var prev=a[count-2];var i,e;if(!this.$extended){e=this.getRow(prev).element();if(e){AW.setOuterHTML(e,this.getRow(prev).toString()+this.getRow(row).toString())}e=null}else{for(i=0;i<3;i++){e=this.getRow(prev,i).element();if(e){AW.setOuterHTML(e,this.getRow(prev,i).toString()+this.getRow(row,i).toString())}e=null}}this.raiseEvent("adjustScrollHeight")}function removeRow(row){var i,e;if(!this.$extended){e=this.getRow(row).element();if(e){AW.setOuterHTML(e,"")}e=null}else{for(i=0;i<3;i++){e=this.getRow(row,i).element();if(e){AW.setOuterHTML(e,"")}e=null}}this.raiseEvent("adjustScrollHeight")}function calcRowState(v,i){this.calculateRowState(i)}return{onRowAdded:addRow,onRowDeleted:removeRow,onRowSelectedChanged:calcRowState,onRowStateChanged:refresh}})();
 AW.Grid.Controllers.View={onRowIndicesChanged:function(indices){var positions=[];for(var i=0;i<indices.length;i++){positions[indices[i]]=i}this.setRowPosition(positions);this.refresh()},onColumnIndicesChanged:function(indices){var positions=[];for(var i=0;i<indices.length;i++){positions[indices[i]]=i}this.setColumnPosition(positions);this.setColumnCount(indices.length);this.refresh()}};
 AW.Grid.Controllers.Navigation=(function(){var serial=1;function syncSelected(){serial=serial % 1000+1;var s=serial;if(!this._columnsSelected || this._columnsSelected.$ !==this){this._columnsSelected={$:this}}if(!this._rowsSelected || this._rowsSelected.$ !==this){this._rowsSelected={$:this}}var cc=this._columnsSelected;var rr=this._rowsSelected;var mode=this.getCurrentSelection();var cols=this.getSelectedColumns();var rows=this.getSelectedRows();var i,j,col,row,ext={$:1};if(mode=="cell"){var added=[],unchanged=[],removed=[];for(i=0;i<cols.length;i++){col=cols[i];(cc[col]?unchanged:added).push(col);cc[col]=s}for(col in cc){if(cc[col] && cc[col] !==s && !ext[col]){delete cc[col];removed.push(col)}}for(i=0;i<rows.length;i++){row=rows[i];if(!rr[row]){rr[row]=s;for(j=0;j<unchanged.length;j++){col=unchanged[j];this.setCellSelected(true,col,row)}for(j=0;j<added.length;j++){col=added[j];this.setCellSelected(true,col,row)}}else{rr[row]=s;for(j=0;j<added.length;j++){col=added[j];this.setCellSelected(true,col,row)}for(j=0;j<removed.length;j++){col=removed[j];this.setCellSelected(false,col,row)}}}for(row in rr){if(rr[row] && rr[row] !==s && !ext[row]){delete rr[row];for(j=0;j<unchanged.length;j++){col=unchanged[j];this.setCellSelected(false,col,row)}for(j=0;j<removed.length;j++){col=removed[j];this.setCellSelected(false,col,row)}}}}else{for(i=0;i<rows.length;i++){row=rows[i];if(!rr[row]){rr[row]=s;this.setRowSelected(true,row)}else{rr[row]=s}}for(row in rr){if(rr[row] && rr[row] !==s && !ext[row]){delete rr[row];this.setRowSelected(false,row)}}}}function syncRow(value,row){if(!this._rowsSelected ||(!this._rowsSelected[row])!=(!value)){var i,rows=this.getSelectedRows().concat();if(value){rows.push(row)}else{for(i=0;i<rows.length;i++){if(rows[i]==row){rows.splice(i--,1)}}}this.setSelectedRows(rows)}}var Grid=AW.Grid.Controllers;return{onSelectedColumnsChanged:syncSelected,onSelectedRowsChanged:syncSelected,onRowSelectedChanged:syncRow,onSelectionModeChanged:function(mode){switch(mode){case "none":this.setController("selection",{});this.setController("edit",{});this.setCurrentSelection("none");break;case "single-cell":this.setController("selection",Grid.SingleCell);this.setController("edit",Grid.Edit);this.setCurrentSelection("cell");break;case "single-row":this.setController("selection",Grid.SingleRow);this.setController("edit",{});this.setCurrentSelection("row");break;case "multi-cell":this.setController("selection",Grid.MultiCell);this.setController("edit",Grid.Edit);this.setCurrentSelection("cell");break;case "multi-row":this.setController("selection",Grid.MultiRow);this.setController("edit",{});this.setCurrentSelection("row");break;case "multi-row-marker":this.setController("selection",Grid.MultiRowMarker);this.setController("edit",{});this.setCurrentSelection("row");var checkbox=new AW.Templates.CheckedItem;this.setCell(checkbox,0);break}}}})();
 AW.Grid.Controllers.Sort={doSort:function(src,index,header){if(this.$edit){return}if(!(header=="0" || typeof(header)=="undefined")){return}var format=this.getCellFormat(index);function compare(values,pos,dir){var greater=1,less=-1;if(dir=="descending"){greater=-1;less=1}var equal=function(i,j){var a=pos[i];var b=pos[j];if(a > b){return 1}if(a < b){return -1}return 0};var error=function(){return 0};var types={"undefined":0,"boolean":1,"number":2,"string":3,"object":4,"function":5};if(format){return format.comparator(values,greater,less,equal,error)}else if("".localeCompare){return function(i,j){try{var a=values[i],b=values[j],x,y;if(typeof(a)!=typeof(b)){x=types[typeof(a)];y=types[typeof(b)];if(x > y){return greater}if(x < y){return less}}else if(typeof(a)=="number"){if(a > b){return greater}if(a < b){return less}return equal(i,j)}else{return(greater *((""+a).localeCompare(b)))|| equal(i,j)}}catch(e){return error(i,j,e)}}}else{return function(i,j){try{var a=values[i],b=values[j],x,y;if(typeof(a)!=typeof(b)){x=types[typeof(a)];y=types[typeof(b)];if(x > y){return greater}if(x < y){return less}}else{if(a > b){return greater}if(a < b){return less}}return equal(i,j)}catch(e){return error(i,j,e)}}}}var direction=this.getSortDirection(index);if(direction !="ascending"){direction="ascending"}else{direction="descending"}if(src=="ascending" || src=="descending"){direction=src}var i,value={},pos={};var offset=this.getRowOffset();var count=this.getRowCount();var rows=this.getRowIndices();if(!rows){rows=[];for(i=0;i<count;i++){rows[i]=i+offset}}else{rows=rows.slice(offset,offset+count)}for(i=0;i<rows.length;i++){value[rows[i]]=this.getCellValue(index,rows[i]);pos[rows[i]]=i}rows.sort(compare(value,pos,direction));var a=[];for(i=0;i<offset;i++){a[i]=i}rows=a.concat(rows);var old=this.getSortColumn();if(old !=-1){this.setSortDirection("",old)}this.setSortColumn(index);this.setSortDirection(direction,index);this.setRowIndices(rows)},onHeaderClicked:function(src,index,header){if(this.$active){AW.Grid.Controllers.Sort.doSort.call(this,src,index,header)}}};
 AW.Grid.Controllers.Overflow=(function(){function calcWidth(){var i,a=this.getColumnIndices();var left=0,lc=this.$extended?this.getFixedLeft():0;var center=0,cc=this.getColumnCount();var right=0,rc=this.$extended?this.getFixedRight():0;left=this.getSelectorVisible()?this.getSelectorWidth():left;if(!this.$extended){center=left;left=0}for(i=0;i<lc;i++){left+=this.getColumnWidth(a?a[i]:i)}for(i=lc;i<cc-rc;i++){center+=this.getColumnWidth(a?a[i]:i)}for(i=cc-rc;i<cc;i++){right+=this.getColumnWidth(a?a[i]:i)}var total=left+center+right;if(total !=this.getScrollWidth()){this.setScrollWidth(total)}if(left !=this.getContentWidth("left")){this.setContentWidth(left,"left")}if(right !=this.getContentWidth("right")){this.setContentWidth(right,"right")}}function calcHeight(){if(!this.getScrollWidth()){calcWidth.call(this)}var i,a,count;var headers=0;count=this.$extended?this.getHeaderCount():1;a=this.getHeaderIndices();if(this.getHeaderVisible()){for(i=0;i<count;i++){headers+=this.getHeaderHeight(a?a[i]:i)}}var rows=this.getRowHeight()* this.getRowCount();var footers=0;count=this.$extended?this.getFooterCount():1;a=this.getFooterIndices();if(this.getFooterVisible()){for(i=0;i<count;i++){footers+=this.getFooterHeight(a?a[i]:i)}}var total=headers+rows+footers;if(total !=this.getScrollHeight()){this.setScrollHeight(total)}if(headers !=this.getContentHeight("top")){this.setContentHeight(headers,"top")}if(footers !=this.getContentHeight("bottom")){this.setContentHeight(footers,"bottom")}}function calcBars(){var s,x,y;var l=this.getScrollLeft();var t=this.getScrollTop();var w=this.getScrollWidth();var h=this.getScrollHeight();var ww=this.getContentWidth("total");var hh=this.getContentHeight("total");if(!ww || !hh){return}if(w <=ww && h <=hh){s="none";x=0;y=0}else if(w <=ww - AW.sx){s="vertical";x=AW.sx;y=0}else if(h <=hh - AW.sy){s="horizontal";x=0;y=AW.sy}else{s="both";x=AW.sx;y=AW.sy}if(this.getScrollBars()!=s){this.setScrollBars(s)}if(w - l < ww - x){var ll=Math.max(0,w - ww+x);if(ll !=l){this.setScrollLeft(ll)}}if(h - t < hh - y){var tt=Math.max(0,h - hh+y);if(tt !=t){this.setScrollTop(tt)}}var cw=ww - x - this.getContentWidth("left")- this.getContentWidth("right");var ch=hh - y - this.getContentHeight("top")- this.getContentHeight("bottom");if(cw !=this.getContentWidth("center")){this.setContentWidth(cw,"center")}if(ch !=this.getContentHeight("center")){this.setContentHeight(ch,"center")}}return{onColumnWidthChanged:calcWidth,onColumnCountChanged:calcWidth,onSelectorWidthChanged:calcWidth,onSelectorVisibleChanged:calcWidth,onRowHeightChanged:calcHeight,onRowCountChanged:calcHeight,onHeaderVisibleChanged:calcHeight,onHeaderHeightChanged:calcHeight,onHeaderCountChanged:calcHeight,onFooterVisibleChanged:calcHeight,onFooterHeightChanged:calcHeight,onFooterCountChanged:calcHeight,onScrollWidthChanged:calcBars,onScrollHeightChanged:calcBars,onContentWidthChanged:calcBars,onContentHeightChanged:calcBars}})();
 AW.Grid.Controllers.Scroll=(function(){return{onScrollLeftChanged:function(x){var e=this.getScroll().getContent("box").element();if(e){e.scrollLeft=x}},onScrollTopChanged:function(y){var e=this.getScroll().getContent("box").element();if(e){e.scrollTop=y}},onScrollWidthChanged:function(w){this.getScroll().getContent("box/spacer").setStyle("width",w+"px")},onScrollHeightChanged:function(h){this.getScroll().getContent("box/spacer").setStyle("height",h+"px")},onScrollBarsChanged:function(bars){this.getScroll().setClass("scrollbars",bars)}}})();
 AW.Grid.Controllers.Content={onScrollLeftChanged:function(x){this.getView().changeScrollLeft(x)},onScrollTopChanged:function(y){this.getView().changeScrollTop(y)},onContentWidthChanged:function(width,panel){this.getView().changePanelWidth(width,panel)},onContentHeightChanged:function(height,panel){this.getView().changePanelHeight(height,panel)}};
 AW.Grid.Controllers.Virtual=(function(){var oldScrollTop,oldScrollLeft,scrollTime=new Date();function calcVirtual(dir){if(!this.getVirtualMode()){return}dir=dir || 0;var scrollTop=this.getScrollTop();var scrollLeft=this.getScrollLeft();var totalHeight=this.getContentHeight("center");var totalWidth=this.getContentWidth("center");if(!totalHeight || !totalWidth){return}var delta1=dir < 0?10:1;var delta2=dir > 0?10:1;var rowCount=this.getRowCount();var rowOffset=this.getRowOffset();var rowHeight=this.getRowHeight();var firstRow=Math.floor(scrollTop/rowHeight);var lastRow=Math.floor((scrollTop+totalHeight)/rowHeight);var start=Math.max(0,Math.min(rowCount - 1,firstRow - delta1));var end=Math.max(0,Math.min(rowCount - 1,lastRow+delta2));var rvScroll=start * rowHeight;var rvOffset=start+rowOffset;var rvCount=Math.min(rowCount,end-start+1);var i,ii;var columnCount=this.getColumnCount();var columnOffset=this.getColumnOffset();var columnIndices=this.getColumnIndices();if(this.$extended){columnCount -=this.getFixedLeft()+this.getFixedRight();columnOffset+=this.getFixedLeft()}else if(this.getSelectorVisible()){scrollLeft -=this.getSelectorWidth()}var w=0,wp=0,ww;for(i=0;i<columnCount;i++){ii=columnIndices?columnIndices[i+columnOffset]:i+columnOffset;ww=this.getColumnWidth(ii);if(w+ww > scrollLeft){break}wp=w;w+=ww}var k=i?i-1:0;for(i=k;i<columnCount;i++){ii=columnIndices?columnIndices[i+columnOffset]:i+columnOffset;w+=this.getColumnProperty("width",ii);if(w > totalWidth+scrollLeft){break}}this._startUpdate();this.setRowVirtualScroll(rvScroll);this.setRowVirtualOffset(rvOffset);this.setRowVirtualCount(rvCount);this.setColumnVirtualScroll(wp);this.setColumnVirtualOffset(columnOffset+k);this.setColumnVirtualCount(Math.min(i+2,columnCount)- k);this._endUpdate()}function startVirtual(dir){var s=++this._scrollSerial;scrollTime=new Date();var wait=function(){if(s==this._scrollSerial){if((new Date())- scrollTime > 200 || !AW._scrollWait){calcVirtual.call(this,dir);this.getRows().refreshVirtual()}else{this.setTimeout(wait,20)}}};this.setTimeout(wait,50)}return{paint:function(){calcVirtual.call(this)},onControlRefreshing:function(){calcVirtual.call(this)},onScrollLeftChanging:function(){oldScrollLeft=this.getScrollLeft()},onScrollTopChanging:function(){oldScrollTop=this.getScrollTop()},onScrollLeftChanged:function(scrollLeft){if(this.getVirtualMode()&& scrollLeft !=oldScrollLeft){AW._scrollWait=true;startVirtual.call(this)}},onScrollTopChanged:function(scrollTop){if(this.getVirtualMode()&& scrollTop !=oldScrollTop){AW._scrollWait=true;if(Math.abs(scrollTop - oldScrollTop)> this.getScrollHeight()/5){AW._scrollWait=false}var dir=scrollTop > oldScrollTop?1:-1;startVirtual.call(this,dir)}},onCurrentRowChanged:function(i){var current=this.getCurrentRow();var scroll=this.getScrollProperty("top");var height=this.getRowProperty("height");var top=(this.getRowPosition(current)-this.getRowOffset())* height;var bottom=top+height;var max=this.getContentHeight("center");if(!max){return}if(top < scroll){this.setScrollTop(top)}if(max+scroll < bottom){this.setScrollTop(bottom - max)}if(AW.ie && this.element()){var h=this.element().offsetHeight}},onCurrentColumnChanged:function(index){var scroll=this.getScrollProperty("left");var col=this.getColumnPosition(index);var max=this.getContentWidth("center");if(!max){return}var i,a=this.getColumnIndices();var lw=0,lc=this.$extended?this.getFixedLeft():0;var mw=0,c=this.getColumnCount();var rw=0,rc=this.$extended?this.getFixedRight():0;lw=this.getSelectorVisible()?this.getSelectorWidth():lw;if(!this.$extended){mw=lw;lw=0}for(i=0;i<lc;i++){lw+=this.getColumnWidth(a?a[i]:i)}for(i=lc;i<Math.min(col,c-rc-1);i++){mw+=this.getColumnWidth(a?a[i]:i)}for(i=c-rc;i<c;i++){rw+=this.getColumnWidth(a?a[i]:i)}if(!col){mw=0}if(mw < scroll){this.setScrollLeft(mw);return}var right=mw+this.getColumnWidth(index);if(max+scroll < right){this.setScrollLeft(right - max)}}}})();
 AW.Grid.Controllers.Grid={onRowsTemplateChanged:function(rows){rows.mapTemplate("item","row");rows.mapModel("view","row")},onRowTemplateChanged:function(row){row.setClass("grid","row");row.setClass("row",function(){return this.$0});row.setClass("rows",function(){return this.getRowProperty("state")|| "normal"});row.setClass("alternate",function(){return this.getRowProperty("position")% 2?"odd":"even"});row.mapTemplate("item",function(i){return this.$owner.getCell(i,this.$0)});row.mapTemplate("selector",function(){return this.$owner.getSelector(this.$0)});row.mapModel("view","column")},onCellTemplateChanged:function(cell){cell.setAttribute("title","");cell.setClass("grid","cell");cell.setClass("column",function(){return this.$0});cell.setClass("cells",function(){return this.getControlProperty("state")|| "normal"});cell.mapModel("control","cell");cell.getStateProperty=function(p){return this.$owner.getRowProperty(p,this.$1)};cell.setStateProperty=function(p,v){this.$owner.setRowProperty(p,v,this.$1)}},onHeadersTemplateChanged:function(headers){headers.setClass("grid","headers");headers.setClass("header",function(){return this.$0 || "0"});headers.setStyle("height",function(){return this.getHeaderProperty("height")- AW.dy+"px"});headers.getContent("end").setClass("grid","header");headers.mapTemplate("item",function(i){return this.$owner.getHeader(i,this.$0)+this.$owner.getSeparator(i,this.$0)});headers.mapTemplate("selector",function(){return this.$owner.getTopSelector(this.$0)+(this.$owner.getSelectorResizable()&& !this.$0?this.$owner.getSeparator("selector"):"")});headers.mapModel("view","column");headers._raiseEvents=false},onFootersTemplateChanged:function(footers){footers.setClass("grid","footers");footers.setClass("footer",function(){return this.$0 || "0"});footers.setStyle("height",function(){return this.getFooterProperty("height")- AW.dy+"px"});footers.mapTemplate("item",function(i){return this.$owner.getFooter(i,this.$0)});footers.mapTemplate("selector","bottomSelector");footers.mapModel("view","column");footers._raiseEvents=false},onHeaderTemplateChanged:function(header){header.setClass("grid","header");header.setClass("column",function(){return this.$0});header.mapModel("control","header");header.getStateProperty=function(p){return this.$owner.getColumnProperty(p,this.$0)};header.setStateProperty=function(p,v){this.$owner.setColumnProperty(p,v,this.$0)}},onFooterTemplateChanged:function(footer){footer.setClass("grid","footer");footer.setClass("column",function(){return this.$0});footer.mapModel("control","footer")},onSelectorTemplateChanged:function(selector){selector.setClass("row","selector");selector.mapModel("control","selector");selector.mapModel("state","row")},onTopSelectorTemplateChanged:function(selector){selector.setClass("grid","header");selector.setClass("row","selector");selector.mapModel("control","top")},onBottomSelectorTemplateChanged:function(selector){selector.setClass("row","selector");selector.mapModel("control","bottom")},onViewTemplateChanged:function(view){view.mapModel("panel","content");view.mapTemplate("panel",function(i){switch(i){case "top":return this.getHeaders();case "center":return this.getRows();case "bottom":return this.getFooters()}})},onScrollTemplateChanged:function(scroll){scroll.setStyle("visibility","hidden")},onPopupTemplateChanged:function(popup){popup.onItemClicked=function(event,i){try{var s=this.getItemText(i);this.$owner.setCellText(s,this.$0,this.$1);AW.$popup.hidePopup()}catch(e){}}}};
 AW.Grid.Controllers.Extended={onViewTemplateChanged:function(view){view.mapModel("panel","content");view.mapTemplate("panel",function(i,j){switch(i){case "top":return this.$owner.getTop(j);case "center":return this.$owner.getRows(j);case "bottom":return this.$owner.getBottom(j)}})},onTopTemplateChanged:function(top){top.mapTemplate("item","headers");top.mapModel("view","header")},onBottomTemplateChanged:function(bottom){bottom.mapTemplate("item","footers");bottom.mapModel("view","footer")}};
 AW.Grid.Controllers.SingleCell=(function(){var cc=["getCurrentColumn","getFirstColumn","getPreviousColumn","getNextColumn","getLastColumn"];var rr=["getCurrentRow","getFirstRow","getPreviousRow","getNextRow","getLastRow","getPageUpRow","getPageDownRow"];function kb(i,j){return function(event){var col=this[cc[i]]();var row=this[rr[j]]();this.selectCell(col,row);AW.setReturnValue(event,false)}}function ms(){return function(event,col,row){this.selectCell(col,row)}}return{onKeyCtrlUp:kb(0,1),onKeyUp:kb(0,2),onKeyDown:kb(0,3),onKeyCtrlDown:kb(0,4),onKeyPageUp:kb(0,5),onKeyPageDown:kb(0,6),onKeyCtrlLeft:kb(1,0),onKeyLeft:kb(2,0),onKeyRight:kb(3,0),onKeyCtrlRight:kb(4,0),onKeyHome:kb(1,0),onKeyEnd:kb(4,0),onKeyCtrlHome:kb(1,1),onKeyCtrlEnd:kb(4,4),onCellClicking:ms()}})();
 AW.Grid.Controllers.SingleRow=(function(){var rr=["getCurrentRow","getFirstRow","getPreviousRow","getNextRow","getLastRow","getPageUpRow","getPageDownRow"];function kb(i){return function(event){var row=this[rr[i]]();this.selectRow(row);AW.setReturnValue(event,false)}}function ms(){return function(event,row){this.selectRow(row)}}return{onKeyHome:kb(1),onKeyUp:kb(2),onKeyDown:kb(3),onKeyEnd:kb(4),onKeyCtrlHome:kb(1),onKeyCtrlEnd:kb(4),onKeyPageUp:kb(5),onKeyPageDown:kb(6),onRowClicking:ms()}})();
 AW.Grid.Controllers.MultiCell=(function(){var cc=["getCurrentColumn","getFirstColumn","getPreviousColumn","getNextColumn","getLastColumn"];var rr=["getCurrentRow","getFirstRow","getPreviousRow","getNextRow","getLastRow","getPageUpRow","getPageDownRow"];function kb(i,j,mode){return function(event){var col=this[cc[i]]();var row=this[rr[j]]();this.selectCell(col,row,mode);AW.setReturnValue(event,false)}}function ms(mode){return function(event,col,row){if(event.button==2 && this.getCellSelected(col,row)){return}this.selectCell(col,row,mode);if(AW.gecko && mode){try{window.getSelection().collapseToEnd()}catch(err){}}}}return{onKeyCtrlUp:kb(0,1),onKeyUp:kb(0,2),onKeyDown:kb(0,3),onKeyCtrlDown:kb(0,4),onKeyPageUp:kb(0,5),onKeyPageDown:kb(0,6),onKeyCtrlLeft:kb(1,0),onKeyLeft:kb(2,0),onKeyRight:kb(3,0),onKeyCtrlRight:kb(4,0),onKeyHome:kb(1,0),onKeyEnd:kb(4,0),onKeyCtrlHome:kb(1,1),onKeyCtrlEnd:kb(4,4),onKeyShiftUp:kb(0,2,1),onKeyShiftDown:kb(0,3,1),onKeyShiftPageUp:kb(0,5,1),onKeyShiftPageDown:kb(0,6,1),onKeyShiftLeft:kb(2,0,1),onKeyShiftRight:kb(3,0,1),onCellClicking:ms(),onCellShiftClicking:ms(1)}})();
 AW.Grid.Controllers.MultiRow=(function(){var rr=["getCurrentRow","getFirstRow","getPreviousRow","getNextRow","getLastRow","getPageUpRow","getPageDownRow"];function kb(i,mode){return function(event){var row=this[rr[i]]();this.selectRow(row,mode);AW.setReturnValue(event,false)}}function ms(mode){return function(event,row){if(event.button==2 && this.getRowSelected(row)){return}this.selectRow(row,mode);if(AW.gecko && mode){try{window.getSelection().collapseToEnd()}catch(err){}}}}return{onKeyHome:kb(1),onKeyUp:kb(2),onKeyDown:kb(3),onKeyEnd:kb(4),onKeyCtrlHome:kb(1),onKeyCtrlEnd:kb(4),onKeyPageUp:kb(5),onKeyPageDown:kb(6),onKeyShiftHome:kb(1,1),onKeyShiftUp:kb(2,1),onKeyShiftDown:kb(3,1),onKeyShiftEnd:kb(4,1),onKeyCtrlShiftHome:kb(1,1),onKeyCtrlShiftEnd:kb(4,1),onKeyShiftPageUp:kb(5,1),onKeyShiftPageDown:kb(6,1),onRowClicking:ms(),onRowShiftClicking:ms(1),onRowCtrlClicking:ms(2)}})();
 AW.Grid.Controllers.MultiRowMarker=(function(){var rr=["getCurrentRow","getFirstRow","getPreviousRow","getNextRow","getLastRow","getPageUpRow","getPageDownRow"];function kb(i,mode){return function(event){var row=this[rr[i]]();this.selectRow(row,mode);AW.setReturnValue(event,false)}}function refresh(v,i){this.getRow(i).refresh()}return{onKeyHome:kb(1,3),onKeyUp:kb(2,3),onKeyDown:kb(3,3),onKeyEnd:kb(4,3),onKeyPageUp:kb(5,3),onKeyPageDown:kb(6,3),onRowSelectedChanged:refresh}})();
 AW.Grid.Separator=AW.System.Template.subclass();AW.Grid.Separator.create=function(){var obj=this.prototype;obj.setClass("grid","separator");obj.setClass("resizable",function(){return this.getColumnProperty("resizable")?true:false});obj._raiseEvents=true;obj.setEvent("onmousedown",function(event){if(!this.getColumnProperty("resizable")){return false}var start=event.screenX;var self=this;var width=self.element().previousSibling.offsetWidth;var scroll=self.element().parentNode.parentNode.scrollLeft;function doResize(event){var w=width+event.screenX - start;w=w > 9?w:9;self.element().previousSibling.style.width=(w - AW.dx)+"px"}function endResize(event){var w=width+event.screenX - start;w=w > 9?w:9;var e=AW.opera?window:self.element();AW.detachEvent(e,"onmousemove",doResize);AW.detachEvent(e,"onmouseup",endResize);AW.detachEvent(e,"onlosecapture",endResize);AW.releaseCapture(e);AW.ignoreMouse=false;e=self.element();if(AW.gecko){try{e.parentNode.parentNode.scrollLeft=scroll;e.parentNode.focus()}catch(err){}}var id=e.previousSibling.id;if(id.match("header")){self.$owner.setColumnProperty("width",w,self.$0)}else if(id.match("topSelector")){self.$owner.setSelectorProperty("width",w)}e.previousSibling.style.width="";e=null}var e=AW.opera?window:self.element();AW.setCapture(e);AW.attachEvent(e,"onmousemove",doResize);AW.attachEvent(e,"onmouseup",endResize);AW.attachEvent(e,"onlosecapture",endResize);e=null;event.cancelBubble=true;AW.ignoreMouse=true;if(AW.opera || AW.konqueror){event.preventDefault();return false}})};
 AW.Grid.Header=AW.Templates.ImageText.subclass();AW.Grid.Header.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;function _direction(){return this.getSortProperty("direction")|| "none"}obj.setClass("sort",_direction);var sort=new AW.HTML.SPAN;sort.setClass("grid","sort");obj.setContent("box/text/sort",sort);obj.element=function(){if(typeof(this.$1)=="undefined" && this.$owner && this.$owner.$extended){return _super.element.call(this.$owner.getHeader(this.$0,0))}else{return _super.element.call(this)}}};
 AW.Grid.Row=AW.System.Template.subclass();AW.Grid.Row.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setTag("span");obj.setClass("templates","list");obj.setClass("text","normal");if(AW.gecko){obj.setAttribute("tabIndex","-1")}obj.setContent("selector",function(){return(!this.$1 || this.$1=="left")&& this.getSelectorProperty("visible")?this.getSelector():""});var span=AW.HTML.SPAN;var start=new span;start.setClass("row","start");start.setStyle("width",function(){if((!this.$1 || this.$1=="center")&& this.$name=="row" && this.getVirtualProperty("mode")){return this.getViewProperty("virtualScroll")+"px"}return 0});obj.setContent("start",start);obj.setContent("items",function(){var i,ii,a=[];var virtual=this.getVirtualProperty("mode");var indices=this.getViewProperty("indices");var offset,count;if(virtual &&(!this.$1 || this.$1=="center")&& this.$name=="row"){count=this.getViewProperty("virtualCount");offset=this.getViewProperty("virtualOffset")}else{count=this.getViewProperty("count");offset=this.getViewProperty("offset")}var clone=this.$owner.$clone;this.$owner.$clone=false;for(i=0;i<count;i++){ii=indices?indices[i+offset]:i+offset;a[i]=this.getItem(ii).toString()}this.$owner.$clone=clone;return a.join("")});var space=new span;var box=new span;space.setClass("item","template");space.setClass("grid","cell");space.setClass("column","space");box.setClass("item","box");space.setContent("box",box);obj.setContent("end",space);obj.refreshVirtual1=function(h,a){var i,ii;var se=this.getContent("start").element();var ee=this.getContent("end").element();se.style.width=this.getViewProperty("virtualScroll")+"px";for(i=h.start1;i<h.start2;i++){se.parentNode.removeChild(se.nextSibling)}for(i=h.end1;i>h.end2;i--){ee.parentNode.removeChild(ee.previousSibling)}var indices=this.getViewProperty("indices");var clone=this.$owner.$clone;this.$owner.$clone=false;for(i=h.start1-1;i>=h.start2;i--){ii=indices?indices[i]:i;a.push(this.getItem(ii).toString())}for(i=h.end1+1;i<=h.end2;i++){ii=indices?indices[i]:i;a.push(this.getItem(ii).toString())}this.$owner.$clone=clone;se=null;ee=null};obj.refreshVirtual2=function(h,p){var i;var se=this.getContent("start").element();var ee=this.getContent("end").element();for(i=h.start1-1;i>=h.start2;i--){se.parentNode.insertBefore(p.firstChild,se.nextSibling)}for(i=h.end1+1;i<=h.end2;i++){ee.parentNode.insertBefore(p.firstChild,ee)}se=null;ee=null};var rf=obj.refresh;obj.refresh=function(){if(typeof(this.$1)=="undefined" && this.$owner.$extended){rf.call(this.$owner.getRow(this.$0,"left"));rf.call(this.$owner.getRow(this.$0,"center"));rf.call(this.$owner.getRow(this.$0,"right"))}else{rf.call(this)}};var rc=obj.refreshClasses;obj.refreshClasses=function(){if(typeof(this.$1)=="undefined" && this.$owner.$extended){rc.call(this.$owner.getRow(this.$0,"left"));rc.call(this.$owner.getRow(this.$0,"center"));rc.call(this.$owner.getRow(this.$0,"right"))}else{rc.call(this)}};AW._addMouseEvents(obj);function extendEvent(name){var f=obj[name];obj[name]=function(){if(this.$owner.$extended){f.call(this.$owner.getRow(this.$0,"left"));f.call(this.$owner.getRow(this.$0,"center"));f.call(this.$owner.getRow(this.$0,"right"))}else{f.call(this)}}}extendEvent("onMouseOver");extendEvent("onMouseOut");extendEvent("onMouseDown");extendEvent("onMouseUp")};
 AW.Grid.Rows=AW.Templates.List.subclass();AW.Grid.Rows.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setClass("grid","view");var init=new AW.System.HTML;init.setTag("marquee");init.setClass("grid","init");init.setAttribute("behavior","slide");init.setEvent("onstart",waitInit);init.setEvent("onresize",waitInit);obj.setContent("init",AW.ie?init:"");function initialize(){if(AW.ie){var e=this.getContent("init").element();if(e){e.parentNode.removeChild(e);e=null}this.setContent("init","")}if(this.$owner._initialized){return}this.$owner._initialized=true;this.setTimeout(function(){this.raiseEvent("paint")})}function waitInit(){var e=this.element();if((e && e.offsetWidth && e.offsetHeight)|| this.$owner._initialized){initialize.call(this)}else{this.setTimeout(waitInit,1000)}e=null}obj.setContent("items",function(){if(!this.$owner._initialized){if(!AW.ie){this.setTimeout(waitInit,100)}return ""}var i,ii,a=[];var virtual=this.getVirtualProperty("mode");var indices=this.getViewProperty("indices");var count,offset;if(virtual){count=this.getViewProperty("virtualCount");offset=this.getViewProperty("virtualOffset")}else{count=this.getViewProperty("count");offset=this.getViewProperty("offset")}var clone=this.$owner.$clone;this.$owner.$clone=false;for(i=0;i<count;i++){ii=indices?indices[i+offset]:i+offset;a[i]=this.getItem(ii).toString()}this.$owner.$clone=clone;return a.join("")});var span=AW.HTML.SPAN;var top=new span;top.setClass("view","top");top.setStyle("height",function(){return this.getVirtualProperty("mode")?this.getViewProperty("virtualScroll")+"px":0});obj.setContent("start",top);var space=new span;var box=new span;space.setClass("item","template");space.setClass("row","selector");space.setClass("selector","space");box.setClass("item","box");space.setContent("box",box);obj.setContent("end",space);obj.refresh=function(){if(this.$owner && this.$owner.$active){this.$owner.focus()}if(typeof(this.$0)=="undefined" && this.$owner.$extended){_super.refresh.call(this.$owner.getRows("left"));_super.refresh.call(this.$owner.getRows("center"));_super.refresh.call(this.$owner.getRows("right"))}else{_super.refresh.call(this)}};obj.refreshVirtual=function(){if(this.$owner && this.$owner.$active){this.$owner.focus()}var undef;var panel=this.$owner.$extended?"center":undef;var se=this.getRows(panel).getContent("start").element();var ee=this.getRows(panel).getContent("end").element();if(!se || !ee || se.nextSibling==ee){se=null;ee=null;return this.refresh()}var si=AW.object(se.nextSibling.id).$0;var ei=AW.object(ee.previousSibling.id).$0;var start1=this.getRowProperty("position",si);var end1=this.getRowProperty("position",ei);var start2=this.getRowProperty("virtualOffset");var end2=start2+this.getRowProperty("virtualCount")- 1;var h={};se=this.getRow(si,panel).getContent("start").element();ee=this.getRow(si,panel).getContent("end").element();if(!se || !ee || se.nextSibling==ee){se=null;ee=null;return this.refresh()}si=AW.object(se.nextSibling.id).$0;ei=AW.object(ee.previousSibling.id).$0;h.start1=this.getColumnProperty("position",si);h.end1=this.getColumnProperty("position",ei);h.start2=this.getColumnProperty("virtualOffset");h.end2=h.start2+this.getColumnProperty("virtualCount")- 1;if(start2 > end1 || end2 < start1 || h.start2 > h.end1 || h.end2 < h.start1){se=null;ee=null;return this.refresh()}var i,ii,j;var indices=this.getRowProperty("indices");var panels=this.$owner.$extended?["left","center","right"]:[undef];for(j=0;j<panels.length;j++){panel=panels[j];se=this.getRows(panel).getContent("start").element();ee=this.getRows(panel).getContent("end").element();se.style.height=this.getRowProperty("virtualScroll")+"px";for(i=start1;i<start2;i++){se.parentNode.removeChild(se.nextSibling)}for(i=end1;i>end2;i--){ee.parentNode.removeChild(ee.previousSibling)}}var a=[];var p=document.createElement("span");var start3=Math.max(start1,start2);var end3=Math.min(end1,end2);panel=this.$owner.$extended?"center":undef;if(h.start1 !=h.start2 || h.end1 !=h.end2){for(i=start3;i<=end3;i++){ii=indices?indices[i]:i;this.getRow(ii,panel).refreshVirtual1(h,a)}p.innerHTML=a.join("");for(i=start3;i<=end3;i++){ii=indices?indices[i]:i;this.getRow(ii,panel).refreshVirtual2(h,p)}}for(j=0;j<panels.length;j++){panel=panels[j];se=this.getRows(panel).getContent("start").element();ee=this.getRows(panel).getContent("end").element();var k=0;a=[];var clone=this.$owner.$clone;this.$owner.$clone=false;for(i=start1-1;i>=start2;i--){ii=indices?indices[i]:i;a[k++]=this.getRow(ii,panel).toString()}for(i=end1+1;i<=end2;i++){ii=indices?indices[i]:i;a[k++]=this.getRow(ii,panel).toString()}this.$owner.$clone=clone;p.innerHTML=a.join("");for(i=start1-1;i>=start2;i--){se.parentNode.insertBefore(p.firstChild,se.nextSibling)}for(i=end1+1;i<=end2;i++){ee.parentNode.insertBefore(p.firstChild,ee)}se=null;ee=null}p=null}};
 AW.Grid.Control=AW.System.Control.subclass();AW.Grid.Control.create=function(){var obj=this.prototype;var _super=this.superclass.prototype;obj.setClass("grid","control");obj.setClass("selectors",function(){return this.getSelectorVisible()?"visible":"hidden"});var focus=new AW.HTML.TEXTAREA;focus.setClass("control","focus");focus.setAttribute("tabIndex",function(){return this.getTabProperty("index")});var sample=new AW.HTML.SPAN;sample.setClass("row","sample");sample.setClass("grid","row");var box=new AW.HTML.SPAN;box.setClass("grid","box");box.setContent("focus",focus);box.setContent("html",function(){return this.getLayout()});box.setContent("sample",sample);obj.setContent("box",box);var Grid=AW.Grid.Controllers;obj.setController("size",Grid.Size);obj.setController("cell",Grid.Cell);obj.setController("edit",Grid.Edit);obj.setController("row",Grid.Row);obj.setController("view",Grid.View);obj.setController("navigation",Grid.Navigation);obj.setController("selection",Grid.SingleCell);obj.setController("sort",Grid.Sort);obj.setController("overflow",Grid.Overflow);obj.setController("scroll",Grid.Scroll);obj.setController("content",Grid.Content);obj.setController("virtual",Grid.Virtual);obj.setController("grid",Grid.Grid);obj.defineTemplate("layout",function(){return this.getScrollTemplate()});obj.defineTemplate("scroll",new AW.Scroll.Bars);obj.defineTemplate("view",new AW.Panels.Horizontal);obj.defineTemplate("panel",function(){return ""});obj.defineTemplate("rows",new AW.Grid.Rows);obj.defineTemplate("row",new AW.Grid.Row);obj.defineTemplate("cell",new AW.Templates.Cell);obj.defineTemplate("headers",new AW.Grid.Row);obj.defineTemplate("footers",new AW.Grid.Row);obj.defineTemplate("header",new AW.Grid.Header);obj.defineTemplate("footer",new AW.Templates.ImageText);obj.defineTemplate("separator",new AW.Grid.Separator);obj.defineTemplate("selector",new AW.Templates.ImageText);obj.defineTemplate("topSelector",new AW.Templates.ImageText);obj.defineTemplate("bottomSelector",new AW.Templates.ImageText);obj.defineTemplate("popup",new AW.System.Template);function value(i,j){var text=this.getCellText(i,j);var format=this.getCellFormat(i,j);return format?format.textToValue(text):AW.textToValue(text)}function position(i){return Number(i)}var models={scroll:{left:0,top:0,width:0,height:0,bars:"both"},cell:{text:"",image:"",link:"",value:value,data:"",format:"",tooltip:"",state:"",selected:false,editable:false},header:{text:"",image:"",link:"",value:value,data:"",format:"",tooltip:"",state:"",count:1,offset:0,height:20,visible:true},selector:{text:"",image:"",link:"",value:value,data:"",format:"",tooltip:"",state:"",width:20,resizable:false,visible:false},top:{text:"",image:"",link:"",value:value,data:"",format:"",tooltip:"",state:""},column:{offset:0,count:0,position:position,state:"",selected:false,resizable:true,width:100,virtualOffset:0,virtualCount:0,virtualScroll:0},row:{offset:0,count:0,position:position,state:"",selected:false,height:18,virtualOffset:0,virtualCount:0,virtualScroll:0},current:{row:0,column:0,selection:"cell"},selected:{},selection:{mode:"rows",multiple:false},sort:{column:-1,direction:""},fixed:{left:1,right:0},virtual:{mode:true,top:0},content:{width:0,height:0}};obj.defineModel("scroll",models.scroll);obj.defineModel("cell",models.cell);obj.defineModel("header",models.header);obj.defineModel("footer",models.header);obj.defineModel("selector",models.selector);obj.defineModel("top",models.top);obj.defineModel("bottom",models.top);obj.defineModel("column",models.column);obj.defineModel("row",models.row);obj.defineModel("current",models.current);obj.defineModel("selected",models.selected);obj.defineModel("selection",models.selection);obj.defineModel("sort",models.sort);obj.defineModel("virtual",models.virtual);obj.defineModel("content",models.content);obj.defineModel("panel",models.content);obj.defineModel("fixed",models.fixed);obj.defineColumnProperty("indices","",true);obj.defineRowProperty("indices","",true);obj.defineHeaderProperty("indices","",true);obj.defineFooterProperty("indices","",true);obj.defineSelectedProperty("rows",[],true);obj.defineSelectedProperty("columns",[],true);obj.setFooterVisible(false);obj.setContentWidth(100,"left");obj.setContentHeight(20,"top");obj.getFirstColumn=function(){var p=this.getColumnOffset();var a=this.getColumnIndices();return a?a[p]:p};obj.getLastColumn=function(){var p=this.getColumnOffset()+this.getColumnCount()- 1;var a=this.getColumnIndices();return a?a[p]:p};obj.getNextColumn=function(){var i=this.getCurrentColumn();var p=Math.min(this.getColumnPosition(i)+1,this.getColumnOffset()+this.getColumnCount()- 1);var a=this.getColumnIndices();return a?a[p]:p};obj.getPreviousColumn=function(){var i=this.getCurrentColumn();var p=Math.max(this.getColumnPosition(i)- 1,this.getColumnOffset());var a=this.getColumnIndices();return a?a[p]:p};obj.getFirstRow=function(){var p=this.getRowOffset();var a=this.getRowIndices();return a?a[p]:p};obj.getLastRow=function(){var p=this.getRowOffset()+this.getRowCount()- 1;var a=this.getRowIndices();return a?a[p]:p};obj.getNextRow=function(){var i=this.getCurrentRow();var p=Math.min(this.getRowPosition(i)+1,this.getRowOffset()+this.getRowCount()- 1);var a=this.getRowIndices();return a?a[p]:p};obj.getPreviousRow=function(){var i=this.getCurrentRow();var p=Math.max(this.getRowPosition(i)- 1,this.getRowOffset());var a=this.getRowIndices();return a?a[p]:p};obj.getPageUpRow=function(){var i=this.getCurrentRow();var p=Math.max(this.getRowPosition(i)- 10,this.getRowOffset());var a=this.getRowIndices();return a?a[p]:p};obj.getPageDownRow=function(){var i=this.getCurrentRow();var p=Math.min(this.getRowPosition(i)+10,this.getRowOffset()+this.getRowCount()- 1);var a=this.getRowIndices();return a?a[p]:p};obj.selectRow=function(row,mode){if(this.$edit){this.focus()}if(this.$edit){return}this._startUpdate();if(this.getCurrentSelection()!="row"){this.setCurrentSelection("row")}var start,end,i,a;var rr=this.getSelectedRows();if(!mode){if(rr.length !=1 || rr[0] !=row){this.setSelectedRows([row])}}else if(mode==1){if(!rr.length){this.setSelectedRows([row])}else{start=this.getRowPosition(rr[0]);end=this.getRowPosition(row);a=this.getRowIndices();rr=[];if(start < end){for(i=start;i <=end;i++){rr.push(a?a[i]:i)}}else{for(i=start;i >=end;i--){rr.push(a?a[i]:i)}}this.setSelectedRows(rr)}}else if(mode==2){this.setRowSelected(!this.getRowSelected(row),row)}if(row!=this.getCurrentRow()){this.setCurrentRow(row)}this._endUpdate()};obj.selectCell=function(col,row,mode){if(this.$edit){this.focus()}if(this.$edit){return}this._startUpdate();if(this.getCurrentSelection()!="cell"){this.setCurrentSelection("cell")}var start,end,i,a;var cc=this.getSelectedColumns();var rr=this.getSelectedRows();if(!mode){if(cc.length !=1 || cc[0] !=col){this.setSelectedColumns([col])}if(rr.length !=1 || rr[0] !=row){this.setSelectedRows([row])}}else if(mode==1){if(!cc.length){this.setSelectedColumns([col])}else{start=this.getColumnPosition(cc[0]);end=this.getColumnPosition(col);a=this.getColumnIndices();cc=[];if(start < end){for(i=start;i <=end;i++){cc.push(a?a[i]:i)}}else{for(i=start;i >=end;i--){cc.push(a?a[i]:i)}}this.setSelectedColumns(cc)}if(!rr.length){this.setSelectedRows([row])}else{start=this.getRowPosition(rr[0]);end=this.getRowPosition(row);a=this.getRowIndices();rr=[];if(start < end){for(i=start;i <=end;i++){rr.push(a?a[i]:i)}}else{for(i=start;i >=end;i--){rr.push(a?a[i]:i)}}this.setSelectedRows(rr)}}if(col!=this.getCurrentColumn()){this.setCurrentColumn(col)}if(row!=this.getCurrentRow()){this.setCurrentRow(row)}this._endUpdate()};obj.calculateRowState=function(i){var state="";if(this.getCurrentRow()==i){state="current"}if(this.getRowSelected(i)){state="selected"}this.setRowState(state,i)};obj.calculateCellState=function(i,j){var state="";if(this.getCurrentColumn()==i && this.getCurrentRow()==j){state="current"}if(this.getCellSelected(i,j)){state="selected"}this.setCellState(state,i,j)};obj.startCellEdit=function(text){if(this.$edit){return}var c=this.getCurrentColumn();var r=this.getCurrentRow();if(!this.getCellEditable(c,r)){return}var cell=this.getCell(c,r);return AW._startEdit(cell,text)};obj.cancelCellEdit=function(){AW._cancelEdit();this.focus();return !AW._edit};obj.endCellEdit=function(){this.focus();return !AW._edit};box.setEvent("onactivate",function(event){try{if(event.srcElement.tagName=="SPAN"){var src=AW.object(event.srcElement.id,true);if(src && src.setController && src !==this){return}var target=this;function onfocus(event){event.srcElement.detachEvent("onfocus",onfocus);target.focus();target=null}event.srcElement.attachEvent("onfocus",onfocus)}}catch(err){}});focus.setEvent("onbeforedeactivate",function(event){try{if(this.getView().element().contains(event.toElement)&& event.toElement.tagName=="SPAN"){var src=AW.object(event.toElement.id,true);if(src && src.setController && src !==this){return}event.returnValue=false;event.cancelBubble=true}}catch(err){}});focus.setEvent("onselectstart",function(event){if(AW.ie){event.cancelBubble=true}else{event.stopPropagation()}});focus.setEvent("onbeforecopy",function(event){if(AW.webkit){expandFocus.call(this,false)}});obj.getSelectedText=function(){var c,r,a,text=[];var cols=this.getSelectedColumns();var rows=this.getSelectedRows();if(this.getCurrentSelection()=="row"){cols=[];var count=this.getColumnCount();var indices=this.getColumnIndices();for(c=0;c<count;c++){cols[c]=indices?indices[c]:c}}for(r=0;r<rows.length;r++){a=[];for(c=0;c<cols.length;c++){a[c]=this.getCellText(cols[c],rows[r])}text[r]=a.join("\t")}return text.join("\r\n")};focus.setEvent("oncut",function(event){var txt=this.getSelectedText();if(AW.ie){window.clipboardData.setData("Text",txt);event.returnValue=false}else{var e=this.getContent("box/focus").element();e.value=txt;e.select()}this.startCellEdit("")});focus.setEvent("oncopy",function(event){var txt=this.getSelectedText();if(AW.ie){window.clipboardData.setData("Text",txt);event.returnValue=false}else{var e=this.getContent("box/focus").element();e.value=txt;e.select()}});focus.setEvent("onpaste",function(event){var txt;if(AW.ie){txt=window.clipboardData.getData("Text");event.returnValue=false}else if(AW.webkit){txt=event.clipboardData.getData('text/plain');event.preventDefault();event.stopPropagation()}else{return}this.startCellEdit(txt)});obj.setEvent("oncontextmenu",function(event){if(AW.webkit){expandFocus.call(this,true)}if(AW.ffx){expandFocus.call(this,false);return ffCopy.call(this)}this.focus()});function ffCopy(){if(!AW._edit){var e=this.getContent("box/focus").element();e.value=this.getSelectedText();e.select();e.focus()}}if(AW.gecko){obj.setController("copypaste",{onKeyCtrlC:AW.ffx?ffCopy:null,onCellMouseUp:function(event){if(event.button==2){expandFocus.call(this,true);if(AW.ff3 && !AW._edit){this.getContent("box/focus").element().select()}this.setTimeout(function(){expandFocus.call(this,false)})}}})}function expandFocus(on){try{var e=this.getContent("box/focus").element();e.style.zIndex=on?1:0;e.style.width=on?"100%":"1px";e.style.height=on?"100%":"1px";e=null}catch(err){}}obj.focus=function(){try{if(this.getControlDisabled()){return}var e=this.getContent("box/focus").element();e.value=" ";if(AW.opera){e.focus()}else{e.select()}e=null}catch(err){}};obj.refresh=function(){var x=this.getScrollLeft();var y=this.getScrollTop();this.raiseEvent("onControlRefreshing");_super.refresh.call(this);this.getScroll().setStyle("visibility","hidden");this.setScrollLeft(x);this.setScrollTop(y);this.getScroll().setStyle("visibility","inherit");this.raiseEvent("onControlRefreshed")};obj.addRow=function(row){if(this.raiseEvent("onRowAdding",row)){return}var i,count=this.getRowCount();var a=this.getRowIndices();if(typeof(row)=="undefined"){row=count}if(this._cellModel && this._cellModel.addRow){this._cellModel.addRow(row)}if(!a){a=[];for(i=0;i<count;i++){a[i]=i}}a.push(row);var refresh=this.refresh;this.refresh=function(){};this.setRowIndices(a);this.setRowCount(count+1);this.setCurrentRow(row);this.setSelectedRows([row]);this.refresh=refresh;this.raiseEvent("onRowAdded",row)};obj.deleteRow=function(row){if(this.raiseEvent("onRowDeleting",row)){return}if(this._cellModel && this._cellModel.deleteRow){this._cellModel.deleteRow(row)}var i,count=this.getRowCount();var a=this.getRowIndices();if(!a){a=[];for(i=0;i<count;i++){a[i]=i}i=row}else{i=this.getRowPosition(row)}a.splice(i,1);var refresh=this.refresh;this.refresh=function(){};this.setRowIndices(a);this.setRowCount(count-1);this.setCurrentRow(i>0?a[i-1]:-1);this.setSelectedRows(i>0?[a[i-1]]:[]);this.refresh=refresh;this.raiseEvent("onRowDeleted",row)};obj.sort=function(column,direction){this.raiseEvent("doSort",direction,column)};var setCellModel=obj.setCellModel;obj.setCellModel=function(model){setCellModel.call(this,model);function dataToText(i,j){var data=this.getCellData(i,j);var format=this.getCellFormat(i,j);return format?format.dataToText(data):data}function dataToValue(i,j){var data=this.getCellData(i,j);var format=this.getCellFormat(i,j);return format?format.dataToValue(data):data}this.setCellText(dataToText);this.setCellValue(dataToValue)};obj.onControlDisabledChanged=function(value){this.setClass("disabled",value?"control":null);this.setAttribute("disabled",value?true:null)};obj._scrollSerial=0};AW.UI.Grid=AW.Grid.Control;
 AW.Grid.Extended=AW.Grid.Control.subclass();AW.Grid.Extended.create=function(){var obj=this.prototype;obj.$extended=true;obj.setController("extended",AW.Grid.Controllers.Extended);obj.setView(new AW.Panels.Grid);obj.defineTemplate("top",new AW.Templates.List);obj.defineTemplate("bottom",new AW.Templates.List);var splitColumns=function(p,j){var left=this.$owner._fixedLeft,right=this.$owner._fixedRight;var i=this.$1;switch(p){case "count":if(i=="left"){return left}if(i=="center"){return this.$owner.getColumnProperty("count")- left - right}if(i=="right"){return right}return 0;case "offset":if(i=="left"){return 0}if(i=="center"){return left}if(i=="right"){return this.$owner.getColumnProperty("count")- right}return 0;default:return this.$owner.getColumnProperty(p,j)}};obj.getHeaders().mapModel("view",splitColumns);obj.getFooters().mapModel("view",splitColumns);obj.getRow().mapModel("view",splitColumns)};
 AW.Tree.Item=AW.Templates.ImageText.subclass();AW.Tree.Item.create=function(){var obj=this.prototype;obj.setClass("tree",function(){return this.getViewProperty("count")?"folder":"leaf"});obj.setClass("expanded",function(){return this.getViewProperty("expanded")?"true":"false"});var sign=new AW.HTML.SPAN;sign.setClass("tree","sign");sign.setEvent("onclick",function(){this.raiseEvent("onTreeSignClicked")});obj.setContent("box/sign",sign)};
 AW.Tree.View=AW.System.Template.subclass();AW.Tree.View.create=function(){var obj=this.prototype;obj.setTag("span");obj.setClass("tree","view");obj.setContent("start",function(){return this.$0?this.getItem():""});obj.setContent("items",function(){if(this.$0 && !this.getViewProperty("expanded")){return ""}var i,ii,a=[];var count=this.getViewProperty("count");var offset=this.getViewProperty("offset");var indices=this.getViewProperty("indices");var clone=this.$owner.$clone;this.$owner.$clone=false;for(i=0;i<count;i++){ii=indices?indices[i+offset]:i+offset;a[i]=this.getView(ii).toString()}this.$owner.$clone=clone;return a.join("")});obj.setContent("end","")};
 AW.Tree.Group=AW.System.Template.subclass();AW.Tree.Group.create=function(){var obj=this.prototype;obj.setTag("span");obj.setClass("tree","view");obj.setContent("start",function(){return this.$0?this.getItem():""});obj.setContent("items",function(){if(this.$0 && !this.getViewProperty("expanded")){return ""}else{return this.getView()}});obj.setContent("end","")};
 AW.Tree.Control=AW.UI.List.subclass();AW.Tree.Control.create=function(){var obj=this.prototype;obj.defineTemplate("group",new AW.Tree.Group);obj.setItem(new AW.Tree.Item);obj.setScroll(function(){return this.getGroup(0)});obj.getView().mapTemplate("item",function(i){return this.$owner.getGroup(i)});obj.defineViewProperty("expanded",false);obj.onTreeSignClicked=function(src,i){if(this.getViewIndices(i)){this.setViewExpanded(!this.getViewExpanded(i),i)}};obj.onViewExpandedChanged=function(e,i){this.getGroup(i).refresh()}};AW.UI.Tree=AW.Tree.Control;
 AW.HTTP.Request=AW.System.Model.subclass();AW.HTTP.Request.create=function(){var obj=this.prototype;obj.defineProperty("URL");obj.defineProperty("async",true);obj.defineProperty("requestMethod","GET");obj.defineProperty("requestData","");obj.defineProperty("responseText",function(){return this._http?this._http.responseText:""});obj.defineProperty("responseXML",function(){return this._http?this._http.responseXML:""});obj.defineProperty("username",null);obj.defineProperty("password",null);obj.setNamespace=function(name,value){this._namespaces+=" xmlns:"+name+"=\""+value+"\""};obj._namespaces="";obj.setParameter=function(name,value){this["_"+name+"Parameter"]=value;if((this._parameters+" ").indexOf(" "+name+" ")< 0){this._parameters+=" "+name}};obj._parameters="";obj.setRequestHeader=function(name,value){this["_"+name+"Header"]=value;if((this._headers+" ").indexOf(" "+name+" ")< 0){this._headers+=" "+name}};obj._headers="";obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");obj.getResponseHeader=function(name){return this._http?this._http.getResponseHeader(name):""};obj.request=function(){var self=this;this._ready=false;var i,j,name,value,data="",params=this._parameters.split(" ");for(i=1;i<params.length;i++){name=params[i];value=this["_"+name+"Parameter"];if(typeof value=="function"){value=value()}if(typeof value=="object" && value.constructor==Array){for(j=0;j<value.length;j++){data+=encodeURIComponent(name)+"="+encodeURIComponent(value[j])+"&"}}else{data+=encodeURIComponent(name)+"="+encodeURIComponent(value)+"&"}}var URL=this._URL;if((this._requestMethod !="POST")&& data){URL+="?"+data;data=null}this._http=AW.createXMLHttpRequest();this._http.open(this._requestMethod,URL,this._async,this._username,this._password);var headers=this._headers.split(" ");for(i=1;i<headers.length;i++){name=headers[i];value=this["_"+name+"Header"];if(typeof value=="function"){value=value()}this._http.setRequestHeader(name,value)}this._http.send(data);if(this._async){this.setTimeout(wait,200)}else{returnResult()}function wait(){if(self._http.readyState==4){self._ready=true;returnResult()}else{self.setTimeout(wait,200)}}function returnResult(){var xml=self._http.responseXML;if(xml && xml.firstChild && xml.hasChildNodes()&& !(xml.firstChild && xml.firstChild.nodeName=="parsererror")&& !(xml.firstChild && xml.firstChild.firstChild && xml.firstChild.firstChild.firstChild && xml.firstChild.firstChild.firstChild.nodeName=="parsererror")){self.response(xml);xml=null;return}xml=null;self.response(self._http.responseText)}};obj.response=function(result){if(this.$owner){this.$owner.refresh()}};obj.isReady=function(){return this._ready}};
 AW.CSV.Table=AW.HTTP.Request.subclass();AW.CSV.Table.create=function(){var obj=this.prototype;obj.response=function(text){this._rows=text.split(/\r*\n/);if(!this._rows[this._rows.length-1]){this._rows.pop()}this._data=[];if(this.$owner){this.$owner.clearScrollModel();this.$owner.clearSelectedModel();this.$owner.clearSortModel();this.$owner.clearRowModel();this.$owner.setRowCount(this.getCount());this.$owner.refresh()}};obj._rows=[];obj._data=[];obj.getCount=function(){return this._rows.length};obj.getData=function(c,r){if(!this._data[r]){if(!this._rows[r]){return ""}this._data[r]=this._rows[r].replace(x1,s1).replace(x2,s2).split(s3)}return this._data[r][c] || ""};var x1=/(([^,\t\"]*)|\"(([^\"]|\"\")*)\")(,|\t|$)/g;var x2=/\"\"/g;var s1="$2$3\x01";var s2="\"";var s3="\x01"};
 AW.XML.Table=AW.HTTP.Request.subclass();AW.XML.Table.create=function(){var obj=this.prototype;obj.response=function(xml){this.setXML(xml);if(this.$owner){this.$owner.clearScrollModel();this.$owner.clearSelectedModel();this.$owner.clearSortModel();this.$owner.clearRowModel();this.$owner.setRowCount(this.getCount());this.$owner.refresh()}};obj.defineProperty("XML");obj.setXML=function(xml){if(!xml.nodeType){var s=""+xml;xml=new ActiveXObject("MSXML2.DOMDocument");xml.loadXML(s)}xml.setProperty("SelectionLanguage","XPath");if(this._namespaces){xml.setProperty("SelectionNamespaces",this._namespaces)}this._xml=xml;this._data=this._xml.selectSingleNode(this._dataPath);this._items=this._data?this._data.selectNodes(this._itemPath):null;this._ready=true};if(!AW.ie){obj.setXML=function(xml){if(!xml.nodeType){var parser=new DOMParser;xml=parser.parseFromString(""+xml,"text/xml")}else if(xml.nodeName=="XML" && xml.ownerDocument==document){var node=document.evaluate("*",xml,null,9,null).singleNodeValue;xml=document.implementation.createDocument("","",null);xml.appendChild(node)}namespaces={};var a=this._namespaces.split(" xmlns:");for(var i=1;i<a.length;i++){var s=a[i].split("=");namespaces[s[0]]=s[1].replace(/\"/g,"")}this._ns={lookupNamespaceURI:function(prefix){return namespaces[prefix]}};this._xml=xml;this._data=xml.evaluate(this._dataPath,this._xml,this._ns,9,null).singleNodeValue;this._items=this._data?xml.evaluate(this._itemPath,this._data,this._ns,7,null):null;this._ready=true}}obj.getXML=function(){return this._xml};obj._dataPath="*";obj._itemPath="*";obj._valuePath="*";obj._valuesPath=[];obj._formats=[];obj.setColumns=function(array){this._valuesPath=array};obj.setRows=function(xpath){this._itemPath=xpath};obj.setTable=function(xpath){this._dataPath=xpath};obj.getCount=function(){if(!this._items){return 0}return AW.ie?this._items.length:this._items.snapshotLength};obj.getData=function(i,j){var node=this.getNode(i,j);return node?(AW.ie?node.text:node.textContent):""};obj.getNode=function(j,i){if(!this._items || !this._items[i]){return null}if(this._valuesPath[j]){return this._items[i].selectSingleNode(this._valuesPath[j])}else{return this._items[i].selectNodes(this._valuePath)[j]}};if(!AW.ie){obj.getNode=function(c,r){if(!this._items){return null}var row=this._items.snapshotItem(r);if(!row){return null}if(this._valuesPath[c]){return row.ownerDocument.evaluate(this._valuesPath[c],row,this._ns,9,null).singleNodeValue}else{return row.ownerDocument.evaluate(this._valuePath,row,this._ns,7,null).snapshotItem(c)}}}};
 document.documentElement.className+=AW._htmlClasses;

// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "id":
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


// post data
function PostformResponse(intext, thisuserkey, thisformkey, thispagekey, thissessionkey, database, testanswerkey, referringuserkey, patientsessionkey, formtype, formname, customersitekey, customerkey, listdatatype, regfieldtype, reviewerpage)
   {
//document.getElementById(thisformkey).value =intext;

//alert("val=" + intext + "user=" + thisuserkey + "formkey=" + thisformkey + "pagekey=" + thispagekey + "sessionkey=" + thissessionkey + "db=" + database + "testanswerkey=" + testanswerkey + "refuserkey=" + referringuserkey + "patsession=" +  patientsessionkey + "formtype=" + formtype + "formname=" + formname)

// checkbox
if (formtype==1)
{

    if (intext == '1' || intext == 'true' || intext == 'on')
    {
        intext = '1';
    }
    else
    {
        intext = '0';
    }
}
var updateURL = "";
intext = escape(intext);
      updateURL = "postformdata.aspx?text=" + intext + "&formkey=" + thisformkey + "&pagekey=" + thispagekey + "&sessionkey=" + thissessionkey + "&pageviewdb=" + database + "&testanswerkey=" + testanswerkey + "&referringuserkey=" + referringuserkey + "&formtype=" + formtype + "&formname=" + formname + "&custsitekey=" + customersitekey + "&custkey=" + customerkey + "&listdatatype=" + listdatatype + "&regfield=" + regfieldtype + "&productkey=" + jsproductkey;
//alert(updateURL);
       var r = new AW.HTTP.Request;
       if (!r){return};
       r.setURL(updateURL);
       r.setRequestMethod("POST");
       r.request();

       r.response = function(data){
        //alert(data);
       }
    
if (reviewerpage == "True" && referringuserkey != "0" && referringuserkey != "" && patientsessionkey != "0" && patientsessionkey != "")
{
      updateURL = "postformdata.aspx?text=" + intext + "&formkey=" + thisformkey + "&pagekey=" + thispagekey + "&sessionkey=" + patientsessionkey + "&pageviewdb=" + database + "&testanswerkey=" + testanswerkey + "&referringuserkey=" + thisuserkey + "&formtype=" + formtype + "&formname=" + formname + "&custsitekey=" + customersitekey + "&custkey=" + customerkey + "&listdatatype=" + listdatatype + "&regfield=" + regfieldtype + "&reviewerpage=" + reviewerpage + "&productkey=" + jsproductkey;
       var r = new AW.HTTP.Request;
       if (!r){return};
       r.setURL(updateURL);
       r.setRequestMethod("POST");
       r.request();
       r.response = function(data){
       
       }
}
if (formname == 'talcommentfield')
{
      updateURL = "postpagefeedback.aspx?text=" + intext + "&sessionkey=" + thissessionkey + "&pagekey=" + thispagekey + "&pageviewdb=" + database + "&talcomments=yes&userkey=" + thisuserkey;

       var r = new AW.HTTP.Request;
       if (!r){return};
       r.setURL(updateURL);
       r.setRequestMethod("POST");
       r.request();

       r.response = function(data){

       }
}

return;
  }  
//

// left function
function Left(str, n)
{
   if (n <= 0)
         return "";
   else if (n > String(str).length)
         return str;
   else
         return String(str).substring(0,n);
}

//right function
function Right(str, n)
{
      if (n <= 0)
          return "";
      else if (n > String(str).length)
          return str;
      else
   {
          var iLen = String(str).length;
          return String(str).substring(iLen, iLen - n);
      }
}
//

var jshilitebtnid = '';
var jshilitecolor = '';
function getSelText(thispagekey, thissessionkey, thisdatabase, thisuserkey)
{

    if (jshilitebtnid == '' || jshilitebtnid == null){return;}
    var colors = "yellow;lightblue;lightgreen;orange;red;pink;purple"
    var colorarray = colors.split(";")
    var hilites = '';
    var ibegin = 0;
    var iend = 0;
    var strtxt_ie = "";
    var strtxt_ff = "";
    var regexp_ie = "";
    var regexp_ff = "";    
    var regexp_all = "";
    var txt = '';
    var htmltxt = '';
    var innertxt = '';
    var hrefstr = '';
    var thisrange;
   
    if (window.getSelection)
    {
        txt = window.getSelection().toString();
        thisrange = window.getSelection().getRangeAt(0);
        if (jshilitecolor == 'none' || jshilitecolor == 'white')
        {
            thisrange.deleteContents(); 
            var repl=document.createTextNode(txt); 
            thisrange.insertNode(repl);
        
        }
        else
        {
            var parent_html = thisrange.commonAncestorContainer.innerHTML;
            var parenthtmlstr = new String(parent_html);
            if (parenthtmlstr.indexOf('<li') == -1 && parenthtmlstr.indexOf('<LI') == -1 && parenthtmlstr.indexOf('<A') == -1 && parenthtmlstr.indexOf('<a') == -1)
            {
                thisrange.deleteContents(); 
                var repl=document.createTextNode(txt); 
                var newfont = document.createElement('font'); 
                newfont.style.backgroundColor = 'yellow';
                newfont.appendChild(repl); 
                thisrange.insertNode(newfont);
                document.all(jshilitebtnid).src = document.all(jshilitebtnid).src.replace(/-down.gif/,'.gif');
            }
            else
            {
             alert('cannot hilight across numbered lists or hyperlinks');
            document.all(jshilitebtnid).src = document.all(jshilitebtnid).src.replace(/-down.gif/,'.gif');
            return;
            }
        //thisrange.pasteHTML("<FONT style='BACKGROUND-COLOR:"+jshilitecolor+"';>" + txt + "</font>");
        }


    }
    else
    {
         if (document.getSelection)
         {
            txt = document.getSelection();
             
         }
         else
         {
           if (document.selection)
            {
                txt = document.selection.createRange().text;
                innertxt = document.selection.createRange().htmlText;
                thisrange = document.selection.createRange();
                if (txt =='' || txt ==' ')
                {
                    document.getElementById('talariapagecontent').style.className = 'cursorpen';
                    return;
                }
                if (thisrange)
                {
                    if (jshilitecolor == 'none'){thisrange.execCommand("backColor",false,"white");}
                    else {thisrange.pasteHTML("<FONT style='BACKGROUND-COLOR:"+jshilitecolor+"';>" + innertxt + "</font>");}
                }
            }
            else
            {
                return;
            }
         }
      }
      
    //string expressions for beginning and end of string
    var oP1 = document.getElementById('talariapagecontent');
    htmltxt = new String();
    htmltxt = oP1.innerHTML;

    ibegin = 0;
    var delim = '';
    var strwork = new String('');
    var strlen =0;
    hilites = '';
    //document.all('hilightholder').value = "";
    if (htmltxt.indexOf('<font') != -1)
     {
         if (htmltxt.indexOf('<font') < htmltxt.indexOf('<FONT') || htmltxt.indexOf('<FONT') == -1)
         {
         ibegin = htmltxt.indexOf('<font');
         }
         else
         {
         ibegin = htmltxt.indexOf('<FONT');
         }
     }
     else
     {
         ibegin = htmltxt.indexOf('<FONT');
     }
    var thiscolor = '';
   
    while (ibegin != -1)
    {
        strwork = Right(htmltxt, htmltxt.length - ibegin);
        strwork = Left(strwork, strwork.indexOf('>') + 1);
        if (strwork.indexOf('background-color') != -1 || strwork.indexOf('BACKGROUND-COLOR') != -1)
        {   
            thiscolor = '';
            for (var i=0; i< colorarray.length-1; i++)
            {
                if (strwork.indexOf(colorarray[i]) != -1){thiscolor = colorarray[i];}
            }
        }
        iend = htmltxt.indexOf('</font>',ibegin)
        if (iend == -1)
        {
            iend = htmltxt.indexOf('</FONT>',ibegin)
        }
        else
        {
            if (htmltxt.indexOf('</FONT>',ibegin) != -1 && htmltxt.indexOf('</FONT>',ibegin) < iend)
            {
            iend = htmltxt.indexOf('</FONT>',ibegin);
            }
        }
        if (iend == -1){iend = htmltxt.length;}
        strlen = iend - ibegin - strwork.length;
        strwork = Right(htmltxt, htmltxt.length - ibegin - strwork.length);
        strwork = Left(strwork, strlen);
      //  alert(strwork);
        if (thiscolor != '' && Left(strwork, 2) != '<1' && strwork != ''  && strwork != '')
        {
            if (strwork.indexOf('<LI>') ==-1 && strwork.indexOf('<li>') ==-1) 
            {
               if (strwork.indexOf('BACKGROUND-COLOR: white') == -1 && strwork.indexOf('background-color: white') == -1 && strwork != '' && strwork != ' ' && escape(strwork) != '%0D%0A')

               hilites = hilites + delim +escape(strwork)  + '~' + thiscolor;
                delim = '|';         
            }
            else
            {
            
            if (strwork.indexOf('<LI>') !=-1  && !window.getSelection)
            {
                var strworkarray = strwork.split('<LI>');
                for (var j=0;j<strworkarray.length;j++)
                {
                    if (strworkarray[j].indexOf('BACKGROUND-COLOR: white') == -1 && strworkarray[j].indexOf('background-color: white') == -1 && strworkarray[j] != '' && strworkarray[j] != ' ' && escape(strworkarray[j]) != '%0D%0A')
                    {
                        hilites = hilites + delim +escape(strworkarray[j])  + '~' + thiscolor;
                        delim = '|'; 
                    }
                }
            }  
            if (strwork.indexOf('<li>') !=-1 && !window.getSelection)
            {
                var strworkarray = strwork.split('<li>');
                for (var j=0;j<strworkarray.length;j++)
                {
                   if (strworkarray[j].indexOf('BACKGROUND-COLOR: white') == -1 && strworkarray[j].indexOf('background-color: white') == -1 && strworkarray[j] != '' && strworkarray[j] != ' ' && escape(strworkarray[j]) != '%0D%0A')
                   {
                        hilites = hilites + delim +escape(strworkarray[j])  + '~' + thiscolor;
                        delim = '|'; 
                   }
                }
            }              
         }
       }
        ibegin = iend;   

         if (htmltxt.indexOf('<font', ibegin) != -1)
         {
             if (htmltxt.indexOf('<font', ibegin + 1) < htmltxt.indexOf('<FONT style="BACKGROUND-COLOR', ibegin))
             {
                ibegin = htmltxt.indexOf('<font', ibegin);
             }
             else
             {
                 if (htmltxt.indexOf('<FONT ', ibegin) != -1)
                 {
                     ibegin = htmltxt.indexOf('<FONT', ibegin);
                 }
                 else
                 {
                     ibegin = htmltxt.indexOf('<font', ibegin);
                 }
             }
         }
         else
         {
            ibegin = htmltxt.indexOf('<FONT', ibegin);
         }
      }
    if (jshilitebtnid != '') 
    {
        if (document.getElementById(jshilitebtnid) == null) 
        {document.all(jshilitebtnid).src = document.all(jshilitebtnid).src.replace(/-down.gif/,'.gif');}
        else
        {document.getElementById(jshilitebtnid).src = document.getElementById(jshilitebtnid).src.replace(/-down.gif/,'.gif');}
    }  
    jshilitebtnid = '';
  //  htmltxt = putemback(htmltxt);
  // var oP2 = document.getElementById('talariapagecontent');
  
  //  document.all('hilightholder').value = hilites;
 //   document.all('hilightholder').click();
       var updateURL = "";

       updateURL = "postpagefeedback.aspx?text=" + escape(hilites) + "&sessionkey=" + thissessionkey + "&pagekey=" + thispagekey + "&pageviewdb=" + thisdatabase + "&hilites=yes&userkey=" + thisuserkey;
//document.write(updateURL);
       var r = new AW.HTTP.Request;
       r.setURL(updateURL);
       r.setRequestMethod("POST");
       r.request();

       r.response = function(data){

       }
       return;
}
//
function PutHilites(iHilitetext, icontent)
{

if (iHilitetext == ''){return;}
var lireplace = new RegExp("</li>","gim");
var hilitearray = iHilitetext.split("|");

for (var i=0;i<hilitearray.length;i++)
{
    var hitextarray = hilitearray[i].split('~');
    var strcontent = document.getElementById('talariapagecontent').innerHTML;
    
    var strold =unescape(hitextarray[0]);
    if (strold != '' && strold != ' ')
    {  
        strold = strold.replace(lireplace, "")
       // alert(strold);
       var strnew = "<FONT style='BACKGROUND-COLOR:"+hitextarray[1]+"';>" + unescape(hitextarray[0]) + "</font>";
        strcontent =strcontent.replace(strold, strnew);
        document.getElementById('talariapagecontent').innerHTML = strcontent; 
   
   }
}

return;

}


//Drag Drop jscript
// iMouseDown represents the current mouse button state: up or down
/*
lMouseState represents the previous mouse button state so that we can
check for button clicks and button releases:

if(iMouseDown && !lMouseState) // button just clicked!
if(!iMouseDown && lMouseState) // button just released!
*/
var mouseOffset = null;
var iMouseDown  = false;
var lMouseState = false;
var dragObject  = null;

// Demo 0 variables
var DragDrops   = [];
var curTarget   = null;
var lastTarget  = null;
var dragHelper  = null;
var tempDiv     = null;
var rootParent  = null;
var rootSibling = null;

Number.prototype.NaN0=function(){return isNaN(this)?0:this;}

function CreateDragContainer(){
	/*
	Create a new "Container Instance" so that items from one "Set" can not
	be dragged into items from another "Set"
	*/
	var cDrag        = DragDrops.length;
	DragDrops[cDrag] = [];

	/*
	Each item passed to this function should be a "container".  Store each
	of these items in our current container
	*/
	for(var i=0; i<arguments.length; i++){
		var cObj = arguments[i];
		DragDrops[cDrag].push(cObj);
		cObj.setAttribute('DropObj', cDrag);

		/*
		Every top level item in these containers should be draggable.  Do this
		by setting the DragObj attribute on each item and then later checking
		this attribute in the mouseMove function
		*/
		for(var j=0; j<cObj.childNodes.length; j++){

			// Firefox puts in lots of #text nodes...skip these
			if(cObj.childNodes[j].nodeName=='#text') continue;

			cObj.childNodes[j].setAttribute('DragObj', cDrag);
		}
	}
}

function mouseMove(ev){
	ev         = ev || window.event;

	/*
	We are setting target to whatever item the mouse is currently on

	Firefox uses event.target here, MSIE uses event.srcElement
	*/
	var target   = ev.target || ev.srcElement;
	var mousePos = mouseCoords(ev);
	//window.status = mousePos.x;
if (mousePos.x > 1000)
{
return;
}
	// mouseOut event - fires if the item the mouse is on has changed
	if(lastTarget && (target!==lastTarget)){
		// reset the classname for the target element
		var origClass = lastTarget.getAttribute('origClass');
		if(origClass) lastTarget.className = origClass;
	}

	/*
	dragObj is the grouping our item is in (set from the createDragContainer function).
	if the item is not in a grouping we ignore it since it can't be dragged with this
	script.
	*/

	
	var dragObj = target.getAttribute('DragObj');

	 // if the mouse was moved over an element that is draggable
	if(dragObj!=null){

		// mouseOver event - Change the item's class if necessary
		if(target!=lastTarget){
			var oClass = target.getAttribute('overClass');
			if(oClass){
				target.setAttribute('origClass', target.className);
				target.className = oClass;
			}
		}

		// if the user is just starting to drag the element
		if(iMouseDown && !lMouseState){
			// mouseDown target
			curTarget     = target;

			// Record the mouse x and y offset for the element
			rootParent    = curTarget.parentNode;
			rootSibling   = curTarget.nextSibling;

			mouseOffset   = getMouseOffset(target, ev);

			// We remove anything that is in our dragHelper DIV so we can put a new item in it.
			for(var i=0; i<dragHelper.childNodes.length; i++) dragHelper.removeChild(dragHelper.childNodes[i]);

			// Make a copy of the current item and put it in our drag helper.
			dragHelper.appendChild(curTarget.cloneNode(true));
			dragHelper.style.display = 'block';

			// set the class on our helper DIV if necessary
			var dragClass = curTarget.getAttribute('dragClass');
			if(dragClass){
				dragHelper.firstChild.className = dragClass;
			}

			// disable dragging from our helper DIV (it's already being dragged)
			dragHelper.firstChild.removeAttribute('DragObj');

			/*
			Record the current position of all drag/drop targets related
			to the element.  We do this here so that we do not have to do
			it on the general mouse move event which fires when the mouse
			moves even 1 pixel.  If we don't do this here the script
			would run much slower.
			*/
			var dragConts = DragDrops[dragObj];

			/*
			first record the width/height of our drag item.  Then hide it since
			it is going to (potentially) be moved out of its parent.
			*/
			curTarget.setAttribute('startWidth',  parseInt(curTarget.offsetWidth));
			curTarget.setAttribute('startHeight', parseInt(curTarget.offsetHeight));
			curTarget.style.display  = 'none';

			// loop through each possible drop container
			for(var i=0; i<dragConts.length; i++){
				with(dragConts[i]){
					var pos = getPosition(dragConts[i]);

					/*
					save the width, height and position of each container.

					Even though we are saving the width and height of each
					container back to the container this is much faster because
					we are saving the number and do not have to run through
					any calculations again.  Also, offsetHeight and offsetWidth
					are both fairly slow.  You would never normally notice any
					performance hit from these two functions but our code is
					going to be running hundreds of times each second so every
					little bit helps!

					Note that the biggest performance gain here, by far, comes
					from not having to run through the getPosition function
					hundreds of times.
					*/
					setAttribute('startWidth',  parseInt(offsetWidth));
					setAttribute('startHeight', parseInt(offsetHeight));
					setAttribute('startLeft',   pos.x);
					setAttribute('startTop',    pos.y);
				}

				// loop through each child element of each container
				for(var j=0; j<dragConts[i].childNodes.length; j++){
					with(dragConts[i].childNodes[j]){
						if((nodeName=='#text') || (dragConts[i].childNodes[j]==curTarget)) continue;

						var pos = getPosition(dragConts[i].childNodes[j]);

						// save the width, height and position of each element
						setAttribute('startWidth',  parseInt(offsetWidth));
						setAttribute('startHeight', parseInt(offsetHeight));
						setAttribute('startLeft',   pos.x);
						setAttribute('startTop',    pos.y);
					}
				}
			}
		}
	}

	// If we get in here we are dragging something
	if(curTarget){
		// move our helper div to wherever the mouse is (adjusted by mouseOffset)
		dragHelper.style.top  = mousePos.y - mouseOffset.y;
		dragHelper.style.left = mousePos.x - mouseOffset.x;

		var dragConts  = DragDrops[curTarget.getAttribute('DragObj')];
		var activeCont = null;

		var xPos = mousePos.x - mouseOffset.x + (parseInt(curTarget.getAttribute('startWidth')) /2);
		var yPos = mousePos.y - mouseOffset.y + (parseInt(curTarget.getAttribute('startHeight'))/2);

		// check each drop container to see if our target object is "inside" the container
		for(var i=0; i<dragConts.length; i++){
			with(dragConts[i]){
				if(((getAttribute('startLeft'))                               < xPos) &&
					((getAttribute('startTop'))                                < yPos) &&
					((getAttribute('startLeft') + getAttribute('startWidth'))  > xPos) &&
					((getAttribute('startTop')  + getAttribute('startHeight')) > yPos)){

						/*
						our target is inside of our container so save the container into
						the activeCont variable and then exit the loop since we no longer
						need to check the rest of the containers
						*/
						activeCont = dragConts[i];

						// exit the for loop
						break;
				}
			}
		}

		// Our target object is in one of our containers.  Check to see where our div belongs
		if(activeCont){
			// beforeNode will hold the first node AFTER where our div belongs
			var beforeNode = null;

			// loop through each child node (skipping text nodes).
			
			for(var i=activeCont.childNodes.length-1; i>=0; i--){
				with(activeCont.childNodes[i]){
					if(nodeName=='#text') continue;
					var testtest = 1*getAttribute('startTop')  + 1*getAttribute('startHeight');

					// if the current item is "After" the item being dragged
					if(
						curTarget != activeCont.childNodes[i]                              &&
						//((getAttribute('startLeft') + getAttribute('startWidth'))  > xPos) &&
						((1*getAttribute('startTop')  + 1*getAttribute('startHeight')) > 1*yPos)){
							beforeNode = activeCont.childNodes[i];
					}
				}
			}

			// the item being dragged belongs before another item
			if(beforeNode){
			
				if(beforeNode!=curTarget.nextSibling){
					activeCont.insertBefore(curTarget, beforeNode);
				}

			// the item being dragged belongs at the end of the current container
			} else {
				
				if((curTarget.nextSibling) || (curTarget.parentNode!=activeCont)){
					activeCont.appendChild(curTarget);
				}
			}

			// make our drag item visible
			if(curTarget.style.display!=''){
				curTarget.style.display  = '';
			}
		} else {

			// our drag item is not in a container, so hide it.
			if(curTarget.style.display!='none'){
				curTarget.style.display  = 'none';
			}
		}
	}
    SaveDragOrder();
	// track the current mouse state so we can compare against it next time
	lMouseState = iMouseDown;

	// mouseMove target
	lastTarget  = target;

	// track the current mouse state so we can compare against it next time
	lMouseState = iMouseDown;

	// this helps prevent items on the page from being highlighted while dragging
	return false;
}

function mouseUp(ev){

	if(curTarget){
		// hide our helper object - it is no longer needed
		dragHelper.style.display = 'none';

		// if the drag item is invisible put it back where it was before moving it
		if(curTarget.style.display == 'none'){
			if(rootSibling){
				rootParent.insertBefore(curTarget, rootSibling);
			} else {
				rootParent.appendChild(curTarget);
			}
		}

		// make sure the drag item is visible
		curTarget.style.display = '';
	}
	curTarget  = null;
	iMouseDown = false;
}

function mouseDown(){
	iMouseDown = true;
	if(lastTarget){
		return false;
	}
}





function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}
function getMouseOffset(target, ev){
	ev = ev || window.event;

	var docPos    = getPosition(target);
	var mousePos  = mouseCoords(ev);
	//window.status ="x" + mousePos.y + "y" + docPos.y;
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

function getPosition(e){
	var left = 0;
	var top  = 0;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;

	return {x:left, y:top};
}



function makeDraggable(item){
	if(!item) return;
	item.onmousedown = function(ev){
		dragObject  = this;
		mouseOffset = getMouseOffset(this, ev);
		return false;
	}
}
 function makeClickable(object){   
     object.onmousedown = function(){   
         dragObject = this;   
     }   
 }  

function SaveDragOrder() {

var list = document.getElementById('DragContainer1');

var itemyholder = "";

items = list.getElementsByTagName("DIV")


        for (i=0; i < items.length; i++)
        {

        itemyholder = itemyholder + items[i].id + "|";
        }
        
 document.all('taldragorder').value = itemyholder; 
 document.all('taldragorder').click();   
document.cookie= jspagekey + '-' + document.all('taldragorder').id + '-5='+ escape(itemyholder);
 if (jspatientkey !=0 && jsadminproduct == true && jspageprocessrule == 0){document.cookie= jspagekey + '-' + document.all('taldragorder').id + '-5-' + jspatientkey + '='+ escape(itemyholder);}
}
//
function SetDragOrder()
{

if (document.all('taldragorder').value == "")
{
hideblankdragdivs();
return;
}
var list = document.getElementById('DragContainer1');

var orderholder = "";
orderholder = document.all('taldragorder').value;
var orderarray = orderholder.split("|");
items = list.getElementsByTagName("DIV")
var innerhtmlholder = "";
var innerhtmlarray = "";
var delim = "";
for (i=0; i < orderarray.length - 1; i++)
  {

	var d = document.getElementById(orderarray[i]);
	if (d != null)
	{

        innerhtmlholder += delim + d.innerHTML;
       
        delim = "|";
	}

  }

innerhtmlarray = innerhtmlholder.split("|");
for (i=0; i < items.length; i++)
 {
   items[i].innerHTML = innerhtmlarray[i];
   items[i].id = orderarray[i];
 }

hideblankdragdivs();
}

function hideblankdragdivs()
{
   
    var holdtext;
    var list = document.getElementById('DragContainer1');  
    items = list.getElementsByTagName("DIV")
    var probdesc = new RegExp(document.all("taldragproblbl").value, 'gim');  
    
    for (i=0; i < items.length; i++)
    {
        if (navigator.appName=='Microsoft Internet Explorer') 
        { 
            holdtext = items[i].innerText;
            holdtext = holdtext.replace(probdesc, "");
            //holdtext = holdtext.replace(/Problema:/gmi, "");
            holdtext = holdtext.replace(/\u00a0+/,'');
            holdtext = holdtext.replace(/ /g,'');

            if (holdtext == "" || holdtext == " ")
            {
                items[i].style.visibility='hidden';
            }
        }
        else
        {
            holdtext = items[i].textContent;
            holdtext = holdtext.replace(probdesc, "");
            holdtext = holdtext.replace(/\u00a0+/,''); //replace &nbsp;
            holdtext = holdtext.replace(/ /g,'');

            if (holdtext == "" || holdtext == " " || escape(holdtext) == '%A0')
            {
                items[i].style.visibility='hidden';
            }
        }

     }
     var list2 = document.getElementById('PriorityContainer1');
     priitems = list2.getElementsByTagName("SPAN")
    var probdesc = new RegExp(document.all("taldragproblbl").value, 'gim');
    for (i=0; i < priitems.length; i++)
    {
        if (navigator.appName=='Microsoft Internet Explorer') 
        {     
            holdtext = items[i].innerText;
            
            holdtext = holdtext.replace(probdesc, "");
          //  holdtext = holdtext.replace(/Problema:/gmi, "");
            holdtext = holdtext.replace(/\u00a0+/,'');
            holdtext = holdtext.replace(/ /g,'');

            if (holdtext == "" || holdtext == " ")
            {
                priitems[i].style.visibility='hidden';
            }
         }
         else
         {
            holdtext = items[i].textContent;
            holdtext = holdtext.replace(probdesc, "");
          //  holdtext = holdtext.replace(/Problema:/gmi, "");
            holdtext = holdtext.replace(/\u00a0+/,'');
            holdtext = holdtext.replace(/ /g,'');

            if (holdtext == "" || holdtext == " " || escape(holdtext) == '%A0')
            {
                priitems[i].style.visibility='hidden';
            }
         }
     }
}
//
function SetDIVOrder(divorder)
{

if (divorder == "")
{

return;
}

var list = document.getElementById('DIVContainer1');

var orderholder = "";
orderholder = divorder;
var orderarray = orderholder.split("|");
items = list.getElementsByTagName("DIV")
var innerhtmlholder = "";
var innerhtmlarray = "";
var delim = "";
var htmlarray = new Array();
for (i=0; i < orderarray.length - 2; i++)
  {
      var d = document.getElementById(orderarray[i]);
      htmlarray[i] = escape(d.innerHTML);
    
  }
for (i=0; i < orderarray.length - 2; i++)
  {
    if (items[i].id != orderarray[i])
    {
        items[i].innerHTML = unescape(htmlarray[i]);
    }
      
  }
  return;
  
}
//fake popup code
var popupdivid = '';
var showblanket=0;
var thisdivleft = 0;
var thisdivtop = 0;
var thisdivheight = 0;
var thisdivwidth = 0;
var thisdivclickctr = 0;
function Hidediv(div_id) {

	var el = document.getElementById(div_id);
	if ( el.style.display != 'none' ) 
    {
    el.style.display = 'none';
    }
}
function Showdiv(div_id) {

	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' )
	 {	
	 el.style.display = 'block';
	 }
	 else
	 {
	 el.style.display = 'none';
	 }
	

}
function toggle(div_id) {

	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar,divtop) {
    blanket_height=screen.availHeight;

	blanket_width = screen.availWidth;
    if (document.getElementById('blanket'))
    {
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	blanket.style.width = blanket_width + 'px';
	}
	var popUpDiv = document.getElementById(popUpDivVar);
    thisdivheight = popUpDiv.style.height;
    thisdivheight = thisdivheight.replace(/px/i, "");
    
    popUpDiv.style.position = 'absolute';
    if (divtop !='' && divtop != null && divtop != '0')
    {   
        popUpDiv.style.top = divtop + 'px';
        thisdivtop = divtop;
       
        return;
    }
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
		viewportwidth = window.innerWidth;
	} else {
		viewportheight = document.documentElement.clientHeight;
		viewportwidth = document.documentElement.ClientWidth;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	 if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		blanket_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			blanket_width = document.body.parentNode.clientWidth;
		} else {
			blanket_width = document.body.parentNode.scrollWidth;
		}
	}
	
	var halfheight = popUpDiv.style.height;
	halfheight = halfheight.replace(/px/i, "");

	popUpDiv_height=((blanket_height-halfheight)/2);
	popUpDiv.style.top = popUpDiv_height + 'px';
	thisdivtop = popUpDiv_height;
}
function window_pos(popUpDivVar,divleft) {

	var popUpDiv = document.getElementById(popUpDivVar);
	var halfwidth = popUpDiv.style.width;
	halfwidth = halfwidth.replace(/px/i, "");
	thisdivwidth = halfwidth;
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	if (divleft !='' && divleft != null && divleft != '0')
    {   
        popUpDiv.style.left = divleft + 'px';
        thisdivleft = divleft;
       
        return;
    }
   // alert(window_width)
   // window_width =screen.availWidth;
	//alert(window_width)

	thisdivleft = window_width/2-halfwidth;
	halfwidth = halfwidth/2;
	window_width=(window_width - thisdivwidth)/2;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
	
	
}
function popup(windowname,blanketind,divtop,divleft, divtopadd, divleftadd) {
    thisdivclickctr = 0;
    if (divtopadd == undefined || divtopadd == ''){divtopadd=0;}
    if (divleftadd == undefined || divleftadd == ''){divleftadd=0;}
    thisdivtop = divtop + divtopadd;
    thisdivleft = divleft + divleftadd;

    showblanket = blanketind;
    popupdivid = windowname;
	blanket_size(windowname, divtop);
	window_pos(windowname,divleft);	
	var divarray = rolloverdivids.split(";");

	for (var i = 0; i < divarray.length - 1; i++)
	{
	    if (divarray[i] != windowname)
	    {
             Hidediv(divarray[i]);
            
        }
	}
	if (blanketind ==1)
	{
	Showdiv('blanket');
	
	}
	else
	{
	Hidediv('blanket');
	}
	Showdiv(windowname);	

}
function synchTab(frameName) {

  var elList, i;

  // Exit if no frame name was given.

  if (frameName == null)
    return;

  // Check all links.

  elList = document.getElementsByTagName("A");
  for (i = 0; i < elList.length; i++)


    // Check if the link's target matches the frame being loaded.
    if (elList[i].id == frameName) {
      // If the link's URL matches the page being loaded, activate it.
      // Otherwise, make sure the tab is deactivated.

        

     // if (elList[i].href == window.frames[frameName].location.href) {
        elList[i].className += " activeTab";
        elList[i].blur();
    }
    else
    {
        removeName(elList[i], "activeTab");
    }
}
function removeNameold(el, name) {

  var i, curList, newList;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}
var lastdivname = '';
function synchTabdiv(frameName, divName, divHolder, lasttabholder) {
  var elList, i;
 var divholderobj;
// divholderobj = document.getElementById(divHolder);
divholderobj = document.getElementById(divHolder);

var lasttabname = document.getElementById(lasttabholder).value;
if (lastdivname != '')
{
document.getElementById(lastdivname).innerHTML = divholderobj.innerHTML;
}
else
{
document.getElementById('div1').innerHTML = divholderobj.innerHTML;
}
lastdivname = divName;
document.getElementById(lasttabholder).value = frameName;
  var divcontentobj;
 divcontentobj = document.getElementById(divName);
  // Exit if no frame name was given.
divholderobj.innerHTML = divcontentobj.innerHTML;

  if (frameName == null)
    return;
  // Check all links.

  elList = document.getElementsByTagName("A");
  for (i = 0; i < elList.length; i++)


    // Check if the link's target matches the frame being loaded.
    if (elList[i].id == frameName) {
      // If the link's URL matches the page being loaded, activate it.
      // Otherwise, make sure the tab is deactivated.

        

     // if (elList[i].href == window.frames[frameName].location.href) {
        elList[i].className += " activeTab";
        
        elList[i].blur();
      }
      else
      {
        if (elList[i].id == lasttabname) {
        removeName(elList[i], "activeTab");
        }
        
      }
}
function removeName(el, name) {

  var i, curList, newList;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}
/**
This is a JavaScript library that will allow you to easily add some basic DHTML
drop-down datepicker functionality to your Notes forms. This script is not as
full-featured as others you may find on the Internet, but it's free, it's easy to
understand, and it's easy to change.
 
You'll also want to include a stylesheet that makes the datepicker elements
look nice. An example one can be found in the database that this script was
originally released with, at:
 
http://www.nsftools.com/tips/NotesTips.htm#datepicker
 
I've tested this lightly with Internet Explorer 6 and Mozilla Firefox. I have no idea
how compatible it is with other browsers.
 
version 1.5
December 4, 2005
Julian Robichaux -- http://www.nsftools.com
 
HISTORY
--  version 1.0 (Sept. 4, 2004):
Initial release.
 
--  version 1.1 (Sept. 5, 2004):
Added capability to define the date format to be used, either globally (using the
defaultDateSeparator and defaultDateFormat variables) or when the displayDatePicker
function is called.
 
--  version 1.2 (Sept. 7, 2004):
Fixed problem where datepicker x-y coordinates weren't right inside of a table.
Fixed problem where datepicker wouldn't display over selection lists on a page.
Added a call to the datePickerClosed function (if one exists) after the datepicker
is closed, to allow the developer to add their own custom validation after a date
has been chosen. For this to work, you must have a function called datePickerClosed
somewhere on the page, that accepts a field object as a parameter. See the
example in the comments of the updateDateField function for more details.
 
--  version 1.3 (Sept. 9, 2004)
Fixed problem where adding the <div> and <iFrame> used for displaying the datepicker
was causing problems on IE 6 with global variables that had handles to objects on
the page (I fixed the problem by adding the elements using document.createElement()
and document.body.appendChild() instead of document.body.innerHTML += ...).
 
--  version 1.4 (Dec. 20, 2004)
Added "targetDateField.focus();" to the updateDateField function (as suggested
by Alan Lepofsky) to avoid a situation where the cursor focus is at the top of the
form after a date has been picked. Added "padding: 0px;" to the dpButton CSS
style, to keep the table from being so wide when displayed in Firefox.
 
-- version 1.5 (Dec 4, 2005)
Added display=none when datepicker is hidden, to fix problem where cursor is
not visible on input fields that are beneath the date picker. Added additional null
date handling for date errors in Safari when the date is empty. Added additional
error handling for iFrame creation, to avoid reported errors in Opera. Added
onMouseOver event for day cells, to allow color changes when the mouse hovers
over a cell (to make it easier to determine what cell you're over). Added comments
in the style sheet, to make it more clear what the different style elements are for.
*/
 
var datePickerDivID = "datepicker";
var iFrameDivID = "datepickeriframe";
 
var dayArrayShort = new Array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
var dayArrayMed = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
var dayArrayLong = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
var monthArrayShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var monthArrayMed = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
var monthArrayLong = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
 
// these variables define the date formatting we're expecting and outputting.
// If you want to use a different format by default, change the defaultDateSeparator
// and defaultDateFormat variables either here or on your HTML page.
var defaultDateSeparator = "/";        // common values would be "/" or "."
var defaultDateFormat = "mdy"    // valid values are "mdy", "dmy", and "ymd"
var dateSeparator = defaultDateSeparator;
var dateFormat = defaultDateFormat;
 
/**
This is the main function you'll call from the onClick event of a button.
Normally, you'll have something like this on your HTML page:
 
Start Date: <input name="StartDate">
<input type=button value="select" onclick="displayDatePicker('StartDate');">
 
That will cause the datepicker to be displayed beneath the StartDate field and
any date that is chosen will update the value of that field. If you'd rather have the
datepicker display beneath the button that was clicked, you can code the button
like this:
 
<input type=button value="select" onclick="displayDatePicker('StartDate', this);">
 
So, pretty much, the first argument (dateFieldName) is a string representing the
name of the field that will be modified if the user picks a date, and the second
argument (displayBelowThisObject) is optional and represents an actual node
on the HTML document that the datepicker should be displayed below.
 
In version 1.1 of this code, the dtFormat and dtSep variables were added, allowing
you to use a specific date format or date separator for a given call to this function.
Normally, you'll just want to set these defaults globally with the defaultDateSeparator
and defaultDateFormat variables, but it doesn't hurt anything to add them as optional
parameters here. An example of use is:
 
<input type=button value="select" onclick="displayDatePicker('StartDate', false, 'dmy', '.');">
 
This would display the datepicker beneath the StartDate field (because the
displayBelowThisObject parameter was false), and update the StartDate field with
the chosen value of the datepicker using a date format of dd.mm.yyyy
*/
function displayDatePicker(dateFieldName, displayBelowThisObject, dtFormat, dtSep)
{
  var targetDateField = document.getElementsByName (dateFieldName).item(0);
 
  // if we weren't told what node to display the datepicker beneath, just display it
  // beneath the date field we're updating
  if (!displayBelowThisObject)
    displayBelowThisObject = targetDateField;
 
  // if a date separator character was given, update the dateSeparator variable
  if (dtSep)
    dateSeparator = dtSep;
  else
    dateSeparator = defaultDateSeparator;
 
  // if a date format was given, update the dateFormat variable
  if (dtFormat)
    dateFormat = dtFormat;
  else
    dateFormat = defaultDateFormat;
 
  var x = displayBelowThisObject.offsetLeft;
  var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight ;
 
  // deal with elements inside tables and such
  var parent = displayBelowThisObject;
  while (parent.offsetParent) {
    parent = parent.offsetParent;
    x += parent.offsetLeft;
    y += parent.offsetTop ;
  }
 
  drawDatePicker(targetDateField, x, y);
}
 
 
/**
Draw the datepicker object (which is just a table with calendar elements) at the
specified x and y coordinates, using the targetDateField object as the input tag
that will ultimately be populated with a date.
 
This function will normally be called by the displayDatePicker function.
*/
function drawDatePicker(targetDateField, x, y)
{
  var dt = getFieldDate(targetDateField.value );
 
  // the datepicker table will be drawn inside of a <div> with an ID defined by the
  // global datePickerDivID variable. If such a div doesn't yet exist on the HTML
  // document we're working with, add one.
  if (!document.getElementById(datePickerDivID)) {
    // don't use innerHTML to update the body, because it can cause global variables
    // that are currently pointing to objects on the page to have bad references
    //document.body.innerHTML += "<div id='" + datePickerDivID + "' class='dpDiv'></div>";
    var newNode = document.createElement("div");
    newNode.setAttribute("id", datePickerDivID);
    newNode.setAttribute("class", "dpDiv");
    newNode.setAttribute("style", "visibility: hidden;");
    document.body.appendChild(newNode);
  }
 
  // move the datepicker div to the proper x,y coordinate and toggle the visiblity
  var pickerDiv = document.getElementById(datePickerDivID);
  pickerDiv.style.position = "absolute";
  pickerDiv.style.left = x + "px";
  pickerDiv.style.top = y + "px";
  pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
  pickerDiv.style.display = (pickerDiv.style.display == "block" ? "none" : "block");
  pickerDiv.style.zIndex = 10000;
 
  // draw the datepicker table
  refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
}
 
 
/**
This is the function that actually draws the datepicker calendar.
*/
function refreshDatePicker(dateFieldName, year, month, day)
{
  // if no arguments are passed, use today's date; otherwise, month and year
  // are required (if a day is passed, it will be highlighted later)
  var thisDay = new Date();
 
  if ((month >= 0) && (year > 0)) {
    thisDay = new Date(year, month, 1);
  } else {
    day = thisDay.getDate();
    thisDay.setDate(1);
  }
 
  // the calendar will be drawn as a table
  // you can customize the table elements with a global CSS style sheet,
  // or by hardcoding style and formatting elements below
  var crlf = "\r\n";
  var TABLE = "<table cols=7 class='dpTable'>" + crlf;
  var xTABLE = "</table>" + crlf;
  var TR = "<tr class='dpTR'>";
  var TR_title = "<tr class='dpTitleTR'>";
  var TR_days = "<tr class='dpDayTR'>";
  var TR_todaybutton = "<tr class='dpTodayButtonTR'>";
  var xTR = "</tr>" + crlf;
  var TD = "<td class='dpTD' onMouseOut='this.className=\"dpTD\";' onMouseOver=' this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  var TD_title = "<td colspan=5 class='dpTitleTD'>";
  var TD_buttons = "<td class='dpButtonTD'>";
  var TD_todaybutton = "<td colspan=7 class='dpTodayButtonTD'>";
  var TD_days = "<td class='dpDayTD'>";
  var TD_selected = "<td class='dpDayHighlightTD' onMouseOut='this.className=\"dpDayHighlightTD\";' onMouseOver='this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  var xTD = "</td>" + crlf;
  var DIV_title = "<div class='dpTitleText'>";
  var DIV_selected = "<div class='dpDayHighlight'>";
  var xDIV = "</div>";
 
  // start generating the code for the calendar table
  var html = TABLE;
 
  // this is the title bar, which displays the month and the buttons to
  // go back to a previous month or forward to the next month
  html += TR_title;
  html += TD_buttons + getButtonCode(dateFieldName, thisDay, -1, "&lt;") + xTD;
  html += TD_title + DIV_title + monthArrayLong[ thisDay.getMonth()] + " " + thisDay.getFullYear() + xDIV + xTD;
  html += TD_buttons + getButtonCode(dateFieldName, thisDay, 1, "&gt;") + xTD;
  html += xTR;
 
  // this is the row that indicates which day of the week we're on
  html += TR_days;
  for(i = 0; i < dayArrayShort.length; i++)
    html += TD_days + dayArrayShort[i] + xTD;
  html += xTR;
 
  // now we'll start populating the table with days of the month
  html += TR;
 
  // first, the leading blanks
  for (i = 0; i < thisDay.getDay(); i++)
    html += TD + "&nbsp;" + xTD;
 
  // now, the days of the month
  do {
    dayNum = thisDay.getDate();
    TD_onclick = " onclick=\"updateDateField('" + dateFieldName + "', '" + getDateString(thisDay) + "');\">";
    
    if (dayNum == day)
      html += TD_selected + TD_onclick + DIV_selected + dayNum + xDIV + xTD;
    else
      html += TD + TD_onclick + dayNum + xTD;
    
    // if this is a Saturday, start a new row
    if (thisDay.getDay() == 6)
      html += xTR + TR;
    
    // increment the day
    thisDay.setDate(thisDay.getDate() + 1);
  } while (thisDay.getDate() > 1)
 
  // fill in any trailing blanks
  if (thisDay.getDay() > 0) {
    for (i = 6; i > thisDay.getDay(); i--)
      html += TD + "&nbsp;" + xTD;
  }
  html += xTR;
 
  // add a button to allow the user to easily return to today, or close the calendar
  var today = new Date();
  var todayString = "Today is " + dayArrayMed[today.getDay()] + ", " + monthArrayMed[ today.getMonth()] + " " + today.getDate();
  html += TR_todaybutton + TD_todaybutton;
  html += "<button class='dpTodayButton' onClick='refreshDatePicker(\"" + dateFieldName + "\");'>this month</button> ";
  html += "<button class='dpTodayButton' onClick='updateDateField(\"" + dateFieldName + "\");'>close</button>";
  html += xTD + xTR;
 
  // and finally, close the table
  html += xTABLE;
 
  document.getElementById(datePickerDivID).innerHTML = html;
  // add an "iFrame shim" to allow the datepicker to display above selection lists
  adjustiFrame();
}
 
 
/**
Convenience function for writing the code for the buttons that bring us back or forward
a month.
*/
function getButtonCode(dateFieldName, dateVal, adjust, label)
{
  var newMonth = (dateVal.getMonth () + adjust) % 12;
  var newYear = dateVal.getFullYear() + parseInt((dateVal.getMonth() + adjust) / 12);
  if (newMonth < 0) {
    newMonth += 12;
    newYear += -1;
  }
 
  return "<button class='dpButton' onClick='refreshDatePicker(\"" + dateFieldName + "\", " + newYear + ", " + newMonth + ");'>" + label + "</button>";
}
 
 
/**
Convert a JavaScript Date object to a string, based on the dateFormat and dateSeparator
variables at the beginning of this script library.
*/
function getDateString(dateVal)
{
  var dayString = "00" + dateVal.getDate();
  var monthString = "00" + (dateVal.getMonth()+1);
  dayString = dayString.substring(dayString.length - 2);
  monthString = monthString.substring(monthString.length - 2);
 
  switch (dateFormat) {
    case "dmy" :
      return dayString + dateSeparator + monthString + dateSeparator + dateVal.getFullYear();
    case "ymd" :
      return dateVal.getFullYear() + dateSeparator + monthString + dateSeparator + dayString;
    case "mdy" :
    default :
      return monthString + dateSeparator + dayString + dateSeparator + dateVal.getFullYear();
  }
}
 
 
/**
Convert a string to a JavaScript Date object.
*/
function getFieldDate(dateString)
{
  var dateVal;
  var dArray;
  var d, m, y;
 
  try {
    dArray = splitDateString(dateString);
    if (dArray) {
      switch (dateFormat) {
        case "dmy" :
          d = parseInt(dArray[0], 10);
          m = parseInt(dArray[1], 10) - 1;
          y = parseInt(dArray[2], 10);
          break;
        case "ymd" :
          d = parseInt(dArray[2], 10);
          m = parseInt(dArray[1], 10) - 1;
          y = parseInt(dArray[0], 10);
          break;
        case "mdy" :
        default :
          d = parseInt(dArray[1], 10);
          m = parseInt(dArray[0], 10) - 1;
          y = parseInt(dArray[2], 10);
          break;
      }
      dateVal = new Date(y, m, d);
    } else if (dateString) {
      dateVal = new Date(dateString);
    } else {
      dateVal = new Date();
    }
  } catch(e) {
    dateVal = new Date();
  }
 
  return dateVal;
}
 
 
/**
Try to split a date string into an array of elements, using common date separators.
If the date is split, an array is returned; otherwise, we just return false.
*/
function splitDateString(dateString)
{
  var dArray;
  if (dateString.indexOf("/") >= 0)
    dArray = dateString.split("/");
  else if (dateString.indexOf(".") >= 0)
    dArray = dateString.split(".");
  else if (dateString.indexOf("-") >= 0)
    dArray = dateString.split("-");
  else if (dateString.indexOf("\\") >= 0)
    dArray = dateString.split("\\");
  else
    dArray = false;
 
  return dArray;
}
 
/**
Update the field with the given dateFieldName with the dateString that has been passed,
and hide the datepicker. If no dateString is passed, just close the datepicker without
changing the field value.
 
Also, if the page developer has defined a function called datePickerClosed anywhere on
the page or in an imported library, we will attempt to run that function with the updated
field as a parameter. This can be used for such things as date validation, setting default
values for related fields, etc. For example, you might have a function like this to validate
a start date field:
 
function datePickerClosed(dateField)
{
  var dateObj = getFieldDate(dateField.value);
  var today = new Date();
  today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
 
  if (dateField.name == "StartDate") {
    if (dateObj < today) {
      // if the date is before today, alert the user and display the datepicker again
      alert("Please enter a date that is today or later");
      dateField.value = "";
      document.getElementById(datePickerDivID).style.visibility = "visible";
      adjustiFrame();
    } else {
      // if the date is okay, set the EndDate field to 7 days after the StartDate
      dateObj.setTime(dateObj.getTime() + (7 * 24 * 60 * 60 * 1000));
      var endDateField = document.getElementsByName ("EndDate").item(0);
      endDateField.value = getDateString(dateObj);
    }
  }
}
 
*/
function updateDateField(dateFieldName, dateString)
{
  var targetDateField = document.getElementsByName (dateFieldName).item(0);
  if (dateString)
    targetDateField.value = dateString;
    targetDateField.click();
  var pickerDiv = document.getElementById(datePickerDivID);
  pickerDiv.style.visibility = "hidden";
  pickerDiv.style.display = "none";
 
  adjustiFrame();
  targetDateField.focus();
 
  // after the datepicker has closed, optionally run a user-defined function called
  // datePickerClosed, passing the field that was just updated as a parameter
  // (note that this will only run if the user actually selected a date from the datepicker)
  if ((dateString) && (typeof(datePickerClosed) == "function"))
    datePickerClosed(targetDateField);
}
 
 
/**
Use an "iFrame shim" to deal with problems where the datepicker shows up behind
selection list elements, if they're below the datepicker. The problem and solution are
described at:
 
http://dotnetjunkies.com/WebLog/jking/archive/2003/07/21/488.aspx
http://dotnetjunkies.com/WebLog/jking/archive/2003/10/30/2975.aspx
*/
function adjustiFrame(pickerDiv, iFrameDiv)
{
  // we know that Opera doesn't like something about this, so if we
  // think we're using Opera, don't even try
  var is_opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
  if (is_opera)
    return;
  
  // put a try/catch block around the whole thing, just in case
  try {
    if (!document.getElementById(iFrameDivID)) {
      // don't use innerHTML to update the body, because it can cause global variables
      // that are currently pointing to objects on the page to have bad references
      //document.body.innerHTML += "<iframe id='" + iFrameDivID + "' src='javascript:false;' scrolling='no' frameborder='0'>";
      var newNode = document.createElement("iFrame");
      newNode.setAttribute("id", iFrameDivID);
      newNode.setAttribute("src", "javascript:false;");
      newNode.setAttribute("scrolling", "no");
      newNode.setAttribute ("frameborder", "0");
      document.body.appendChild(newNode);
    }
    
    if (!pickerDiv)
      pickerDiv = document.getElementById(datePickerDivID);
    if (!iFrameDiv)
      iFrameDiv = document.getElementById(iFrameDivID);
    
    try {
      iFrameDiv.style.position = "absolute";
      iFrameDiv.style.width = pickerDiv.offsetWidth;
      iFrameDiv.style.height = pickerDiv.offsetHeight ;
      iFrameDiv.style.top = pickerDiv.style.top;
      iFrameDiv.style.left = pickerDiv.style.left;
      iFrameDiv.style.zIndex = pickerDiv.style.zIndex - 1;
      iFrameDiv.style.visibility = pickerDiv.style.visibility ;
      iFrameDiv.style.display = pickerDiv.style.display;
    } catch(e) {
    }
 
  } catch (ee) {
  }
 
}

//check size limit for text areas and text boxes
function checksizelimit(obj, sizelimit, formfieldtype)
{

var objval = obj.value;
if (objval.length > sizelimit - 1)
{
    if (formfieldtype == 6)
    {
        obj.value = Left(obj.value, sizelimit - 1)
        alert("You have exceeded the maximum number of characters (" + sizelimit + ") for this field");
    }
    else
    {
        obj.value = Left(obj.value, sizelimit)
    }
}
return;
}
//check size limit for text areas and text boxes
function edittextbox(obj, numlist, specmsg)
{
var alertmsg = specmsg;
var gottit = 0;
var loval = 0;
var hival = 9;
var objval = obj.value;
if (numlist == '')
{
 if (specmsg == ''){alertmsg = "must be numeric";}
 if (objval.indexOf('.') > -1){var objtest = objval.split('.');if (objtest.length > 2){alert(alertmsg);return;};objval = objtest[0] + '' + objtest[1];}
 var objarray = objval.split('');
  for (var i=0; i < objarray.length;i++)
  {
    gottit = 0;
    for (var j=0; j < 11;j++){if (objarray[i] == j){gottit = 1};};
    if (gottit == 0)
    {
       obj.value =""
       alert(alertmsg);
       return;
    }
  }
  return;
}
if (specmsg == ''){alertmsg = "must be one of following values " + numlist;}
numvals = numlist.split(','); 
for (var j=0;j < numvals.length;j++)
{
  if (numvals[j].indexOf('-') > -1)
  {
     var testrange = numvals[j].split('-');
     loval = testrange[0];
     hival = testrange[1];
     if (1*objval >= 1*loval && 1*objval <= 1*hival){gottit = 1};
  }
  else
  {
     if (objval == numvals[j]){gottit = 1};
  }
}
 if (gottit == 0){obj.value ="";alert(alertmsg);}
 return;
}

function getthistop(thisobj)
{
  var thistop = thisobj.offsetTop;
  thistop = 1*thistop + 20;
  var parent = thisobj;
  while (parent.offsetParent) {
    parent = parent.offsetParent;
    thistop = 1*parent.offsetTop + 1*thistop;
  }

  return thistop;
}

function getthisleft(thisobj)
{
  var thisleft = thisobj.offsetLeft + thisobj.style.width;
  
  var parent = thisobj;
  while (parent.offsetParent) {
    parent = parent.offsetParent;
    thisleft = 1*thisleft + 1*parent.offsetLeft ;
  }

  return thisleft;
}
//
//open search fields page script
//

function OpenSearch(ipageno,winHt,winWth,isearchid)
{
var searchval = document.getElementById(isearchid).value;
if (searchval=='')
{
alert('nothing to search for');
return;
}
searchval = searchval.replace(/%20/g, " ")
var oURL = "buildcontent.aspx?pagekey="+ipageno+"&sessionkey=" + jssessionkey + "&tut="+ jsproductkey + "&popup=yes&searchval="+ searchval;
eval("page" + ipageno + " = window.open(oURL, '" + ipageno + "', 'toolbar=0,left=0,top=0,scrollbars=1,location=0,menubar=0,resizable=1,directories=0,width=" + winWth + ",height=" + winHt + ", copyhistory=0',1);");

}

// get test score - html version
function gethtmltestscore(iscalekey, iscoretype)
{
    var ckie = unescape(document.cookie);
    
    var cv = ckie.split(';');
    var cv2;
    var questcountarray = scalequestcount.split('|');
    if (iscoretype == 3)
    {
        var totalcorrect = 0;
        var score3array = scaleformholder3.split('|');
        for (var i=0; i < score3array.length; i++)
        {
            var scale3array = score3array[i].split(',');
            if (scale3array[0] == iscalekey && FindPageVisited('scale3array[1]',pagevisitedcookie) == 'true')
            {
            //if correctanswer or checkbox, look to find form field in the cookies
                if (scale3array[4] == 'True' || scale3array[6] ==1)
                {
                    var founditt = 0;
                    for (var j = 0; j < cv.length; j++)
                    {
                        cv2 = cv[j];
                        var testcookie = cv2.split('=');
                        var testpage = testcookie[0].split('-');
                        var ipagekey = scale3array[1];
                        var iformkey = scale3array[2];
                        if (testpage[0].replace(/ /g,'') == ipagekey && testpage[1] == iformkey && testcookie[1] != ''&& testcookie[1] != undefined)
                        {
                             //combo box or listbox
                            if (testpage[2]==3)
                            {
                               if (testcookie[1] == scale3array[7] && founditt == 0)
                               {
                                totalcorrect = totalcorrect + 1;
                                founditt = 1;
                               }
                            }
                            //radiobutton
                            if (testpage[2]==2)
                            {
                                totalcorrect = totalcorrect + 1;
                                founditt = 1;
                              // alert(iformkey + ' ' + testcookie[1]);
                            }
                            //checkbox
                                                       //checkbox
                            if (testpage[2]==1)
                            {
                                if (testcookie[1] ==1) //checked
                                {
                                    if(scale3array[5]== 'True') //corrrect answer checked
                                    {
                                    
                                        totalcorrect = totalcorrect + 1;
                                        founditt = 1;
                                    }
                                    else
                                    {
                                    
                                        founditt = 1;
                                    }
                                 }
                                 else
                                 {
                                   founditt = 1;
                                   if(scale3array[5]!= 'True') {totalcorrect = totalcorrect + 1;};
                                  
                                  }
                              }
                           }
                     }
                    if (founditt == 0 && scale3array[6] ==1 && scale3array[5] =='False'){totalcorrect = totalcorrect + 1;};            
          
                }
            }
        }
        var questcount = 1;
        for (var k = 0; k < questcountarray.length; k++)
        {
             var thisscaleqc = questcountarray[k].split(',');
            if (iscalekey == thisscaleqc[0])
            {
                
                questcount =  thisscaleqc[1];
               
            }
        }
        if (questcount == 0)
        {
            questcount = 1;
        }
      //  document.write(Math.round(100*totalcorrect/questcount));
        return Math.round(100*totalcorrect/questcount);
    }
     if (iscoretype == 1)
    {
        var score1array = scaleformholder1.split('|');
        var totalscore1 = 0;
        for (var i=0; i < score1array.length; i++)
        {
            var scale1array = score1array[i].split(',');
            if (scale1array[0] == iscalekey)
            {
            //if scorevalue > = 0 look to find form field in the cookies
                if (scale1array[3] != 0)
                {
                    for (var j = 0; j < cv.length; j++)
                    {
                        cv2 = cv[j];
                        var testcookie = cv2.split('=');
                        var testpage = testcookie[0].split('-');
                        var ipagekey = scale1array[1];
                        var iformkey = scale1array[2];
                        if (testpage[0].replace(/ /g,'') == ipagekey && testpage[1] == iformkey)
                        {
                              totalscore1 = 1*totalscore1 + 1;             
                        }
                    }
                }
            }
        }
        var questcount = 1;
        for (var k = 0; k < questcountarray.length; k++)
        {
             var thisscaleqc = questcountarray[k].split(',');
            if (iscalekey == thisscaleqc[0])
            {
                questcount =  thisscaleqc[1];
            }
        }
        if (questcount == 0)
        {
            questcount = 1;
        }
       // document.write(Math.round(totalscore1/questcount));
        return Math.round(totalscore1/questcount);
    }
    //score types 2,4 and 5 (sum of response score values)
    var totalscore2 = 0;
    var answercounter2 = 0;
    var score2array = scaleformholder2.split('|');
    for (var i=0; i < score2array.length; i++)
    {
        var scale2array = score2array[i].split(',');
        if (scale2array[0] == iscalekey)
        {
            if (scale2array[3] != 0)
            {
                var founditt = 0;
                for (var j = 0; j < cv.length; j++)
                {
                    cv2 = cv[j];
                    var testcookie = cv2.split('=');
                    var testpage = testcookie[0].split('-');
                    var ipagekey = scale2array[1];
                    var iformkey = scale2array[2];
                    if (testpage[0].replace(/ /g,'') == ipagekey && testpage[1] == iformkey && testcookie[1] != ''&& testcookie[1] != undefined)
                    {
                        //radiobutton
                        if (testpage[2]==2 && founditt==0)
                        {
                            totalscore2 = 1*totalscore2 + 1*scale2array[3];
                            answercounter2 = 1*answercounter2 + 1
                            founditt = 1;
                        }

                        //combo box or listbox
                        if (testpage[2]==3)
                        {
                            if (testcookie[1] == scale2array[7] && founditt == 0)
                            {
                                 totalscore2 = 1*totalscore2 + 1*scale2array[3];
                                 answercounter2 = 1*answercounter2 + 1
                                 founditt = 1;
                             }
                         }
                        //checkbox
                        if (testpage[2]==1)
                        {
                            answercounter2 = 1*answercounter2 + 1
                            // check if only count answered
                            if (iscoretype == 4 && testcookie[1] ==1)
                            {
                                totalscore2 = 1*totalscore2 + 1*scale2array[3];
                                founditt = 1;    
                            }
                            else
                            {                       
                                if (testcookie[1] ==1 && scale2array[5]== 'True')
                                {
                                    totalscore2 = 1*totalscore2 + 1*scale2array[3];
                                    founditt = 1;   
                                }
                            }
                         }
                    }
                }
                if (founditt == 0 && scale2array[6] ==1 && scale2array[5] =='False' && iscoretype != 4)
                {
                   totalscore2 = 1*totalscore2 + 1*scale2array[3];
                   answercounter2 = 1*answercounter2 + 1         
                }
            }
        }
    }
    var questcount = 1;
    for (var k = 0; k < questcountarray.length; k++)
    {
      var thisscaleqc = questcountarray[k].split(',');
      if (iscalekey == thisscaleqc[0])
      {
            questcount =  thisscaleqc[1];
       }
    }
    if (questcount == 0)
    {
        questcount = 1;
    }
    if (iscoretype == 5 && questcount > answercounter2)
    {
    return 0;
    }
    else
    {
       // document.write(totalscore2);
        return totalscore2;
    }
}
//html formresponse


function gethtmlresponse(ipagekey,iformkey,iformtype, iformvalue, iHideit, iTestresponse, icorrect, icbcorrect)
{

var ckie = unescape(document.cookie);
var cv = ckie.split(';');
var cv2;
var returnval = '';
for (var i = 0; i < cv.length; i++)
{
    cv2 = cv[i];
    var testcookie = cv2.split('=');
    var testpage = testcookie[0].split('-');
    var ispatientpage = false;
    if (jsadminproduct == true && jspageprocessrule == 0 && jspatientkey != 0){ispatientpage = true};
    if (testpage[0].replace(/ /g,'') == ipagekey && testpage[1] == iformkey && testcookie[1] != undefined)
    {
      if ((ispatientpage == true && testcookie[0].indexOf('-'+jspatientkey) > -1) || ispatientpage == false)
      {
        if (testpage[2]==6)
        {
            returnval = testcookie[1];
            return returnval;
        }
        if (testpage[2]==5)
        {
            returnval = testcookie[1];
            return returnval;
        }
        // combo / list box
        if (testpage[2]==3)
        {
               if (iTestresponse != 0)
               {
                  if (iTestresponse == testcookie[1])
                  {
                       returnval = iformvalue;
                       if (iHideit == 0)
                       {
                           if (icorrect == 'True')
                           {
                               returnval += "<img alt='correct' src='graphics/correct.gif' border='0' />";
                           }
                           else
                           {
                               returnval += "<img alt='incorrect' src='graphics/incorrect.gif' border='0' />";
                           }
                        }
                        return returnval;
                    }
            }
            return returnval;
        }
        if (testpage[2]==1)
        {
       
         if (testcookie[1] ==1)
          {
               returnval = "<img alt='checked' src='graphics/check.gif'/>";
               if (iTestresponse != 0 && iHideit == 0)
               {
                   if (icbcorrect == 'True')
                   {
                       returnval += "<img alt='correct' src='graphics/correct.gif' border='0' />";
                   }
                   else
                   {
                      returnval += "<img alt='incorrect' src='graphics/incorrect.gif' border='0' />";
                   }
               }
            return returnval;
          }
          else
          {
            returnval = "<img alt='unchecked' src='graphics/unchecked.gif'/>";
            if (iTestresponse != 0 && iHideit == 0)
               {
                   if (icbcorrect == 'True')
                   {
                       returnval += "<img alt='correct' src='graphics/incorrect.gif' border='0' />";
                   }
                   else
                   {
                      returnval += "<img alt='incorrect' src='graphics/testspacer.gif' border='0' />";
                   }
               }
             return returnval;
          }
        }
        if (testpage[2]==2)
        {
         if (testcookie[1] == iformvalue)
          {
               returnval = "<img alt='checked' src='graphics/form_radio_checked.gif'/>";
               if (iTestresponse != 0 && iHideit == 0)
               {
                   if (icorrect == 'True')
                   {
                       returnval += "<img alt='correct' src='graphics/correct.gif' border='0' />";
                   }
                   else
                   {
                       returnval += "<img alt='incorrect' src='graphics/incorrect.gif' border='0' />";
                   }
               }
               return returnval;
          }
          else
          {
            returnval = "<img alt='checked' src='graphics/form_radio.gif'/>";
               if (iTestresponse != 0 && iHideit == 0)
               {
                   if (icorrect == 'True')
                   {
                       returnval += "<img alt='correct' src='graphics/correct.gif' border='0' />";
                   }
                   else
                   {
                      returnval += "<img alt='' src='graphics/testspacer.gif' border='0' />";
                   }
               }
             return returnval;
          }
        }
       } 
    }
}
if (iformtype == 1)
{
    returnval = "<img alt='unchecked' src='graphics/unchecked.gif'/>";
    if (iTestresponse != 0 && iHideit == 0)
    {
         if (icbcorrect == 'True')
             {
                returnval += "<img alt='correct' src='graphics/incorrect.gif' border='0' />";
             }
            else
            {
                returnval += "<img alt='incorrect' src='graphics/testspacer.gif' border='0' />";
            }
    }
    return returnval;
}
if (iformtype == 2)
{
    returnval = "<img alt='checked' src='graphics/form_radio.gif'/>";
    if (iHideit == 0)
    {
        if (icorrect == 'True')
        {
           returnval += "<img alt='correct' src='graphics/correct.gif' border='0' />";
        }
        else
        {
           returnval += "<img alt='' src='graphics/testspacer.gif' border='0' />";
        }
     }
    return returnval;
}
return '';
}
// get total scales answered correctly for metascale

function gethtmlmetatestscore(imetascalekey, imetascoretype)
{
    if (metascaleholder == '')
    {
        document.write(0)
        return;
    }
    var correctcounter = 0;
    var metascalearray = metascaleholder.split('|');
 
    for (var i=0; i < metascalearray.length; i++)
    {
        var metastuff = metascalearray[i].split(',');
        if (metastuff[0] == imetascalekey)
        {
            if (gethtmltestscore(metastuff[1], 3) == 100)
            {
                correctcounter = correctcounter + 1;
            }
        }
    }

    return correctcounter;
}
// get testscorefeedback - html version
function gethtmlscorefeedback(iscalekey, iscoretype)
{
    var thistestscore = gethtmltestscore(iscalekey, iscoretype);
    
    var scalefeedbackarray = scalefeedbackholder.split('|');
    for (var i=0; i < scalefeedbackarray.length; i++)
    {
        var scalefeedback = scalefeedbackarray[i].split(',');
        if (scalefeedback[0] == iscalekey && thistestscore >= scalefeedback[2] &&  thistestscore <= scalefeedback[3])
        {
        if (scalefeedback[4]=="critical care" || scalefeedback[4] == "Critical Care")
        {
        
            var ccformarray = ccarecheckboxholder.split('|');
            var gottitt = 0;
            for (var j=0;j < ccformarray.length; j++)
            {
                var ccformstuff = ccformarray[j].split(',');
                if (ccformstuff[0] == iscalekey && GetCookieValue(ccformstuff[1]+'-'+ccformstuff[2]+'-'+ccformstuff[3]) != '')
                {
                
        
                  if (GetCookieValue(ccformstuff[1]+'-'+ccformstuff[2]+'-'+ccformstuff[3]) == 1)
                  {
                   return scalefeedback[4];
                  }
                  else
                  {
                    return "Level 5";
                  }
                }
            }
        
        }
       
        return scalefeedback[4];
        }
    }
    return thistestscore;
}
//get testanswer feedback
function gethtmltestanswerfeedback(ipagekey,iformkey,iformtype,iTestanswerkey)
{
var ckie = unescape(document.cookie);
var cv = ckie.split(';');
var cv2;
var returnval = '';
for (var i = 0; i < cv.length; i++)
{
    cv2 = cv[i];
    var testcookie = cv2.split('=');
    var testpage = testcookie[0].split('-');
    if (testpage[0].replace(/ /g,'') == ipagekey && testpage[1] == iformkey && testcookie[1] != undefined)
    {
       // combo / list box
        if (testpage[2]==3)
        {
            if (iTestanswerkey == testcookie[1])
            {
                return 'True';      
            }
            else
            {
                return 'False';  
            }
        }
        //checkbox
        if (testpage[2]==1)
        {
           if (testcookie[1] ==1)
           {
             return "True";
           }
           else
           {
             return 'False';  
           }
        }
        if (testpage[2]==2)
        {
         if (testcookie[1] == iTestanswerkey)
          {
               return 'True';
          }
          else
          {
            return 'False'; 
          }
       }
    }
  }
  return '';
}
// Get cookie value
function GetCookieValue(icookiekey)
{
var ckie = unescape(document.cookie);

var cv = ckie.split(';');
var cv2;
var returnval = '';
var testval = '';
for (var i = 0; i < cv.length; i++)
{
    cv2 = cv[i];
    var testcookie = cv2.split('=');
    testval = testcookie[0];
    testval = testval.replace(/ /g,"");
    returnval = testcookie[1];
    if (returnval == undefined)
    {
        returnval = "";
    }

    if (testval == icookiekey)
    {
      return returnval;
    }
}
for (var i = 0; i < cv.length; i++)
{
    cv2 = cv[i];
    var testcookie = cv2.split('=');
    testval = testcookie[0];
    testval = testval.replace(/ /g,"");
    testval = testval.replace(/_/g,"");
    returnval = testcookie[1];
    if (returnval == undefined)
    {
        returnval = "";
    }

    if (testval == icookiekey)
    {
      return returnval;
    }
}
return '';
}

// determine if pagevisited in pagevisited cookie
function FindPageVisited(ipagekey, pagevisitedcookie)
{
if (pagevisitedcookie == '')
{
    return 'false';
}
pagevisitedcookie = pagevisitedcookie + ",";
var pagevisitedarray = pagevisitedcookie.split(',');
for (var i=0;i < pagevisitedarray.length - 1;i++)
{
    if (pagevisitedarray[i] == ipagekey)
    {
    return 'true';
    }
}
return 'false';
}
/// for html / database version



function updateform(intext, thisformkey, thispagekey)
{
//alert(thisformkey);
var formregexp = new RegExp(','+thisformkey+',','gim');
jspageformlist = jspageformlist.replace(formregexp,',');
if (jshtmlversion == 1){return '';};
if (intext == "null"){intext = "";}
document.getElementById(thisformkey).value =intext;


var updateURL = "";
request = false;
if (jshtmlversion ==0)
{
      updateURL = "postformdata.aspx?text=" + intext + "&formkey=" + thisformkey + "&pagekey=" + thispagekey + "&sessionkey=" + jssessionkey + "&pageviewdb=" + jsdatabase + "&referringuserkey=" + jsreferringuserkey + "&custsitekey=" + jscustsitekey + "&custkey=" + jscustomerkey + "&productkey=" + jsproductkey;
}
else
{
updateURL = "posthtmlformdata.aspx?text=" + escape(intext) + "&formkey=" + thisformkey + "&pagekey=" + thispagekey + "&sessionkey=" + jssessionkey + "&pageviewdb=" + jsdatabase + "&patientkey=" + jspatientkey + "&custsitecoordkey=" + jscustsitecoordkey + "&custsitegroupkey=" + jscustsitegroupkey + "&custsitekey=" + jscustsitekey + "&custkey=" + jscustomerkey + "&studypaymentdb=" + jsstudydatabase + "&userkey=" + jsuserkey +"&productkey=" + jsproductkey + "&patientsessionkey=" + jspatientsessionkey;
}
//alert(updateURL);
var updaterequest;

  try {
    updaterequest = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      updaterequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        updaterequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        updaterequest = false;
      }
    }
  }
 if (!updaterequest){alert("Error initializing XMLHttpRequest!");}
   		
    // alert("Ready state is: " + request.readyState);
     // Setup (initialize) the request
updaterequest.open("POST", updateURL, true);
updaterequest.onreadystatechange = function()
 {
          if (updaterequest.readyState == 4) 
           {
             if (updaterequest.status == 200) 
             {
                var inresp = updaterequest.responseText.split("|");
                if (inresp.length > 0) 
                {
                  if (Left(inresp[0], 6) == "error=" && Right(inresp[0], inresp[0].length - 6) != '')
                  {
                    var msg=inresp[0];
                    msg = msg.replace(/error=/,'');
                     alert(msg);
                   // document.getElementById(thisformkey).value="";
                  }
                  else
                  {
                    for (var i = 0;i<inresp.length;i++){document.cookie = inresp[i];};
                  
                  }
                }
            }
         }
}
     updaterequest.send(null);
} 

// bookmark page javascript

function bookmarkpage(ipagekey, isessionkey, idatabase, iuserkey, iproductkey)
{
var updateURL = "";

updateURL = "postpagefeedback.aspx?text=1&sessionkey=" + isessionkey + "&pagekey=" + ipagekey + "&pageviewdb=" + idatabase + "&userkey=" + iuserkey;
//document.write(updateURL);
document.location=updateURL;
var bookmarkrequest;
bookmarkrequest = false;
  try {
    bookmarkrequest= new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      bookmarkrequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        bookmarkrequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        bookmarkrequest = false;
      }
    }
  }
 if (!bookmarkrequest){alert("Error initializing XMLHttpRequest!");}

bookmarkrequest.open("POST", updateURL, true);
bookmarkrequest.onreadystatechange = function()
{
   if (bookmarkrequest.readyState == 4) {
     if (bookmarkrequest.status == 200) {
     }
   }
}
bookmarkrequest.send(null);
alert("This page has been bookmarked");
//alert(request.getAllResponseHeaders());
document.location="buildcontent.aspx?sessionkey="+isessionkey+"&pagekey="+ipagekey+"&userkey="+iuserkey+"&tut="+iproductkey;
return true;
}  

//html version - set up user and session and formfieldcookies
function setupuserinfo(icustkey, iproductkey, idatabase, ipagekey)
{

    updateURL = "setupusersession.aspx?pageviewdb=" + idatabase + "&custkey=" + icustkey + "&productkey=" + iproductkey;
   // alert(updateURL);
var setuprequest;
  try {
    setuprequest = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      setuprequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        setuprequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        setuprequest = false;
      }
    }
  }

  if (!setuprequest){alert("Error initializing XMLHttpRequest!");}


    setuprequest.open("POST", updateURL, true);
//request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); 
setuprequest.onreadystatechange = function()
{

    if (setuprequest.readyState == 4)
    {
      if (setuprequest.status == 200)
      {
     
        var inresp = setuprequest.responseText.split("|");
        while (inresp.length == 0) 
        {
        }
         jssessionkey = inresp[0];
         if (jssessionkey != ''){document.cookie = 'sessionkey=' + jssessionkey;updatesessionpagehistory(ipagekey, 'BuilderElearning')}
  
        if (inresp.length > 1) 
        {
         jsuserkey = inresp[1];
         if (jsuserkey != ''){document.cookie = 'userkey=' + jsuserkey;}
         }
        if (inresp.length > 2)
        {
            if (inresp[3] != '')
            {
             //alert(inresp[3]);
            }
        }
      }
    }
}

setuprequest.send(null);

}

//html version - set up user and session and formfieldcookies
function updatesessionpagehistory(ipagekey, idatabase)
{

    updateURL = "updatepagevisitedtable.aspx?pageviewdb=" + idatabase + "&sessionkey=" + jssessionkey + "&pagekey=" + ipagekey;
    //alert(updateURL);
var updatesessionrequest;
  try {
    updatesessionrequest = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      updatesessionrequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        updatesessionrequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        updatesessionrequest = false;
      }
    }
  }
 if (!updatesessionrequest){alert("Error initializing XMLHttpRequest!");}
updatesessionrequest.open("POST", updateURL, true);
updatesessionrequest.onreadystatechange = function()
{
    if (updatesessionrequest.readyState == 4)
    {
        if (updatesessionrequest.status == 200)
        {
        return true;
        }
    }
}
updatesessionrequest.send(null);
}
function setformval(iFormkey, iVal, iFormtype)
{

      switch(iFormtype)
     {
      case 1: //checkboxes
              if (iVal ==1){document.getElementById(iFormkey).checked = true;}else{document.getElementById(iFormkey).checked = false;};break
      case 2: //radio buttons
             if (iVal ==document.getElementById(iFormkey).value){document.getElementById(iFormkey).checked = true;}else {document.getElementById(iFormkey).checked =false;};break;
      case 3: //comboboxes
             document.getElementById(iFormkey).value=iVal;break;
      case 4: //listboxes
             document.getElementById(iFormkey).value=iVal;break;
      case 5: //textbox
             document.getElementById(iFormkey).value=iVal;break;
      case 6: //textarea
              document.getElementById(iFormkey).innerHTML=iVal;
              document.getElementById(iFormkey).style.color='black';break;
       }
}
function getformdbvalue(iuserkey, ipagekey, iformkey, iformname, iformtype, ivisitnum)
{

var formval = '';
ivisitnum = 0;
if (jsadminproduct != 'True' && (ivisitnum == 0 || ivisitnum == 20))
{



    if (iformtype != 2){formval = GetCookieValue(ipagekey + '-' + iformkey + '-' + iformtype);}else{formval = GetCookieValue(ipagekey + '-' + iformkey + '-' + iformtype + '-' + iformname);}
    if (ivisitnum == 20 && formval == ''){if (iformtype > 2){document.getElementById(iformkey).innerHTML='';}else{document.getElementById(iformkey).checked = false;}return;}

    if (formval != ''){setformval(iformkey, formval, iformtype);return;}
}
if (jspatientkey !=0 && jsadminproduct == true)
{updateURL = "getformresponses.aspx?userkey=" + jspatientkey  + "&pagekey=" + ipagekey + "&formkey=" + iformkey + "&formname=" + iformname + "&formtype=" + iformtype + "&pageviewdb=" + jsdatabase + "&patientform=yes&custsitecoordkey=" + jscustsitecoordkey + "&custsitegroupkey=" + jscustsitegroupkey + "&custsitekey=" + jscustsitekey + "&custkey=" + jscustomerkey + "&custadminkey=" + jscustadminkey + "&tut=" + jsproductkey;}
else
{updateURL = "getformresponses.aspx?userkey=" + iuserkey + "&pagekey=" + ipagekey + "&formkey=" + iformkey + "&formname=" + iformname + "&formtype=" + iformtype + "&pageviewdb=" + jsdatabase + "&custsitecoordkey=" + jscustsitecoordkey + "&custsitegroupkey=" + jscustsitegroupkey + "&custsitekey=" + jscustsitekey + "&custkey=" + jscustomerkey + "&custadminkey=" + jscustadminkey + "&tut=" + jsproductkey;}
//alert(updateURL);
var getformrequest;
  try {
    getformrequest = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      getformrequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        getformrequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        getformrequest = false;
      }
    }
  }
 if (!getformrequest){alert("Error initializing XMLHttpRequest!");}


getformrequest.open("POST", updateURL, true);
//request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); 
getformrequest.onreadystatechange = function()
{

    if (getformrequest.readyState == 4)
    {
    
      if (getformrequest.status == 200)
      {

            var inresp = getformrequest.responseText.split("|");
            for (var i=0; i< inresp.length - 1; i++)
            {      
                if (inresp[i].indexOf("noresponse") == -1)
                {      
                    document.cookie = inresp[i];
                    if (jshtmlversion == 2)
                    {
                       var getval = inresp[i].split('=')
                        formval = getval[1];
                        setformval(iformkey, formval, iformtype);return;
                    }                    
                }
            }
       }
    }
}

getformrequest.send(null);
                       
}
// set cookies from flash if needed for html version

function setthiscookie(str)
{
str = str.replace(/;/, '~');
document.cookie = str;

}



//clear all cookies for this session
function clearallcookies()
{
var mydate = new Date(); 
mydate.setTime(mydate.getTime() - 1); 
var ckie = unescape(document.cookie);

var cv = ckie.split(';');
var cv2;
var returnval = '';
var testval = '';
for (var i = 0; i < cv.length; i++)
{
    cv2 = cv[i];
    var testcookie = cv2.split('=');
    testval = testcookie[0];
    testval = testval.replace(/ /g,"");
    document.cookie= testval + '=; expires=' + mydate.toGMTString();
}
return '';
}



/*********************
//* jQuery Drop Line Menu- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last updated: June 27th, 09'
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/
//build menu with DIV ID="myslidemenu" on page:
var thismenuid = '';
var thismenuSRC = '';
var droplinemenu={

arrowimage: {classname: 'downarrowclass', src: 'bluedefault.gif', leftpadding: 5}, //customize down arrow image
animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={h:$curobj.find('a:eq(0)').outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			if (!this.istopheader)
				$subul.css({left:0, top:this._dimensions.h})
			var $innerheader=$curobj.children('a').eq(0)
			$innerheader=($innerheader.children().eq(0).is('span'))? $innerheader.children().eq(0) : $innerheader //if header contains inner SPAN, use that

			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						if (this.istopheader)
							$targetul.css({left: $mainmenu.offset().left, top: $mainmenu.offset().top+this._dimensions.h})
						if (document.all && !window.XMLHttpRequest) //detect IE6 or less, fix issue with overflow
							$mainmenu.find('ul').css({overflow: (this.istopheader)? 'hidden' : 'visible'})
						$targetul.slideDown(droplinemenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
				    $targetul.slideUp(droplinemenu.animateduration.out) 
		            document.getElementById(thismenuid).src = thismenuSRC;
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()})
	}) //end document.ready
}
}


////////////// timepicker
var timePickerDivID = "timepicker";
function displayTimePicker(timeFieldName, displayBelowThisObject, dtFormat, dtSep)
{

  var targettimeField = document.getElementsByName(timeFieldName).item(0);

  // if we weren't told what node to display the timepicker beneath, just display it
  // beneath the time field we're updating
  if (!displayBelowThisObject)
    displayBelowThisObject = targettimeField;
 
  // if a time separator character was given, uptime the timeSeparator variable

 
  // if a time format was given, uptime the timeFormat variable
 
 
  var x = displayBelowThisObject.offsetLeft;
  var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight ;
 
  // deal with elements inside tables and such
  var parent = displayBelowThisObject;
  while (parent.offsetParent) {
    parent = parent.offsetParent;
    x += parent.offsetLeft;
    y += parent.offsetTop ;
  }
 
  drawtimePicker(targettimeField, x, y);
}
 
 
/**
Draw the timepicker object (which is just a table with calendar elements) at the
specified x and y coordinates, using the targettimeField object as the input tag
that will ultimately be populated with a time.
 
This function will normally be called by the displaytimePicker function.
*/
function drawtimePicker(targetTimeField, x, y)
{
 var thisDay = new Date();
 var thisHour = thisDay.getHours()
 var thisMinute = thisDay.getMinutes();
 var ampm;
 if (thisHour >12)
 {
 thisHour = thisHour - 12;
 ampm = "pm";
 }else{
 ampm = "am";
 }


  var dt =targetTimeField.value;
  if (dt == '')
    {
        var testminute = thisMinute;
        if (testminute <= 15){thisMinute=15;}
        if (testminute > 15 && testminute <=30){thisMinute=30;}
        if (testminute > 30 && testminute <=45){thisMinute=45;}
        if (testminute > 45){thisMinute=0;}
        if (testminute ==0){thisMinute=0;}
        
        if (thisMinute ==0)
            {dt=thisHour+':00'+ampm;}
            else
            {dt=thisHour+':'+thisMinute+ampm;}
    }
    else
    {
	var timesplitter = dt.split(':');
        thisHour = timesplitter[0];
	thisMinute = timesplitter[1];
	if (thisMinute.indexOf('am') >-1)
        {thisMinute = thisMinute.replace(/am/,'');ampm='am';}
	else
	{thisMinute = thisMinute.replace(/pm/,'');ampm='pm';}	 

    }
  targetTimeField.value=dt;

  // the timepicker table will be drawn inside of a <div> with an ID defined by the
  // global timePickerDivID variable. If such a div doesn't yet exist on the HTML
  // document we're working with, add one.
  if (!document.getElementById(timePickerDivID)) {
    // don't use innerHTML to uptime the body, because it can cause global variables
    // that are currently pointing to objects on the page to have bad references
    //document.body.innerHTML += "<div id='" + timePickerDivID + "' class='dpDiv'></div>";
    var newNode = document.createElement("div");
    newNode.setAttribute("id", timePickerDivID);
    newNode.setAttribute("class", "dpDiv");
    newNode.setAttribute("style", "visibility: hidden;");
    document.body.appendChild(newNode);
  }
if (document.getElementById(timePickerDivID).style.display == 'block'){document.getElementById(timePickerDivID).style.display = 'none';return;}

  // move the timepicker div to the proper x,y coordinate and toggle the visiblity
  var pickerDiv = document.getElementById(timePickerDivID);
  pickerDiv.style.position = "absolute";
  pickerDiv.style.left = x + "px";
  pickerDiv.style.top = y + "px";
  pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
  pickerDiv.style.display = (pickerDiv.style.display == "block" ? "none" : "block");
  pickerDiv.style.zIndex = 10000;
 
  // draw the timepicker table
  refreshTimePicker(targetTimeField.id,dt,ampm,thisHour,thisMinute,ampm,timePickerDivID);
}
 

/**
This is the function that actually draws the datepicker calendar.
*/
function refreshTimePicker(timeFieldID,dt,mode,thisHour,thisMinute,thisampm,timePickerDivID)
{

  // if no arguments are passed, use today's date; otherwise, month and year
  // are required (if a day is passed, it will be highlighted later)
 //alert(timeFieldName);
  // the calendar will be drawn as a table
  // you can customize the table elements with a global CSS style sheet,
  // or by hardcoding style and formatting elements below
  var crlf = "\r\n";
  var TABLE = "<table cols='4' class='dtTable' cellpadding='0' cellspacing='0'>" + crlf;
  var xTABLE = "</table>" + crlf;
  var TR = "<tr class='dpTR'>";
  var TR_title = "<tr class='dtTitleTR'>";
  var TR_nowbutton = "<tr class='dpTodayButtonTR'>";
  var xTR = "</tr>" + crlf;
  var TD = "<td class='dpTD' onMouseOut='this.className=\"dpTD\";' onMouseOver=' this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  var TD_title = "<td colspan=4 class='dtTitleTD'>";
  var TD_buttons = "<td class='dtButtonTD'>";
  var TD_todaybutton = "<td class='dpTodayButtonTD'>";
  var TD_days = "<td class='dpDayTD'>";
  var TD_selected = "<td class='dpDayHighlightTD' onMouseOut='this.className=\"dpDayHighlightTD\";' onMouseOver='this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  var xTD = "</td>" + crlf;
  var DIV_title = "<div class='dpTitleText'>";
  var DIV_selected = "<div class='dpDayHighlight'>";
  var xDIV = "</div>";
 
  // start generating the code for the calendar table
  var html = TABLE;
 
  // this is the title bar, which displays the month and the buttons to
  // go back to a previous month or forward to the next month
  html += TR_title;

  html += TD_title + DIV_title + "Select a Time" + xDIV + xTD + xTR;
  html += TR_title + "<td colspan='2' style='border-top:0;border-left:0;border-right:0;border-bottom:1 solid;'>&nbsp;</td>"
  html += getTimeButtonCode(timeFieldID, dt,"am",mode,thisHour,thisMinute,timePickerDivID) + xTD;
  html += getTimeButtonCode(timeFieldID, dt,"pm",mode,thisHour,thisMinute,timePickerDivID) + xTD;
  html += xTR;
 

  // now we'll start populating the table with times
  html += TR;
 var newhour = new Number;
 var newminute = new Number;
 var newtime;
newminute = 0;
newhour = 1;

var colctr = 1;
  do {
    if (newminute < 10)
     {newtime = newhour.toString()+':0'+newminute.toString()+mode;}
    else
     {newtime = newhour.toString()+':'+newminute+mode;} 
    
   var TD_onclick = " onclick=\"document.getElementById("+timeFieldID+").value='"+newtime+"';updateform('" + newtime + "'," + timeFieldID + ", "+jspagekey+");document.getElementById('"+timePickerDivID+"').style.display='none';\">";

    if (newhour == thisHour && newminute == thisMinute && dt.indexOf(mode)>-1)
      {html += TD_selected + TD_onclick + DIV_selected + newtime + xDIV + xTD;}
    else
      {html += TD + TD_onclick + newtime + xTD;}
    colctr +=1;
    // if this is a Saturday, start a new row
    if (colctr == 5){colctr = 1;html += xTR + TR;}
    if (newminute > 44)
    {newminute=0;newhour+=1;}
    else
    {newminute +=15;}
 } while (newhour<13)

 
  html += xTR;
 
  // add a button to allow the user to easily return to today, or close the calendar
 
 html += "<tr><td colspan='4'><button class='dpTodayButton' onclick=\"document.getElementById('"+timePickerDivID+"').style.display='none';\">close</button></td></tr>";
  //html += xTD + xTR;
 
  // and finally, close the table
  html += xTABLE;
  

  document.getElementById(timePickerDivID).innerHTML = html;
  document.getElementById(timePickerDivID).style.visibility='visible';
  document.getElementById(timePickerDivID).style.display='block';

  // add an "iFrame shim" to allow the datepicker to display above selection lists
  adjustiFrame();
}

function getTimeButtonCode(timeFieldID, dt, mode, oldmode, thishour, thisminute,timePickerDivID)
{
var newmode;

if (mode == 'am'){newmode='pm';}else{newmode='am';}

 if (oldmode == newmode)

  {return "<td ><button class='dtButton' id='curampmbtnid' >" + newmode + "</button>";}
  else
   {return "<td ><button onmouseover=\"document.getElementById('curampmbtnid').className='dtButtondown';this.className='dtButton';this.style.cursor='pointer';\" onmouseout=\"this.className='dtButtondown';document.getElementById('curampmbtnid').className='dtButton';\" class='dtButtondown' onClick=\"refreshTimePicker('"+timeFieldID+"','"+dt+"','"+newmode+"','"+thishour+"','"+thisminute+"','" +mode + "','" + timePickerDivID +"');\">" + newmode + "</button>";}
}

