/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/


var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
var tipiframe=document.all? document.all["dhtmltooltipiframe"] : document.getElementById? document.getElementById("dhtmltooltipiframe") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if(tipobj==null){
	document.onmousemove=positiontip
	tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
	tipiframe=document.all? document.all["dhtmltooltipiframe"] : document.getElementById? document.getElementById("dhtmltooltipiframe") : ""
}
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
tipiframe.style.width=tipobj.style.width
tipiframe.height=tipobj.offsetHeight
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//KDP position iframe to cover up any windowed objects (select's and certain others)
tipiframe.style.left=tipobj.style.left

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"

//KDP position iframe to cover up any windowed objects (select's and certain others)
tipiframe.style.top=tipobj.style.top
tipobj.style.visibility="visible"
tipiframe.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
//KDP - hide iframe.
tipiframe.style.visibility='hidden'
tipiframe.style.left="-1000px"
tipiframe.style.width=''
}
}



/*
HARDCODED items....
oForm gets set to the form with the ID = 'vuForm'
Rows get set to ID = 'ROWID<tableID>'

*/

var arrDirty = new Array();
var arrFields = new Array();
var arrIDs = new Array();
var bTest=true;
var bDebug=false;
var w,oForm,oNewForm;

//TMK 5/18/2005 - check if we wrote out a javascript variable to set the debug value
if (typeof vudebug != "undefined") {bDebug = vudebug} 

function dtRemoveDetail(sDTName, oButton) {
/*
- check to see if the step is add
  - y - actually remove it from the form..
  - n - set step to delete
      - hide field
*/
var o,iCount;

	iCount=oButton.getAttribute("itemIndex");
	o=document.getElementById(sDTName +'_'+ iCount +'_step');
	if (o.value=='add'){
		o=document.getElementById(sDTName +'_'+ iCount +'_hide');
		o.parentNode.removeChild(o);
		}
	else {
		o.value='delete'; 
		o=document.getElementById(sDTName +'_'+ iCount +'_hide');
		o.style.visibility='hidden';
		o.style.position='absolute';
		}

}

function dtAddDetail(sDTName) {
/*
- copy hidden tags
- make copy visible
- set copied fields to what they need to be
*/

var oNew,iCount,sFields;
var o,a,t,s; 

	//increment the count by 1
	iCount=0
	o=document.getElementById(sDTName +'_count');
	iCount=o.value;
	iCount++;
	o.value=iCount;
	//get our fields
	sFields=','+ document.getElementById(sDTName +'_fieldlist').value +',';
	//copy the hidden object
	o=document.getElementById(sDTName +'_hide');
	oNew=o.cloneNode(true);
	o.parentNode.insertBefore(oNew,o);
	//make copy visible
	o.style.visibility='visible';
	o.style.position='relative';
	//step through and process the elements you need to change
	t=o.id;
	o.id=sDTName +'_'+ iCount + t.substring(sDTName.length,t.length);
	o.name=sDTName +'_'+ iCount + t.substring(sDTName.length,t.length);
	a=o.getElementsByTagName('*');
	for(i=0;i<a.length;i++){
		o=a[i];
		t=o.id;
		//rename all fields that start with sDTName to reflect our new count#
		if(t.substring(0,sDTName.length)==sDTName){
			o.id=sDTName +'_'+ iCount + t.substring(sDTName.length,t.length);
			o.name=sDTName +'_'+ iCount + t.substring(sDTName.length,t.length);
			//clear fields when adding new entries
			//do not clear system fields
			if(o.name.indexOf('_detailid')<0 && o.name.indexOf('_step')<0){
				o.value='';
			}
		}
		//set our itemIndex property on the remove button so it will work properly
		if(t=='Remove Entry Above' || t=='Remove' || t=='removebutton'){o.setAttribute("itemIndex",iCount);};
	}
}


/*var oDetail,oTable,oNewRow,regexp;
var o,a,t,s; 
	oDetail=document.getElementById(sETName +'');
	oTable=document.getElementById('vu_report');//due to a goofy way IE impliments parentNode we have to do it this way.
	//loop through and change the fields we need to change.
	oNewRow=oRow.cloneNode(true);
//	oRow.insertAdjacentElement('afterEnd',oNewRow);
//	o=oTable.insertRow(oRow.rowIndex);
//	o.replaceNode(oNewRow);
	
	oRow.parentNode.insertBefore(oNewRow,oRow);
	a=oRow.getElementsByTagName('*');
	for(i=0;i<a.length;i++){
		o=a[i];
		t=o.id;
		//rename all fields that start with ID to reflect our new ID
		if(t.substring(0,2)=='ID'){
			o.id='ID'+ iNewID + t.substring(t.indexOf('_'),t.length);
			o.name='ID'+ iNewID + t.substring(t.indexOf('_'),t.length);
			//change the ID<tableID>_ID field's value to be our new ID
			if(t=='ID'+ iOldID +'_ID'){o.value=iNewID};
		}
		//fix links
		if(o.nodeName=='A'){o.href=o.href.replace(iOldID,iNewID);};
		//fix non-editable fields like count and ID...
		switch(o.getAttribute('headers')){
			case 'Count':
				o.innerHTML='&nbsp;';
				break;
			case 'ID':
				o.innerHTML=iNewID;
				break;
	}}
if (bDebug) {alert('Close')};	
w.close();
w=null;
oForm=null;
oNewForm=null;

*/



// variable to use quote in various strings
 jquote = '"' 
 
 
// timecheck(pcstring)
// radiochecked(thisradiobutton) returns true or false
// dateclean(pcstring)
// datecheck(pcstring)
// emailclean(pcstring)
// emailvalidate(this)
// sw(swstring,swa,swb)
// listadd(thislist,thisitem)
// listremove(thislist,thisitem)
// phoneclean(pcstring)
// creditcardclean(pcstring)
// validcreditcardnumbercheck(cardnumber)
// popUp(url)
// SetSelectToThis(thisselectfield,thisvalue)
// SetListBox(thisselectfield,thisvalue)
// datetoyearquarter(strDate,qtradjust)

