/**
 * Test the string is empty or not
 */
function isEmpty(strText) {
	var re = /^\s{1,}$/g; //match any white space including space, tab, form-feed, etc. 
	if ((strText.length==0) || (strText=="") || 
		((strText.search(re)) > -1)) {
		return true;
	}
	else {
		return false;
	}
}

/**
 * Test whether the string all numeric. No negatvie number
 */
function isAllNumeric(sTestText)
{
	var regexp = /^(\d+)$/;	
	return regexp.test(sTestText);
}

/**
 * Test whether the string is numeric. Negative is allowed here
 */
function isNumeric(sTestText)
{
	var regexp = /^([-]?\d+)$/;	
	return regexp.test(sTestText);
}

/**
 * Test whether the string is numeric and greater than zero
 */
function isGreaterThanZero(sTestText){
	if(isEmpty(sTestText))
		return false;
	if(isNumeric(sTestText) && parseInt(sTestText) > 0)
		return true;
	return false;
}

/**
 * Test whether the string matches these numeric format:
 * 123.12 or -123.12
 */
function isFloat(sTestText)
{
	var regexp = /^([-]?\d+)(\.\d+)?$/;	
	return regexp.test(sTestText);
}

function isFloatRange(sTestText){
	var regexp = /^([-]?\d+)(\.\d+)?\/([-]?\d+)(\.\d+)?$/;	
	return regexp.test(sTestText);
}

/**
 * Test whether the string is the date format
 */
function isDate(sTestText)
{
	/*
	 * RULES:
	 *		MONTHS: 
	 *			Case 1: 0 followed by 1 to 9					0[1-9]
	 *			Case 2: 1 followed by 0,1,2					1[012]
	 *			Case 3: 1 to 9										[1-9]
	 *		DAYS: 
	 *			Case 1: 1 to 9										[1-9]
	 *			Case 1: 0 followed by 1 to 9					0[1-9]
	 *			Case 2: 1 or 2 followed by any digits		[12]\d
	 *			Case 3: 3 followed by 0 or 1					3[01]
	 *		YEAR:		Contain 4 digits							\d{4}
	 */	
	 
	 //mm/dd/yyyy or mm/dd/yy		mm-dd-yyyy or mm-dd-yy	
	 var dateReg1 = /^([1-9]|0[1-9]|1[012])(\/|-)([1-9]|0[1-9]|[12]\d|3[01])(\/|-)(\d{4}|\d{2})$/;
	 
	 //dd/mm/yyyy or dd/mm/yy		dd-mm-yyyy or dd-mm-yy
	 //var dateReg2 = /^([1-9]|0[1-9]|[12]\d|3[01])(\/|-)([1-9]|0[1-9]|1[012])(\/|-)(\d{4}|\d{2})$/;
	 
	 if(dateReg1.test(sTestText))
	 	return true;
	 //else if(dateReg2.test(sTestText))
	 //	return true;
	 else
	 	return false;
}

/**
 * Test whether the string is in the data format range
 */ 
function isDateRange(sTestText)
{
	/*
	 * RULES:
	 *		MONTHS: 
	 *			Case 1: 0 followed by 1 to 9					0[1-9]
	 *			Case 2: 1 followed by 0,1,2					1[012]
	 *			Case 3: 1 to 9										[1-9]
	 *		DAYS: 
	 *			Case 1: 1 to 9										[1-9]
	 *			Case 1: 0 followed by 1 to 9					0[1-9]
	 *			Case 2: 1 or 2 followed by any digits		[12]\d
	 *			Case 3: 3 followed by 0 or 1					3[01]
	 *		YEAR:		Contain 4 digits							\d{4}
	 */	
	 
	 //mm/dd/yyyy or mm/dd/yy		mm-dd-yyyy or mm-dd-yy	
	 var dateReg1 = /^([1-9]|0[1-9]|1[012])(\/|-)([1-9]|0[1-9]|[12]\d|3[01])(\/|-)(\d{4}|\d{2})@([1-9]|0[1-9]|1[012])(\/|-)([1-9]|0[1-9]|[12]\d|3[01])(\/|-)(\d{4}|\d{2})$/;
	 
	 //dd/mm/yyyy or dd/mm/yy		dd-mm-yyyy or dd-mm-yy
	 //var dateReg2 = /^([1-9]|0[1-9]|[12]\d|3[01])(\/|-)([1-9]|0[1-9]|1[012])(\/|-)(\d{4}|\d{2})$/;
	 
	 if(dateReg1.test(sTestText))
	 	return true;
	 //else if(dateReg2.test(sTestText))
	 //	return true;
	 else
	 	return false;
}

