<!--
// open window functions
var newWin;
var photoWin;

var IE;
var FireFox;

var i_brower_IE_reg = new RegExp("MSIE");
var i_brower_Firefox_reg = new RegExp("Firefox");

IE = i_brower_IE_reg.test(navigator.userAgent);
Firefox = i_brower_Firefox_reg.test(navigator.userAgent);

function newWindow(url, winType) {
        win_name = "intranet_popup";
        win_size = "resizable,scrollbars,status,top=40,left=40,width=400,height=400";
        if(winType==0){
                win_name = "intranet_popup0";
                win_size = "resizable,scrollbars,status,top=40,left=40,width=400,height=400";
        }
        if(winType==1){
                win_name = "intranet_popup1";
                win_size = "resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==2){
                win_name = "intranet_popup2";
                win_size = "resizable,scrollbars,status,top=40,left=40,width=500,height=400";
        }
        if(winType==3){
                win_name = "intranet_popup3";
                win_size = "toolbar,location,resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==4){
                win_name = "intranet_popup4";
                win_size = "menubar,resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==5){
                win_name = "intranet_popup5";
                win_size = "menubar,toolbar,resizable,scrollbars,status,top=40,left=40,width=620,height=400";
        }
        if(winType==6){
                win_name = "intranet_popup6";
                win_size = "menubar,resizable,scrollbars,status,top=40,left=40,width=500,height=350";
        }
        if(winType==7){
                win_name = "intranet_popup7";
                win_size = "toolbar,resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==8){
                win_name = "intranet_popup8";
                win_size = "menubar,toolbar,resizable,scrollbars,status,top=40,left=40,width=800,height=500";
        }
        if(winType==9){
                win_name = "intranet_popup9";
                win_size = "resizable,scrollbars,status,top=40,left=500,width=500,height=400";
        }
        if(winType==10){
                win_name = "intranet_popup10";
                win_size = "resizable,scrollbars,status,top=40,left=40,width=800,height=600";
        }
        if(winType==11){
                win_name = "intranet_popup11";
                win_size = "resizable,scrollbars,status,top=40,left=40,width=500,height=500";
        }
        if(winType==12){
                win_name = "intranet_popup12";
                win_size = "menubar,resizable,scrollbars,status,top=40,left=40,width=630,height=400";
        }
        if(winType==13){
                win_name = "intranet_popup13";
                win_size = "menubar,resizable,scrollbars,status,top=40,left=40,width=800,height=600";
        }
        if(winType==14){
                win_name = "intranet_popup14";
                win_size = "resizable,scrollbars,status,top=40,left=500,width=500,height=500";
        }
        if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion >="4")
        if (newWin!=null) newWin.close();
        newWin = window.open (url, win_name, win_size);
        if (navigator.appName=="Netscape" && navigator.appVersion >= "3") newWin.focus();
}

function imageWindow(url,photowidth,photoheight){
    win_name = "ImageWindow";
    win_size = "resizable=false,scrollbars=false,status,top=40,left=500,width="+photowidth+",height="+photoheight;
    if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion >="4")
    if (photoWin!=null) photoWin.close();
    photoWin = window.open ("viewImg.php?url="+url, win_name, win_size);
    if (navigator.appName=="Netscape" && navigator.appVersion >= "3") newWin.focus();
}

function newWindowWithName(url, winType){
        if(winType==8){
                win_name = "intranet_popup8";
                win_size = "menubar,toolbar,resizable,scrollbars,status,top=40,left=40,width=800,height=500";
        }
        if(winType==13){
                win_name = "intranet_pop13ForExport";
                win_size = "menubar,resizable,scrollbars,status,top=40,left=40,width=800,height=600";
        }

        if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion >="4")
        if (newWin!=null) newWin.close();
        newWin = window.open (url, win_name, win_size);
        if (navigator.appName=="Netscape" && navigator.appVersion >= "3") newWin.focus();

        return win_name;
}

