﻿// JScript 文件

// 在新窗口中打开一个网页
function OpenWindow(url, title, width, height, top, left)
{
    var argString = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes," +
    "width=" +width + ",height=" + height + ", top=" + top +", left=" + left;
    var newWindow = open(url, title, argString);
    newWindow.focus();
}

function OpenWindowFullScreen(url, title)
{
    var argString = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,fullscreen=yes";
    var newWindow = open(url, title, argString);
    newWindow.focus();
}

// 在屏幕中央打开一个新窗口
function OpenWindowOnScreenCenter(url, title, width, height)
{
    swidth = screen.width - width;
    sheight = screen.height - height;
    var left = swidth / 2;
    var top = sheight / 2;
    var argString = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no," +
    "width=" +width + ",height=" + height + ", top=" + top +", left=" + left;
    var newWindow = open(url, title, argString);
    newWindow.focus();
}

function OpenNormalWindow(url, title)
{
    var newWindow = open(url, title);
    newWindow.focus();
}

// 获取指定的QueryString
function GetQueryString(fieldname)
{
    var urlstring = document.location.search;
    if(urlstring != null)
    {
         var typequ = fieldname+"=";
         var urlend = urlstring.indexOf(typequ);
         if(urlend != -1)
         {
              var paramsurl = urlstring.substring(urlend+typequ.length);
              var isend =  paramsurl.indexOf('&');
              if(isend != -1)
              {
                   return paramsurl.substring(0, isend);
              }
              else
              {
                  return paramsurl;
              }
         }
         else 
         return null;
    }
    else
        return null;
}

// 无询问关闭窗口
function CloseWindow()
{
    window.opener=null; 
    window.close()
}

function Redirect(url)
{
    window.location = url;
}

function Deletecookie (name)
{ //删除名称为name的Cookie 
var exp = new Date(); 
exp.setTime (exp.getTime() - 1); 
var cval = GetCookie (name); 
documents.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); 
}

//去左空格; 
function TrimStart(s){ 
return s.replace( /^\s*/, ""); 
} 
//去右空格; 
function TrimEnd(s){ 
return s.replace( /\s*$/, ""); 
} 
//去左右空格; 
function Trim(s){ 
return TrimStart(TrimEnd(s)); 
}