/**
 * Test whether the string is the numeric range
 * 123-456 or -123-456 or -123--456
 */
function isNumericRange(sTestText)
{
	var regexp = /^([-]?\d+)-([-]?\d+)$/;	
	return regexp.test(sTestText);
}

/**
 * Test whether the string is an email format
 */
function isEmail(sTestText)
{
	/* RULE:
    * One or more character(s) before @ sign   
    * There may be either a . or a -, but not together before the @ sign
    * Have @ and one or more character(s) followed
    * There may be either a . or a -, but not together in the address
    * The address must end with a . followed by at least 2 characters
    */
   
   var regExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	return regExp.test(sTestText);        	
}


/**
 * Test whether the string is an SSN format
 */
function isSSN(sTestText)
{
	/*
	 *	Define a RegExp object which checks for either a 9 digit input or an input in the form
	 * xxx-xx-xxxx or 123456789
	 */
	var regexp = "/^(\d{9}|\d{3}[-./\|]?\d{2}[-./\|]?\d{4})$/";
	return regexp.test(sTestText);	
}

/**
 * Show the object
 */
function doExpand(sObjName)
{
	var oObject = document.getElementById(sObjName);
	oObject.style.display='inline'; 
}

/**
 * Hide the object
 */
function doUnExpand(sObjName)
{
	var oObject = document.getElementById(sObjName);
	oObject.style.display='none';					
}

/**
 * Auto hide and show the object. If the current stage of the
 * object is show, then hide it; otherwise, show it.
 */
function autoExpand(sObjName){
	var oObject = document.getElementById(sObjName);
	if(oObject.style.display=='none')
		oObject.style.display='inline';
	else
		oObject.style.display='none';
}

/**
 * Display the Progress message
 */
function displayProgressMsg(sObjName, sText)
{
	var oObject = document.getElementById(sObjName);
	oObject.innerHTML = sText;
	//oObject.style.display='inline' 	
}

/**
 * Show the object with option text
 */
function displayObject(sObjName, sText)
{
	var oObject = document.getElementById(sObjName);
	oObject.innerHTML = sText;
}

/**
 * Focus the object
 */
function onFocusMenu(oObject)
{
	oObject.style.backgroundColor='#F5F5FF';
	oObject.style.color='#2D5986';
	oObject.style.cursor='hand';
}
function onBlurMenu(oObject)
{
	oObject.style.backgroundColor='#93B0C6';
	oObject.style.color='white';
	oObject.style.cursor='auto';
}

/**
 * Focus the object
 */
function onFocusColor(oObject)
{
	//oObject.style.backgroundColor='lemonchiffon';
	oObject.style.backgroundColor='#FFFFF9';
}
	
/**
 * Blur the object
 */
function onBlurColor(oObject)
{
	//oObject.style.backgroundColor='white';
	oObject.style.backgroundColor='#F3F3FF';
}

/**
 * Focus/hi-lite the cell
 */
function onFocusCell(oObject)
{
	oObject.style.backgroundColor='lemonchiffon';
}
	
/**
 * Blur/unhi-lite the cell
 */
function onBlurCell(oObject)
{
	oObject.style.backgroundColor='white';
}

/**
 * Set the cell to gray color
 */
function onBlurCell_grey(oObject)
{
	oObject.style.backgroundColor='#F5F5F5';
}

//pop up with everything
function openNewWin(newURL, width, height) {
  document.open(newURL, "NewName", "location=no, menubar=no, dependent=yes, directories=no, status=no, titlebar=yes, toolbar=no, scrollbars=no, width=" + width + ", height=" + height + ", resizable=no");
}

//pop up with resize+scroll bar
function openResizeScroll(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=no, menubar=no, dependent=no, directories=no, status=no, titlebar=yes, toolbar=no, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=yes" );
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;  
}

//pop up with everything
function openAnotherWin(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=yes, menubar=yes, dependent=yes, directories=no, status=yes, titlebar=yes, toolbar=yes, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=yes" );
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;  
  //return remote;
}

//pop up with everything
function openWinMenu(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=no, menubar=yes, dependent=yes, directories=no, status=no, titlebar=yes, toolbar=no, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=yes" );
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;  
  //return remote;
}