// listclean(pcstring) - clean up a CSV string
// AddToList(oList,oValue) - new listadd function
// RemoveFromList(oList,oValue) - new listremove function
// AddToField(oField,oValue) - like listadd, but using a field
// RemoveFromField(oField,oValue) - like listremove but using a field
// UpdateAListFieldOnClick(this,this.form.where_campaigntype) - update a list field based on a checkbox being checked or unchecked.
 
function timecheck(value) {
   var colonCount = 0;
   var hasMeridian = false;
   for (var i=0; i<value.length; i++) {
      var ch = value.substring(i, i+1);
      if ( (ch < '0') || (ch > '9') ) {
         if ( (ch != ':') && (ch != ' ') && (ch != 'a') && (ch != 'A') && (ch != 'p') && (ch != 'P') && (ch != 'm') && (ch != 'M')) {
            return false;
         }
      }
      if (ch == ':') { colonCount++; }
      if ( (ch == 'p') || (ch == 'P') || (ch == 'a') || (ch == 'A') ) { hasMeridian = true; }
   }
   if ( (colonCount < 1) || (colonCount > 2) ) { return false; }
   var hh = value.substring(0, value.indexOf(":"));
   if ( (parseFloat(hh) < 0) || (parseFloat(hh) > 23) ) { return false; }
   if (hasMeridian) {
      if ( (parseFloat(hh) < 1) || (parseFloat(hh) > 12) ) { return false; }
   }
   if (colonCount == 2) {
      var mm = value.substring(value.indexOf(":")+1, value.lastIndexOf(":"));
   } else {
      var mm = value.substring(value.indexOf(":")+1, value.length);
   }
   if ( (parseFloat(mm) < 0) || (parseFloat(mm) > 59) ) { return false; }
   if (colonCount == 2) {
      var ss = value.substring(value.lastIndexOf(":")+1, value.length);
   } else {
      var ss = "00";
   }
   if ( (parseFloat(ss) < 0) || (parseFloat(ss) > 59) ) { return false; }
   return true;
}
 
function radiochecked(thisradiobutton){
var movefromidchecked = false;
if (typeof thisradiobutton != "undefined"){
if (thisradiobutton.checked > 0) {movefromidchecked=true;};
for (i = 0;  i < thisradiobutton.length;  i++) {if (thisradiobutton[i].checked)  {movefromidchecked=true;}};
if (movefromidchecked==true) {return true} else {return false};
}
}

function dateclean(pcstring) {
if (pcstring.charAt(0) == '0') pcstring = pcstring.substring(1,pcstring.length);
if (pcstring.charAt(0) == ' ') pcstring = pcstring.substring(1,pcstring.length);
pcstring=sw(pcstring,'-','/');
pcstring=sw(pcstring,'.','/');
pcstring=sw(pcstring,' ','/');
pcstring=sw(pcstring,'//','/');
if (pcstring.charAt(pcstring.length-1) == '/') pcstring = pcstring.substring(0,pcstring.length-1);
if (pcstring.charAt(pcstring.length-1) == '/') pcstring = pcstring.substring(0,pcstring.length-1);  
var dd = pcstring.substring(0,pcstring.indexOf('/'));
if (dd.charAt(0) == '0') dd = dd.substring(1,dd.length);
var mm = pcstring.substring(pcstring.indexOf('/')+1,pcstring.length);
if (mm.charAt(0) == '0') mm = mm.substring(1,mm.length);
var yy = mm;
mm = mm.substring(0,mm.indexOf('/'));
yy = yy.substring(yy.indexOf('/')+1,yy.length);
if (yy.length == 2) {yy = '20'+yy};
if (dd+mm+yy != '') {pcstring = dd+'/'+mm+'/'+yy};
pcstring=sw(pcstring,'//','/');
pcstring=sw(pcstring,'//','/');
if (pcstring.charAt(pcstring.length-1) == '/') pcstring = pcstring.substring(0,pcstring.length-1);
return(pcstring);
}
 
 
function sw(swstring,swa,swb) {
for (var i=0; (i < 1000) && (swstring.indexOf(swa,0) >= 0); i++) {
swstring = swstring.substring(0,swstring.indexOf(swa,0))+swb+swstring.substring(swstring.indexOf(swa,0)+swa.length,swstring.length)  
}
return(swstring);
}

function switchon(thisfield,thisitem) {
 for (i = 0;  i < thisfield.length;  i++) {
  if (thisfield[i].value == thisitem) {
   thisfield[i].checked = true;
  }
 }
}

function switchoff(thisfield,thisitem) {
 for (i = 0;  i < thisfield.length;  i++) {
  if (thisfield[i].value == thisitem) {
   thisfield[i].checked = false;
  }
 }
}

function listadd(thislist,thisitem) {
 if(thisitem.length>0){
  if(thislist.indexOf(thisitem)==0){thislist=thislist+','+thisitem};
 }
 return(thislist);
}

function listremove(thislist,thisitem) {
 if(thisitem.length>0){
  if(thislist.indexOf(thisitem)>0){thislist=sw(thislist,thisitem,'')};
  thislist=sw(thislist,',,',',');
 }
 return(thislist);
}

