
function PopUpload(formName,UploadPath, fileName) {
  var n = window.open("upload.asp?field=" + formName + "&path=" + UploadPath ,'uploader','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=320,height=285');
}

// A general-purpose popup window function
function popupWindow(uri, width, height) {

    var windowName = 'popup';
    if(arguments.length > 3) {
        windowName = arguments[3];
    }
    var popUp = window.open(uri, windowName, 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
    if (typeof popUp == 'object') { popUp.focus(); }
}

function getRef(obj){
  if(typeof obj == "string") {obj= document.getElementById(obj);}
  else if (typeof obj == "object") {obj = obj;}

  return obj;
}



// This function is used to make sure that required form fields have values.
//    Field_Name: name of a form field in the form of document.form_name.form_field_name that will be validated.
//    Error_Message: this is the alert error message that will be displayed to the user.
function Has_Value(Field_Name, Error_Message) {
	var text;

	text = Field_Name.value;

	while(text.search(/\s/) > -1) {
        text = text.replace(/\s/, "");
    }
	
    if(text == 0) {
        alert(Error_Message);
        Field_Name.focus();
        return false;   
    }
    return true;
}

// IS_VALID_EMAIL( emailaddy )
// Returns TRUE if Email is valid and FALSE if NOT VALID
function Is_Valid_Email( emailaddy ){
    var tempchar;       // temp holder
    var atPos;          // string position holder
    var periodPos;      // position of the period in string
    var invalchar = "/:,;"; // not valid email characters
    // if the email string is empty return false
    //if( Is_Empty( emailaddy ) ){ return false; }
    // Loop through each invalid character
    for( count = 0; count < invalchar.length; count++ ){
        // Pull one character out of the string
        tempchar = invalchar.charAt( count );
        // If an invalid character is found return false
        if( emailaddy.indexOf( tempchar, 0 ) > -1 ){
            return false;
        }
    }
    // find and store the position of the at sign
    atPos = emailaddy.indexOf( "@", 1 );
    // If no at sign is in the string return false
    if( atPos == -1 ){ return false; }
    // If at sign is the last character in the string return false
    if( emailaddy.indexOf( "@", atPos + 1 ) > -1 ){ return false; }
    // Find and store the position of the period in the email string
    periodPos = emailaddy.indexOf(".", atPos);
    // If there is no period in the string return false
    if( periodPos == -1 ){ return false; }
    // If the period is less than 3 characters from
    // the end of the string return false
    if( periodPos + 3 > emailaddy.length ){ return false; }
    // all is well this is a valid email address so return true
    return true;
}
// END OF FUNCTION

function Is_Valid_Date(Field_Name, Error_Message)
	//This function will validate a form date field to make sure that its in the proper
	//format.  It will accept dates in the following format: mm/dd/yyyy || m/dd/yyyy || m/d/yy || 
	// 	m/dd/yy || mm/d/yy || any valid date that is delemitted by the '/' symbol.
	//Field_Name: name of a form field in the form of document.form_name.form_field_name that will be validated.
	//Error_Message: this is the alert error message that will be displayed to the user.
	{
		if (!Is_Date(Field_Name, Error_Message))
			{
			 alert(Error_Message);
			 Field_Name.focus();
			 return false;
			}
		//everything passed so...
		return true;
	}	
	
	function Is_Date(Field_Name)
	    {
	    //Returns true if value is a date format or is NULL
	    //otherwise returns false   
	
	    if (Field_Name.value.length == 0)
	        return true;
	
	    //Returns true if value is a date in the mm/dd/yyyy format
	        isplit = Field_Name.value.indexOf('/');
	
	        if (isplit == -1 || isplit == Field_Name.value.length)
	                {
					 return false;
					}
	
	    sMonth = Field_Name.value.substring(0, isplit);
	
	        if (sMonth.length == 0)
	        {
			 return false;
			}
	
	        isplit = Field_Name.value.indexOf('/', isplit + 1);
	
	        if (isplit == -1 || (isplit + 1 ) == Field_Name.value.length)
	                {
					 return false;
					}
	
			sDay = Field_Name.value.substring((sMonth.length + 1), isplit);
	
	        if (sDay.length == 0)
	        {
			 return false;
			}
			
	        sYear = Field_Name.value.substring(isplit + 1);
	
	        if (!_CF_checkinteger(sMonth)) //check month
	                {
					 return false;
					}
	        else
	        if (!_CF_checkrange(sMonth, 1, 12)) //check month
	                {
					 return false;
					}
	        else
	        if (!_CF_checkinteger(sYear)) //check year
	                {
					 return false;
					}
	        else
	        if (!_CF_checkrange(sYear, 0, 9999)) //check year
	                {
					 return false;
					}
	        else
	        if (sYear.length != 4)
				{
				return false;
				}
	        if (!_CF_checkinteger(sDay)) //check day
	                {
					 return false;
					}
	        else
	        
	        
	        if (!_CF_checkday(sYear, sMonth, sDay)) // check day
	                {
					 return false;
					}
	        else
	                return true;
	    }







function _CF_checkday(checkYear, checkMonth, checkDay)
    {

        maxDay = 31;

        if (checkMonth == 4 || checkMonth == 6 ||
                        checkMonth == 9 || checkMonth == 11)
                maxDay = 30;
        else
        if (checkMonth == 2)
        {
                if (checkYear % 4 > 0)
                        maxDay =28;
                else
                if (checkYear % 100 == 0 && checkYear % 400 > 0)
                        maxDay = 28;
                else
                        maxDay = 29;
        }

        return _CF_checkrange(checkDay, 1, maxDay); //check day
    }

function _CF_checkinteger(Field_Name)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false   

    if (Field_Name.length == 0)
        return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
        var decimal_format = ".";
        var check_char;

    //The first character can be + -  blank or a digit.
        check_char = Field_Name.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
        return _CF_checknumber(Field_Name);
    else
        {
		 return false;
		}
    }

