<!--
// get date time with locale
function getDate() {
    var today = new Date();              
    var date;
    var day;

    if(today.getDay()==0) {day = "Sunday";}
    if(today.getDay()==1) {day = "Monday";}
    if(today.getDay()==2) {day = "Tuesday";}
    if(today.getDay()==3) {day = "Wednesday";}
    if(today.getDay()==4) {day = "Thursday";}
    if(today.getDay()==5) {day = "Friday";}
    if(today.getDay()==6) {day = "Saturday";}

    date = today.getYear() + "-" + (today.getMonth() + 1 ) + "-" + today.getDate() + "-" + " " + day;
    return date;
}

// get date time with locale
function getDateLocale() {
	var date = "";
	var now = new Date().toLocaleString();
	
	if (now != null && now != "") {
		date = now.substring(0, now.lastIndexOf(" "));
		date = date.substring(0, date.lastIndexOf(" "));
	}
	
	return date;
}


// whether a valid email address
function isValidEmail(email) {
    var emailFormat = /^.+@.+\..{2,3}$/;
    var arr = email.match(emailFormat);
    if (arr == null) return false;

    return true;
}

	
// back to previous page
function goBack() {
    top.window.history.go(-1);
}


// go to specify page
function gotoPage(page) {
    top.window.location = page;
}	


// Whether is an empty value
function isEmpty(str) {
    return ((str == null) || (trim(str).length == 0));
}

// Trim white spaces from a string
function trim(str) {
    //"\s" - matches any whitespace character; this is equivalent to the class [ \t\n\r\f\v]. 
    var re = /\s*/;
    return (str.replace(re, ""));
}

// Trim white spaces from a string
function isContainsSpace(str) {
    if (str != null) {
        for(var i=0; i<str.length; i++) {
            var getChar = str.charAt(i);
            if((getChar==' ') || (getChar=='\n') || (getChar=='\t') || (getChar=='\r')) // || (getChar=='\f') || (getChar=='\v'))
                return true;
        }
    }	
    return false;
}


// Key press checking
function checkKeyPress(e){
    var isIE = (navigator.appName.indexOf("Microsoft") > -1) ? true : false;
    var charCode = isIE ? e.keyCode : e.which;
    if (charCode == 13 ) {
        if (typeof(historyCount)!="undefined")
            --historyCount;

        return true;
    }	
    if (charCode < 48 || charCode > 57) return false;

    return true;
}


// Whether is a valid time format: (24 hours)
function isValidTime(timeStr) {
	var hour, minute;
	
	hour = timeStr.substring(0,2);
	minute = timeStr.substring(timeStr.indexOf(":")+1);

	if (timeStr.length < 5 || (parseInt(hour,10) > 24) || (parseInt(hour,10) < 0) || (parseInt(minute,10) > 59) || (parseInt(minute,10) < 0)) {
            return false;
	}	
		
	return true;	
}


// Whether is a valid date format: YYYY-MM-DD or YYYY/MM/DD
function isValidDate(dateStr) {
    var year, month, day, symbol

    symbol = "-";
    if (dateStr.indexOf("/") > -1)
        symbol="/";

    year = dateStr.substring(0,dateStr.indexOf(symbol));
    dateStr = dateStr.substring(dateStr.indexOf(symbol)+1,dateStr.length);
    month = dateStr.substring(0,dateStr.indexOf(symbol));
    dateStr = dateStr.substring(dateStr.indexOf(symbol)+1,dateStr.length);
    day = dateStr

    if ((year.length<4) || (month.length<2) || (day.length<2) || (isNaN(year)) || (isNaN(month)) || (isNaN(day))) {
        return false;
    }	

    year = parseInt(year,10);
    month = parseInt(month,10); 
    day = parseInt(day,10);
    if (year<1000 || month<1 || month>12 || day<1 || day>31) {
        return false;
    }	

    if (month == 2 || month == 4 || month == 6 || month == 9 || month == 11) {
        if (month == 2) {
            var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
            if (isleap && day > 29) {
                return false;
            }	
            else if (!isleap && day > 28) {
                return false;
            }	
        }
        else if (day > 30) {
            return false;
        }	
    }

    return true;
}