function newWindowNotClose(url, winType,name) {
        var newWindow;
        win_name = name;
        win_size = "resizable,scrollbars,status,top=40,left=40,width=400,height=400";
        if(winType==0){
                win_size = "resizable,scrollbars,status,top=40,left=40,width=400,height=400";
        }
        if(winType==1){
                win_size = "resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==2){
                win_size = "resizable,scrollbars,status,top=40,left=40,width=500,height=400";
        }
        if(winType==3){
                win_size = "toolbar,location,resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==4){
                win_size = "menubar,resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==5){
                win_size = "menubar,toolbar,resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==6){
                win_size = "menubar,resizable,scrollbars,status,top=40,left=40,width=500,height=350";
        }
        if(winType==7){
                win_size = "toolbar,resizable,scrollbars,status,top=40,left=40,width=600,height=400";
        }
        if(winType==8){
                win_size = "menubar,toolbar,resizable,scrollbars,status,top=40,left=40,width=800,height=500";
        }
        if(winType==9){
                win_size = "resizable,scrollbars,status,top=40,left=500,width=500,height=400";
        }
        if(winType==10){
                win_size = "resizable,scrollbars,status,top=40,left=40,width=800,height=600";
        }
        if(winType==11){
                win_size = "resizable,scrollbars,status,top=40,left=40,width=500,height=500";
        }
        if(winType==12){
                win_size = "menubar,resizable,scrollbars,status,top=40,left=40,width=630,height=400";
        }
//        if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion >="4")
        newWindow = window.open (url, win_name, win_size);
        if (navigator.appName=="Netscape" && navigator.appVersion >= "3") newWindow.focus();
}

// trim functions
function LTrim(str){
        var whitespace = new String(" \t\n\r");
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
                var j=0, i = s.length;
                while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                        j++;
                s = s.substring(j, i);
        }
        return s;
}
function RTrim(str){
        var whitespace = new String(" \t\n\r");
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
                var i = s.length - 1;       // Get length of string
                while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                        i--;
                s = s.substring(0, i+1);
        }
        return s;
}
function Trim(str){
        return RTrim(LTrim(str));
}

// form validation functions
function setChecked(val, obj, element_name){
        len=obj.elements.length;
        var i=0;
        for( i=0 ; i<len ; i++) {
                if (obj.elements[i].name==element_name)
                obj.elements[i].checked=val;
        }
}
function countChecked(obj, element_name){
        len=obj.elements.length;
        var i=0;
        var j=0;
        for( i=0 ; i<len ; i++) {
                if (obj.elements[i].name==element_name && obj.elements[i].checked)
                j=j+1;
        }
        return j;
}
function returnChecked(obj, element_name){
        len=obj.elements.length;
        var i=0;
        for( i=0 ; i<len ; i++) {
                if (obj.elements[i].name==element_name && obj.elements[i].checked)
                return obj.elements[i].value;
        }
        return null;
}

function returnDefaultChecked(obj, element_name){
        len=obj.elements.length;
        var i=0;
        for( i=0 ; i<len ; i++) {
                if (obj.elements[i].name==element_name && obj.elements[i].defaultChecked)
                return obj.elements[i].value;
        }
        return null;
}

