
function printWindow() {    	    	

	var pop = window.open('PrintView.html','','width=650,height=500,toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
		if(pop.focus) { pop.focus(); }
	}

function goto_URL(object) {

    window.location.href = object.options[object.selectedIndex].value;

}



function dimension(){

       if (document.all)

           var xMax = screen.width - 10, yMax = screen.height - 30;

       else

           var xMax = window.outerWidth - 10, yMax = window.outerHeight - 20;

       return yMax;

}





//********************

// ***register.php***

//********************

function show(object) {

    if (document.layers && document.layers[object])

        document.layers[object].visibility = 'visible';

    else if (document.all)

        document.all[object].style.visibility = 'visible';

}

function hide(object) {

    if (document.layers && document.layers[object])

        document.layers[object].visibility = 'hidden';

    else if (document.all)

        document.all[object].style.visibility = 'hidden';

}

function trim(strText) {

    while (strText.substring(0,1) == ' ')

        strText = strText.substring(1, strText.length);



    while (strText.substring(strText.length-1,strText.length) == ' ')

        strText = strText.substring(0, strText.length-1);



   return strText;

}

function isDate (objname, DateField) {

    var ValidDigits = "0123456789/";

    var allNum = "";

    var InvalidDigit = "";

    var mmddccyy = DateField.replace(/ /gi,"");

    var month = mmddccyy.substring(0,2);

    var day   = mmddccyy.substring(3,5);

    var year  = mmddccyy.substring(6,10);

    var today = new Date();

    month = ((!month) ? today.getMonth():month-1);

    var test = new Date(year,month,day);



    for (i = 0;  i < DateField.length;  i++)

       {

        ch = DateField.charAt(i);

        for (j = 0;  j < ValidDigits.length;  j++)

           {

            if (ch == ValidDigits.charAt(j))

              {

               break;

              }

           }

        if (j == ValidDigits.length)

          {

           InvalidDigit = 'YES';

           break;

          }

       }

    if (trim(DateField).length == 8 && DateField / DateField == 1)

      {

       mmddccyy = DateField.substring(0,2);

       mmddccyy += '/';

       mmddccyy += DateField.substring(2,4);

       mmddccyy += '/';

       mmddccyy += DateField.substring(4,8);

       mmddccyy = mmddccyy.replace(/ /gi,"");

       month = mmddccyy.substring(0,2);

       day   = mmddccyy.substring(3,5);

       year  = mmddccyy.substring(6,10);

       month = ((!month) ? today.getMonth():month-1);

       var test = new Date(year,month,day);

      }

    if (trim(mmddccyy).length == 0)

      {

        return mmddccyy;

      }

    else

    if (InvalidDigit  == 'YES')

      {

       alert("Invalid Date : " + DateField + "\nPlease Enter Valid Date : Format MM/DD/CCYY");

       objname.focus();

       return "";

      }

    else

    if (mmddccyy / mmddccyy == 1 || trim(year).length != 4)

      {

        alert("Invalid Date : " + DateField + "\nPlease Enter Valid Date : Format MM/DD/CCYY");

        objname.focus();

        return "";

      }

    else

    if ( (month == test.getMonth()) && (day == test.getDate()) )

      {

        return mmddccyy;

      }

    else

      {

        alert("Invalid Date : " + DateField + "\nPlease Enter Valid Date : Format MM/DD/CCYY");

        objname.focus();

        return "";

      }

}

function checkNumeric(NumField) {

 if (((NumField.value / NumField.value) != 1) && (NumField.value != 0))

   {

    alert('Please Enter Only Numeric Values Into This Text Box');

    NumField.focus();

    return "";

   }

 else

   {

    return NumField.value;

   }

}
function getAge(dateString,dateType) {
/*
   function getAge
   parameters: dateString dateType
   returns: boolean

   dateString is a date passed as a string in the following
   formats:

   type 1 : 19970529
   type 2 : 970529
   type 3 : 29/05/1997
   type 4 : 29/05/97
   type 5 : 05/29/1997

   dateType is a numeric integer from 1 to 4, representing
   the type of dateString passed, as defined above.

   Returns string containing the age in years, months and days
   in the format yyy years mm months dd days.
   Returns empty string if dateType is not one of the expected
   values.
*/
    var now = new Date();
    var today = new Date(now.getYear(),now.getMonth(),now.getDate());

    var yearNow = now.getYear();
    var monthNow = now.getMonth();
    var dateNow = now.getDate();

    if (dateType == 1)
        var dob = new Date(dateString.substring(0,4),
                            dateString.substring(4,6)-1,
                            dateString.substring(6,8));
    else if (dateType == 2)
        var dob = new Date(dateString.substring(0,2),
                            dateString.substring(2,4)-1,
                            dateString.substring(4,6));
    else if (dateType == 3)
        var dob = new Date(dateString.substring(6,10),
                            dateString.substring(3,5)-1,
                            dateString.substring(0,2));
    else if (dateType == 4)
        var dob = new Date(dateString.substring(6,8),
                            dateString.substring(3,5)-1,
                            dateString.substring(0,2));
    else if (dateType == 5)
        var dob = new Date(dateString.substring(6,10),
                            dateString.substring(0,2)-1,
                            dateString.substring(3,5));
    else
        return '';

    var yearDob = dob.getYear();
    yearDob = getCorrectedYear(yearDob);
    var monthDob = dob.getMonth();
    var dateDob = dob.getDate();
    yearAge = yearNow - yearDob;

    if (monthNow >= monthDob)
        var monthAge = monthNow - monthDob;
    else {
        yearAge--;
        var monthAge = 12 + monthNow -monthDob;
    }

    if (dateNow >= dateDob)
        var dateAge = dateNow - dateDob;
    else {
        monthAge--;
        var dateAge = 31 + dateNow - dateDob;

        if (monthAge < 0) {
            monthAge = 11;
            yearAge--; 
        }
    }

/*    return yearAge + ' years ' + monthAge + ' months ' + dateAge + ' days'; */
    return yearAge;
} 
function getCorrectedYear(year) {
    year = year - 0;
    if (year < 70) return (2000 + year);
    if (year < 1900) return (1900 + year);
    return year;
}

//////////  PHONE NUMBER FORMATTING  ////////////////////
var n;
var p;
var p1;
function ValidatePhone(){
p=p1.value
if(p.length==3){
	//d10=p.indexOf('(')
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1){
		pp="("+pp;
	}
	if(d5==-1){
		pp=pp+")";
	}
	//pp="("+pp+")";
	//document.frmPhone.txtphone.value="";
	//document.frmPhone.txtphone.value=pp;
	o.value="";
	o.value=pp;
}
if(p.length>3){
	d1=p.indexOf('(')
	d2=p.indexOf(')')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+")"
		p31=p.substring(4,l30);
		pp=p30+p31;
		//alert(p31);
		//document.frmPhone.txtphone.value="";
		//document.frmPhone.txtphone.value=pp;
		o.value="";
		o.value=pp;
	}
	}
