/*
	Header Script
*/
sfHover = function() {
	if (document.getElementById("nav"))
	{
		var sfEls = document.getElementById("nav").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//--><!]]>
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



/*
	From AC_RunActiveContent.js
*/
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  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;

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] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
	str += '<param name="wmode" value="transparent">';
    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_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  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":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      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;
}

































/*
Store Global Variables of a site
*/






























/* Javascript to invoke the print client */
function InvokePrintQueue()
{	
	if ( SiteParameterObj ) 
	{
		//if ( Trim(SiteParameterObj.policyNo).length != 0  )
		{		
			var url = "/pages/documents/printQueue/printQueueCaller.asp?policy_id=" + SiteParameterObj.policy_id;
			window.document.cmd_frame.location.href = url;
			window.status = 'Call Print Client : ' + url;
		}	
	}	
}

/* This store a global variable in javascript space */
function SiteParameterClass()
{	
	this.policy_id = '';
	this.member_id = '';	
}

SiteParameterObj = new SiteParameterClass()

// call the pop up screen
function ShowPopUpScreen( url, width, height, name )
{	
	//var h=600;
	var h=height
	var w=width;
	//var toppos1=screen.height/2-(h-50)/2;
	var l=screen.width-w-30  ;
	str='status=1, resizable=1,top='+0+',left='+l+',width='+w+',height='+h;
	newWindow=window.open( url ,name, str );
	newWindow.focus();
}


/* ------------------------------------------------------------------------
 Short Cut Key - listener
------------------------------------------------------------------------ */

// inner function
function CheckShortCutKey( e )
{	
	var code = EventUtils.getKeyCode(e);
	
	var clicked = false;
	
	//window.status = ' Short Key Pressed : ' +  EventUtils.getCharCode(e) ;	
	//window.status = ' Short Key Code Pressed : ' +  code ;
		
	// Esc is pressed
	if ( code == 27 ) {
		
		// close the pop up search screen		
		if ( window.parent ) 
		{			
			if ( window.parent.name == 'search_win' ) window.parent.close();							
			
			if ( IsIWinLayer() ) {				
				if (  window.parent && window.parent.iwin_def )
					window.parent.HideIWin();	// focus on iwin title bar
				else
					window.HideIWin();	// focus on iwin content
			}
			return false;
		}
		
		CloseMeOrGoBack();				
		return true;
	}

	// S is pressed - Save	
	if ( ( e.ctrlKey == true ) && ( code == 83 ) ) {		
		ClickIfExist( document.getElementById('dbfrm_update') ); 
		ClickIfExist( document.getElementById('dbfrm_new') );		
		ClickIfExist( document.getElementById('create') );
		ClickIfExist( document.getElementById('new') );
		return;
	}

	// Short Cut Key if pressed
	if ( e.shiftKey && e.ctrlKey )
	{	
		//window.status = ' Short Key Code Pressed : ' +  code ;

		var clicked = false

		// A -- Open the member list
		if ( code == 65 ) { 
			ClickIfExist( document.getElementById('CLICK_TO_SHOW_MEMBER_LIST') ); 
			if ( !clicked ) WindowUtils.maxWindow();
			return;
		}	
		
		// standard short key
		// S
		if ( code == 19 ) {		
			ClickIfExist( document.getElementById('dbfrm_update') );
			ClickIfExist( document.getElementById('dbfrm_new') );
			ClickIfExist( document.getElementById('create') );
			ClickIfExist( document.getElementById('new') );
			return;
		}
		
		// R - Reprocess ( crach with system short key ) 
		//if ( code == 18 ) {
		
		// O - Reprocess
		if ( code == 79 ) {
			ClickIfExist( document.getElementById('reprocess') ); 
			ClickIfExist( document.getElementById('reprocess_ap') );
			return;
		}
		
		// P - Process or Review or Pay
		if ( code == 80 ) {
			ClickIfExist( document.getElementById('process') ); 
			ClickIfExist( document.getElementById('review') ); 
			ClickIfExist( document.getElementById('approve') );
			return;
		}	

		// N - New claim or new claim items		
		if ( code == 78 ) {
			ClickIfExist( document.getElementById('new_claim_item_href') );
			ClickIfExist( document.getElementById('NEW_ENTRY') );
			return;
		}	
		
		// L - Reload
		if ( code == 76 ) window.location.reload();
		
		// Q - Show Search Screen
		if ( code == 81 ) ShowSearchWindowEx(); 
		
		// W - Show Member Profile
		if ( code == 23 ) ShowMemberProfile();
		
		// E - Print Client
		//if ( code == 69 ) InvokePrintQueue();
		if ( code == 69 ) ShowPopUpScreen('/pages/test/driver.asp?form_cmd=clone', 600, 700);
		
		// M
		if ( code == 12 ) window.location.reload();
		
		
		
	}

	return true;

	function ClickIfExist( obj ){
		if ( clicked ) return false;
		if ( obj ) obj.click();
	}
	
}