//pop up with everything
function openDepWin(newURL, width, height) {  
	 window.showModalDialog(newURL, self ,"dialogWidth:" + width + "px; dialogHeight:" + height + "px; dialogTop=10px; dialogLeft=10px; status=no; titlebar=no; scroll=yes");
}

function openSimpleDialog(newURL, width, height) {
	 window.showModalDialog(newURL, "" ,"dialogWidth:" + width + "px; dialogHeight:" + height + "px; dialogTop:10px; dialogLeft:10px; status:no; scroll:no");
}

function createPopup(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=no, menubar=no, dependent=yes, modal=yes, directories=no, status=no, titlebar=yes, toolbar=no, scrollbars=no, width=" + width + ", height=" + height + ", resizable=no");
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  
  //return remote;
}

function createPopupScroll(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=no, menubar=no, dependent=yes, directories=no, status=no, titlebar=Yes, toolbar=no, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=no");
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  
  //return remote;
}

function showCalendarDialog(pContextPath, pFormName, pFieldName) {
	var sLink = pContextPath + '/CalendarPopup.do?SCREEN=CALENDAR&FORMNAME=' + pFormName + '&FIELDNAME=' + pFieldName;
	window.showModalDialog(sLink, self ,"dialogWidth:150px; dialogHeight:195px; top:10px; left:10px; status:no; titlebar:no; scroll:no; help:no");
	//alert(sLink);
	//createPopupScroll(sLink, 500, 400, '1', 'b');
}

/*
 * Function get Radio Value
 * Parameter: radioComponent
 */
function getRadioValue(oRadioComp)
{	
    for (x = 0; x < oRadioComp.length; x++)
    {    
    	//alert("dd: "+oRadioComp[x].checked);
       if (oRadioComp[x].checked == true) return oRadioComp[x].value;                      
    } 
    // if it didn't find anything, return the .value  (behaviour of single radio btn)
    return "false";
}

function getSelectValue(oSelectComp){
	//alert("oSelectComp.selectedIndex="+oSelectComp.selectedIndex);
	return oSelectComp.options[oSelectComp.selectedIndex].value;
}

function getSelectText(oSelectComp){
	//alert("oSelectComp.selectedIndex="+oSelectComp.selectedIndex);
	return oSelectComp.options[oSelectComp.selectedIndex].text;
}

function getIsCheckboxChecked(oSelectComp){	
	if(oSelectComp.checked){ 
		return true; //checkbox has only one option
	}else{
		for (counter = 0; counter < oSelectComp.length; counter++)
		{	
			if(oSelectComp[counter].checked)
				return true;
		}	
	}	
	return false;
}

function getCheckboxValueByComma(oSelectComp){	
	var idVal = "";
	if(oSelectComp.checked){ 
		return oSelectComp.value; //checkbox has only one option
	}else{
		
		for (counter = 0; counter < oSelectComp.length; counter++)
		{	
			if(oSelectComp[counter].checked){				
				if(idVal != "")
					idVal += ",";
				idVal += oSelectComp[counter].value;
			}
		}	
		return idVal;
	}	
}

function checkAllBox(pFormName, pObjName){
	var formObj = eval("document."+pFormName+"."+pObjName);
	checkBoxCheckAll(formObj, true);
}

function unCheckAllBox(pFormName, pObjName){
	var formObj = eval("document."+pFormName+"."+pObjName);
	checkBoxCheckAll(formObj, false);
}

function checkBoxCheckAll(oSelectComp, pChecked){
	if(oSelectComp.length==undefined){		
		oSelectComp.checked = pChecked; //checkox has only one option
	}
	else{
		for (counter = 0; counter < oSelectComp.length; counter++)
		{	
			oSelectComp[counter].checked = pChecked;
		}	
	}
}

function msgLimit(sFormName, sFieldName) {
	var obj = eval("document."+sFormName+"."+sFieldName);
	//var obj=form1.Comments;
	if (obj.value.length==obj.maxLength*1) 
	{
		alert ("Only " + obj.maxLength + " characters are allowed!");
		obj.value = obj.value.substr(0, 250);
		return false;
	}
}

function msgCount(sFormName, sFieldName, msgCounterTxt) { 
	var oMsgCounter = document.getElementById(msgCounterTxt);
	
	if(oMsgCounter != null || oMsgCounter!="undefined")
	{
		var obj = eval("document."+sFormName+"."+sFieldName);		
		if (obj.value.length>obj.maxLength*1) obj.value=obj.value.substring(0,obj.maxLength*1);	
		oMsgCounter.innerText=obj.maxLength-obj.value.length;		
	}
	
}