if(p.length>5){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,3);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	//document.frmPhone.txtphone.value="";
	o.value="";
	pp="("+p13+")"+p14+p15;
	//document.frmPhone.txtphone.value=pp;
	o.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+4);
		p18=p.substring(d2+4,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	//document.frmPhone.txtphone.value="";
	//document.frmPhone.txtphone.value=pp;
	o.value="";
	o.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhone,100)
}
function getIt(m){
o=m;
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhone()
}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}
//  End -->
//////////////   TEXTAREA FORMATTING   //////////////////////////
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

//////////    get today's date  //////////////////
function getDate () {
   var now = new Date();
   var today = fmtInt((now.getMonth() + 1).toString(),"##") + '/' + fmtInt(now.getDate().toString(),"##") + '/' + now.getFullYear();
   return today;
}

    function fmtInt(argvalue, format) {
      var arglen = trm(argvalue).length;
      var fmtlen = format.length;
      var max = (fmtlen - 0) - (arglen - 0);
      var retValue = '';
      for (var i = 0; i < max; i++)
         retValue = retValue + '0';
      retValue = retValue + trm(argvalue);
      return retValue;
    }

    function trm(strText) {
        while (strText.substring(0,1) == ' ')
            strText = strText.substring(1, strText.length);

        while (strText.substring(strText.length-1,strText.length) == ' ')
            strText = strText.substring(0, strText.length-1);

       return strText;
    }