function check_text(f, msg){
        if(Trim(f.value)==""){
                alert(msg);
                f.value="";
                f.focus();
                return false;
        }else{
                return true;
        }
}
function check_select(f, msg, g){
        if(Trim(f.options[f.selectedIndex].value)==g){
                alert(msg);
                f.focus();
                return false;
        }else{
                return true;
        }
}
function check_checkbox(obj,element){
        if(countChecked(obj,element)==0){
                return false;
        } else {
                return true;
        }
}
function check_int(f,d,msg){
        if(isNaN(parseInt(f.value)) || parseInt(f.value)==0){
                alert(msg);
                f.value=d;
                f.focus();
                return false;
        }else{
                f.value=parseInt(f.value);
                return true;
        }
}
function check_positive_int (f,msg)
{
     value = parseInt(f.value);
     if (isNaN(value) || value < 0)
     {
         alert(msg);
         f.focus();
         return false;
     }
     else
     {
         f.value = value;
         return true;
     }
}
function check_positive_nonzero_int (f,msg)
{
     value = parseInt(f.value);
     if (isNaN(value) || value <= 0)
     {
         alert(msg);
         f.focus();
         return false;
     }
     else
     {
         f.value = value;
         return true;
     }
}
function check_date(obj, msg){
        var err = 0;
        d_a = obj.value;
        if (d_a.length != 10) err = 1;
        d_b = parseInt(d_a.substring(0, 4),10)        // year
        d_c = d_a.substring(4, 5)                                // '-'
        d_d = parseInt(d_a.substring(5, 7),10)        // month
        d_e = d_a.substring(7, 8)                                // '-'
        d_f = parseInt(d_a.substring(8, 10),10)        // day
        // basic error checking
        if(d_b<0 || d_b>3000 || isNaN(d_b)) err = 1;
        if(d_c != '-') err = 1;
        if(d_d<1 || d_d>12 || isNaN(d_d)) err = 1;
        if(d_e != '-') err = 1;
        if(d_f<1 || d_f>31 || isNaN(d_f)) err = 1;
        // advanced error checking
        // months with 30 days
        if((d_d==4 || d_d==6 || d_d==9 || d_d==11) && (d_f==31)) err = 1;
        // february, leap year
        if(d_d==2){ // feb
                var d_g = parseInt(d_b/4)
                if(isNaN(d_g)) err = 1;
                if(d_f>29) err = 1;
                if(d_f==29 && ((d_b/4)!=parseInt(d_b/4))) err = 1;
        }
        if(err==1){
                alert(msg);
                obj.focus();
                return false;
        }else{
                return true;
        }
}
function check_time(obj,msg)
{
        var err = 0;
        d_a = obj.value;
        if (d_a.length != 8) err = 1;
        d_b = parseInt(d_a.substring(0, 2),10)        // hr
        d_c = d_a.substring(2, 3)                                // ':'
        d_d = parseInt(d_a.substring(3, 5),10)        // min
        d_e = d_a.substring(5, 6)                                // ':'
        d_f = parseInt(d_a.substring(6, 8),10)        // sec
        // basic error checking
        if(d_b<0 || d_b>23 || isNaN(d_b)) err = 1;
        if(d_c != ':') err = 1;
        if(d_d<0 || d_d>59 || isNaN(d_d)) err = 1;
        if(d_e != ':') err = 1;
        if(d_f<0 || d_f>59 || isNaN(d_f)) err = 1;
        if(err==1){
                alert(msg);
                obj.focus();
                return false;
        }else{
                return true;
        }
}

/*
Compare date. Return
1  if s1 is dated later than s2
-1 if s2 is dated later then s1
0  if s1 and s2 are dated the same
*/
function compareDate(s1,s2)
{
        y1 = parseInt(s1.substring(0,4),10);
        y2 = parseInt(s2.substring(0,4),10);
        m1 = parseInt(s1.substring(5,7),10);
        m2 = parseInt(s2.substring(5,7),10);
        d1 = parseInt(s1.substring(8,10),10);
        d2 = parseInt(s2.substring(8,10),10);

        if (y1 > y2)
        {
                return 1;
        }
        else if (y1 < y2)
        {
                return -1;
        }
        else if (m1 > m2)
        {
                return 1;
        }
        else if (m1 < m2)
        {
                return -1;
        }
        else if (d1 > d2)
        {
                return 1;
        }
        else if (d1 < d2)
        {
                return -1;
        }
        return 0;


}

