
/*
"doublelistbox_alltorightbtn_clicked(this, hiddenfieldname);");
"doublelistbox_torightbtn_clicked(this, hiddenfieldname);");
"doublelistbox_toleftbtn_clicked(this, hiddenfieldname);");
"doublelistbox_alltoleftbtn_clicked(this, hiddenfieldname);");
"doublelistbox_upbtn_clicked(this, hiddenfieldname);");
"doublelistbox_downbtn_clicked(this, hiddenfieldname);");

function DoubleList_MoveItem(itemIndex,source,target) {
	var itemValue = source.options[itemIndex].value;
	var itemText = source.options[itemIndex].text;
	source.Remove( itemIndex );
	target.Add(itemValue, itemText);
}
function DoubleList_MoveAllItems(source,target) 
{
	while ( source.options.length > 0 ) 
	{
		DoubleList_MoveItem( 0, source, target );
	}
}
function DoubleList_MoveSelectedItems(source,target) 
{
	if ( source.options.length == 0 ) 
	{
		return;
	}
	var originalIndex = source.options.selectedIndex;
	while ( source.options.selectedIndex >= 0 ) 
	{
		DoubleList_MoveItem( source.options.selectedIndex, source, target );
	}
	if ( originalIndex < source.options.length ) 
	{
		source.options.selectedIndex = originalIndex;
	} 
	else 
	{
		source.options.selectedIndex = source.options.length - 1;
	}
	target.options.selectedIndex = target.options.length - 1;
}









function MoveItem(listTo, listFrom, removeFromSource)
{
	var newOption;
	var i = 0;			
	for (; i&lt;listFrom.options.length; i++)
	{
		if (listFrom.options[i].selected == true)
		{
			newOption = new Option();
			newOption.value = listFrom.options[i].value;
			newOption.text = listFrom.options[i].text;
			if (IsItemPresent(listFrom.options[i].text, listTo) == false)
				listTo[listTo.options.length] = newOption;
			if (removeFromSource == true)
				listFrom[listFrom.selectedIndex] = null;	
		}
	}	
}
*/
function datagridradiobuttonclicked(me) 
{
	//alert('This is me.id:'+ me.id);
	//for(var i in bbbb)
	//{	
	//	var obj = document.getElementById(bbbb[i]);
	//	if (obj.id == me.id)
	//	{
	//		obj.checked = true;
	//	} 
	//	else 
	//	{
	//		obj.checked = false;
	//	}
	//}
	for (var i=2; i>1; i++)
	{
			var obj = eval('Form1.dg__ctl'+i+'_Answer');
			if(obj==undefined)
			{
				break;
			}
			if (obj.id == me.id)
			{
				obj.checked = true;
				var objInfo = eval('Form1.'+'txtRadioInfo');
				objInfo.value = i-2;
			} 
			else 
			{
				obj.checked = false;
			}
	}
	
}
		

function MetaBuilders_RowSelectorColumn_SelectAll( parentCheckBox ) {
    if ( typeof( document.getElementById ) == "undefined" ) return;
    if ( parentCheckBox == null || typeof( parentCheckBox.participants ) == "undefined" ) {
        return;
    }
    var participants = parentCheckBox.participants;
    for ( var i=0; i < participants.length; i++ ) {
        var participant = participants[i];
        if ( participant != null ) {
            participant.checked = parentCheckBox.checked;
        }
    }
}
function MetaBuilders_RowSelectorColumn_Register( parentName, childName ) {
    if ( typeof( document.getElementById ) == "undefined" ) return;
    var parent = document.getElementById( parentName );
    var child = document.getElementById( childName );
    if ( parent == null || child == null ) {
        return;
    }
    if ( typeof( parent.participants ) == "undefined" ) {
        parent.participants = new Array();
    }
    parent.participants[parent.participants.length] = child;
}
function MetaBuilders_RowSelectorColumn_CheckChildren( parentName ) {
	if ( typeof( document.getElementById ) == "undefined" ) return;
    var parent = document.getElementById( parentName );
    if ( parent == null || typeof( parent.participants ) == "undefined" ) return;
    var participants = parent.participants;
    for ( var i=0; i < participants.length; i++ ) {
        var participant = participants[i];
        if ( participant != null && !participant.checked ) {
				parent.checked = false;
				return;
        }
    }
    parent.checked = true;
}

