﻿// JScript File
	FillText = null;
	function UploadFile( objText, upFolder, maxSize, upType, upRename ){
		FillText = objText;
		if(upRename)
		    OpenCenterWin( "../include/upload.aspx?ts=1&upFolder="+upFolder+"&maxSize="+maxSize+"&upType="+upType, 350, 200, "status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no" );
		else
		    OpenCenterWin( "../include/upload.aspx?upFolder="+upFolder+"&maxSize="+maxSize+"&upType="+upType, 350, 200, "status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no" );
	}
	function PickDate( objText ){
		FillText = objText;
		OpenCenterWin( "../include/datepicker.aspx?evtDate="+objText.value, 240, 280, "status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no" );
	}
	function OpenCenterWin( TargetURL, OpenWidth, OpenHeight, Features ){
		LeftPos = ( screen.availWidth - OpenWidth ) / 2;
		TopPos = ( screen.availHeight - OpenHeight ) / 2;
		if( Features != "" ) Features += ",";
		Features += "width=" + OpenWidth + ",height=" + OpenHeight + ",left=" + LeftPos + ",top=" + TopPos;
		window.open( TargetURL, null, Features );
	}
	function SelectMenu( objVal, objText ){
	    var res = window.showModalDialog( "../sys/modal.aspx?page=MenuPicker.aspx&iniMenu=" + objVal.value, "", "dialogWidth=420,dialogHeight=260" );
	    if( res != undefined ){
	        objVal.value = res.split(',')[0];
	        objText.innerHTML = res.split(',')[1];
	    }
	}
	function ShowModalPage( TargetURL, OpenWidth, OpenHeight ){
	    return window.showModaldialog( TargetURL, "", "resizable=0,dialogWidth=" + OpenWidth + ",dialogHeight=" + OpenHeight + ",scroll=0,status=0")
	}
	
	function DoAction(){
        var btnPostBack = null;
        for( i = 0 ; i < document.getElementsByTagName("input").length ; i++ ){
            var strName = document.getElementsByTagName("input")[i].name;
            if( strName.indexOf("__DoAction") != -1 ) document.getElementsByTagName("input")[i].value = arguments[0];
            if( strName.indexOf("btnDoAction") != -1 ) btnPostBack = document.getElementsByTagName("input")[i];
        }
        if( btnPostBack != null ) btnPostBack.click();
	}

    function ResizeIMG( objImg , Wbound, Hbound)
    {
	    var w = Wbound / objImg.width;
	    var h = Hbound / objImg.height;
	    if( w<1 && h<1)
	    {
		    if( w>h )
		    {
			    objImg.width = objImg.width * Wbound / objImg.width;
			    objImg.height = objImg.height * Wbound / objImg.width;
		    }
		    else
		    {
			    objImg.width = objImg.width * Hbound / objImg.height;
			    objImg.height = objImg.height * Hbound / objImg.height;
		    }
	    }
	    else if( w<1 )
	    {
		    objImg.width = objImg.width * Wbound / objImg.width;
		    objImg.height = objImg.height * Wbound / objImg.width;
	    }
	    else if( h<1 )
	    {
			    objImg.width = objImg.width * Hbound / objImg.height;
			    objImg.height = objImg.height * Hbound / objImg.height;
	    }
    }
    
    function MultiUploadSelectAll(){
        var objCbxs = document.getElementsByTagName("INPUT");
        for(var i=0;i<objCbxs.length;i++)
        {
            if(objCbxs[i].type=='checkbox' && objCbxs[i].id.indexOf('cbxSelected')>0)
                objCbxs[i].checked=true;
        }
    }
    function MultiUploadSelectNone(){
        var objCbxs = document.getElementsByTagName("INPUT");
        for(var i=0;i<objCbxs.length;i++)
        {
            if(objCbxs[i].type=='checkbox' && objCbxs[i].id.indexOf('cbxSelected')>0)
                objCbxs[i].checked=false;
        }
    }
    function ScriptDisplay(DivId){
        var obj=document.getElementById(DivId);
        if(obj!=null){
            obj.style.display=(obj.style.display=='none')?'block':'none';
        }
    }