// Check all Checkbox
function checkAllBox(item, form) {
    for (var i=0; i<form.elements.length; i++) {
        if (form.elements[i].name.substring(0, item.length) == item) {
            if(form.elements[i].disabled != true)
                form.elements[i].checked=true;
        }	
    }
}

//
function uncheckAllBox(item, form) {
    for (var i=0; i<form.elements.length; i++) {
        if (form.elements[i].name.substring(0, item.length) == item) {
            if(form.elements[i].disabled != true)
                form.elements[i].checked=false;
        }	
    }
}

// Any Checkbox has been checked
function isChecked(item, form) {
    itemcount = 0;

    for (var i=0; i<form.elements.length; i++) {
        if (form.elements[i].name.substring(0, item.length) == item) {
            if (form.elements[i].checked == true) {
                itemcount+=1;
            }	
        }		
    }

    if (itemcount > 0) return true;
    return false;
}

// The specified checkbox has been checked
function isCheckedIt(obj) {
    return obj.checked;
}
/*
function isCheckedIt(item, form) {
    itemcount = 0;
    for (var i=0; i<form.elements.length; i++) {
        if (form.elements[i].name == item) {
            if (form.elements[i].checked == true)
                itemcount+=1;
        }		
    }
    if (itemcount > 0) return true;
    return false;
}
*/

// How many checkboxes were checked
function hmChecked(item, form) {
    item_count = 0;

    for (i=0; i<form.elements.length; i++) {
        if (form.elements[i].name.substring(0, item.length) == item) {
            if (form.elements[i].checked == true) {
                item_count+=1;
            }	
        }		
    }

    return item_count;
}

// The specified checkbox has been checked
function isSelected(obj) {
    itemcount = 0;

    for (var i=0; i<obj.options.length; i++) {
        if (obj.options[i].selected)
            itemcount+=1;
    }

    if (itemcount > 0) return true;
    return false;
}

//
function getScreenWidth() {
    var screenWidth = 0;
    if (document.all)
    	screenWidth = screen.width;
	
    return screenWidth;
}

//
function getMouseXPos() {
    var xMousePos = 0;
	
    if (document.layers || document.getElementById) {
//	var e = document.captureEvents(Event.MOUSEMOVE);
//        xMousePos = e.pageX;
    } else if (document.all) {
        xMousePos = window.event.x+document.body.scrollLeft;
    }

    return xMousePos;
}

//
function getMouseYPos() {
    var yMousePos = 0;
	
    if (document.layers || document.getElementById) {
//	var e = document.captureEvents(Event.MOUSEMOVE);
//       yMousePos = e.pageY;
    } else if (document.all) {
        yMousePos = window.event.y+document.body.scrollTop;
    }
    
    return yMousePos;
}

//
function getLinkByName(str) {
    for (var i=0; i<document.links.length; i++) {
        if (document.links[i].name == str)
            return document.links[i];
    }

    return false;
}

//
function padChar(ins, num, str) {
    var returnValue;

    if(str.length < num) {
        for(var i=0; i<(num-str.length); i++) {
            returnValue+=ins;
        }
        returnValue+=str;
    }
    else
        returnValue = str;

    return returnValue;
}

//
function isInteger(val) {
    if(!isEmpty(val)) {
        if(!isNaN(val) && val.indexOf(".") == -1 && val >= 0)
           return true;
    }
    return false;
}

//
function isNumber(val) {
    if(!isEmpty(val)) {
        if(!isNaN(val) && val > 0)
            return true;
    }
    return false;
}

//
function getTokenValue(str, delim, index) {
    var returnValue = "";
    if(!isEmpty(str)) {
        var arrStr = str.split(delim);
        for(var i=0; i<arrStr.length; i++) {
            if(i == (index-1)) 
                returnValue = arrStr[i];
        }
    }

    return returnValue;
}
//-->