function _CF_numberrange(Field_Name, min_value, max_value)
    {
    // check minimum
    if (min_value != null)
        {
        if (Field_Name < min_value)
                {
				 return false;
				}
        }

    // check maximum
    if (max_value != null)
        {
        if (Field_Name > max_value)
                {
				 return false;
				}
        }
        
    //All tests passed, so...
    return true;
    }

function _CF_checknumber(Field_Name)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false   

    if (Field_Name.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
        var start_format = " .+-0123456789";
        var number_format = " .0123456789";
        var check_char;
        var decimal = false;
        var trailing_blank = false;
        var digits = false;

    //The first character can be + - .  blank or a digit.
        check_char = start_format.indexOf(Field_Name.charAt(0))
    //Was it a decimal?
        if (check_char == 1)
            decimal = true;
        else if (check_char < 1)
                {
				 return false;
				}
        
        //Remaining characters can be only . or a digit, but only one decimal.
        for (var i = 1; i < Field_Name.length; i++)
        {
                check_char = number_format.indexOf(Field_Name.charAt(i))
                if (check_char < 0)
                        {
						 return false;
						}
                else if (check_char == 1)
                {
                        if (decimal)            // Second decimal.
                                {
								 return false;
								}
                        else
                                decimal = true;
                }
                else if (check_char == 0)
                {
                        if (decimal || digits)  
                                trailing_blank = true;
        // ignore leading blanks

                }
                else if (trailing_blank)
                        {
						 return false;
						}
                else
                        digits = true;
        }       
    //All tests passed, so...
    return true
    }

function _CF_checkrange(Field_Name, min_value, max_value)
    {
    //if value is in range then return true else return false

    if (Field_Name.length == 0)
        return true;


    if (!_CF_checknumber(Field_Name))
        {
         return false;
        }
    else
        {
        return (_CF_numberrange((eval(Field_Name)), min_value, max_value));
        }
        
    //All tests passed, so...
    return true;
    }







// x_core.js, X v3.15.2, Cross-Browser.com DHTML Library
// Copyright (c) 2004 Michael Foster, Licensed LGPL (gnu.org)

// global vars still duplicated in xlib.js - I still don't know what I'm going to do about this
var xVersion='3.15.2',xNN4,xOp7,xOp5or6,xIE4Up,xIE4,xIE5,xMac,xUA=navigator.userAgent.toLowerCase();
if (window.opera){
  xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
  if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
}
else if (document.all && xUA.indexOf('msie')!=-1) {
  xIE4Up=parseInt(navigator.appVersion)>=4;
  xIE4=xUA.indexOf('msie 4')!=-1;
  xIE5=xUA.indexOf('msie 5')!=-1;
}
else if (document.layers) {xNN4=true;}
xMac=xUA.indexOf('mac')!=-1;