function phoneclean(pcstring) {
pcstring=sw(pcstring,'\-','.');
pcstring=sw(pcstring,'\(','.');
pcstring=sw(pcstring,'\)','.');
pcstring=sw(pcstring,'x','.x');
pcstring=sw(pcstring,'X','.x');
pcstring=sw(pcstring,' ','.');
pcstring=sw(pcstring,'..','.');
pcstring=sw(pcstring,'.x','x');
pcstring=sw(pcstring,'x.','x');
if (pcstring.charAt(0) == '.') pcstring = pcstring.substring(1,pcstring.length);
if (pcstring.charAt(pcstring.length-1) == '.') pcstring = pcstring.substring(0,pcstring.length-1);
if (pcstring.charAt(pcstring.length-1) == '.') pcstring = pcstring.substring(0,pcstring.length-1);  
return(pcstring);
}
 
function creditcardclean(pcstring) {
pcstring=sw(pcstring,'\-','');
pcstring=sw(pcstring,' ','');
if (pcstring.charAt(0) == ' ') pcstring = pcstring.substring(1,pcstring.length);
if (pcstring.charAt(pcstring.length-1) == ' ') pcstring = pcstring.substring(0,pcstring.length-1);                
if (pcstring.charAt(pcstring.length-1) == ' ') pcstring = pcstring.substring(0,pcstring.length-1);                
return(pcstring);
}
 
function validcreditcardnumbercheck(s,ccType) {

 //see if we have a type - if we do, make sure its one that we support; otherwise skip the test;
 var strCcType = ccType+'';
 if (strCcType != ''){
  if (strCcType.toLowerCase().indexOf('visa') >= 0 || strCcType.toLowerCase().indexOf('master') >= 0 || strCcType.toLowerCase().indexOf('discover') >= 0 || strCcType.toLowerCase().indexOf('ame') >= 0){
   // we support checks on these cards, so continue
   } else {
   // we don't support checks on other cards at this time
   return true;
  }
 }

 // remove non-numerics
 var v = "0123456789";
 var w = "";
 for (i=0; i < s.length; i++) {
 x = s.charAt(i);
 if(i == 0 && x == '0') return false;
 if (v.indexOf(x,0) != -1)
 w += x;
 }
 // validate number
 j = w.length / 2;
 if (j < 6.5 || j > 8 || j == 7) return false;
 k = Math.floor(j);
 m = Math.ceil(j) - k;
 c = 0;
 for (i=0; i<k; i++) {
 a = w.charAt(i*2+m) * 2;
 c += a > 9 ? Math.floor(a/10 + a%10) : a;
 }
 for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
 return (c%10 == 0);
 }
 
function emailclean(pcstring) {
pcstring=sw(pcstring,' ','');
pcstring=sw(pcstring,'__','_');
pcstring=sw(pcstring,'..','.');
pcstring=sw(pcstring,'.@','@');
pcstring=sw(pcstring,'@.','@');
pcstring=sw(pcstring,'--','-');
return(pcstring);
}

