function SortOrder()
{
var x = document.forms[2].sortby1[0].checked;
}

function LocChange(FileName)
{
	var elmAll  = document.forms[2];
	valRMLoc=elmAll.RMLoc.options[elmAll.RMLoc.selectedIndex].value;
	valRMLocTxt=elmAll.RMLoc.options[elmAll.RMLoc.selectedIndex].text;

	elmAll.RMLocName.value = valRMLocTxt;
	elmAll.action = FileName;
	elmAll.submit();
}

		
function DROptChange(){

		var MINUTE = 60 * 1000
		var HOUR = MINUTE * 60
		var DAY = HOUR * 24
		var WEEK = DAY * 7

   		var elmAll  = document.forms[2];
		val=elmAll.DateRange.options[elmAll.DateRange.selectedIndex].value;
		od=new Date();
		d=od.getDate();
		m=od.getMonth()+1;
		y=od.getYear();
		today= m + '/' + d + '/' + y;
		monthstart= m + '/01/' + y;
		yearstart='01/01/' + y;
		w=od.getDay();
		delete od
	if (elmAll.DateRange.options[elmAll.DateRange.selectedIndex].value == "yesterday")
		{ 
		od1=new Date();//today's date used in calculations
		d1=od1.getTime()-DAY;//SUNDAY weekstart
		od=new Date(d1); //create date object based on prevweekstart SUNDAY
	
		d= od.getDate(); 
		m=od.getMonth()+1;
		y=od.getYear();

		var yesterday= m +'/' + d + '/' + y;

		elmAll.StartDate.value = yesterday;
		elmAll.EndDate.value = yesterday;
		delete od;
		delete od1;
		}
	
	
	if (elmAll.DateRange.options[elmAll.DateRange.selectedIndex].value == "weektodate")
		{ 
		//sunday to today
		od1=new Date();//today's date used in calculations
		d1=od1.getTime()-DAY * od1.getDay(); //SUNDAY weekstart
		od=new Date(d1); //create date object based on prevweekstart SUNDAY
	
		d= od.getDate(); 
		m=od.getMonth()+1;
		y=od.getYear();

		weekstart= m +'/' + d + '/' + y;

		elmAll.StartDate.value = weekstart;
		elmAll.EndDate.value = today;
		delete od;
		delete od1;
		}
		if (elmAll.DateRange.options[elmAll.DateRange.selectedIndex].value == "lastweek")
		{ 
		//sunday to sutarday
		od1=new Date();//today's date used in calculations
		d1=od1.getTime()-DAY * (od1.getDay() + 7); //SUNDAY prevweekstart
		d2=od1.getTime()-DAY * (od1.getDay()+ 1); // SATURDAY preveweekend
		od=new Date(d1); //create date object based on prevweekstart SUNDAY
		od2= new Date(d2); //create date object based on the prevweekend SATURDAY
		
		sund= od.getDate(); 
		sunm=od.getMonth()+1;
		suny=od.getYear();
		
		satd= od2.getDate(); 
		satm=od2.getMonth()+1;
		saty=od2.getYear();
		
		prevweekstart= sunm +'/' + sund + '/' + suny;
		prevweekend= satm +'/' + satd + '/' + saty;
		
		elmAll.StartDate.value = prevweekstart;
		elmAll.EndDate.value = prevweekend;
		delete od;
		delete od1;
		delete od2;
		}
	if (elmAll.DateRange.options[elmAll.DateRange.selectedIndex].value == "lastmonth")
		{ 
		var MINUTE = 60 * 1000
		var HOUR = MINUTE * 60
		var DAY = HOUR * 24
		var WEEK = DAY * 7
		
		od1=new Date(monthstart);//monthstart is start of the current month for exp: 10/01/2001 
		d1=od1.getTime()-DAY;
		od=new Date(d1); //create date object based on the monthstart - day date.
		d= od.getDate(); // in our case it will be 30
		m=od.getMonth()+1;//9
		y=od.getYear();//2001
		prevmonthstart= m +'/01/' + y;
		prevmonthend=m +'/' + d + '/' + y;
		elmAll.StartDate.value = prevmonthstart;
		elmAll.EndDate.value = prevmonthend;
		delete od;
		delete od1;
		}
	if (elmAll.DateRange.options[elmAll.DateRange.selectedIndex].value == "today")
		{ 
		elmAll.StartDate.value = today;
		elmAll.EndDate.value = today;
		}
	if (elmAll.DateRange.options[elmAll.DateRange.selectedIndex].value == "monthtodate")
		{ 
		elmAll.StartDate.value = monthstart;
		elmAll.EndDate.value = today;
		}
	if (elmAll.DateRange.options[elmAll.DateRange.selectedIndex].value == "yeartodate")
		{ 
		elmAll.StartDate.value = yearstart;
		elmAll.EndDate.value = today;
		}
		
	
	   return true;
	}