function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function xParent(e,bNode){
  if (!(e=xGetElementById(e))) return null;
  var p=null;
  if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
  else if (xDef(e.parentNode)) p=e.parentNode;
  else if (xDef(e.parentElement)) p=e.parentElement;
  return p;
}
function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
function xStr(s) {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}
function xNum(n) {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='number') return false;}
  return true;
}
function xShow(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.visibility)) e.style.visibility='visible';
}

function xShow2(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.visibility)) e.style.visibility='visible';
  if(e.style && xDef(e.style.display)) e.style.display='inline';
}

function xShowBlock(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.visibility)) e.style.visibility='visible';
  if(e.style && xDef(e.style.display)) e.style.display='block';
}

function xShowHide(e) {
  if(!(e=xGetElementById(e))) return;
  if (e.style && e.style.visibility == 'visible') {
  	e.style.visibility = "hidden";
  	e.style.display = "none";
  } else {
  if(e.style && xDef(e.style.visibility)) e.style.visibility='visible';
  if(e.style && xDef(e.style.display)) e.style.display='inline';
  }
}


function xHide(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.visibility)) e.style.visibility='hidden';
}

function xHide2(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.visibility)) e.style.visibility='hidden';
  if(e.style && xDef(e.style.visibility)) e.style.display='none';
}