// ============================================================

function ShowSearchWindowEx(){
	ShowSearchWindow('/pages/search/summary/summary.asp?style=popup' );
}	

function ShowMemberProfile()
{
	var url = '/pages/member_profile/profiles.asp?style=popup';
	
	if ( SiteParameterObj )
	{
		if  ( ( SiteParameterObj.policy_id.length > 0  )||( SiteParameterObj.member_id.length > 0  ))
		{
			url = url + '&cmd=search&policy_id=' + SiteParameterObj.policy_id + '&member_id=' + SiteParameterObj.member_id ;
		}
	}
	
	ShowSearchWindow( url  );
	return false;
}

function ShowHelp()
{
	ShowPopUpScreen( '/pages/manual/help/index.html', 600, 800, '_blank' );
	return false;
}


function ShowSearchWindow( url )
{
	var search_url = '/pages/search/search_window/index.asp?url=' + url;
	
	ShowPopUpScreen( search_url, 845, 400, 'search_win' );
}


function ShowUndoScreen( cmd, id )
{
	showLayer('Undo Movement', '/pages/undo_utils/undoPage.asp?cmd=' + cmd + '&id=' + id, '', 'white', 500, 300 );
}




// ===========================================
// The search box in the menu bar
// ============================================
function SiteSearchHandler(e)
{	
	var code = EventUtils.getKeyCode(e);
	var search_value = Trim( $('__site_search_box').value );
	
	// Pressed Enter
	if ( code == 13 ) 
	{	
		if ( CheckSearchStr(search_value, 'c ') ) {
			// for claim ref			
			window.location = '/pages/claims/Claim.asp?cmd=search&search_sub_ref=' + ExractSearchStr(search_value);	
		}else if ( CheckSearchStr(search_value, 'm ') ) {
			// for member history			
			window.location = '/pages/search/insuredmember.asp?cmd=search&member_name=' + ExractSearchStr(search_value);	
		}else if ( CheckSearchStr(search_value, 'p ') ) {
			// for plan checking
			window.location = '/pages/plans/plan.asp?cmd=search&search=' + ExractSearchStr(search_value);	
		}else{
			// for group number
			window.location = '/pages/policies/Policy.asp?cmd=search&group_no=' + search_value;	
		}	
		return false;
	}
	return true;
	
	
	function ExractSearchStr(s){return s.substring(2,s.length);}
	function CheckSearchStr(s, pref){ return (s.toLowerCase().indexOf(pref) >= 0 ) }
}

// A Post Onload function
function PageOnLoadPost()
{
	// Add an listener to the onkeypress event to whole window
	EventUtils.addEvent( window.document, "keydown", CheckShortCutKey );
	
	// Add event to the site search box
	if ( $('__site_search_box') ) EventUtils.addEvent($('__site_search_box'), 'keypress', SiteSearchHandler );	
}


function ToggleImg( img, src1, src2 )
{	
	if ( img.src.indexOf(src1) > 0 ) { img.src = src2 } else { img.src = src1 };
}

function ValidateCreditCardInput()
{
	return true;
	var type = $('creditcard_cardtype').options[ $('creditcard_cardtype').selectedIndex ].value;
	var card_num, card_num_obj, y, m
	card_num_obj	= $('creditcard_num')	
	card_num		= card_num_obj.value;	
	y	= $('creditcard_expiry_year').value
	m	= $('creditcard_expiry_month').value
	
	var bAny = false;
	if ( !IsEmptyString( y ) ) bAny = true;
	if ( !IsEmptyString( m ) ) bAny = true;
	if ( !IsEmptyString( card_num ) ) bAny = true;
	if ( !IsEmptyString( type ) ) bAny = true;

	// Cannot be empty for some fields
	if ( bAny )
	{
		if ( IsEmptyString( card_num	) ) { alert('Please input credit number') ; return false; }
		if ( IsEmptyString( type		) ) { alert('Please select credit type') ; return false; }
		if ( IsEmptyString( y			) ) { alert('Please input expiry year') ; return false; }	
		if ( IsEmptyString( m			) ) { alert('Please input expiry month') ; return false; }
	}
	
	if ( !IsEmptyString( type ) || !IsEmptyString(card_num) )
	{
		
		var bNoErr = true;
		var msg = '';
		
		if ( bNoErr ) 
		{
			bNoErr = CreditCardUtils.isValidCardNumber( card_num );		
			if ( !bNoErr ) { msg = 'Invalid Credit Card Number' };
		}	

		var typeString
		if ( type == 1 )  typeString = 'Visa'; else if ( type == 2 )  typeString = 'Master'; else if ( type == 3 )  typeString = 'Amex';				
		if ( bNoErr && !(IsEmptyString(typeString)) ) {
			bNoErr = CreditCardUtils.isCardTypeCorrect( card_num, typeString );
			if ( !bNoErr ) { msg = 'Invalid Credit Card Type' };
		}	
		
		// perform checking		
		if ( !bNoErr )
		{
			if ( FormUtils.IsFocusableField(card_num_obj) )
			{ 
				card_num_obj.style.background = '#FFFFCB';
				card_num_obj.focus(); 
				alert( msg );
				return false;
			}
		}
	}		
	
	return true;
}




