function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
	win = window.open(mypage, myname, winprops);
	return win;
}

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.01
  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 && d.getElementById) x=d.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];}
}
function TopDate() {

	var mydate=new Date()
	var year=mydate.getFullYear()
	if (year<2000)
	year="19"+year
	var day=mydate.getDay()
	var month=mydate.getMonth()
	var daym=mydate.getDate()
	if (daym<10)
	daym="0"+daym
	var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	var montharray=new Array("Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec.")
document.write("<font face='arial, verdana'; color='#000000'; size='1' >"+montharray[month]+" "+daym+", "+year+"</font>")
}

function _CF_trim(text)
{
	pos=0;
	for(i=0; i < text.length; i++)
		if(text.charAt(i) == " ")
			pos = i + 1;
		else
			break;
	text = text.substr(pos,text.length - pos);
	pos = text.length;
	for(i = text.length - 1;i >= 0; i--)
		if(text.charAt(i) == " ")
			pos = i;
		else
			break;
	return text.substr(0,pos)
}

function _CF_onError(form_object, input_object, error_message)
{
	alert(error_message);
	input_object.focus();
  	return false;	
}

function _CF_hasValue(obj, obj_type)
{
    if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
		obj.value = _CF_trim(obj.value);
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
    }
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
    	{
			if (obj.options[i].selected && obj.options[i].value != "")
				return true;
		}
       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{
		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{
	    if (obj[0] == null) {
			if(obj.checked)	return true;			
			else return false;
	    } 		
   	    for (i=0; i < obj.length; i++)
    	{
			if (obj[i].checked)
				return true;
		}
       	return false;	
	}
}


function _CF_checknumber(object_value)
{
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.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(object_value.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 < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.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_numberrange(object_value, min_value, max_value)
{
    // check minimum
    if (min_value != null)
	{
        if (object_value < min_value)
			return false;
	}
    // check maximum
    if (max_value != null)
	{
		if (object_value > max_value)
			return false;
	}
    //All tests passed, so...
    return true;
}

function _CF_checkinteger(object_value)
{
    //Returns true if value is a number or is NULL
    //otherwise returns false	
    if (object_value.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 = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
		return _CF_checknumber(object_value);
    else
		return false;
}

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_numberrange(checkDay, 1, maxDay); //check day
}


function _CF_checkdate(object_value)
{
    //Returns true if value is a date format or is NULL
    //otherwise returns false	
	object_value = _CF_trim(object_value);
    if (object_value.length == 0)
        return true;

    //Returns true if value is a date in the dd/mm/yyyy format
	isplit = object_value.indexOf('/');

	if (isplit == -1 || isplit == object_value.length)
		return false;

    sMonth = object_value.substring(0, isplit);
	isplit = object_value.indexOf('/', isplit + 1);

	if (isplit == -1 || (isplit + 1 ) == object_value.length)
		return false;

    sDay = object_value.substring((sMonth.length + 1), isplit);

	sYear = object_value.substring(isplit + 1);

	if (!_CF_checkinteger(sMonth)) //check month
		return false;
	else
	if (!_CF_numberrange(sMonth, 1, 12)) //check month
		return false;
	else
	if (!_CF_checkinteger(sYear)) //check year
		return false;
	else
	if (!_CF_numberrange(sYear, 0, 9999)) //check year
		return false;
	else
	if (!_CF_checkinteger(sDay)) //check day
		return false;
	else
	if (!_CF_checkday(sYear, sMonth, sDay)) // check day
		return false;
	return true;
}

function _CF_checkDateUS(object_value)
{
    //Returns true if value is a date format or is NULL
    //otherwise returns false	
    if (object_value.length == 0)

        return true;

    //Returns true if value is a date in the mm/dd/yyyy format

	isplit = object_value.indexOf('/');
	if (isplit == -1 || isplit == object_value.length)

		return false;

    sMonth = object_value.substring(0, isplit);

	isplit = object_value.indexOf('/', isplit + 1);

	if (isplit == -1 || (isplit + 1 ) == object_value.length)

		return false;

    sDay = object_value.substring((sMonth.length + 1), isplit);

	sYear = object_value.substring(isplit + 1);

	if (!_CF_checkInteger(sMonth)) //check month
		return false;
	else
	if (!_CF_numberrange(sMonth, 1, 12)) //check month
		return false;
	else
	if (!_CF_checkInteger(sYear)) //check year
		return false;
	else
	if (!_CF_numberrange(sYear, 0, 9999)) //check year
		return false;
	else

	if (!_CF_checkInteger(sDay)) //check day
		return false;
	else
		if (!_CF_checkDay(sYear, sMonth, sDay)) // check day
			return false;
		else
			return true;
}


function comparedate(sbeg,send) {	

	sbeg = _CF_trim(sbeg);
	send = _CF_trim(send);

	if ((sbeg.length == 0 )&& (send.length == 0))   return 0;
    if (send.length == 0)        return 1;
    if (sbeg.length == 0)        return -1;

    //Returns true if value is a date in the dd/mm/yyyy format
	isplit = sbeg.indexOf('/');
	isplit1 = send.indexOf('/');

    ssDay = sbeg.substring(0, isplit);
    seDay = send.substring(0, isplit1);

	isplit  = sbeg.indexOf('/', isplit + 1);
	isplit1 = send.indexOf('/', isplit1 + 1);

    ssMonth = sbeg.substring((ssDay.length + 1), isplit);
    seMonth = send.substring((seDay.length + 1), isplit1);

	ssYear = sbeg.substring(isplit + 1);
	seYear = send.substring(isplit1 + 1);

	sDay = parseInt(ssDay);
	eDay = parseInt(seDay);

	sMonth = parseInt(ssMonth);
	eMonth = parseInt(seMonth);

	sYear = parseInt(ssYear);
	eYear = parseInt(seYear);
	
	if ((sYear == eYear) && (sMonth == eMonth))
		return (sDay - eDay);
	if (sYear == eYear)
		return (sMonth - eMonth);
	return (sYear - eYear);
}
function viewpicture(href, _width, _height){
	  _left = parseInt((window.screen.width - _width)/2);
	  _top = parseInt((window.screen.height - _height)/2);
	  features ="toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no";
	  features+=",width="+_width+",height="+_height+",left="+_left+",top="+_top;
	  window.open("viewpicture.php?imgsrc="+escape(href),"_blank",features);
	  //return false;
}