function LOptChange(){
   		var elmAll  = document.forms[2];
		val=elmAll.Length1.options[elmAll.Length1.selectedIndex].value;
	if (elmAll.Length1.options[elmAll.Length1.selectedIndex].value == "NONE")
		{ 
		elmAll.Length2.value = '';
		}
	   return true;
	}
function LROptChange(){
   		var elmAll  = document.forms[2];
		val=elmAll.Length1R.options[elmAll.Length1R.selectedIndex].value;
	if (elmAll.Length1R.options[elmAll.Length1R.selectedIndex].value == "NONE")
		{ 
		elmAll.Length2R.value = '';
		}
	   return true;
	}
function LHOptChange(){
   		var elmAll  = document.forms[2];
		val=elmAll.Length1H.options[elmAll.Length1H.selectedIndex].value;
	if (elmAll.Length1H.options[elmAll.Length1H.selectedIndex].value == "NONE")
		{ 
		elmAll.Length2H.value = '';
		}
	   return true;
	}
	
	function COptChange(){
   		var elmAll  = document.forms[2];
		val=elmAll.Cost1.options[elmAll.Cost1.selectedIndex].value;
	if (elmAll.Cost1.options[elmAll.Cost1.selectedIndex].value == "NONE")
		{ 
		elmAll.Cost2.value = '';
		}
	   return true;
	}

   var g_Interval;

   function setValue( combo, value )
   {
      var i = 0;
      for (i=0; i < combo.options.length; i++) 
      {
         if ( combo.options[i].value == value )
         {
            combo.options[i].selected = true;
         }

      }
   }
	
	function CheckFmtDec2(et,checkOK,specialChar) 
	{
          	s=et.value;
      		s = s.replace(/\)/gi,"");
      		s = s.replace(/\(/gi,"");
      		s = s.replace(/ /g,"");
      		s = s.replace(/\-/g,"");
      		
			for(i=0;i< s.length;i++) {
			ch = s.substr(i,1);
          	//"$+^?/\\*."
			if(ch.search(/\$/) != -1 | ch.search(/\+/) != -1 | ch.search(/\^/) != -1 | ch.search(/\?/) != -1 | ch.search(/\\/) != -1 | ch.search(/\*/) != -1 | ch.search(/\./) != -1)
			{
				return false; //not found

			}
			else
			{
				if(checkOK.search(ch) == -1) 
				{
					return false; //not found

				}
			}
		}
	
      	g_Telephone = s
		return true;
		
	}   
   
   
   function isIntervalStartEnd( et )
   {
      g_Interval = 0;
      var s, hh, mm, n;
      s = et.value.split(":");
      n = s.length;

      if ( n != 2 )
      {
          	alert( 'TIME WINDOW: Please enter a time interval in the following format "hh:mm"' );
         return false;   
      }
      for ( i = 0; i < n; i++ )
      {
         if ( isNaN( parseInt( s[i], 10 ) ) )
         {
          	alert( 'TIME WINDOW: Please enter a time interval in the following format "hh:mm"' );
            return false;
         }
      }

      hh = mm = 0;
      
         mm = parseInt( s[n - 1], 10 );
      if ( n > 1 )
         hh = parseInt( s[n - 2], 10 );
      if ( ( hh < 0 ) || ( hh > 23 ) || ( mm < 0 ) || ( mm > 59 ) )
      {
         alert( 'TIME WINDOW: Please enter a valid time interval' );
         return false;
      }

      g_Interval = hh * 3600 + mm * 60

      return true;

   }
   function isInterval( et,lbl )
   {
      g_Interval = 0;
      var s, hh, mm, ss, n;
      s = et.value.split(":");
      n = s.length;
      if ( n != 3 )
      {
   		alert( lbl + ': Please enter call duration in the following format "hh:mm:ss"' );
	      return false;   
      }
      for ( i = 0; i < n; i++ )
      {
         if ( isNaN( parseInt( s[i], 10 ) ) )
         {
          	alert( lbl + ': Please enter call duration in the following format "hh:mm:ss"' );
           return false;
         }
      }

      hh = mm = ss = 0;
      ss = parseInt( s[n - 1], 10 );
      if ( n > 1 )
         mm = parseInt( s[n - 2], 10 );
      if ( n > 2 )
         hh = parseInt( s[n - 3], 10 );

      if ( ( hh < 0 ) || ( hh >23 ) || ( mm < 0 ) || ( mm > 59 ) || ( ss < 0 ) || ( ss > 59 ) )
      {
         alert( 'LENGTH: Please enter valid call duration' );
         return false;
      }

      g_Interval = hh * 3600 + mm * 60 + ss;

      return true;

   }
   function isNumeric( et, fromValue )
   {
      if ( et.value != '' )
      {
         if ( isNaN(parseFloat( et.value)) )
         {
            //alert( 'Please enter a numeric value for this filed' );
            et.focus;
            return false;
         }

         v = parseFloat( et.value, 10 );

         if ( v < fromValue )
         {
            alert( 'Please enter a number which is greater then or equal to ' + fromValue );
            et.focus;
            return false;
         }

         et.value = v;
      }

      return true;
   }
	
   
   function isValidOp( edit, combo )
   {
      if ( combo.options[combo.selectedIndex].value != 'NONE' && edit.value == '' )
      {
         alert( "Please enter a value or set the search criteria to 'any'" );
         edit  .focus;
         return false;
      }
      return true;
   }

   function blankOut( edit, combo )
   {
      var sz = '';
      if ( edit.value != '' && combo.options[combo.selectedIndex].value == 'NONE' )
      {
			 sz = '>';
      }
      if ( combo.options[combo.selectedIndex].value != 'NONE' && edit.value == '' )
      {
         sz = 'NONE';
      }
      if ( sz != '' ) 
      {

         var i = 0;
         
         for (i=0; i < combo.options.length; i++) 
         {


            if ( combo.options[i].value == sz )
            {

               combo.options[i].selected = true;
            }

         }
      }
      return true;
   }
   
   function createTrRep(FileName,RepId)
   {
      var elmAll  = document.forms[2];
	 
		//===========transfer selections from lists to coresponding hidden lists
		//===========to read for the report legend
		fillSelectNames('RMLoc','RMLocHidden');
	 
	 
	 ///////////////LOCATIONS - write locations names in the RMLocName hidden text box
	 /////////it will be read by the reports file
	 //elmAll.RMLoc.options=the location list's selected items
		valLoc = '';
		valLocLC='';
		var x = elmAll.RMLoc.options.length;

		for (var i=0;i< x; i++)
		{
			if (elmAll.RMLoc.options(i).selected)
			{
			valSelText =elmAll.RMLoc.options(i).text;
			valSelVal = elmAll.RMLoc.options(i).value;
			valLoc=valLoc + valSelText + '^';
			valLocLC=valLocLC + valSelText + '^' + valSelVal + ';';
			}
		}
		
		//get rid of the last ^ if any
		var valLocL = valLoc.length;
		var rmvItem = valLoc.substring(valLocL-1,valLocL);
		
		var valLocLCL = valLocLC.length;
		var rmvItemLC = valLocLC.substring(valLocLCL-1,valLocLCL);
		
		if(	rmvItem == "^" )
		{
			valLoc = valLoc.substring(0,valLocL-1);
		}
		if(	rmvItemLC == "^" )
		{
			valLocLC = valLocLC.substring(0,valLocLCL-1);
		}

		
				
		elmAll.RMLocName.value = valLoc;
		elmAll.RMLocNameLC.value = valLocLC;
	///////////////////LOCATIONS - END//////////////////////////////////////////////////	
      // *** Start/End date ***

      et1 = elmAll.StartDate;
      et2 = elmAll.EndDate;

      if ( et1.value != '' )
         dtStart = Date.parse( et1.value );
      else
         dtStart = new Date();

      if ( et2.value != '' )
         dtEnd = Date.parse( et2.value );
      else
         dtEnd = new Date();

      if ( isNaN( dtStart ) )
      {
         alert( 'Please enter a valid date (mm/dd/yy)');
         et1.focus;
         return false;
      }

      if ( isNaN( dtEnd ) ) 
      {
         alert( 'Please enter a valid date (mm/dd/yy)');
         et2.focus;
         return false;
      }
	if (RepId!="88"){

      if (  dtStart > dtEnd ) 
      {
         alert( 'DATE: Please enter a valid date interval');
         return false;
      }
	}
      // *** Start/End Time (Time Window) ***

      et1 = elmAll.StartTime;
      et2 = elmAll.EndTime;
      et3 = elmAll.StartTime1;
      et4 = elmAll.EndTime1;
      
      if ( et1.value != '' && et1.value!='hh:mm')
      {
         if ( !isIntervalStartEnd( et1 ) )
         {
            return false;
         }
          et3.value = g_Interval;         
      }
      if ( et2.value != '' && et2.value!='hh:mm')
      {
         if ( !isIntervalStartEnd( et2 ) )
         {
	       return false;
         }
          et4.value = g_Interval;         
      }

      if (  et3.value > et4.value ) 
      {
         alert( 'TIME WINDOW: Please enter a valid time interval');
         return false;
      }


      if (  elmAll.StartTrunk.value > elmAll.EndTrunk.value ) 
      {
			if (elmAll.EndTrunk.value=='')
			{
				elmAll.EndTrunk.value = elmAll.StartTrunk.value;
			}
			else
			{
				alert( 'TRUNK: Please enter a valid account code range');
				return false;
			}
      }

      if (  elmAll.StartTrunkGrp.value > elmAll.EndTrunkGrp.value ) 
      {
			if (elmAll.EndTrunkGrp.value=='')
			{
				elmAll.EndTrunkGrp.value = elmAll.StartTrunkGrp.value;
			}
			else
			{
				alert( 'TRUNK GROUP: Please enter a valid account code range');
				return false;
			}
      }
      
      //elmAll.action = "report.asp";
      elmAll.action = FileName;
      elmAll.submit();
      return true;
   
   }
  
   function fillSelectNames(visibleList,hiddenList)
   {
	//05_06_2004
	//poplates hidden list corresponding to the visible list with selected text from the visible list
	//for example Client list returns ClientsID when submited. To retrieve Client Names
	//for the report legend, I call this function in CreateRep and poplate hidden list values with 
	//the text from the visible list. I read the hidden list to create legend. 
		
		var vList= document.all.tags("SELECT").item(visibleList);//visible Select list
		var hList = document.all.tags("SELECT").item(hiddenList);//hidden Select list
		
		var hList_len = hList.options.length;
		var vList_len = vList.options.length;
		var commaPos
		var tempStrLeft
		var tempStrRight
		var x
		

		var j = 0;

		for (var i = 0; i < vList_len; i++)
		{   if (vList.options(i).selected)
			{
			var v = vList.options(i).text;
			hList_len=hList_len+1;
			hList.options.length = hList_len;
			x = v.indexOf(",");
			
			tempStrLeft = ''
			tempStrRight = v
			
			if (x != -1) 
			{
				while (x!=-1)
				{ 
					tempStrLeft = tempStrLeft + tempStrRight.substring(0,x) + "*&$*";
					tempStrRight = tempStrRight.substring(x+1,tempStrRight.lenght);
					x = tempStrRight.indexOf(",");
					
				}
				v= tempStrLeft + tempStrRight;
			}
			hList.options(hList_len-1).text = v;
			hList.options(hList_len-1).value = v;
			hList.options(hList_len-1).selected = true;
			}
		}
   
   }
   
   function createRep(FileName)
   {
		var elmAll  = document.forms[2];
		val=elmAll.Cost1.options[elmAll.Cost1.selectedIndex].value;
		
		//===========transfer selections from lists to coresponding hidden lists
		//===========to read for the report legend
		fillSelectNames('Client','CHidden');
		fillSelectNames('User','UHidden');
		fillSelectNames('Department','DHidden');
		fillSelectNames('RMLoc','RMLocHidden');
		fillSelectNames('Direction','DirHidden');
		fillSelectNames('CallStatus','StatusHidden');
			 
	 ///////////////LOCATIONS - write locations names in the RMLocName hidden text box
	 /////////it will be read by the reports file
	 //elmAll.RMLoc.options=the location list's selected items
		valLoc = '';
		valLocLC='';
		var x = elmAll.RMLoc.options.length;

		for (var i=0;i< x; i++)
		{
			if (elmAll.RMLoc.options(i).selected)
			{
				valSelText =elmAll.RMLoc.options(i).text;
				valSelVal = elmAll.RMLoc.options(i).value;
				valLoc=valLoc + valSelText + '^';
				valLocLC=valLocLC + valSelText + '^' + valSelVal + ';';
			}
		}
		//get rid of the last ^ if any
		var valLocL = valLoc.length;
		var rmvItem = valLoc.substring(valLocL-1,valLocL);
		
		var valLocLCL = valLocLC.length;
		var rmvItemLC = valLocLC.substring(valLocLCL-1,valLocLCL);
		
		if(	rmvItem == "^" )
		{
			valLoc = valLoc.substring(0,valLocL-1);
		}
		if(	rmvItemLC == "^" )
		{
			valLocLC = valLocLC.substring(0,valLocLCL-1);
		}

		elmAll.RMLocName.value = valLoc;
		elmAll.RMLocNameLC.value = valLocLC;
		///////////////////LOCATIONS - END//////////////////////////////////////////////////	
		// *** Start/End date ***

      et1 = elmAll.StartDate;
      et2 = elmAll.EndDate;

      if ( et1.value != '' )
         dtStart = Date.parse( et1.value );
      else
         dtStart = new Date();

      if ( et2.value != '' )
         dtEnd = Date.parse( et2.value );
      else
         dtEnd = new Date();

      if ( isNaN( dtStart ) )
      {
         alert( 'Please enter a valid date (mm/dd/yy)');
         et1.focus;
         return false;
      }

      if ( isNaN( dtEnd ) ) 
      {
         alert( 'Please enter a valid date (mm/dd/yy)');
         et2.focus;
         return false;
      }

		if (  dtStart > dtEnd ) 
		{
			alert( 'DATE: Please enter a valid date interval');
			return false;
		}
	
      // *** Start/End Time (Time Window) ***

      et1 = elmAll.StartTime;
      et2 = elmAll.EndTime;
      et3 = elmAll.StartTime1;
      et4 = elmAll.EndTime1;
      if ( et1.value != '' && et1.value!='hh:mm')
      {
         if ( !isIntervalStartEnd( et1 ) )
         {
            return false;
         }
          et3.value = g_Interval;         
      }
      if ( et2.value != '' && et2.value!='hh:mm')
      {
         if ( !isIntervalStartEnd( et2 ) )
         {
	       return false;
         }
          et4.value = g_Interval;         
      }

      if (  et3.value > et4.value ) 
      {
         alert( 'TIME WINDOW: Please enter a valid time interval');
         return false;
      }
      // *** Cost2***
      if ( !isNumeric( elmAll.Cost2,0))
      {
         alert( 'COST: Please enter a numeric value for this filed' );
         return false;
      }
		//elmAll.Cost2.value=v_val;
      // -----   
      //if ( !isValidOp( elmAll.Cost2, elmAll.Cost1 ) )
      //{
         //return false;
      //}

      //if ( !isValidOp( elmAll.Length2, elmAll.Length1 ) )
      //{
         //return false;
      //}

      // *** Duration*** 
      et1 = elmAll.Length2;
      et2 = elmAll.Length;
      combo = elmAll.Length1;
      slbl= 'DURATION'
      if ( et1.value != '' && et1.value!='hhh:mm:ss' )
      {
         if ( !isInterval( et1,slbl ) )
         {
            return false;
         }
         if ( !isValidOp( et1, combo ) )
         {
            return false;
         }
          et2.value = g_Interval;         
      }
      
      //==========
      // *** HoldDuration*** 
      et1 = elmAll.Length2H;
      et2 = elmAll.LengthH;
      combo = elmAll.Length1H;
      slbl = 'HOLD DURATION'
      if ( et1.value != '' && et1.value!='hhh:mm:ss' )
      {
         if ( !isInterval( et1,slbl) )
         {
            return false;
         }
         if ( !isValidOp( et1, combo ) )
         {
            return false;
         }
          et2.value = g_Interval;         
      }
      
      //==========
      // *** RingDuration*** 
      et1 = elmAll.Length2R;
      et2 = elmAll.LengthR;
      combo = elmAll.Length1R;
      slbl = 'RING DURATION'
      if ( et1.value != '' && et1.value!='hhh:mm:ss' )
      {
         if ( !isInterval( et1,slbl ) )
         {
            return false;
         }
         if ( !isValidOp( et1, combo ) )
         {
            return false;
         }
          et2.value = g_Interval;         
      }
      
      //=====Phone Number=====
      
      et = elmAll.PhoneNo;
      et1 = elmAll.PhoneNo1;
      var special=false;
      var ii = 0;
      var Qstr = "";
      
      if ( et.value != '')
      {
		
		var str_et = elmAll.PhoneNo.value;
		var LIO = str_et.lastIndexOf("?");
		
		//alert (str_et + "  "  +  LIO);
		if(LIO != -1)//if (str_et.substring(0,3)=="???")
		{
		 for (ii = 0; ii < LIO + 1; ii++)
		 {
			//alert("hello");
			Qstr = Qstr + "?";
		 }
		 //alert (Qstr + "  "  +  LIO);
		 et.value = str_et.substring(LIO +1,str_et.length);
		 special=true;
		 //alert (et.value);
		}
		
		checkOK = "0123456789-";
		specialChar= "$+^?/\\*.";

		allValid = CheckFmtDec2(et,checkOK,specialChar);
		if(!allValid) {
			alert('TELEPHONE: Your entry contains invalid character/s. Please enter a correct value.');
			elmAll.PhoneNo.focus();
			return false;
		}
		 
        if (special==true)
        {g_Telephone = Qstr + g_Telephone;
        et.value = g_Telephone;}
        //alert (et.value); 
        et1.value = g_Telephone;     
     }
      
      if ( et.value == '')
      {
          et1.value = '';         
      }
	
	//====IP Address============
	et = elmAll.IPAddress;
		
      if ( et.value != '')
      {
			ch = et.value;
          	//"$+^?/\\"
			if(ch.search(/\$/) != -1 | ch.search(/\+/) != -1 | ch.search(/\^/) != -1 | ch.search(/\?/) != -1 | ch.search(/\\/) != -1 )
			{
				alert( 'Source IP Address: This filed contains illegal characters' );
				return false;

			}
	
     }
	//====IP Address2============
	et = elmAll.IPAddress2;
		
      if ( et.value != '')
      {
			ch = et.value;
          	//"$+^?/\\"
			if(ch.search(/\$/) != -1 | ch.search(/\+/) != -1 | ch.search(/\^/) != -1 | ch.search(/\?/) != -1 | ch.search(/\\/) != -1 )
			{
				alert( 'Dest. IP Address: This filed contains illegal characters' );
				return false;

			}
	
     }
		
		// ***ext, trunk, account,authr,areaCode,matter***
		//area code and ext are checked if they are numeric value
		//trunk, account, authr, matter are not checked for numeric value 
      //=========MATTER CODE============	
      //  if ( !isNumeric( elmAll.StartMatter,0))
      //{
      //   alert( 'MATTER CODE: Please enter a numeric value for this filed' );
      //   return false;
     // }
	//	if ( !isNumeric( elmAll.EndMatter,0))
		//{
		  // alert( 'MATTER CODE: Please enter a numeric value for this filed' );
		 //  return false;
		//}
     
		if (  elmAll.StartMatter.value > elmAll.EndMatter.value ) 
      {
			if (elmAll.EndMatter.value=='')
			{
				elmAll.EndMatter.value = elmAll.StartMatter.value;
			}
			else
			{
				alert( 'MATTER CODE: Please enter a valid matter code range');
				return false;
			}
      }	
      
      //=========AREA CODE============	
      if ( !isNumeric( elmAll.StartArea,0))
      {
         alert( 'AREA CODE: Please enter a numeric value for this filed' );
         return false;
      }

      if ( !isNumeric( elmAll.EndArea,0))
      {
         alert( 'AREA CODE: Please enter a numeric value for this filed' );
         return false;
      }
		if (  elmAll.StartArea.value > elmAll.EndArea.value ) 
      {
         if (elmAll.EndArea.value=='')
         {
			elmAll.EndArea.value = elmAll.StartArea.value
         }
         else
         {
         alert( 'AREA CODE: Please enter a valid area code range');
         return false;
         }
      }	

      //=====================	
      //if ( !isNumeric( elmAll.StartAuthor,0))
      //{
      //   alert( 'AUTHR. CODE: Please enter a numeric value for this filed' );
      //   return false;
      //}

     // if ( !isNumeric( elmAll.EndAuthor,0))
      //{
      //   alert( 'AUTHR. CODE: Please enter a numeric value for this filed' );
        // return false;
     // }
		
		if ( elmAll.StartAuthor.value > elmAll.EndAuthor.value ) 
    {
        if (elmAll.EndAuthor.value=='')
        {
			elmAll.EndAuthor.value = elmAll.StartAuthor.value
        }
        else
        {
			alert( 'AUTHR CODE: Please enter a valid authorization code range');
			return false;
		}
     }	
      
            
      //=====================	
      if ( !isNumeric( elmAll.StartExt,0))
      {
         alert( 'EXTENSION: Please enter a numeric value for this filed' );
         return false;
      }

      if ( !isNumeric( elmAll.EndExt,0))
      {
         alert( 'EXTENSION: Please enter a numeric value for this filed' );
         return false;
      }
		if (  elmAll.StartExt.value > elmAll.EndExt.value ) 
      {
			if (elmAll.EndExt.value=='')
			{
				elmAll.EndExt.value = elmAll.StartExt.value
			}
			else
			{
				alert( 'EXTENSION: Please enter a valid extension range');
				return false;
			}
      }
      
      if (  elmAll.StartAccount.value > elmAll.EndAccount.value ) 
      {
         alert( 'ACCOUNT CODE: Please enter a valid account code range');
         return false;
      }
      if (  elmAll.StartTrunk.value > elmAll.EndTrunk.value ) 
      {
			if (elmAll.EndTrunk.value=='')
			{
				elmAll.EndTrunk.value =elmAll.StartTrunk.value
			}
			else
			{
				alert( 'TRUNK: Please enter a valid account code range');
				return false;
			}
      }
      // -----   

      var x = elmAll.sortby1[0].checked;
      if(x==true)
      { elmAll.sortby.value = "COST"}
		x = elmAll.sortby1[1].checked;
      if(x==true)
      { elmAll.sortby.value = "DURATION"}
		x = elmAll.sortby1[2].checked;
      if(x==true)
     { elmAll.sortby.value = "VOLUME"}
		var y = elmAll.sortby.value;
      
      // some clean up: reset values to an empty string for the none criterias

      blankOut(elmAll.Length2,elmAll.Length1);
      blankOut(elmAll.Length2R,elmAll.Length1R);
      blankOut(elmAll.Length2H,elmAll.Length1H);
      blankOut(elmAll.Cost2,elmAll.Cost1);


      //elmAll.action = "report.asp";
      elmAll.action = FileName;
      elmAll.submit();
      return true;
   }
	function ClearIt(){

   		var elmAll  = document.forms[2];
		elmAll.ClearText.value = 'YES';
		//elmAll.action = "GroupRep.asp";
		//elmAll.submit();
      	return true;
		}
	function GoToSetupTrunk(FName){
		var elmAll  = document.forms[2];
		elmAll.action = FName;
		elmAll.submit();
		return true;
	
	}
   