// ================================================
//  A class for creating a dragging panel
// ================================================
/*
this.element		= $(element);
this.menubar	= $(element + '_hdr__' );
this.container.	= $(element + '_container__' );
*/
var MyClass = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}
DragScrollable = MyClass.create();
DragScrollable.prototype = 
{
  initialize: function(element) 
  {
    this.element		= $(element);
    this.menubar		= $(element + '_hdr__' );
    this.container		= $(element + '_container__' );    
    if ( !this.menubar )	this.menubar = this.element;
	if ( !this.container )	this.container = this.element;
    this.active = false;
    this.scrolling = false;
    this.menubar.style.cursor = 'pointer';
    this.eventMouseDown = this.startScroll.bindAsEventListener(this);
    this.eventMouseUp   = this.endScroll.bindAsEventListener(this);
    this.eventMouseMove = this.scroll.bindAsEventListener(this);
    Event.observe(this.menubar, 'mousedown', this.eventMouseDown);
  },
  destroy: function() {
    Event.stopObserving(this.menubar, 'mousedown', this.eventMouseDown);
    Event.stopObserving(document, 'mouseup', this.eventMouseUp);
    Event.stopObserving(document, 'mousemove', this.eventMouseMove);
  },
  startScroll: function(event) {	
  
    this.startX = Event.pointerX(event);
    this.startY = Event.pointerY(event);
    if (Event.isLeftClick(event) && 
		(this.startX < this.container.offsetLeft + this.container.clientWidth) && 
		(this.startY < this.container.offsetTop + this.container.clientHeight)) 
    { 
      this.menubar.style.cursor = 'move';
      Event.observe(document, 'mouseup', this.eventMouseUp);
      Event.observe(document, 'mousemove', this.eventMouseMove);
      this.active = true;
      Event.stop(event);
    }
  },
  endScroll: function(event) {
//	MTG.LayerUtils.setOpacity(  this.container, 100 );
    this.menubar.style.cursor = 'pointer';
    this.active = false;
    Event.stopObserving(document, 'mouseup', this.eventMouseUp);
    Event.stopObserving(document, 'mousemove', this.eventMouseMove);
    Event.stop(event);
  },
  scroll: function(event) {  
    if (this.active) 
    {
      var dx, dy
      dx = Event.pointerX(event) - this.startX ;
      dy = Event.pointerY(event) - this.startY       
      this.container.style.top =  parseFloat( this.container.style.top ||0 ) + dy + 'px' ;
      this.container.style.left = parseFloat( this.container.style.left||0 ) + dx + 'px' ;      
      this.startX = Event.pointerX(event);
      this.startY = Event.pointerY(event);      
  //    MTG.LayerUtils.setOpacity( this.container, 50 );
    }
    Event.stop(event);
  }, 
  
  // set the content of the 
  setTitle: function( s ) 
  {
	this.menubar.innerHTML = '<table cellpadding=0 cellspacing=0 border=0 >' + 
							'<tr>'+ 		
							'<td align=center ><div class=dragTitle >' + s + '</div></td>' + 
							'<td width=10 nowrap >' + 
								'<div class=dragTitle ></div>' +
							'</td>' + 
							'</tr>' + 
							'</table>';							
		//onclick="LayerUtils.hide(\'' + this.container.id + '\'); "							
  },
  
  // set the content of the 
  setContent: function( s ) 
  {
	this.element.innerHTML = s;
  },
  
  hide : function()
  {
	LayerUtils.hide( this.container );
  }, 
  
  showAtCenter : function()
  {
	LayerUtils.showAtCenter( this.container );	
  }  
}





