<!--
function createQString(s)
{
    var result="";

    for(var i=0;i<s.length;++i)
    {
        if(s.charAt(i)==' ')
        {
            result+="+";
        }
        else
        {
            result+=s.charAt(i);
        }
    }

    return result;
}

function showtip(current, e, text)
{
         
        thetitle=text.split('<br>');
        if (thetitle.length > 1)
        {
            thetitles="";
            for (i=0; i<thetitle.length; i++)
            {
                thetitles += thetitle[i] + "\r\n";
            }
            current.title = thetitles;
        }
        else
        {
            current.title = text;
        }

}

function hidetip()
{
    if (document.layers)
        document.tooltip.visibility="hidden"
}

function updateFilter(fieldName, value, jspName, extraParams)
{
    value = createQString(value);

    if (parent.frames[1] == null)
    {
        location=jspName + "?" + fieldName + "=" + value + "&" + extraParams;
    }
    else
    {
        parent.frames[1].location=jspName + "?" + fieldName + "=" + value + "&" + extraParams;
    }
}

function updateGenericFilter(fieldName, value, jspName)
{
    document.inputForm.action = jspName;
    document.inputForm.filterField.value = fieldName;
    document.inputForm.filter.value = value;

    document.inputForm.submit();
}

function updateGenericRoomsFilter(fieldName, value, jspName, extraParams)
{
    value = createQString(value);

    if (parent.frames[2] == null)
    {
        location=jspName + "?filterField=" + fieldName + "&filter=" + value + "&" + extraParams;
    }
    else
    {
        parent.frames[2].location=jspName + "?filterField=" + fieldName + "&filter=" + value + "&" + extraParams;
    }
}