function rdclicked()
{
	for (var i=2; i>1; i++)
    {
			var rd = eval('Form1.dg__ctl'+i+'_Answer');
			if(rd==undefined)
			{
				break;
			}
			if(rd.checked)
			{
				alert('Row'+i+' is checked. rd.name is ' + rd.name + ' rd.id is ' + rd.id);
			}
			else
			{
				alert('Row'+i+' is unchecked. rd.name is ' + rd.name + ' rd.id is ' + rd.id);
			}
    }
	alert('This is name88899:'+ this.value);
}
function SaveCodeValidation_onclick(st) 
{
    //CodeList
    //Code can not be empty
    var tCode = eval('Form1.'+'TxtCode');
    str0 = Trim(tCode.value);
	if(str0.length==0)
	{
		alert('Code can not be empty!');
		return false;
	}
	//All codes are in CodeList Array, Check if new code already exists
	//if(st.length>0)
	//{
	//    strO = ',' + str0 + ',';
	//	if(st.indexOf(strO) >= 0)
	//	{
	//		alert('The new code alredy exists!');
	//		return false;
	//	}
	//}
	
    str = ',';
    for (var i=2; i>1; i++)
    {
			var textbox = eval('Form1.dg__ctl'+i+'_CodeList');
			if(textbox==undefined)
			{
				break;
			}
			str += textbox.value+ ',' ;
    }
    
    for (var j=2; j>1; j++)
    {
			var tbox = eval('Form1.dg__ctl'+j+'_CodeList');
			if(tbox==undefined)
			{
				break;
			}
			str1 = Trim(tbox.value);
			if(str1.length==0)
			{
				alert('CodeList Items can not be empty!');
				return false;
			}
			str1 = ','+tbox.value+',';
			//alert('index  ' + str.indexOf(str1) + ' lastIndex ' + str.lastIndexOf(str1));
			if(str.indexOf(str1) != str.lastIndexOf(str1)) 
			{
				alert('CodeList Items can not be the same with each other!');
				return false;
			}
    }
    return true;
}



function doValidation(source, arguments)
{
  if(arguments.Value==undefined)
  {
	arguments.IsValid=false;
  }
  else
  { 
	sAfterTrim = Trim(arguments.Value);
	if(sAfterTrim.length==0)
	{
		arguments.IsValid=false;
	}
	else
	{
		arguments.IsValid=true;
	}
  }
}

function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1){
		return '';
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==''){
		return '';
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = '';
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
	  if(VALUE.charAt(iTemp) == w_space){
	  }
	  else{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
	  }
	  iTemp = iTemp-1;

	} //End While
  return strTemp;

} //End Function

function LTrim(VALUE)
{
   var w_space = String.fromCharCode(32);
   if(v_length < 1){
      return"";
   }
   var v_length = VALUE.length;
   var strTemp = "";

   var iTemp = 0;

   while(iTemp < v_length){
      if(VALUE.charAt(iTemp) == w_space){
      }
      else{
        strTemp = VALUE.substring(iTemp,v_length);
        break;
      }
      iTemp = iTemp + 1;
   } //End While
   return strTemp;
} //End Function



var hoverBG = "#fcc917"; 
var orgBG = "#fffacd"; 

function checkBrowser() {
  this.isIE = false;
  var ua = navigator.userAgent;
  if (ua.indexOf("MSIE") > 0) {
    this.isIE = true;
  }
}

var browser = new checkBrowser();

function getPageOffsetLeft(cmpn) {

  var l;
  l = cmpn.offsetLeft;
  if (cmpn.offsetParent != null)
    l += getPageOffsetLeft(cmpn.offsetParent);

  return l;
}

function getPageOffsetTop(cmpn) {
  var t;
  t = cmpn.offsetTop;
  if (cmpn.offsetParent != null)
    t += getPageOffsetTop(cmpn.offsetParent);

  return t;
}

function xjsMenuFindBar(cmpn) {
  if (cmpn == null) return null;
  var clsName = cmpn.className;
  if (cmpn.tagName != undefined)
  if (cmpn.tagName == "DIV" && clsName !=null && clsName.indexOf("xjsMenuCls") >=0 ) {
    return cmpn;
  }
  var pcmp = cmpn.parentNode;
  return xjsMenuFindBar(pcmp);
}

function recCloseSubMenu(subm) {
    do {
      subm = xjsMenuFindBar(subm);
      if (subm == null)break;
      if (subm.getAttribute("xjsTopMenu") != null) break;
      xjsHideMenu(subm);
      subm = subm.xjspmenu;
    } while(true);
}

function xjsMenuIsDirParent(menu, pid) {
  if (menu.id == pid) return true;
  var pnode = menu.parentNode;
  if (pnode ==null) return false;
  return xjsMenuIsDirParent(pnode,pid);
}