function trimleft(str) { 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function trimright(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trimclean(str) {
	return trimleft(trimright(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}

function emaillistvalidate(oEmailField) {
 if (oEmailField.value != '') {
  pcstring=oEmailField.value+',';
  aArray = pcstring.split(",");
  for(var sValue in aArray) {
   if (trimclean(aArray[sValue]+"") != ""){
    emailvalidatethis(oEmailField,trimclean(aArray[sValue]+""),false)
   }
  }
 }
}

function emailvalidate(oEmailField) {
 if (oEmailField.value != '') {
  emailvalidatethis(oEmailField,oEmailField.value,true)
 }
}

function emailvalidatethis(oEmailField,oEmailFieldvalue,bolSingleCheck) {
if (oEmailFieldvalue != '') {
 // validate
 var invalidformat = false;
 var invalidreason = '';
 var pcstring=oEmailFieldvalue;
 if (pcstring.indexOf(' ') >= 0) {invalidformat=true; invalidreason=' Spaces are not allowed in an e-mail address.'; } 
 if (pcstring.indexOf(',') >= 0) {invalidformat=true; invalidreason=' Commas are not allowed in an e-mail address.'; } 
 if (pcstring.indexOf('__') >= 0) {invalidformat=true; invalidreason=' Double underscores are not allowed.'; } 
 if (pcstring.indexOf('--') >= 0) {invalidformat=true; invalidreason=' Double dashes are not allowed.'; } 
 if (pcstring.indexOf('..') >= 0) {invalidformat=true; invalidreason=' Double periods are not allowed.'; } 
 if (pcstring.indexOf('@') < 1) {
  invalidformat=true; invalidreason=' E-mail does not include an \'\@\' sign.';
  } else {
  //name tests
  ename = pcstring.substring(0,pcstring.indexOf('@'));
  if (ename.length < 1) {invalidformat=true};
  // domain tests
  edomain = pcstring.substring(pcstring.indexOf('@')+1,pcstring.length);
  if (edomain.length < 4) {invalidformat=true; invalidreason='Domain is too short'};
  if (edomain.indexOf('.') < 1) {
   invalidformat=true; invalidreason=' Invalid Domain.';
   } else {
   //suffix tests
   esuffix = edomain.substring(edomain.lastIndexOf('.')+1,edomain.length);
   if (esuffix.length < 2) {invalidformat=true; invalidreason='Domain suffix is too short'};
   if (esuffix.length > 3) {invalidformat=true; invalidreason='Domain suffix is too long'};
  }
 }
 if (invalidformat)
    {
    if (bolSingleCheck) {
     alert('I\'m sorry. Your email format is invalid. '+invalidreason);
     } else {
     alert('I\'m sorry. One of your email formats is invalid. '+invalidreason);
    }
    oEmailField.focus();
    }
}
}
 
function ffopenWindow(url, name, w, h, att) {
  var popupWin;
  var satt = att + '';
  if(satt!=''){satt=satt + ','};
  popupWin = window.open(url, name, satt + 'left=50,right=50,top=50,resizable=no,scrollbars=no,menubar=no,directories=no,width=' + w + ',height=' + h);
  // reference the new window and create a 'creator' object that allows the new window to talk BACK to this document
  popupWin.creatorwindow   = self;
  popupWin.creatordocument = this.document;
}
 
//function openInNewWindow(href) { var newWindow = window.open(href, '_blank'); if(newWindow != null){newWindow.focus()};return false; } 
function openInNewWindow(href) {window.open(href, '_blank');} 

function ffopenScrollWindow(url, name, w, h, att) {
  var popupWin;
  var satt = att + '';
  if(satt!=''){satt=satt + ','};
  popupWin = window.open(url, name, satt + 'left=50,right=50,top=50,resizable=no,scrollbars=yes,menubar=no,directories=no,width=' + w + ',height=' + h);
  popupWin.creatorwindow   = self;
  popupWin.creatordocument = this.document;
}
 
function SetSelectToThis(thisselectfield,thisvalue) {
 if (thisselectfield.options(thisselectfield.selectedIndex).value != thisvalue) {
  if (thisselectfield.options(thisselectfield.selectedIndex).value == '') {
   // Set it
   SetListBox(thisselectfield,thisvalue);
   } else {
   // Ask whether to change it
   if (confirm('Do you want to set '+thisselectfield.name+' to '+thisvalue+'?')) {
    // Change it
    SetListBox(thisselectfield,thisvalue);
    } else {
    // Do not change it
   }
  }
 }
}
 
function SetListBox(thisselectfield,thisvalue) { 
 var foundit = false;
 for (i=1; i < thisselectfield.length; i++) {
  if (thisselectfield[i].value == thisvalue) {
   thisselectfield.options.selectedIndex=i;
   thisselectfield.options[thisselectfield.selectedIndex].selected=true;
   foundit = true;
  }
 }
 
 if (!foundit) {
  // Create new option
  var opt = new Option(thisvalue,thisvalue); 
  // Insert new option
  thisselectfield.options[thisselectfield.options.length] = opt; 
  thisselectfield.options.selectedIndex=thisselectfield.options.length-1;
  thisselectfield.options[thisselectfield.selectedIndex].selected=true;
 }
 
 // LATER ENHANCEMENTS
 //Insert in middle
 // function insertOptionAt (select, option, index) {
 //   for (var i = select.options.length; i > index; i--)
 //     select.options[i] = select.options[i - 1];
 //   select.options[index] = option;
 // }
 // example call 
 // insertOptionAt (document.formName.selectName, 
 //                 new Option('text', 'value'), 3);
 //You delete an OPTION simply be setting
 // var sel = document.formName.selectName;
 // sel.options[optionIndex] = null;
}
 
function ClearSelectBox(sSelectID){
var oSelect = document.getElementById(sSelectID);
if(oSelect.options[0].value==''){
oSelect.selectedIndex=0;
return true;
}
if(oSelect.options[1].value==''){
oSelect.selectedIndex=1;
return true;
}
oSelect.selectedIndex=-1;
return true;
}

function datecheck(strDate){
    var val = strDate+'';
    if(val==''){return true};
    var re  = new RegExp( /^\d{1,2}\/\d{1,2}\/(\d{2}|\d{4})$/ );
    if ( !val.match( re ) ) {
      alert( "Unrecognized date. Please enter as mm\/dd\/yy.");
      return false;
    } else {
      return true;
   }
}

///TMK - not working...
//function datecheck(strDate){
// var strRes;
// var str = strDate;
// var re = new RegExp("^([0-9]{1,2})[./]{1}([0-9]{1,2})[./]{1}([0-9]{2,4})$");
// var ar;
// var res = true;
// if ((ar = re.exec(str)) != null){
// var yy;
//var mm;
//var dd;
// yy = parseFloat(ar[3]);
// if (yy < 1900) {yy = 2000 + yy};
// mm = parseFloat(ar[1]);
// // verify mm
// if (mm <= 0 || mm > 12){
//  res = false; 
//}
// dd = parseFloat(ar[2]);
// // verify dd
// if (mm==4 || mm==6 || mm==9 || mm==11) {
//  if (dd <= 0 || dd > 30){ res = false; strRes = 'Invalid day for this month';}
//  }else{
//  if (mm==2) {
//   if (parseInt(yy)%4 != 0){ 
//    if (dd <= 0 || dd > 28){ res = false; strRes = 'February only has 28 days this year.';}
//    }else{
//    if (dd <= 0 || dd > 29){ res = false; strRes = 'February only has 29 days.';}
//   }
//   }else{
//   if (dd <= 0 || dd > 31){ res = false; strRes = 'Invalid day.';}
//  }
// }
// }else{
// res = false;
// }
// if (!res){
//  return false;		
//  //alert('Please enter the date in the MM/DD/YYYY format');
//  }
// // return res;
// return true;		
//}
 
 
function datetoyearquarter(strDate,qtradjust) {
var resStr;
if (datecheck(strDate)) {
 var caldate = new Date(strDate);
 var calmonth = caldate.getMonth()+1;
 var calyear = caldate.getYear(); 
 var qtryear = calyear;
 var qtrmonth = calmonth + qtradjust;
 if (qtrmonth <= 0) {
  qtrmonth = qtrmonth + 12;
  qtryear = qtryear - 1;
 }
 if (qtrmonth > 12) {
  qtrmonth = qtrmonth - 12;
  qtryear = qtryear + 1;
 }
 var calqtr;
 if (qtrmonth >=  1 && qtrmonth <=  3){calqtr = 1};
 if (qtrmonth >=  4 && qtrmonth <=  6){calqtr = 2};
 if (qtrmonth >=  7 && qtrmonth <=  9){calqtr = 3};
 if (qtrmonth >= 10 && qtrmonth <= 12){calqtr = 4};
 if (qtryear > 2000) {qtryear = qtryear - 2000};
 if (qtryear > 1900) {qtryear = qtryear - 1900};
 resStr = '0'+qtryear+'Q'+calqtr;
 return resStr.substring(resStr.length-4);
 }
 else
 {
 return '';
 }
}
//alert(datecheck('111/31/03'));
//alert(datecheck('11/30/03'));
//alert(datecheck('2/28/03'));
//alert(datecheck('2/29/03'));
//alert(datecheck('2/29/04'));
//alert('03Q4'+datetoyearquarter('1055/25/2003',0));
//alert('03Q3'+datetoyearquarter('10/25/2003',-3));
//alert('04Q1'+datetoyearquarter('10/25/2003',+3));
//alert('04Q1'+datetoyearquarter('2/25/04',0));
//alert('03Q4'+datetoyearquarter('2/25/04',-3));
//alert('04Q2'+datetoyearquarter('2/25/04',+3));
 


/***********************************************
* Disable Enter key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
*
* Modified to go to next field in column... or to next field in form...
* Modified to shorten handleevent to hE to cut down on text
*
* USAGE: (USE FOR TEXT FIELD ONLY)
* <input onKeyPress="return EK(this, event)" type=text name=test>
*
***********************************************/

function EK (field, event) {
 var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
 if (keyCode == 13) {
 var fieldname;
 var nextfieldname;
 var i;
 var ii;
 for (i = 0; i < field.form.elements.length; i++)
  if (field == field.form.elements[i])
  break;
  // GET FIELD NAME FOR THIS FIELD... FORMAT ID1234_fieldname
  fieldname = field.form.elements[i].name;
  if (fieldname.indexOf('_') > 0) {
   fieldname = fieldname.substring(fieldname.indexOf('_')+1,fieldname.length);
  }
  // FIND NEXT FIELD IN COLUMN... FORMAT ID78234_fieldname
  i = (i + 1) % field.form.elements.length;
  for (ii = i; ii < field.form.elements.length; ii++) {
   nextfieldname = field.form.elements[ii].name;
   if (nextfieldname.indexOf('_') > 0) {
    nextfieldname = nextfieldname.substring(nextfieldname.indexOf('_')+1,nextfieldname.length);
   }
   if (fieldname==nextfieldname) {
    field.form.elements[ii].focus();
    return false;
   }
  }
  // IF HERE, THEN WE DID NOT FIND ANOTHER IN THE COLUMN... SO GO TO THE NEXT FIELD
  field.form.elements[i].focus();
  return false;
 } 
 else
 return true;
}


function listclean(pcstring){if(pcstring.length >0){if (pcstring.charAt(0) == ',') pcstring = pcstring.substring(1,pcstring.length);if (pcstring.charAt(pcstring.length-1) == ',') pcstring = pcstring.substring(0,pcstring.length-1);pcstring=sw(pcstring,',,',',');}return pcstring;}
function AddToList(oList,oValue){var rs=oList;if((','+rs+',').indexOf(','+oValue+',')<0){if(rs!=''){rs=rs+','};rs=rs+oValue;}return rs;}
function RemoveFromList(oList,oValue){var rs=','+oList+',';if(rs.indexOf(','+oValue+',')>=0){rs=sw(rs,','+oValue+',',',');return listclean(rs);} else {return oList;}}
function AddToField(oField,oValue){oField.value = AddToList(oField.value,oValue);}
function RemoveFromField(oField,oValue){oField.value = RemoveFromList(oField.value,oValue);}
function UpdateAListFieldOnClick(oFromField,oToField){if(oFromField.checked){AddToField(oToField,oFromField.value)}else{RemoveFromField(oToField,oFromField.value)};}

// swap the value with the new value that has been selected
function SetAFieldOnChange(oFromField,oToField){oToField.value = oFromField[oFromField.selectedIndex].value;}

function isValidEmail(emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}
 
 
 
 
//var AValues = new Array("event","press","other")
//var BMatchValue = new Array("event","event","event","event","press","press")
//var BValues = new Array("a","b","c","d","p1","p2")

function updateSelectList(AValues,BMatchValue,BValues,selectBox,Avalue,othersp,DivSelectID,DivTextID,SelectWhat){

	var i;
	var BCount = 0;
	var selectedBIndex = 0;
	selectBox.options.length = 0;
	for (i=0;i<BValues.length;i++)
	{
		if (BMatchValue[i] == Avalue)
		{
				BCount++;
				selectBox.options.length = (BCount);
				selectBox.options[BCount] = new Option(BValues[i], BValues[i]);
				if (BValues[i].toLowerCase() == othersp.value.toLowerCase())
				{
					selectedBIndex = BCount;
				}
		}
	}
	selectBox.options[0] = new Option(SelectWhat, SelectWhat);
	if (selectedBIndex >= 0)
	{
		selectBox.selectedIndex = selectedBIndex;
		othersp.value = '';
	}
	if (Avalue != 'other')
	{
		othersp.value = '';
		document.getElementById(DivSelectID).style.display = "";
		document.getElementById(DivTextID).style.display = "none";
	}
	else
	{
		document.getElementById(DivSelectID).style.display = "none";
		document.getElementById(DivTextID).style.display = "";
	}
}





function UnCheckCheckboxSubItems(f,strItem) {
 if (strItem == '') {strItem = 'type'} 
 if (typeof strItem == "undefined") {strItem = 'type'} 
 //This function goes thru the form elements
 //It finds the current checkbox item
 //It then gets the name of the item following this one (that follows it by 2...)
 //It unchecks that and subsequent 'sub checkbox items' that have the same name
 //It stops when it gets to a checkbox item that is NOT this one
 //alert(f.checked);
 if(!f.checked){
 // find all items in the form
 var allItems = document.getElementsByTagName("input");
 var i;
 var Uncheck = false;
 var UncheckCount = 0;
 var NameToUncheck;
 for (i=0;i<allItems.length;i++) {
  if(allItems.item(i).id==f.id) {
   // turn on the first time we find it...
   Uncheck=true;
   //alert('found match at item '+i+f.id);
   //alert('next name is '+allItems.item(i+1).name);
   //alert('next name is '+allItems.item(i+2).name);
   //alert('next name is '+allItems.item(i+3).name);
   i+=2;
   NameToUncheck = allItems.item(i).name
   //alert('name to uncheck is '+NameToUncheck);
  }
  //uncheck sub items until we get to a new header item
  if(Uncheck) {
   if(NameToUncheck==allItems.item(i).name) {
    if (allItems.item(i).checked==true){
     UncheckCount+=1;
     allItems.item(i).checked=false;
    }
   } else {
    // name has changed so turn it off
    Uncheck=false;
    //alert('stopped at '+allItems.item(i).name);
   }
   //turn off items until we find a different one... or we run out of items...
   }
  }
 }
 if (UncheckCount>0){
  GIAlert('Help Tip<p>You left sub '+strItem+'s checked.<p>Sub '+strItem+'s are not relevant if the main '+strItem+' is unchecked.<p>I unchecked your sub '+strItem+'s for you.');
 }
}

//TMK 10/29/2005 - instruction multi select list boxes
if (typeof displayMultiSelectInstructionTF == "undefined") {
 var displayMultiSelectInstructionTF = true;
}
function displayMultiSelectInstruction(bolReset){
 if (typeof displayMultiSelectInstructionTF != "undefined") {
  if (displayMultiSelectInstructionTF==true) {
   GIAlert('Help Tip<p>Hold down the Control Key to select or unselect multiple entries.');
   if (typeof bolReset != "undefined") {
    if (bolReset==true){
     displayMultiSelectInstructionTF = false;
    } 
   }
  }
 }
}

function WindowRelativeX(x){
if (document.all) {
  return window.screenTop + x;
} else if (document.layers) {
  return window.screenX + x;
} else {
return x;
}
}

function WindowRelativeY(y){
if (document.all) {
  return window.screenLeft + y;
} else if (document.layers) {
  return window.screenY + y;
} else {
return y;
}
}

//WHITE POPUP WINDOW
function GIAlert(str,mw,mh) {
// close if already open
// position relative to current window
var x = 0, y = 0; // default values
x = WindowRelativeX(100)
y = WindowRelativeY(300)

if (typeof GIPopUpWin != "undefined") {GIPopUpWin.close()}
if (typeof mh == "undefined") {mh = 150;}
if (typeof mw == "undefined") {mw = 200;}
GIPopUpWin = window.open('','GIPopUpWin','left='+y+',top='+x+',screenX='+x+',screenY='+y+',height='+mh+',width='+mw+',toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
GIPopUpWin.document.write('<head><title>Note<\/title><\/head><style>body, p,td { font-family: arial; font-size: 8pt; line-height: 100%; margin-top: 1em; margin-bottom: -.3em; }</style><body bgcolor="white"><table width="100%" height="86%" cellpadding=0 cellspacing=0 border=0><tr><td valign=top>')
GIPopUpWin.document.write(str)
GIPopUpWin.document.write('<\/td><\/tr><\/table>')
GIPopUpWin.document.write('<div align="center"><a href="#" onclick="self.close();return false;">Close Window<\/a><\/div>')
GIPopUpWin.document.write('<\/body>')
GIPopUpWin.focus();
}


//set select box to the specified value
function setSelectBoxToThisValue(oSelect,oValue){
 if (oValue=='resetreset') {
  oSelect.selectedIndex = 0;
 } else {
  for (var i = 0; i < oSelect.options.length; i++){
   if (oSelect.options(i).value == oValue) {
    oSelect.selectedIndex = i;
    return;
   }
  }
 }
}


//set country select box based on state select box
function setCountry(stateprovinceI,countryI) {
 of = document.getElementById(stateprovinceI);
 ot = document.getElementById(countryI);
 // since this is activated with onchange... then if the user is setting the value back to 'o' we want to reset...
 setto = 'resetreset'
 // cylce thru the selections up to the one i picked
 for (var i = 0; i <= of.selectedIndex; i++) {
  // set to the us by default, since those are the first selections...
  if (of.options(i).value == 'Alabama') {setto = 'United States'}
  if (of.options(i).value == 'AL') {setto = 'United States'}
  // if we get to the canadian provinces, set canada as the new country value...
  if (of.options(i).value == 'Alberta') {setto = 'Canada'}
  if (of.options(i).value == 'AB') {setto = 'Canada'}
  // if we get to the canadian provinces, set canada as the new country value...
  if (of.options(i).value == 'Australian Capital Territory') {setto = 'Australia'}
  // if the user selects other... reset the country
  if (of.options(i).value == 'Other') {setto = 'resetreset'}
  // if the user selects a blank value that it not the first one... then reset the country
  if(i>10 && of.options(i).value == '') {setto = 'resetreset'}
 }
 if (setto != ''){setSelectBoxToThisValue(ot,setto)}
}



function clearYearQuarter(str){var i, arr;arr=document.getElementsByName(str);
for(i=0;i<arr.length;i++){arr[i].selectedIndex=0;}}



/***********************************************
* Tools to manage moving items to from ordering on select boxes
***********************************************/


var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function insertOption(theSel, theText, theValue, theSelCursor)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
  //if(theSelCursor < 0){theSelCursor = 0};
  selLength = theSel.length;
  for (var i=selLength-1; i>theSelCursor; i--) {
    if(i>0){swapOptions(theSel,i,i-1)};
  }
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
	}

function sortSelect(obj) {

// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/

	var oo = new Array();

	if (!hasOptions(obj)) { return; }

	for (var i=0; i<obj.options.length; i++) {
		oo[oo.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
		}
	if (oo.length==0) { return; }
	oo = oo.sort( 
		function(a,b) { 
			if ((a.text+"") < (b.text+"")) { return -1; }
			if ((a.text+"") > (b.text+"")) { return 1; }
			return 0;
			} 
		);

	for (var i=0; i<oo.length; i++) {
		obj.options[i] = new Option(oo[i].text, oo[i].value, oo[i].defaultSelected, oo[i].selected);
		}
	}

function swapOptions(obj,i,j) {

// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/

	var o = obj.options;
	var i_selected = o[i].selected;
	var j_selected = o[j].selected;
	var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
	o[i] = temp2;
	o[j] = temp;
	o[i].selected = j_selected;
	o[j].selected = i_selected;
	}


function moveOptionUp(obj) {

// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/

	if (!hasOptions(obj)) { return; }
	for (i=0; i<obj.options.length; i++) {
		if (obj.options[i].selected) {
			if (i != 0 && !obj.options[i-1].selected) {
				swapOptions(obj,i,i-1);
				obj.options[i-1].selected = true;
				}
			}
		}
	}

function moveOptionDown(obj) {

// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/

	if (!hasOptions(obj)) { return; }
	for (i=obj.options.length-1; i>=0; i--) {
		if (obj.options[i].selected) {
			if (i != (obj.options.length-1) && ! obj.options[i+1].selected) {
				swapOptions(obj,i,i+1);
				obj.options[i+1].selected = true;
				}
			}
		}
	}




function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}


function moveAndInsertOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in SAME order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  var theSelToCursor = theSelTo.selectedIndex;
  if(theSelToCursor<0){theSelToCursor = 0};
  //for(i=selectedCount-1; i>=0; i--)
  for(i=0; i<selectedCount; i++)
  {
    insertOption(theSelTo, selectedText[i], selectedValues[i], theSelToCursor);
  }
  
  if(NS4) history.go(0);
}

/****
NEW ITEMS FOR OPTION MANAGEMENT
***/

function selectMoveUpOrDownIfShiftKeyOn(obj,strLastIndexId) {
 if(event.ctrlKey || selectedIndexCount(obj)>1){return false;}
 var bolSameIndex = (document.getElementById(strLastIndexId).value==obj.selectedIndex);
 document.getElementById(strLastIndexId).value=obj.selectedIndex;
 if(bolSameIndex){ 
  if(event.shiftKey){
   moveOptionUp(obj);
   document.getElementById(strLastIndexId).value=parseInt(document.getElementById(strLastIndexId).value)-1;
  }else{ 
   moveOptionDown(obj);
   document.getElementById(strLastIndexId).value=parseInt(document.getElementById(strLastIndexId).value)+1;
  }
 } 
}

function selectMoveUpOrDownIfShiftKeyOn(obj,strLastIndexId) {
 if(event.ctrlKey || selectedIndexCount(obj)>1){return true;}
 var bolSameIndex = (document.getElementById(strLastIndexId).value==obj.selectedIndex);
 document.getElementById(strLastIndexId).value=obj.selectedIndex;
 if(bolSameIndex){ 
  if(event.shiftKey){
   moveOptionUp(obj);
   document.getElementById(strLastIndexId).value=parseInt(document.getElementById(strLastIndexId).value)-1;
  }else{ 
   moveOptionDown(obj);
   document.getElementById(strLastIndexId).value=parseInt(document.getElementById(strLastIndexId).value)+1;
  }
 } 
}


function selectedIndexCount(thissel){
var selCount = 0;
for (var i=0; i<thissel.length; i++) {
  if (thissel[i].selected) {
    selCount += 1;
    }
  }
return selCount;
}

function selectClear(thissel){
var selCount = 0;
for (var i=0; i<thissel.length; i++) {
  if (thissel[i].selected) {
    thissel[i].selected = false;
    }
  }
return selCount;
}

function selectAllBeforeSubmitting(thisIdMatchString){
 //select all items in any select box matching the match string plus 0,1,2,3...100
 for (var i=0; i<=100; i++){
  if (!(document.getElementById(thisIdMatchString+i)==null)){
   selectAll(document.getElementById(thisIdMatchString+i))
  }
 }
}

function selectAll(thissel){
    //select all items in the select box
    for (var i=0; i<thissel.length; i++) {thissel[i].selected = true;}
}


function selectTableDoubleClick(obj,strSelectIdMatch){
 //alert(obj.selectedIndex);
 if (isOtherOptionsSelected(strSelectIdMatch,obj.id)){
  moveOptionsFromMatchingSelects(strSelectIdMatch,obj.id);
 }else{
  //if (selectedIndexCount(obj)>1){selectClear(obj);}
if(1==2){
  if (event.shiftKey) {
    moveOptionUp(obj)
  }else{
    moveOptionDown(obj)
  }
}
 }
}

function isOtherOptionsSelected(theSelFromIdMatchString, theSelToId){
 for (var i=0; i<=100; i++){
  if (theSelFromIdMatchString+i!=theSelToId){
   if (!(document.getElementById(theSelFromIdMatchString+i)==null)){
    if(document.getElementById(theSelFromIdMatchString+i).selectedIndex>=0){
     return true;
    }
   }
  }
 }
 return false;
}


function moveOptionsFromMatchingSelects(theSelFromIdMatchString, theSelToId){
 for (var i=0; i<=100; i++){
  if (theSelFromIdMatchString+i!=theSelToId){
   if (!(document.getElementById(theSelFromIdMatchString+i)==null)){
    moveOptions(document.getElementById(theSelFromIdMatchString+i), document.getElementById(theSelToId))
   }
  }
 }
}



var TimeZoneOffset = getTimeZoneOffset();
function getTimeZoneOffset() {d = new Date();return d.getTimezoneOffset();}

function ToggleCheckboxesOnForm(form,checkvalue,checkforpre,checkforpost) {
 f=document.forms[form.name];
 len = f.elements.length;
 if (checkforpost != '') {
  for(var i=0 ; i<len ; i++) {if (f.elements[i].name.indexOf(checkforpre)==0 && f.elements[i].name.indexOf(checkforpost)==f.elements[i].name.indexOf(checkforpost.substring(0,1)) && f.elements[i].name.indexOf(checkforpost)==f.elements[i].name.length-checkforpost.length) {if (checkvalue==false) {f.elements[i].checked=false;} else {f.elements[i].checked=true;}}}
  } else { 
  for(var i=0 ; i<len ; i++) {if (f.elements[i].name.indexOf(checkforpre)==0) {if (checkvalue==false) {f.elements[i].checked=false;} else {f.elements[i].checked=true;}}}
 }
}

function IsSelectFieldTextStartWithOther(strFieldName) {if (document.getElementById(strFieldName)!=null) { if ((''+document.getElementById(strFieldName).options(document.getElementById(strFieldName).selectedIndex).text).indexOf('Other')==0){return true}return false} else {return false}} 

function IsSelectFieldTextContainOther(strFieldName) {if (document.getElementById(strFieldName)!=null) { if ((''+document.getElementById(strFieldName).options(document.getElementById(strFieldName).selectedIndex).text).indexOf('Other')>=0){return true}return false} else {return false}}

function FieldExists(strFieldId) {if (document.getElementById(strFieldId)!=null) {return true} else {return false}}

function ObjectExists(objThis) {if (objThis!=null) {return true} else {return false}}

/***********************************************
***    AJAX ROUTINES
***********************************************/

function ajaxFunction(strFieldId,strUrl,strTextSpanRadioSelect)
  {
  //DEBUG - turn this on to see whats up
  //I had to remove it because if the user is turning off a section of the form, the script will just ignore it in the next statement, but we don't want to alert the user
  //if (!FieldExists(strFieldId)) {alert('Field does not exist: '+strFieldId+document.getElementById(strFieldId)+'.')}
  if (strFieldId==''||FieldExists(strFieldId)) {
  //ifObjectExists(document.getElementById(strFieldId))
  //usage onChange="ajaxFunction(thisSpanId,thisUrlToReturnWhatShouldNowGoThere)
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX. AJAX Is required for the use of this function.");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function(){
      if(xmlHttp.readyState==4)
        {
         if((strTextSpanRadioSelect+'').indexOf('TextAreaField') >= 0) {
          //alert('textareafield');
          document.getElementById(strFieldId).value=''+xmlHttp.responseText;
         }
         if((strTextSpanRadioSelect+'').indexOf('TextField') >= 0) {
          //alert('textfield');
          document.getElementById(strFieldId).value=''+xmlHttp.responseText;
         }
         if((strTextSpanRadioSelect+'').indexOf('Span') >= 0) {
          //alert(strFieldId+':'+document.getElementById(strFieldId).innerHTML);
          //document.getElementById(strFieldId).innerHTML=''+document.getElementById(strFieldId).value;
          document.getElementById(strFieldId).innerHTML='<table cellpadding=0 cellspacing=0><tr><td>'+xmlHttp.responseText+'</td></tr></table>';
         }
         if(strFieldId=='') {
          //No Field - Throw away result;
          //var aa;
          //aa = xmlHttp.responseText;
          //aa = '';
          // document.getElementById('AjaxTestSpanText').innerHTML='<table border=1 cellpadding=0 cellspacing=0><tr><td>'+xmlHttp.responseText+'</td></tr></table>';
         }
        }
      }
    //TEST document.getElementById('AjaxTestSpanUrl').innerHTML=''+strUrl;
    xmlHttp.open("GET",strUrl,true);
    xmlHttp.send(null);
  }
  }

function GetCheckboxValues(strFieldId){
 //alert(strFieldId);
 //alert(document.getElementsByName(strFieldId).length);
 var cbr = '';
 if (document.getElementsByName(strFieldId+'hidden').length > 0) {
  cbr=document.getElementsByName(strFieldId+'hidden')[0].value;
  } else {
  for (i = 0; i < document.getElementsByName(strFieldId).length; i++) {
   //alert(document.getElementsByName(strFieldId)[i].checked);
   if(document.getElementsByName(strFieldId)[i].checked==true){
    if(document.getElementsByName(strFieldId)[i].value+''!='' && cbr!=''){cbr=cbr+',';}
    cbr=cbr+document.getElementsByName(strFieldId)[i].value;
   }
  }
 }
 //alert(cbr);
 return cbr;
} 

function AttachFieldAndValueToQueryString(strFieldId,strFieldType) {
 if(!document.getElementById(strFieldId)){
  return('Missing'+strFieldId+'=')
 } else {
  var rs;
  if(strFieldType=='checkbox'){rs = (strFieldId+'='+GetCheckboxValues(strFieldId));} 
  if(strFieldType=='select'||strFieldType=='radio'){
   if(document.getElementById(strFieldId).options==null) {
    //try as text
    strFieldType = 'text'
    } else {
    rs = (strFieldId+'='+document.getElementById(strFieldId).options[document.getElementById(strFieldId).selectedIndex].value)
   } 
  } 
  if(strFieldType=='text'){rs = (strFieldId+'='+document.getElementById(strFieldId).value);} 
  if(strFieldType=='textarea'){rs = (strFieldId+'='+document.getElementById(strFieldId).value)} 
  return rs;
 } 
}

/***********************************************
***    END AJAX ROUTINES
***********************************************/

/***********************************************
***    END VARIOUS FORM ROUTINES
***********************************************/


