function datePosition(m1,d1,y1,m2,d2,y2,flag)
{
	m1 = parseInt(m1)
	m2  = parseInt(m2)
	d1 = parseInt(d1)
	d2  = parseInt(d2)

  if (m1 < 10)
    m1 = "0" + m1;

  if (m2 < 10)
    m2 = "0" + m2;

  if (d1 < 10)
    d1 = "0" + d1;

  if (d2 < 10)
    d2 = "0" + d2;

  /*
     type 5 : 05/29/1997

     'flag' determines if we are comparing date1 with todays date or not
     Returns -1 if the date1 is behind date2
     Returns 0 if the date1 is equal to date2
     Returns 1 if the date1 is ahead of date2

     Added Y2K checking.  (Works for any century cross over)
  */

    //date format needs to be "mm/dd/yyyy"
    dateString1 = m1 + "/" + d1 + "/" + y1;

    var now = new Date();

    if (flag==1)  //compare with given (second) date
      {
        var dateString2 = m2 + "/" + d2 + "/" + y2;
        var date2 = new Date(dateString2.substring(6,10),
                            dateString2.substring(0,2)-1,
                            dateString2.substring(3,5));
      }


    else //compare with today's date
      var date2 = new Date(now.getFullYear(),now.getMonth(),now.getDate());


      var date1 = new Date(dateString1.substring(6,10),
                            dateString1.substring(0,2)-1,
                            dateString1.substring(3,5));

    if (date1 < date2)
       return -1;

    else if (date1 > date2)
       return 1;

    else
      return 0;

}


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


function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}


function y2k(number)
{
  return (number < 1000) ? number + 1900 : number;
}


function isValidDate (day,month,year)
{
  // checks if date passed is valid
 
    var today = new Date();
    year = ((!year) ? y2k(today.getFullYear()):year);
	month = ((!month) ? today.getMonth():month-1);
  

    if (!day) return false


    var test = new Date(year,month,day);
    if ( (y2k(test.getFullYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) )
        return true;
    else
        return false

}




function replaceCarriageReturn(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replaceCarriageReturn(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


function trim(strText) { 

    strText = replaceCarriageReturn(replaceCarriageReturn(strText,'\r',''),'\n','');

	// this will get rid of leading spaces 
    while ((strText.substring(0,1) == ' ')||(strText.substring(0,2) == '\r')) 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while ((strText.substring(strText.length-1,strText.length) == ' ')||(strText.substring(strText.length-2,strText.length) == '\r'))
        strText = strText.substring(0, strText.length-1);

   return strText;
} 


function is_empty(form, field)
{
  form.field.value = trim(form.field.value);
  if ( (temp_str == null) || (temp_str == " ") || (temp_str == '\t') || (temp_str == "") )
	return true;
  else
	return false;
}


function mOvr(src,colorOver){ 
	if (!src.contains(event.fromElement)){ 
		src.style.cursor = 'hand'; 
		src.bgColor = colorOver; 
	} 
} 
function mOut(src,colorIn){ 
	if (!src.contains(event.toElement)){ 
		src.style.cursor = 'default'; 
		src.bgColor = colorIn; 
	} 
} 
function mClk(src){ 
	if(event.srcElement.tagName=='TD')
		src.children.tags('A')[0].click();
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_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_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];}
}