function checkRegEx(str,msg){
        var RE1 = new RegExp("[^0-9a-zA-Z]");
        if (RE1.test(str)){
                alert(msg);
                return false;
        }else{
                return true;
        }
}
function validateEmail(obj,msg){
        //var re = /^[\w_.-]+@[\w-]+(\.\w+)+$/;
        var re = /^.+@.+\..{2,3}$/;
        if (re.test(obj.value)) {
                return true;
        }else{
                alert(msg);
                obj.focus();
                return false;
        }
}
function validateFilename(str){
        var re = /[:<>\\\/\|\*\?'"]/;
        if (re.test(str)) {
                alert(globalAlertMsg9);
                return false;
        }else{
                return true;
        }
}

// page functions
function gopage(page, obj){
        obj.pageNo.value=page;
        obj.submit();
}
function sortPage(a, b, obj){
        obj.order.value=a;
        obj.field.value=b;
        obj.pageNo.value=1;
        obj.submit();
}

// menu bar functions
function checkNew(page){
        self.location.href=page;
}
function checkPost(obj,url){
        obj.action=url;
        obj.method = "post";
        obj.submit();
}
function checkGet(obj,url){
        obj.action=url;
        obj.method = "get";
        obj.submit();
}
function AlertPost (obj,url,msg){
        if(confirm(msg)){
           obj.action=url;
           obj.method = "post";
           obj.submit();
        }
}
function checkRemoveAll(obj,url){
        if(confirm(globalAlertMsgRemoveAll)){
           obj.action=url;
           obj.method = "get";
           obj.submit();
        }
}

function checkEdit(obj,element,page){
        if(countChecked(obj,element)==1) {
                obj.action=page;
                obj.submit();
        } else {
                alert(globalAlertMsg1);
        }
}
function checkRemove(obj,element,page){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                if(confirm(globalAlertMsg3)){
                obj.action=page;
                obj.method="POST";
                obj.submit();
                }
        }
}
function checkRestore(obj,element,page){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                obj.action=page;
                obj.submit();
        }
}

function checkSaveAs(obj,element,page){
        if(countChecked(obj,element)==0) {
                alert(globalAlertMsg2);
        } else {
                obj.action=page;
                obj.method="POST";
                obj.submit();
        }
}

function checkApprove(obj,element,page){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                if(confirm(globalAlertMsg4)){
                obj.action=page;
                obj.submit();
                }
        }
}
function checkReject(obj,element,page){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                if(confirm(globalAlertMsg22)){
                obj.action=page;
                obj.submit();
                }
        }
}
function checkActivate(obj,element,page){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                if(confirm(globalAlertActivate)){
                obj.action=page;
                obj.submit();
                }
        }
}

function checkSuspend(obj,element,page){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                if(confirm(globalAlertMsg5)){
                obj.action=page;
                obj.submit();
                }
        }
}
function checkSwap(obj,element,page){
        if(countChecked(obj,element)!=2)
                alert(globalAlertMsg6);
        else{
                if(confirm(globalAlertMsg7)){
                obj.action=page;
                obj.submit();
                }
        }
}
function checkImport(obj,element,page){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                obj.action=page;
                obj.submit();
        }
}
function checkIdentity(obj,element){
        if(countChecked(obj,element)==0){
                alert(globalAlertMsg14);
                return false;
        }else{
                return true;
        }
}
function checkRole(obj,element,page){
        if(countChecked(obj,element)==0){
                alert(globalAlertMsg2);
        }else{
                obj.action=page;
                obj.submit();
        }
}
function checkArchive(obj,element,page){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                if(confirm(globalAlertMsg21)){
                obj.action=page;
                obj.submit();
                }
        }
}

function checkAlert(obj,element,page,msg){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                if(confirm(msg)){
                obj.action=page;
                obj.method="POST";
                obj.submit();
                }
        }
}
function checkPrompt(obj,element,page,msg,data,defaultmsg){
        if(countChecked(obj,element)==0)
                alert(globalAlertMsg2);
        else{
                var inputdata = prompt(msg,defaultmsg);
                if (inputdata==null) return;
                else {
                data.value = inputdata;
                obj.action=page;
                obj.method="POST";
                obj.submit();
                }
        }
}

function countOption(obj){
        checkOption(obj);
        var j = 0;
        for(i=0; i<obj.length; i++){
                if(obj.options[i].selected == true){
                        j = j+1;
                }
        }
        return j;
}

function checkOption(obj){
        for(i=0; i<obj.length; i++){
                if(obj.options[i].value== ''){
                        obj.options[i] = null;
                }
        }
}

