function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function MoveOption(objSourceElement, objTargetElement,flag)   
{
	var aryTempSourceOptions = new Array();        
	var x = 0;               
 	//looping through source element to find selected options       
	for (var i = 0; i < objSourceElement.length; i++) {           
		if (objSourceElement.options[i].selected)
		{   
			//if(flag != "D")
			//{    
				var bln=true;
				for (var j = 0; j < objTargetElement.length; j++)
				{
					 if(objTargetElement.options[j].value == objSourceElement.options[i].value)
					 {
					 	bln=false;
					 }	
				}
				if(bln)
				{	        
					//need to move this option to target element               
					var intTargetLen = objTargetElement.length++;                
					objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;                
					objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
				}	           
			//}
			//objSourceElement.options[i].selected=false;	
	 	}  
		          
		else {
			//if(flag=="D")
			//{              
				//storing options that stay to recreate select element                
				var objTempValues = new Object();               
				objTempValues.text = objSourceElement.options[i].text;                
				objTempValues.value = objSourceElement.options[i].value;                
				aryTempSourceOptions[x] = objTempValues;                
				x++;           
			//}	
		}
 	}  
	
	//if(flag=="D")
	//{               
		//resetting length of source        
		objSourceElement.length = aryTempSourceOptions.length;        
		//looping through temp array to recreate source select element        
		for (var i = 0; i < aryTempSourceOptions.length; i++)
		 {            
			objSourceElement.options[i].text = aryTempSourceOptions[i].text;            
			objSourceElement.options[i].value = aryTempSourceOptions[i].value;            
			objSourceElement.options[i].selected = false;        
		}
	//}
	var listobj;
	if(flag=="D")
	{
		listobj=objSourceElement
	}
	else
		listobj=objTargetElement
		
	var idstring,textstring;
	idstring="";
	textstring="";
	for (var j = 0; j < listobj.length; j++)
	{
		if(listobj.options[j].value != -1)
		{
			if(j!=listobj.length-1)
			{
				idstring=idstring+listobj.options[j].value+",";
				textstring=textstring+listobj.options[j].text+",<br>";
			}
			else
			{
				idstring=idstring+listobj.options[j].value;
				textstring=textstring+listobj.options[j].text;
			}
		}			
	}	
	Set_Cookie("IdString", idstring);
	Set_Cookie("TextString", textstring);
}


function ValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

var dtCh= "/";
var minYear=01;
var maxYear=99;
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

// Added By Himanshu Sharma Date:08-january-2007.
function isSignedFloat (s)
{
	var reSignedFloat = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
	var defaultEmptyOK = false;
	
	if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);

    else {
       return reSignedFloat.test(s)
    }
}

function isEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checklength(obj,len)
{
	var temp = obj.value;
	if(temp.length < len)
		return false;
	return true;
}
function checkEmail(strng)
{
	var error = "";
	if (strng == "")
		{
		error = "You did not enter an email-address.\n";
		}
	var emailFilter=/^.+@.+\..{2,4}$/;
	if (!(emailFilter.test(strng))) 
		{ 
		error = "Please enter a valid email address.\n";
		}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	if(strng.match(illegalChars))
		{
		error = "The email address contains illegal characters.\n";
		}
	return error;
}
function checkEmailX(strng,fieldcaption)
{
	var error = "";
	if (strng == "")
		{
		error = "You did not enter an "+fieldcaption+".\n";
		}
	var emailFilter=/^.+@.+\..{2,4}$/;
	if (!(emailFilter.test(strng))) 
		{ 
		error = "Please enter a valid "+fieldcaption+".\n";
		}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	if(strng.match(illegalChars))
		{
		error = "The "+fieldcaption+" contains illegal characters.\n";
		}
	return error;
}

//Link Rollover starts here
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.0
  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 && document.getElementById) x=document.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];}
}
//link rollover ends here