function autoExpand(sObjName)
{
	var oObject = document.getElementById(sObjName);
	if(oObject.style.display == 'inline')	
		oObject.style.display='none'; 
	else
		oObject.style.display='inline' 
}

function loadLink(strLink){
	self.location = strLink;
}

function swapImage(imageObjName, newSrc){
	var oObject = document.getElementById(imageObjName);
	oObject.src = newSrc;
}

function goLastMonth(month,year,form,field) { 
	// If the month is January, decrement the year. 
  if(month == 1) { 
  	--year;   
  	month = 13; 
	}        
  document.location.href = 'schedule.php?month='+(month-1)+'&year='+year; 
} 
  
function goNextMonth(month,year,form,field) { 
	// If the month is December, increment the year. 
  if(month == 12) { 
		++year; 
  	month = 0; 
	}    
  document.location.href = 'schedule.php?month='+(month+1)+'&year='+year; 
} 

function changeScheduleTime(paramLink, pTimeVal){		
		var sLink = paramLink + pTimeVal;
		//openAnotherWin(sLink, '400', '350', 'a', 'b');
		window.showModalDialog(sLink, self ,"dialogWidth:350px; dialogHeight:200px; top:10px; left:10px; status:no; titlebar:no; scroll:no; help:no");
}

function jsValidateAppForm(oFormObj){
	
	if(isEmpty(oFormObj.Name.value)){
		alert("Name is a required field");
		oFormObj.Name.focus();
		return false;
	}
	if(isEmpty(oFormObj.Phone.value)){
		alert(" Phone # is a required field");
		oFormObj.Phone.focus();
		return false;
	}
	if(isEmpty(oFormObj.Email.value)){
		alert("Email is a required field");
		oFormObj.Email.focus();
		return false;
	}
	if(!isEmail(oFormObj.Email.value)){
		alert("Invalid email address");
		oFormObj.Email.focus();
		return false;
	}
	if(isEmpty(oFormObj.Job.value)){
		alert("Job Title is a required field");
		oFormObj.Job.focus();
		return false;
	}
	if(isEmpty(oFormObj.Age.value)){
		alert("Age is a required field");
		oFormObj.Age.focus();
		return false;
	}
		if(getSelectValue(oFormObj.ApptLocation) == ""){
		alert("Appointment Location is a required field");		
		return false;
	}
	if(isEmpty(oFormObj.ApptDate.value)){
		alert("Appointment Date is a required field");
		oFormObj.ApptDate.focus();
		return false;
	}
	if(isEmpty(oFormObj.ApptTime.value)){
		alert("Appointment Time is a required field");
		oFormObj.ApptTime.focus();
		return false;
	}
		if(getSelectValue(oFormObj.ApptLength) == ""){
		alert("Appointment Length is a required field");		
		return false;
	}
	return confirm('Are you sure you want to submit?');
}

//pop up with everything
function openNewWin(newURL, width, height) {
  document.open(newURL, "NewName", "location=no, menubar=no, dependent=yes, directories=no, status=no, titlebar=yes, toolbar=no, scrollbars=no, width=" + width + ", height=" + height + ", resizable=no");
}

//pop up with resize+scroll bar
function openResizeScroll(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=no, menubar=no, dependent=no, directories=no, status=no, titlebar=yes, toolbar=no, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=yes" );
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;  
}

//pop up with everything
function openAnotherWin(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=yes, menubar=yes, dependent=yes, directories=no, status=yes, titlebar=yes, toolbar=yes, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=yes" );
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;  
  //return remote;
}

function openAnotherWin_NoLoc(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=No, menubar=yes, dependent=yes, directories=no, status=yes, titlebar=yes, toolbar=yes, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=yes" );
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;  
  //return remote;
}

//pop up with everything
function openWinMenu(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=no, menubar=yes, dependent=yes, directories=no, status=no, titlebar=yes, toolbar=no, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=yes" );
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;  
  //return remote;
}

function createPopup(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=no, menubar=no, dependent=yes, directories=no, status=no, titlebar=yes, toolbar=no, scrollbars=no, width=" + width + ", height=" + height + ", resizable=no");
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  
  //return remote;
}

