﻿<!--

function CheckExt(f,allowexts)
{	       
  var   reg=/([^\.]+)$/.exec(f);   
  var ext = (RegExp.$1).toLowerCase();   
  var exts = allowexts.split("|");
  var allow = false;
  for(i=0;i<exts.length;i++)
  {
    if(exts[i] == ext)
    {
	  allow = true;
	  break;
	}
  }
  return allow;
}

function ResetFileCtrl(ctrl)
{
     var hiddenForm = document.getElementById("hiddenResetForm");
     var oTemp = document.createElement("<DIV id=tempResetPos>dd</DIV>");
     ctrl.parentNode.insertBefore(oTemp, ctrl);
     hiddenForm.appendChild(ctrl);
     hiddenForm.reset();
     hiddenForm.removeChild(ctrl); 
     oTemp.parentNode.insertBefore(ctrl,oTemp);
     oTemp.parentNode.removeChild(oTemp);
}

function GetParamValueFromQueryString(ParamName)
{
    var sValue=location.search.match(new RegExp("[\?\&]"+ParamName+"=([^\&]*)(\&?)","i"));
    return sValue?sValue[1]:sValue;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)}; 


function fRandomBy(under, over)
{ 
    switch(arguments.length)
    { 
        case 1: return parseInt(Math.random()*under+1); 
        case 2: return parseInt(Math.random()*(over-under+1) + under); 
        default: return 0; 
    } 
} 

function FixupUrl(url)
{
    var appDir = '';
    if(url.substr(0,2) == "~/")
    {
        if(typeof g_appDir == 'undefined')
        {
            // get the application dir
            this.g_appDir = '';
        }
        else
        {
            appDir = g_appDir;
        }
        
        url = appDir + url.substr(1);
    }
    
    return url;
}

// 表示处理图片列表的类
function ImageSelect()
{
    this.Position = 0;
    this.ImageList = null;
    this.ResourceList = null;
    
    this.Step = function(step) {
        if(this.ImageList == null) return;
        
        p1 = this.Position + step;
        p2 = this.ImageList.length;
        this.Position = p1 % p2;
        if(this.Position < 0)
            this.Position = p2 + this.Position;
        
        return this.ImageList[this.Position];
    };
    this.ReturnResourceId = function(){
        return this.ResourceList[this.Position];
    }
}


//-->