function xZIndex(e,uZ) {
  if(!(e=xGetElementById(e))) return 0;
  if(e.style && xDef(e.style.zIndex)) {
    if(xNum(uZ)) e.style.zIndex=uZ;
    uZ=parseInt(e.style.zIndex);
  }
  return uZ;
}
function xColor(e,sColor) {
  if(!(e=xGetElementById(e))) return '';
  var c='';
  if(e.style && xDef(e.style.color)) {
    if(xStr(sColor)) e.style.color=sColor;
    c=e.style.color;
  }
  return c;
}
function xBackground(e,sColor,sImage) {
  if(!(e=xGetElementById(e))) return '';
  var bg='';
  if(e.style) {
    if(xStr(sColor)) {
      if(!xOp5or6) e.style.backgroundColor=sColor;
      else e.style.background=sColor;
    }
    if(xStr(sImage)) e.style.backgroundImage=(sImage!='')? 'url('+sImage+')' : null;
    if(!xOp5or6) bg=e.style.backgroundColor;
    else bg=e.style.background;
  }
  return bg;
}
function xMoveTo(e,iX,iY) {
  xLeft(e,iX);
  xTop(e,iY);
}
function xLeft(e,iX) {
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if (css && xStr(e.style.left)) {
    if(xNum(iX)) e.style.left=iX+'px';
    else {
      iX=parseInt(e.style.left);
      if(isNaN(iX)) iX=0;
    }
  }
  else if(css && xDef(e.style.pixelLeft)) {
    if(xNum(iX)) e.style.pixelLeft=iX;
    else iX=e.style.pixelLeft;
  }
  return iX;
}
function xTop(e,iY) {
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if(css && xStr(e.style.top)) {
    if(xNum(iY)) e.style.top=iY+'px';
    else {
      iY=parseInt(e.style.top);
      if(isNaN(iY)) iY=0;
    }
  }
  else if(css && xDef(e.style.pixelTop)) {
    if(xNum(iY)) e.style.pixelTop=iY;
    else iY=e.style.pixelTop;
  }
  return iY;
}
function xPageX(e) {
  if (!(e=xGetElementById(e))) return 0;
  var x = 0;
  while (e) {
    if (xDef(e.offsetLeft)) x += e.offsetLeft;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
  return x;
}
function xPageY(e) {
  if (!(e=xGetElementById(e))) return 0;
  var y = 0;
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
//  if (xOp7) return y - document.body.offsetTop; // v3.14, temporary hack for opera bug 130324
  return y;
}
function xOffsetLeft(e) {
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.offsetLeft)) return e.offsetLeft;
  else return 0;
}
function xOffsetTop(e) {
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.offsetTop)) return e.offsetTop;
  else return 0;
}
function xScrollLeft(e) {
  var offset=0;
  if (!(e=xGetElementById(e))) {
    if(document.documentElement && document.documentElement.scrollLeft) offset=document.documentElement.scrollLeft;
    else if(document.body && xDef(document.body.scrollLeft)) offset=document.body.scrollLeft;
  }
  else { if (xNum(e.scrollLeft)) offset = e.scrollLeft; }
  return offset;
}
function xScrollTop(e) {
  var offset=0;
  if (!(e=xGetElementById(e))) {
    if(document.documentElement && document.documentElement.scrollTop) offset=document.documentElement.scrollTop;
    else if(document.body && xDef(document.body.scrollTop)) offset=document.body.scrollTop;
  }
  else { if (xNum(e.scrollTop)) offset = e.scrollTop; }
  return offset;
}
function xHasPoint(ele, iLeft, iTop, iClpT, iClpR, iClpB, iClpL) {
  if (!xNum(iClpT)){iClpT=iClpR=iClpB=iClpL=0;}
  else if (!xNum(iClpR)){iClpR=iClpB=iClpL=iClpT;}
  else if (!xNum(iClpB)){iClpL=iClpR; iClpB=iClpT;}
  var thisX = xPageX(ele), thisY = xPageY(ele);
  return (iLeft >= thisX + iClpL && iLeft <= thisX + xWidth(ele) - iClpR &&
          iTop >=thisY + iClpT && iTop <= thisY + xHeight(ele) - iClpB );
}
function xResizeTo(e,uW,uH) {
  xWidth(e,uW);
  xHeight(e,uH);
}
function xWidth(e,uW) {
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(uW)) {
    if (uW<0) uW = 0;
    else uW=Math.round(uW);
  }
  else uW=-1;
  var css=xDef(e.style);
  if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
    if(uW>=0) xSetCW(e, uW);
    uW=e.offsetWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) {
    if(uW>=0) e.style.pixelWidth=uW;
    uW=e.style.pixelWidth;
  }
  return uW;
}
function xHeight(e,uH) {
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(uH)) {
    if (uH<0) uH = 0;
    else uH=Math.round(uH);
  }
  else uH=-1;
  var css=xDef(e.style);
  if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
    if(uH>=0) xSetCH(e, uH);
    uH=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {
    if(uH>=0) e.style.pixelHeight=uH;
    uH=e.style.pixelHeight;
  }
  return uH;
}
function xGetCS(ele,sP){return parseInt(document.defaultView.getComputedStyle(ele,'').getPropertyValue(sP));}
function xSetCW(ele,uW){
  var pl=0,pr=0,bl=0,br=0;
  if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
    pl=xGetCS(ele,'padding-left');
    pr=xGetCS(ele,'padding-right');
    bl=xGetCS(ele,'border-left-width');
    br=xGetCS(ele,'border-right-width');
  }
  else if(xDef(ele.currentStyle,document.compatMode)){
    if(document.compatMode=='CSS1Compat'){
      pl=parseInt(ele.currentStyle.paddingLeft);
      pr=parseInt(ele.currentStyle.paddingRight);
      bl=parseInt(ele.currentStyle.borderLeftWidth);
      br=parseInt(ele.currentStyle.borderRightWidth);
    }
  }
  else if(xDef(ele.offsetWidth,ele.style.width)){ // ?
    ele.style.width=uW+'px';
    pl=ele.offsetWidth-uW;
  }
  if(isNaN(pl)) pl=0; if(isNaN(pr)) pr=0; if(isNaN(bl)) bl=0; if(isNaN(br)) br=0;
  var cssW=uW-(pl+pr+bl+br);
  if(isNaN(cssW)||cssW<0) return;
  else ele.style.width=cssW+'px';
}
function xSetCH(ele,uH){
  var pt=0,pb=0,bt=0,bb=0;
  if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
    pt=xGetCS(ele,'padding-top');
    pb=xGetCS(ele,'padding-bottom');
    bt=xGetCS(ele,'border-top-width');
    bb=xGetCS(ele,'border-bottom-width');
  }
  else if(xDef(ele.currentStyle,document.compatMode)){
    if(document.compatMode=='CSS1Compat'){
      pt=parseInt(ele.currentStyle.paddingTop);
      pb=parseInt(ele.currentStyle.paddingBottom);
      bt=parseInt(ele.currentStyle.borderTopWidth);
      bb=parseInt(ele.currentStyle.borderBottomWidth);
    }
  }
  else if(xDef(ele.offsetHeight,ele.style.height)){ // ?
    ele.style.height=uH+'px';
    pt=ele.offsetHeight-uH;
  }
  if(isNaN(pt)) pt=0; if(isNaN(pb)) pb=0; if(isNaN(bt)) bt=0; if(isNaN(bb)) bb=0;
  var cssH=uH-(pt+pb+bt+bb);
  if(isNaN(cssH)||cssH<0) return;
  else ele.style.height=cssH+'px';
}
function xClip(e,iTop,iRight,iBottom,iLeft) {
  if(!(e=xGetElementById(e))) return;
  if(e.style) {
    if (xNum(iLeft)) e.style.clip='rect('+iTop+'px '+iRight+'px '+iBottom+'px '+iLeft+'px)';
    else e.style.clip='rect(0 '+parseInt(e.style.width)+'px '+parseInt(e.style.height)+'px 0)';
  }
}
function xClientWidth() {
  var w=0;
  if(xOp5or6) w=window.innerWidth;
  else if(!window.opera && document.documentElement && document.documentElement.clientWidth)
    w=document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    w=document.body.clientWidth;
  else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
    w=window.innerWidth;
    if(document.height>window.innerHeight) w-=16;
  }
  return w;
}
function xClientHeight() {
  var h=0;
  if(xOp5or6) h=window.innerHeight;
  else if(!window.opera && document.documentElement && document.documentElement.clientHeight)
    h=document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    h=document.body.clientHeight;
  else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
    h=window.innerHeight;
    if(document.width>window.innerWidth) h-=16;
  }
  return h;
}
function xInnerHtml(e, sHtml) {
  if(!(e=xGetElementById(e))) return '';
  if (xStr(e.innerHTML)) {
    if (xStr(sHtml)) e.innerHTML = sHtml;
    else return e.innerHTML;
  }
}