//pre load images scrip starts here
var myimages=new Array()
function preloadimages()
{
	for (i=0;i<preloadimages.arguments.length;i++)
	{
		myimages[i]=new Image()
		myimages[i].src=preloadimages.arguments[i]
	}
}
function alwaysontop()
{
	window.focus();
}
function tellothers(url)
{
	window.open(url,'popuptellothers','height=440,width=340,toolbar=no,menubar=no,scrollbars=no,top=50,left=100,resizable=no');
}
function consolidation(url)
{
	OpenWin = this.open(url, "consolidationreport", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=280,height=200,top=300,left=300");
}

//FOR FEDERAL EXIT
function show_too_busy()
{
	return overlib(loan,
	 STICKY, CAPTION,' ', CAPTIONPADDING,4, TEXTPADDING,8,
	 CGCLASS,'olcg', FGCLASS,'olfg', CAPTIONFONTCLASS,'olcap', TEXTFONTCLASS,'oltxt',
	 CLOSETEXT,myClose, CLOSECLICK, MIDX,0, MIDY,0, WRAP, BASE,3, SCROLL,
	 DRAGGABLE, SHADOW, SHADOWX,-1, SHADOWY,-1,
	 STATUS,'STICKY popup with link and secondary popup and FILTER for IE v5.5+',
	 FILTER);
}
function checkspecialchar(alphane)
{
	var str = alphane;
	for(var j=0; j<str.length; j++)
	{
		var alphaa = str.charAt(j);
		var chrcode = alphaa.charCodeAt(0);
		if((chrcode > 47 && chrcode<59) || (chrcode > 64 && chrcode<91) || (chrcode > 96 && chrcode<123) || chrcode==95)
		{
		}
		else
		{
			return false;
		}
	}
	return true;
}
function checkspecialcharexceptspace(alphane)
{
	var str = alphane;
	for(var j=0; j<str.length; j++)
	{
		var alphaa = str.charAt(j);
		var chrcode = alphaa.charCodeAt(0);
		if((chrcode > 47 && chrcode<59) || (chrcode > 64 && chrcode<91) || (chrcode > 96 && chrcode<123) || chrcode==95 || chrcode == 32)
		{
		}
		else
		{
			return false;
		}
	}
	return true;
}
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = /  /g;
   while (temp.match(obj)) { temp = temp.replace(obj, " "); }
   return temp;
}


// -------------------------------------------------------------------
// autoComplete (text_input, select_input, ["text"|"value"], [true|false])
//   Use this function when you have a SELECT box of values and a text
//   input box with a fill-in value. Often, onChange of the SELECT box
//   will fill in the selected value into the text input (working like
//   a Windows combo box). Using this function, typing into the text
//   box will auto-select the best match in the SELECT box and do
//   auto-complete in supported browsers.
//   Arguments:
//      field = text input field object
//      select = select list object containing valid values
//      property = either "text" or "value". This chooses which of the
//                 SELECT properties gets filled into the text box -
//                 the 'value' or 'text' of the selected option
//      forcematch = true or false. Set to 'true' to not allow any text
//                 in the text box that does not match an option. Only
//                 supported in IE (possible future Netscape).
// -------------------------------------------------------------------
function autoComplete (field, select, property, forcematch) {
	var found = false;
	for (var i = 0; i < select.options.length; i++) {
	if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
		found=true; break;
		}
	}
	if (found) { select.selectedIndex = i; }
	else { select.selectedIndex = -1; }
	if (field.createTextRange) {
		if (forcematch && !found) {
			field.value=field.value.substring(0,field.value.length-1); 
			return;
			}
		var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
		if (cursorKeys.indexOf(event.keyCode+";") == -1) {
			var r1 = field.createTextRange();
			var oldValue = r1.text;
			var newValue = found ? select.options[i][property] : oldValue;
			if (newValue != field.value) {
				field.value = newValue;
				var rNew = field.createTextRange();
				rNew.moveStart('character', oldValue.length) ;
				rNew.select();
				}
			}
		}
 }


 
 
 
function keySort(dropdownlist,caseSensitive) {
  
  // check the keypressBuffer attribute is defined on the dropdownlist 
  
  var undefined; 

  if (dropdownlist.keypressBuffer == undefined) { 
    dropdownlist.keypressBuffer = ''; 
  } 
  
  // get the key that was pressed 
  var key = String.fromCharCode(window.event.keyCode); 
  
  dropdownlist.keypressBuffer += key;
  
  if (!caseSensitive) {
    // convert buffer to lowercase
    dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase();
  }
  
  // find if it is the start of any of the options 
  var optionsLength = dropdownlist.options.length; 
  
  for (var n=0; n < optionsLength; n++) { 
    var optionText = dropdownlist.options[n].text; 
    if (!caseSensitive) {
      optionText = optionText.toLowerCase();
    }
    if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) { 
      dropdownlist.selectedIndex = n; 
      return false; // cancel the default behavior since 
                    // we have selected our own value 
    } 
  } 
  
  // reset initial key to be inline with default behavior   
  dropdownlist.keypressBuffer = key; 
  
  return true; // give default behavior 
}

