

if (self != top) (top.location.href = self.location.href)


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];}
}

/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
								theCells[c].style.fontColor = theMarkColor;

								theCells[c].style.color = theMarkColor;
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) 
            {
                theCells[c].style.backgroundColor = newColor;

				theCells[c].style.color = theMarkColor;								
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function



/**
 *  SET NEW CLASS
 */
function setNewClass(theRow, theClass, theLinkID, theLinkClass)
{
    var theCells    = null;

    if (typeof(document.getElementsByTagName) != 'undefined') 
    {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') 
    {
        theCells = theRow.cells;
    }
    else 
    {
        return false;
    }
    
    var rowCellsCnt = theCells.length;
    var c = null;
    

    for (c = 0; c < rowCellsCnt; c++) 
    {
        theCells[c].className = theClass;
    } // end for

    return true;
} // end of the 'setNewClass()' function


// CHANGE CLASS FUNCTION
// - much smaller then 'setNewClass()' function
function changeClass(tdItem,tdClass,linkItem,linkClass)
{   
    document.getElementById(linkItem).className = linkClass;
    
    tdItem.className = tdClass;            
}
// end 


function myUbbHelp(scriptURL)
{
    window.open(scriptURL,'windowUBB','height=550,width=400,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no');
}



/******************************
OO-based DropdownDatePicker 
By: Glenn G. Vergara
glenngv@yahoo.com
Philippines

Please make this intact
if you want to use this script.
Thanks!
******************************/

function DropdownDatePicker(month, day, year, hasLeadingZero){
	var me = this;
	this.month = month;
	this.day = day;
	this.year = year;
	if (hasLeadingZero==null || typeof hasLeadingZero=="undefined") hasLeadingZero=false;
	this.hasLeadingZero = hasLeadingZero;
	this.setWeekend = false;
	
	this.populateDate = function(){
		var dSelYear = me.year.options[me.year.selectedIndex].value;
		var dSelMonth = me.month.options[me.month.selectedIndex].value;
		var timeA = new Date(dSelYear,dSelMonth,1); //get date of first day of next month
		var timeDifference = timeA - 86400000;//subtract 1 day
		var timeB = new Date(timeDifference);
		var daysInMonth = timeB.getDate();
		prevDaysInMonth = me.day.options.length;
		if (daysInMonth < prevDaysInMonth){	//current month's days < previous month's
			if (me.day.selectedIndex>=daysInMonth-1){
				me.day.selectedIndex = daysInMonth-1;	//select last day of the current month if previous month's selected day is > current month's
			}
			me.day.options.length = daysInMonth;
   		}
   		else if (daysInMonth > prevDaysInMonth){	//current month's days > previous month's
			var sDay;
			for (var i = prevDaysInMonth; i < (daysInMonth); i++) {
				sDay = ((i+1)<10 && me.hasLeadingZero)?"0"+(i+1):i+1;
				me.day.options[i] = new Option(sDay,sDay);
			}		
	    }
		if (me.setWeekend){
			me.setWeekendStyleOn(me.callbackOn);
		}
	}

	this.setDisplayMonths = function(mode, isUpperCase, arrMonth){
		switch (mode){
			case 1: //numeric months
				for (var i=0;i<12;i++){
					me.month.options[i] = new Option(((i+1)<10 && me.hasLeadingZero)?"0"+(i+1):i+1, i+1);
				}
				break;
			case 2: //full english month names
				var arrMonth = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
				for (var i=0;i<arrMonth.length;i++){
					me.month.options[i] = new Option((isUpperCase)?arrMonth[i].toUpperCase():arrMonth[i],i+1);
				}
				break;
			case 3: //abbreviated english month names (first 3 letters)
				var arrMonth = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
				for (var i=0;i<arrMonth.length;i++){
					me.month.options[i] = new Option((isUpperCase)?arrMonth[i].toUpperCase():arrMonth[i],i+1);
				}
				break;
			case 4: //customized month names
				if (arrMonth==null || typeof arrMonth=="undefined"){ //default is full english month names if arrMonth is invalid
					var arrMonth = new Array("January","February","March","April","May","June","July","August","September","October","November","December");				
				}
				for (var i=0;i<arrMonth.length;i++){
					me.month.options[i] = new Option((isUpperCase)?arrMonth[i].toUpperCase():arrMonth[i],i+1);
				}
				break;
			default: //numeric months
				for (var i=0;i<12;i++){
					me.month.options[i] = new Option(((i+1)<10 && me.hasLeadingZero)?"0"+(i+1):i+1, i+1);
				}
		}		
	}

	this.setDisplayYears = function(fromYear, toYear)
	{
		me.year.length=0;
		for (var i=fromYear;i>=toYear;i--){
			me.year.options[i-fromYear] = new Option(i,i);
		}
	}

	//set default date
	this.setDefaultDate = function(defaultDate){
		if (defaultDate==null || typeof defaultDate=="undefined" || isNaN(defaultDate)){
			defaultDate = new Date();
		}
		//me.month.options[defaultDate.getMonth()].selected = true;		//select default month
		//me.day.options[defaultDate.getDate()-1].selected = true;		//select default day
		//select default year

		for (var i=0;i<me.year.options.length;i++){
			if (me.year.options[i].value==defaultDate.getFullYear()){
				me.year.selectedIndex = i;
				break;
			}
		}
	}

	//set day as title (title attribute in select and option tags is currently supported only by Gecko)
	//no problem with other browsers as this will be ignored by them
	this.displayDay = function(arrDay){
		if (arrDay==null || typeof arrDay=="undefined"){
			var arrDay = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
		}
		me.arrDay = arrDay;

		//set month select title
		me.month.onmouseover = function(){
			var selectedDate = new Date(me.year.options[me.year.selectedIndex].value, this.selectedIndex, me.day.options[me.day.selectedIndex].value);
			this.title = me.arrDay[selectedDate.getDay()];
		}
		//set month options title
		for (var i=0;i<me.month.options.length;i++){
			me.month.options[i].onmouseover = function(){
				var selectedDate = new Date(me.year.options[me.year.selectedIndex].value, this.value-1, me.day.options[me.day.selectedIndex].value);
				this.title = me.arrDay[selectedDate.getDay()];
			}
		}

		//set day select title
		me.day.onmouseover = function(){
			var selectedDate = new Date(me.year.options[me.year.selectedIndex].value, me.month.selectedIndex, this.options[this.selectedIndex].value);
			this.title = me.arrDay[selectedDate.getDay()];
		}
		//set day options title
		for (var i=0;i<me.day.options.length;i++){
			me.day.options[i].onmouseover = function(){
				var selectedDate = new Date(me.year.options[me.year.selectedIndex].value, me.month.selectedIndex, this.value);
				this.title = me.arrDay[selectedDate.getDay()];
			}
		}

		//set year select title
		me.year.onmouseover = function(){
			var selectedDate = new Date(me.year.options[me.year.selectedIndex].value, this.selectedIndex, me.day.options[me.day.selectedIndex].value);
			this.title = me.arrDay[selectedDate.getDay()];
		}
		//set year options title
		for (var i=0;i<me.year.options.length;i++){
			me.year.options[i].onmouseover = function(){
				var selectedDate = new Date(this.value, me.month.selectedIndex, me.day.options[me.day.selectedIndex].value);
				this.title = me.arrDay[selectedDate.getDay()];
			}

		}
	}

	this.setWeekendStyleOn = function(callbackFunc){
		me.callbackOn = callbackFunc;
		me.setWeekend = true;
		for (var i=0;i<me.day.options.length;i++){
			var date = new Date(me.year.options[me.year.selectedIndex].value, me.month.selectedIndex, i+1);
			var day = date.getDay();
			if (day==0 || day==6){
				me.callbackOn(me.day.options[i]);
			}
			else{
				me.callbackOff(me.day.options[i]);
			}

		}
	}

	this.setWeekendStyleOff = function(callbackFunc){
		me.callbackOff = callbackFunc;	
	}
		
	
	//set onchange handler
	var monthChange = this.month.onchange;
	if (monthChange){
		this.month.onchange = function(){
			me.populateDate();
			monthChange();
		}
	}
	else{
		this.month.onchange = this.populateDate;
	}
	var yearChange = this.year.onchange;
	if (yearChange){
		this.year.onchange = function(){
			me.populateDate();
			yearChange();
		}
	}
	else{
		this.year.onchange = this.populateDate;	
	}
	
}

// INIT DATEPICKER
function initDatePicker(frmName,difference)
{
    var theDifference = parseInt(difference);
    
	var f = document.forms[frmName];

	var defaultDate = new Date();
	 
    defaultDate.setDate(defaultDate.getDate() + theDifference);

  	var datePicker1 = new DropdownDatePicker(f.selBirthMonth, f.selBirthDay, f.selBirthYear, true);

	//datePicker1.setDisplayMonths(1);
	//datePicker1.setDisplayYears(defaultDate.getFullYear(), defaultDate.getFullYear()-85);
	//datePicker1.setDefaultDate(defaultDate);    //set default date to tomorrow's date
}    