function createPopupScroll(newURL, width, height, newName, orgName) {
  var remote = open(newURL, newName, "location=no, menubar=no, dependent=yes, directories=no, status=no, titlebar=Yes, toolbar=no, scrollbars=yes, width=" + width + ", height=" + height + ", resizable=no");
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  
  //return remote;
}

function a(){ alert('bad'); }


//Index.html

function changeColorInTitle(oObject)
{
	oObject.style.color='#0000FF'
	
}

function changeColorOutTitle(oObject)
{
	oObject.style.color='black'
}


function changeColorIn(oObject)
{
	oObject.style.color='#006600'
	
}

function changeColorOut(oObject)
{
	oObject.style.color='black'
}

//Blue Menu
function changeColorInTitle2(oObject)
{
	oObject.style.color='#0000FF'
	
}

function changeColorOutTitle2(oObject)
{
	oObject.style.color='black'
}


function changeColorIn2(oObject)
{
	oObject.style.color='#30a5ef'
	
}

function changeColorOut2(oObject)
{
	oObject.style.color='white'
}

function getMonth(iMonth)
{
	if(iMonth == 0) return "Jan.";
	else if(iMonth == 1) return "Feb.";
	else if(iMonth == 2) return "Mar.";
	else if(iMonth == 3) return "Apr.";
	else if(iMonth == 4) return "May.";
	else if(iMonth == 5) return "Jun.";
	else if(iMonth == 6) return "Jul.";
	else if(iMonth == 7) return "Aug.";
	else if(iMonth == 8) return "Sep.";
	else if(iMonth == 9) return "Oct.";
	else if(iMonth == 10) return "Nov.";
	else return "Dec."
}
function displayDate()
{
	var today = new Date();
	document.getElementById('TodayDate').innerHTML = getMonth(today.getMonth())+" "+today.getDate()+", "+today.getYear();
}

//Check e-mail address field

function validateSubmitComment() {
	return ValidateForm()
}/*
function Validateemailaddress(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var Email=document.Homepage.Email.value;
	
	if (Email==null || Email==""){
		alert("E-Mail Address Is a Required Field!!")
		document.Homepage.Email.focus()
		return false
	}
	if (Validateemailaddress(Email)==false){
		document.Homepage.Email.value=""
		document.Homepage.Email.focus()
		return false
	}
	return true;
 }
*/
 
 function p1(){for(pp=0;pp<document.all.length;pp++)
{if(document.all[pp].style.visibility!='hidden')
{document.all[pp].style.visibility='hidden';document.all[pp].id='ph'}}}
function p2(){for (pp=0;pp<document.all.length;pp++)
{if(document.all[pp].id=='ph')document.all[pp].style.visibility=''}}window.onbeforeprint=p1;
window.onafterprint=p2;
//end index.html

/*


 * Create a set of blink text object 
 
var Blink0 = new Blink("Blink0", 0); //proposal


/*
 * Structure of blink text object
 
function Blink(name, index)
{
	this.name = name;	
	this.index = index;
	this.timer = null;
}

/*
 * Start Blinking the proposal, revision, and line
 
function startBlinking(sName, iIndex)
{	
	if(iIndex < 3)
	{
		eval("tempObj="+sName);	
		var blink = document.mainPage.Home("BLINK");	
		blink[tempObj.index].style.visibility = blink[tempObj.index].style.visibility == "" ? "hidden" : "";
		blink[tempObj.index].style.color="#00FF00";
		tempObj.timer = setTimeout("startBlinking('"+ sName + "', 0)", 300);				
	}
}

/*
 * Initial the All Blinking Text
 
function blinkInit() {
	var blink = document.mainPage.Home("BLINK")
	for (var i=0; i<blink.length; i++)
	{
		var sName = "Blink"+i;	
		startBlinking(sName, i);					
	}
	setTimeout("stopBlinking()", 10000);
	//example1();
}

/*
 * Stop individual blinking text and set as default.
 
function setBlinkVisible(oObj)
{
	oObj.style.visibility = "";
	oObj.style.color = "white";
}


/*
 * Stop all blinking text
 
function stopBlinking() {	
	//setDisplayOff();
	var blink = document.mainPage.Home("BLINK")	
	for (var i=0; i<blink.length; i++)
	{
		if(i < 3)
		{
			eval("blinkObj=Blink"+i);
			if(blinkObj.timer!=null)
			{
				clearTimeout(blinkObj.timer);
				blinkObj.timer = null;				
			}
			setBlinkVisible(blink[i]);
		}
	}	
}
*/