function checkOptionAll(obj){
        checkOption(obj);
        for(i=0; i<obj.length; i++){
                obj.options[i].selected = true;
        }
}

function checkOptionNone(obj){
        for(i=0; i<obj.length; i++){
                obj.options[i].selected = false;
        }
}
/*
function checkOptionAdd(obj, text, value){
        obj.options[obj.length] = new Option(text, value, false, false);
}
*/
function checkOptionAdd(obj, text, value, notAllowDuplicates) {
	var i;
	var found = false;
	if(notAllowDuplicates){
		for(i=0; i<obj.length; i++){
			if(obj.options[i].value == value){
				found = true;
				break;
			}
		}
	}
	if(!found){//not found or allowduplicates
		obj.options[obj.length] = new Option(text, value, false, false);
	}
}

function checkOptionRemove(obj){
        checkOption(obj);
        i = obj.selectedIndex;
        while(i!=-1){
                obj.options[i] = null;
                i = obj.selectedIndex;
        }
}

function checkOptionClear(obj){
        i = obj.length;
        while(i!=-1){
                obj.options[i] = null;
                i = i - 1;
        }
}

function checkOptionTransfer(from,to){
        checkOption(from);
        checkOption(to);
        i = from.selectedIndex;
        while(i!=-1){
                to.options[to.length] = new Option(from.options[i].text, from.options[i].value, false, false);
                from.options[i] = null;
                i = from.selectedIndex;
        }
}

// CMS identified JS functions

function csubmit(form) {
	if (checkform(form)) form.submit();
}

function check_text_multiple (objField, msg)
{
	for (i=0; i<objField.length; i++) {
		if (check_text(objField[i], msg) == false) return false;
	}

	return true;
}

// Change the UI language
function changeUILang(newLang)
{
	var s1 = location.toString();
	var s1hasQueryString = (s1.indexOf("?") >= 0);

	if (s1hasQueryString) {
		location = location + "&lang=" + newLang;
	} else {
		location = location + "?lang=" + newLang;
	}
}
function revertDisplay(obj) {
	var display = obj.style.display;
	obj.style.display = (display == '')? 'none' : '';
}

function play_in_doc(doc, filepath, imgpath){
	if(doc){
		if(IE){
			mplayer = doc.getElementById('MusicPlayer');
			
			mplayerclassid = mplayer.getAttribute('classid');//auxiliary for action judging
			if(mplayerclassid=='6BF52A52-394A-11D3-B153-00C04F79FAA6'){//wmp7/9/10
				mplayer.URL = filepath;
			}else{
				mplayer.FileName = filepath;
			}
		}else{
			mplayerdiv = doc.getElementById('MusicPlayer_div');
			var newcode ;
			newcode = '<object id="MusicPlayer" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95">'+
		'<param name="FileName" value="'+filepath+'">'+
		'<embed id="MusicPlayerEmbed" src="'+filepath+'" type="video/x-ms-wmv" autoStart="1" width="300" height="70"></embed>'+
		'</object>';
			mplayerdiv.innerHTML = newcode;
		}
		
		//lyrics pic
		if(doc.getElementById('img_swap')){
			if(imgpath){
				doc.getElementById('img_swap').src = imgpath;
				doc.getElementById('img_swap').style.visibility='visible';
			}else{
				doc.getElementById('img_swap').style.visibility='hidden';
			}
		}
	}
}


function showOnefromAmong(){
	var a=showOnefromAmong.arguments;
	if(a.length<2){return;}
	var show = a[0];
	var theElement;
	var i;
	if(show==''){
		for(i=1;i<a.length;i++){
			theElement = document.getElementById(a[i]);
			if(theElement){
				theElement.style.display = '';
			}
		}
	}else{
		for(i=1;i<a.length;i++){
			theElement = document.getElementById(a[i]);
			if(theElement){
				theElement.style.display = 'none';
			}
		}
		theElement = document.getElementById(a[0]);
		if(theElement){
			theElement.style.display = '';
		}
	}
}
-->