function showcuttext(id)
{
	var objmultiplecombo=document.getElementById(id);				
	var showfulltext;
	showfulltext = '';
	
	for (var j = 0; j < objmultiplecombo.length; j++)
	{
		if(objmultiplecombo.options[j].value != -1 && objmultiplecombo.options[j].selected)
		{
			if(objmultiplecombo.options[j].text.length>42)
			{
				showfulltext += objmultiplecombo.options[j].text + '<br>';
			}	
		}			
	}	
	
	document.getElementById('showfulltext').innerHTML = showfulltext;
}


/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

function setCheckboxColumn(theCheckbox){
    if (document.getElementById(theCheckbox)) {
        document.getElementById(theCheckbox).checked = (document.getElementById(theCheckbox).checked ? false : true);        
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = document.getElementById(theCheckbox).checked;
        }
    } else {
        if (document.getElementById(theCheckbox + 'r')) {
            document.getElementById(theCheckbox + 'r').checked = (document.getElementById(theCheckbox +'r').checked ? false : true);
            if (document.getElementById(theCheckbox)) {
                document.getElementById(theCheckbox).checked = document.getElementById(theCheckbox + 'r').checked;
            }
        }
    }
}
function gotoPage(clslistname)
{
	if(document.getElementById('pageno').value == "")
	{
		alert("Please enter the Go-to page number.");
		document.getElementById('pageno').value.focus();
		return false;
	}	
	else if(!IsNumeric(document.getElementById('pageno').value))
	{
		alert("Go-to page number must be numeric.");		
		document.getElementById('pageno').value.focus();
		return false;
	}
	else
	{	
	    document.getElementById(clslistname+"_currentpage").value=document.getElementById('pageno').value;
		document.formmain.submit();
		return true;
	}
}

var dtCh= "-";
var minYear=1950;
var maxYear=2050;

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr)
{
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 2; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm-dd-yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}
// flash banners - added by mhshah 18/11/2006

function homebanner()
{
   document.write('<object data="http://www.attorneyresearchgroup.com/images/home.swf" type="application/x-shockwave-flash" width="492" height="146">');
   document.write('<param name="MOVIE" value="http://www.attorneyresearchgroup.com/images/home.swf">');
   document.write('<param name="wmode" value="transparent">');
   document.write('</object>');
} 

function chkselectedids(formname,objname)
{
	var chkflg,strmessageid,url,returl;
	strmessageid="";
	chkflg=false;
	for(j=0; j<document.forms.length;j++)
	{
		if(document.forms[j].name==formname)
		{
			for (i=0;i<document.forms[j].elements.length;i++)
			{
				if (document.forms[j].elements[i].name==objname) 
				{
					if (document.forms[j].elements[i].checked)
					{							
						chkflg=true;
						break;
					}
				}
			}			
		}	
	}
	return chkflg;	
}

/**
This function Added By Himanshu Sharma on : 04/03/2007
*/
function changeDateFormat(mmddyyDate)
{
	var DateSeparator="-";//Date Separator, you can change it to "/" if you want.
	var Sp1;//Index of Date Separator 1
	var Sp2;//Index of Date Separator 2
	
	Sp1 = mmddyyDate.indexOf(DateSeparator,0);
	Sp2 = mmddyyDate.indexOf(DateSeparator,(parseInt(Sp1)+1));
	
	strMonth = mmddyyDate.substring(0,Sp1);
	strDay = mmddyyDate.substring(Sp1+1,Sp2);
	
	strYear = mmddyyDate.substring(Sp2+1,Sp2+5);
	YearPattern=/^\d{4}$/;
	
	if (YearPattern.test(strYear))
		strYear = parseInt(strYear,10);
	
	var newDate;
	
	newDate = new Date(strYear,strMonth,strDay);
	
	return newDate;
}

function emailtofriend(title,type,id,url)
{
	var strurl = url+'jdbemailtofriend.php';
	if(typeof(title)!="undefined")
		strurl = strurl + "?videotitle="+escape(title);
	if(typeof(type)!="undefined")
		strurl = strurl + "&videotype=" + escape(type);
  	if(typeof(url)!="undefined")
		strurl = strurl + "&videoid=" + escape(id);
	
	window.open(strurl,'emailtoacolleague','height=500,width=360,toolbar=no,menubar=no,scrollbars=no,top=50,left=100,resizable=no');
}