function CreateDragDiv( divId, title, content )
{
	var containerId, bHeader
	
	bHeader = ( Trim(title).length != 0 )

	// display a header if there is a title
	if ( bHeader ) containerId = divId + '_container__'; else container = divId;
	// dynamically create a div element if no exist
	var oDiv = MyDOMUtils.addDivIfNotExist( containerId );
	Element.setStyle( oDiv, { zIndex:'20' });
	oDiv.innerHTML = '';
	oDiv.className		= 'dragTable';
	
	Position.absolutize( oDiv );
	//MTG.LayerUtils.hide( oDiv );
	var titleDiv, contentDiv 
	if ( bHeader ) 
	{	
		titleDiv					= document.createElement("DIV");
		titleDiv.id					= divId + '_hdr__';
		titleDiv.className			= 'dragTitle';
		
		titleDiv.innerHTML = 			
		'<table cellpadding=0 cellspacing=0 border=0 width=100%  >' + 
		'<tr>'+ 		
		'<td align=center ><div class=dragTitle >' + title + '</div></td>' + 
		'<td width=10 nowrap onclick="LayerUtils.hide(\'' + oDiv.id + '\'); " >' + 
			'<div  class=dragTitle >X&nbsp;</div>' +
		'</td>' + 
		'</tr>' + 
		'</table>'

		contentDiv					= document.createElement("DIV");			
		contentDiv.id				= divId ;			
		contentDiv.innerHTML		= content;
		contentDiv.className		= 'dragContent';

		oDiv.appendChild(titleDiv);
		oDiv.appendChild(contentDiv);

	}else
	{
		oDiv.className = 'dragContent';
	}

	// create a draggable object
	var da = new DragScrollable( divId );		
	return da;
}



MyDOMUtils = new function(){
	
	//dynamiccally create a div, if the div does not already exist
	this.addDivIfNotExist = function(divID, bTail)
	{
		var oDiv = $(divID)
		if(!oDiv)
		{
			oDiv = document.createElement("DIV");
			oDiv.id = divID;				
			if ( document.body ){
				if ( bTail ) document.body.appendChild(oDiv);				
				else document.body.insertBefore(oDiv, document.body.firstChild)
			} else alert('No document.body found ');			
		}

		oDiv.style.position = 'absolute';
		
		return oDiv;
	}
}

function CommaListAppend( id, id_list )
{
	var list = id_list;
	if ( CommaListItemPos( id, list ) < 0 ) 
	{ 
		if (list.length == 0)
			list += id; 
		else
			list += ',' + id;
	}
	return list;
}

// Remove a selected tooth
function CommaListRemove( id, id_list )
{
	var pos = CommaListItemPos(id, id_list);
	var arr = id_list.split(",");
	var s = "";
	arr.splice(pos,1)
	for (var i = 0; i < arr.length; i++)
	{
		s += arr[i] + ','
	}			
	return s.substr(0,s.length-1)
}

// Get the id position
function CommaListItemPos( id, id_list )
{
	var arr = id_list.split(",");
	for (var i = 0; i < arr.length; i++)
	{
		if (arr[i] == id)
		{
			return i;
		}
	} 
	return -1;
}

function get_xml(ajaxResponse)																	
{																								
	var xmldoc = MTGXML.parse( RicoUtil.getContentAsString( ajaxResponse ) );					
	var myxml = xmldoc.getElementsByTagName('myxml')[0];										
	return myxml;																				
}

function trim_str(str) { return str.replace(/^\s+(.*?)\s+$/, '$1'); }

function retrieve(xml, tag_name)																
{																								
	return trim_str(RicoUtil.getContentAsString( xml.getElementsByTagName(tag_name)[0] ));		
}	

function CopyInputValue(from_id, to_id)
{
	if ($(from_id) && $(to_id))
	{
		$(to_id).value = $(from_id).value;
	}
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}


function BlinkWarning(blink_key)
{
	if (!IsEmptyString(blink_key))
	{
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#f66262\' );', 100 );
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#f47b7b\' );', 600 );
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#f38c8c\' );', 700 );
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#f39b9b\' );', 790 );
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#f1a8a8\' );', 870 );
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#efb6b6\' );', 950 );	                
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#efc4c4\' );', 1000 );			                
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#edcfcf\' );', 1050 );			                
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#ecdbdb\' );', 1040 );			                
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'#eae5e5\' );', 1150 );			                
		setTimeout( 'HightLighthRow( \'' + blink_key + '\', \'\' );'	   , 1250 );
	}
}

function HightLighthRow( id, color )
{   
	if ( $(id) )
	{
		$(id).style.backgroundColor = color;
	}	
}

function SubQWarning(sub_q_id, question_num)
{
	window.location.hash = sub_q_id + '_ti';
	$(sub_q_id).style.backgroundColor='#f66262';
	alert('Missing answer for Question ' + question_num);
	BlinkWarning(sub_q_id);
}