function xjsInitMenu(menu) {
  if (menu.xjsMenuInit != undefined) return;
  menu.xjsMenuInit = true;

  ///////////////

  var mList = menu.getElementsByTagName("A");
  if (mList.length == 0) return;
  var itemWidth = mList[0].offsetWidth;

  var i;
  for (i = 0; i < mList.length; i++) {
    var spans = mList[i].getElementsByTagName("SPAN");
    var text  = null;
    var arrow = null;
    var totalLen = 0;

    var len = spans.length;
    if (len < 2) continue;

    text = spans[len-2];
    arrow = spans[len-1];

 
    var arrowW =0;
    arrowW = arrow.offsetWidth;
    
    var rt = (itemWidth 
        - (text.offsetLeft+ text.offsetWidth + arrowW));
    text.style.paddingRight = rt + "px";
  }
  ///////////////*/

  if (menu.xjsIEMenuFrame != null || !browser.isIE) return;
  // Fix IE hover problem by setting an explicit width on first item of
  // the menu.
  //see http://www.brainjar.com/dhtml/menubar/default2.asp
  var item0 = menu.childNodes;
  if (item0.length >0) {
    item0 = item0[0];
    var w = item0.offsetWidth;
    item0.style.width = w + "px";
    var dw = item0.offsetWidth - w;
    w -= dw;
    item0.style.width = w + "px";
  }

  var iframeie = document.createElement("IFRAME");
  iframeie.frameBorder = 0;
  iframeie.src = "javascript:;";
  iframeie.style.display = "none";
  iframeie.style.position = "absolute";
  iframeie.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
  menu.xjsIEMenuFrame = menu.parentNode.insertBefore(iframeie, menu);
}

function xjsShowIEMenu(menu) {
  if (menu.xjsIEMenuFrame != null)
  {
    menu.xjsIEMenuFrame.style.left = menu.style.left;
    menu.xjsIEMenuFrame.style.top  = menu.style.top;
    menu.xjsIEMenuFrame.style.width  = menu.offsetWidth + "px";
    menu.xjsIEMenuFrame.style.height = menu.offsetHeight + "px";
    menu.xjsIEMenuFrame.style.display = "";
  }
}

function xjsHideMenu(menu) {
  menu.style.visibility = "hidden";
  var fram = menu.xjsIEMenuFrame;
  if (fram != null) {
    fram.style.display = "none";
  }
}

function showmenu(menuname, submenuname) {
  var menu, subm;
  menu = document.getElementById(menuname);  
  subm = document.getElementById(submenuname);
  
  xjsInitMenu(menu);
  xjsInitMenu(subm);
  subm.style.left = (getPageOffsetLeft(menu) + menu.offsetWidth-1) + 'px';
  subm.style.top = getPageOffsetTop(menu) + "px";
  subm.style.visibility = "visible";
  var winHeight = 1024;
  if (browser.isIE) {
    if (document.body)
    {
      winHeight = document.body.clientHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
      winHeight = document.documentElement.clientHeight;
    }
  } else {
    winHeight = window.innerHeight;
  }
  if (subm.offsetTop + subm.offsetHeight > winHeight) {
    var adj = winHeight - subm.offsetHeight;
    if (adj < 0 )adj = 0;
    subm.style.top = adj+"px";
  }


  //if (menu.menu != null && menu.menu != subm) {
  //  menu.menu.style.visibility = "hidden";
  //}
  subm.xjspmenu = menu;

  subm.onmouseout = function(event) {
    var target;
    if (event) {
       target = event.relatedTarget;
    } else {
      event = window.event;
      target = event.toElement;
    }

    if (target == null) {
      recCloseSubMenu(subm);
      return;
    }

    var tparent = xjsMenuFindBar(target);
    if (subm == tparent) return;  //target is on same level
    var myParent=xjsMenuFindBar(subm).xjspmenu;
    if (tparent == xjsMenuFindBar(myParent)) {
      //target is in my parent
      
      if (xjsMenuIsDirParent(target, myParent.id)) {        
        return;
      }
      xjsHideMenu(subm);
      return; 
    }
    if (tparent != null) {
      var pmenu = tparent.xjspmenu;
      //alert("submpar " + xjsMenuFindBar(subm).id +" submid " + subm.id+" tpid "+tparent.id);
      if (xjsMenuFindBar(pmenu) ==subm) return; //target is my child
    }
    
    pmenu =target.xjspmenu;
    if (pmenu != undefined && pmenu == subm) return; //direct child
    recCloseSubMenu(subm);
  };

    menu.onmouseout = function(event) {
      var target, tparent;
      if (event == null) {
          event= window.event;
          target = event.toElement;
      } else {
         target = event.relatedTarget;
      }
      if (target == null) {
         recCloseSubMenu(subm);
      }
      if (target == subm) return; //target is child
      tparent = xjsMenuFindBar(target);
      if (tparent != null && tparent == subm) return; //target is child's child 
      xjsHideMenu(subm);
    };
}