/*
xFade levels

e = element
dir = either "in" or "out"
uTime = total time to elapse for fade
interval = milliseconds between fade levels
*/

function xFade(e,dir,uTime,interval) {
  if (!(e=xGetElementById(e))) return;

  if (!e.isFading) {
  
    if (!dir) dir = 'out';
    if (!uTime) uTime = 1000;
    if (!interval) interval = 100;

    e.fadeDir = dir
    e.fadeTime = uTime;
    e.fadeInterval = interval
    e.fadeStep = 1;
    e.isFading = 1;
    e.startingOpacity = xOpacity(e);

    var d = new Date();
    e.C = d.getTime();

    if (e.fadeDir == 'in') {
      xShow2(e);
      xOpacity(e,0);
    }


    xFade(e);

  } else {

    var now,t;

    e.isFading = 1;
    e.fadeStep++;

    now = new Date();
    t = now.getTime() - e.C;
    if (t < e.fadeTime) {
      if (e.fadeDir == 'out') {
        xOpacity(e, e.startingOpacity - e.fadeStep*(e.startingOpacity /(e.fadeTime/e.fadeInterval))  );
      }

      if (e.fadeDir == 'in') {
        xOpacity(e, 0 + e.fadeStep*(e.startingOpacity /(e.fadeTime/e.fadeInterval))  );
      }

      setTimeout('xFade("' + e.id + '")', e.fadeInterval );
    } else {


      if (e.fadeDir == 'out') {
        xOpacity(e.id,0);
        xHide(e);
      } 

      xOpacity(e,e.startingOpacity);
      e.isFading = 0;
    } //if timefade

  }

}

function xOpacity(e,opacity) {
  if (!(e=xGetElementById(e))) return;

  if (!opacity) {
    return xGetStyle(e,'opacity') * 100;
  }

  e.style['opacity'] = opacity/100;
  e.style['MozOpacity'] = opacity/100;
  e.style['filter'] = "alpha(opacity=" + opacity  + ")";

}

function xGetStyle(e,styleProp) {
  if (!(e=xGetElementById(e))) return;
 
  var y;
  if (window.getComputedStyle)
    var y = window.getComputedStyle(e,null).getPropertyValue(styleProp);
  else if (e.currentStyle)
    var y = eval('e.currentStyle.' + styleProp);
  return y;
}