function displayCalendar(dateFieldInst, eventInst)
{

    window.dateField = dateFieldInst;

    var calendar, Xpos, Ypos, sOptions, calWidth, calHeight;

    calWidth = 220;
    calHeight = 225;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;

    if (navigator.appName.indexOf("Netscape") >= 0)
    {
        if(parseInt(navigator.appVersion.charAt(0)) < 5)
        {
            calWidth = 370;
            calHeight = 280;
        }
        else
        {
            calWidth = 220;
            calHeight = 225;
        }

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight + ',resizable=yes';

        calendar = window.open('calendar.jsp?dateField=' + dateFieldInst.value ,'cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight + ',resizable=yes';

         
        
        calendar = window.open('calendar.jsp?dateField=' + dateFieldInst.value ,'cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
      
    }

    return false;
}

function displayTimeTool(startTime, endTime, eventInst)
{

    
    window.startTime = startTime;
    window.endTime = endTime;

    var Xpos, Ypos, sOptions, calWidth, calHeight;

    calWidth = 280;
    calHeight = 275;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;

    if (navigator.appName.indexOf("Netscape") >= 0)
    {

        calWidth = 280;
        calHeight = 350;

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight + ',resizable=yes';

        timetool = window.open('timetool.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
        //timetool.close();
        timetool = window.open('timetool.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;
        timetool = window.open('timetool.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
        //timetool.close();
        timetool = window.open('timetool.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
    }

    return false;
}

function displayTimeToolSearchBean(startTime, endTime, eventInst)
{

    
    window.startTime = startTime;
    window.endTime = endTime;

    var Xpos, Ypos, sOptions, calWidth, calHeight;

    calWidth = 280;
    calHeight = 275;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;
    
    if (navigator.appName.indexOf("Netscape") >= 0)
    {
        calWidth = 280;
        calHeight = 350;

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight + ',resizable=yes';

        timetool = window.open('searchbeantimetool.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
        //timetool.close();
        timetool = window.open('searchbeantimetool.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;
        timetool = window.open('searchbeantimetool.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
        //timetool.close();
        timetool = window.open('searchbeantimetool.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
    }

    return false;
}

function displayGridTimeTool(startTime, endTime, eventInst)
{

    window.startTime = startTime;
    window.endTime = endTime;

    var Xpos, Ypos, sOptions, calWidth, calHeight;

    calWidth = 280;
    calHeight = 225;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;

    if (navigator.appName.indexOf("Netscape") >= 0)
    {

        calWidth = 280;
        calHeight = 350;

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;

        timetool = window.open('gridtimetool.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
        //timetool.close();
        timetool = window.open('gridtimetool.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;
        timetool = window.open('gridtimetool.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
       // timetool.close();
        timetool = window.open('gridtimetool.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
    }

    return false;
}

function displayGridLegend(eventInst)
{


    var Xpos, Ypos, sOptions, calWidth, calHeight;

    calWidth = 240;
    calHeight = 375;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;

    if (navigator.appName.indexOf("Netscape") >= 0)
    {

        calWidth = 320;
        calHeight = 380;

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;

        timetool = window.open('gridLegend.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
        //timetool.close();
        timetool = window.open('gridLegend.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;
        timetool = window.open('gridLegend.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
        //timetool.close();
        timetool = window.open('gridLegend.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
    }

    return false;
}


function displayResourceGridLegend(eventInst)
{


    var Xpos, Ypos, sOptions, calWidth, calHeight;

    calWidth = 240;
    calHeight = 375;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;

    if (navigator.appName.indexOf("Netscape") >= 0)
    {

        calWidth = 320;
        calHeight = 380;

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;

        timetool = window.open('resourceGridLegend.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
        //timetool.close();
        timetool = window.open('resourceGridLegend.jsp','cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;
        timetool = window.open('resourceGridLegend.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
       // timetool.close();
        timetool = window.open('resourceGridLegend.jsp','cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
    }

    return false;
}




function eventPopup(subject, course, sectionNum, title, building,
                    room, daysMet, instructorCustomer, startTime,
                    endTime, startDate, endDate, eventType, campus,
                    id, isEvent)
{

    var sURL = 'class_popup.jsp';

    if (isEvent == 'true')
    {
        sURL = 'event_popup.jsp';
    }

    popupWin = window.open(sURL + '?'+
        'subject=' + subject + '&' +
        'course=' + course + '&' +
        'sectionNum=' + sectionNum + '&' +
        'title=' + title + '&' +
        'building=' + building + '&' +
        'room=' + room + '&' +
        'daysMet=' + daysMet + '&' +
        'instructorCustomer=' + instructorCustomer + '&' +
        'startTime=' + startTime + '&' +
        'endTime=' + endTime + '&' +
        'startDate=' + startDate + '&' +
        'endDate=' + endDate + '&' +
        'campus=' + campus + '&' +
        'id=' + id + '&' +
        'eventType=' + eventType
    , 'POPUP', 'alwaysRaised=yes,menubar,status,scrollbars,resizable,dependent,width=800,height=400');

    popupWin.focus();
}

function adHocResourcePopup(adHocId)
{

    var sURL = 'adhoc_popup.jsp';

    popupWin = window.open(sURL + '?'+
        'AdHocId=' + adHocId 
    , 'POPUP', 'alwaysRaised=yes,menubar,status,scrollbars,resizable,dependent,width=800,height=400');
    popupWin.focus();
}




function updatePage(pageName, startDate, endDate)
{
    //
    // update display by reloading this page
    //

    location = pageName+'?startDate=' + startDate + '&endDate=' + endDate;
}

function emailCheck (emailStr) {

    var isValid = false;
    if (emailStr != null)
    {
      if ((emailStr.length > 0) && (emailStr.indexOf(" ") == -1))
      {
        isValid = true;
      }
    }
    return isValid;    
}

function stringEmpty (testString) {
    isEmpty = true;
    for(var i=0;i<testString.length;++i)
    {
        if(testString.charAt(i)!=' ')
        {
            isEmpty = false;
        }
              
    }
    return isEmpty;    
}

function multiPopUp(timeSpanId)
{

    var sURL = 'multi_popup.jsp';

    popupWin = window.open(sURL + '?'+
        'timeSpanId=' + timeSpanId
    , 'POPUP', 'alwaysRaised=yes,menubar,status,scrollbars,resizable,dependent,width=800,height=400');
    popupWin.focus();
}

function multiResourcePopUp(timeSpanId)
{

    var sURL = 'resource_multi_popup.jsp';

    popupWin = window.open(sURL + '?'+
        'timeSpanId=' + timeSpanId
    , 'POPUP', 'alwaysRaised=yes,menubar,status,scrollbars,resizable,dependent,width=800,height=400');
    popupWin.focus();
}


function validateAttendance(attendanceValue)
{
    var correctValue = 0;
    if (attendanceValue != null && attendanceValue != "")
    {
    	correctValue = parseInt(attendanceValue,10);
        if ((correctValue == "NaN") || (correctValue < 0))
        {
            correctValue  = 0;
        }
     }
    return correctValue;
}

function isStartDateLargerThanEndDate(startDate, endDate)
{
	var isLarger = false;
    var dStartDate     = new Date(startDate);
    var dEndDate       = new Date(endDate);
    
    if (dStartDate.valueOf() > dEndDate.valueOf())
    	isLarger = true;

    return isLarger;	
}

function areDatesEqual(startDate, endDate)
{
	var isSame = false;
    var dStartDate     = new Date(startDate);
    var dEndDate       = new Date(endDate);
    
    //alert('dStartDate.valueOf(): ' + dStartDate.valueOf());
	//alert('dEndDate.valueOf(): ' + dEndDate.valueOf());
	
    if (dStartDate.valueOf() == dEndDate.valueOf())
    	isSame = true;

    return isSame;	
}

function isStartTimeLargerThanEndTime(startHour, startMinutes, startPeriod, endHour, endMinutes, endPeriod)
{
	
	
	
	/*alert('startHour: ' + startHour);
	alert('startMinutes: ' + startMinutes);
	alert('startPeriod: ' + startPeriod);
	alert('endHour: ' + endHour);
	alert('endMinutes: ' + endMinutes);
	alert('endPeriod: ' + endPeriod);
	*/
	
	if (startPeriod == 'PM' && endPeriod== 'AM') 
	{
		alert('Start is pm end is am');
		return true;
	}
	
	if (startPeriod == 'AM' && endPeriod== 'PM') 
	{
		alert('Start is am end is pm');	
		return false;
	}
	
	if (startHour == 12)
	{
	    startHour = 0;
	}
	if (endHour == 12)
	{
	   endHour = 0;
	}
	
	
	if (parseInt(startHour) > parseInt(endHour)) return true;
	else
		if ((parseInt(startHour) == parseInt(endHour)) && (parseInt(startMinutes) > parseInt(endMinutes))) return true;
	
	return false;

}

function displayBuildingRoomSelect(building, room, includeAll, eventInst)
{ 
    window.BUILDING = building;
    window.ROOM = room;
    window.INCLUDEALL = includeAll;
    

    var Xpos, Ypos, sOptions, calWidth, calHeight,includeAllString;
    if (includeAll)
    {
        includeAllString = "True";
    }
    else
    {
        includeAllString = "False";
    }
    

    calWidth = 280;
    calHeight = 225;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;

    if (navigator.appName.indexOf("Netscape") >= 0)
    {

        calWidth = 280;
        calHeight = 350;

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;

        timetool = window.open('selectBuildingRoom.jsp?building=' +building.value + '&room=' + room.value + '&includeAll=' + includeAllString,'cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
       // timetool.close();
        timetool = window.open('selectBuildingRoom.jsp?building=' +building.value + '&room=' + room.value + '&includeAll=' + includeAllString,'cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;
        timetool = window.open('selectBuildingRoom.jsp?building=' +building.value + '&room=' + room.value + '&includeAll=' + includeAllString,'cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
       // timetool.close();
        timetool = window.open('selectBuildingRoom.jsp?building=' +building.value + '&room=' + room.value + '&includeAll=' + includeAllString,'cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
    }
   

    return false;
}
function displaySubjectCourseSelect(subject, course, includeAll, eventInst)
{

    window.SUBJECT = subject;
    window.COURSE = course;
    window.INCLUDEALL = includeAll;
    

    var Xpos, Ypos, sOptions, calWidth, calHeight,includeAllString;
    if (includeAll)
    {
        includeAllString = "True";
    }
    else
    {
        includeAllString = "False";
    }
    

    calWidth = 280;
    calHeight = 225;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;

    if (navigator.appName.indexOf("Netscape") >= 0)
    {

        calWidth = 280;
        calHeight = 350;

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;

        timetool = window.open('selectSubjectCourse.jsp?subject=' +subject.value + '&course=' + course.value + '&includeAll=' + includeAllString,'cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
        //timetool.close();
        timetool = window.open('selectSubjectCourse.jsp?subject=' +subject.value + '&course=' + course.value + '&includeAll=' + includeAllString,'cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;
        timetool = window.open('selectSubjectCourse.jsp?subject=' +subject.value + '&course=' + course.value + '&includeAll=' + includeAllString,'cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
        //timetool.close();
        timetool = window.open('selectSubjectCourse.jsp?subject=' +subject.value + '&course=' + course.value + '&includeAll=' + includeAllString,'cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
    }

    return false;
}

function displayCategoryGroupSelect(category, group, includeAll, eventInst)
{
    window.CATEGORY = category;
    window.GROUP = group;
    window.INCLUDEALL = includeAll;
    

    var Xpos, Ypos, sOptions, calWidth, calHeight,includeAllString;
    if (includeAll)
    {
        includeAllString = "True";
    }
    else
    {
        includeAllString = "False";
    }
    

    calWidth = 280;
    calHeight = 225;

    Xpos = eventInst.screenX - (calWidth / 2);
    Ypos = eventInst.screenY + 20;

    if (navigator.appName.indexOf("Netscape") >= 0)
    {

        calWidth = 280;
        calHeight = 350;

        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;

        timetool = window.open('selectCategoryGroup.jsp?category=' +category.value + '&group=' + group.value + '&includeAll=' + includeAllString,'cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
        //timetool.close();
        timetool = window.open('selectCategoryGroup.jsp?category=' +category.value + '&group=' + group.value + '&includeAll=' + includeAllString,'cal','SCREENY=' + Ypos + ',SCREENX=' + Xpos  + sOptions);
    }
    else
    {
        sOptions = ',WIDTH=' + calWidth + ',HEIGHT=' + calHeight;
        timetool = window.open('selectCategoryGroup.jsp?category=' +category.value + '&group=' + group.value + '&includeAll=' + includeAllString,'cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
        //timetool.close();
        timetool = window.open('selectCategoryGroup.jsp?category=' +category.value + '&group=' + group.value + '&includeAll=' + includeAllString,'cal','LEFT=' + Xpos + ', TOP=' + Ypos + sOptions);
    }

    return false;
}

function Trim(TRIM_VALUE){


        	if(TRIM_VALUE.length < 1){
        		return"";
        	}
        	TRIM_VALUE = RTrim(TRIM_VALUE);
        	TRIM_VALUE = LTrim(TRIM_VALUE);


            	if(TRIM_VALUE==""){
            		return "";
            	}


                	else{
                		return TRIM_VALUE;
                	}
            }


                function RTrim(VALUE){
                	var w_space = String.fromCharCode(32);
                	var v_length = VALUE.length;
                	var strTemp = "";


                    	if(v_length < 0){
                    		return"";
                    	}
                    	var iTemp = v_length -1;


                        	while(iTemp > -1){
                        		if(VALUE.charAt(iTemp) == w_space){}


                            		else{
                            			strTemp = VALUE.substring(0,iTemp +1);
                            			break;
                            		}
                            		iTemp = iTemp-1;
                            	}
                            	return strTemp;
                        }


                            function LTrim(VALUE){
                            	var w_space = String.fromCharCode(32);


                                	if(v_length < 1){
                                		return"";
                                	}
                                	var v_length = VALUE.length;
                                	var strTemp = "";
                                	var iTemp = 0;


                                    	while(iTemp < v_length){
                                    		if(VALUE.charAt(iTemp) == w_space){}


                                        		else{
                                        			strTemp = VALUE.substring(iTemp,v_length);
                                        			break;
                                        		}
                                        		iTemp = iTemp + 1;
                                        	}
                                        	return strTemp;
                                    }







//-->
