﻿<!-- 
//控制ID
function $() {
    var elements = new Array();
    for (var ii = 0; ii < arguments.length; ii++) {
        var element = arguments[ii];
        if (typeof element == 'string') element = document.getElementById(element);
        if (arguments.length == 1) return element;
        elements.push(element);
    }
    return elements;
}

String.prototype.trim=function()
{
return this.replace(/(^\s*)|(\s*$)/g,"");
};
String.prototype.lTrim=function()
{
return this.replace(/(^\s*)/g,"");
};
String.prototype.rTrim=function()
{
return this.replace(/(\s*$)/g,"");
};
String.prototype.startsWith=function(s){
return this.indexOf(s)==0;
};
String.prototype.endsWith=function(s){
return this.indexOf(s)+s.length==this.length;
};
String.prototype.isEmpty=function(){
return this.trim()=='';
};
function displayChange(objId,objStyle) 
{ 
    if($(objId)!=null)
    $(objId).style.display = objStyle 
}
function getArgs() {
     var args = new Object( );
     var query = location.search.substring(1);      // Get query string
     var pairs = query.split("&");                  // Break at ampersand
     for(var i = 0; i < pairs.length; i++) {
         var pos = pairs[i].indexOf('=');           // Look for "name=value"
         if (pos == -1) continue;                   // If not found, skip
         var argname = pairs[i].substring(0,pos); // Extract the name
         var value = pairs[i].substring(pos+1);     // Extract the value
         value = decodeURIComponent(value);         // Decode it, if needed
         args[argname] = value;                     // Store as a property
     }
     return args;                                   // Return the object
}
//取得css一样的元素数组
function getElementsByClassName(className, parentElement) {
    var elems = ($(parentElement) || document.body).getElementsByTagName("*");
    var result = [];
    for (i = 0; j = elems[i]; i++) {
        if ((" " + j.className + " ").indexOf(" " + className + " ") != -1) {
            result.push(j);
        }
    }
    return result;
}

function dark( element, n )
{
	if(element==null)
	    var od = $("mask");
	else
	    var od = $("mask");
	od.style.zIndex		= 9;
	od.style.background = '#2a2a2a';
	od.style.display	= 'block';
	od.style.position	= 'absolute';

	var h = document.body.clientHeight;
	if( getBrowser() == 'ie' && h < window.screen.availHeight )
	{
		h = window.screen.availHeight + 'px';
	}

	var sh = document.body.scrollHeight;
	var wh = window.screen.availHeight;

	od.style.height = getBrowser() != 'ie' ? ( sh > wh ? sh : wh ) + 'px' : h;
	od.style.width  = getBrowser() != 'ie' ? '100%' : window.screen.width;
	//od.style.width = '100%';
	
	var size = getViewportSize();
	//od.style.height = size[1];
	//od.style.width = size[0];

	var num = n ? n : 40;
	od.style.filter  = "alpha(opacity=" + num + ")";
	od.style.opacity = num/100;
	od.style.MozOpacity  = num/100;
}
function getViewportSize()
{
  var size = [0, 0];

  if (typeof window.innerWidth != 'undefined')
  {
    size = [
        window.innerWidth,
        window.innerHeight
    ];
  }
  else if (typeof document.documentElement != 'undefined'
      && typeof document.documentElement.clientWidth != 'undefined'
      && document.documentElement.clientWidth != 0)
  {
    size = [
        document.documentElement.clientWidth,
        document.documentElement.clientHeight
    ];
  }
  else
  {
    size = [
        document.getElementsByTagName('body')[0].clientWidth,
        document.getElementsByTagName('body')[0].clientHeight
    ];
  }

  return size;
}
function light(element)
{
    if(element==null)
	    var od = $("mask");
	else
	    var od = $("mask");
	if( !od ) return false;
	od.style.display = 'none';
}

function ShowInfo(info, control)
{
    $(control).innerHTML = info || '';
}
function getBrowser()
{
	var bf = navigator.userAgent;
	if( bf.indexOf( "MSIE" ) != -1 )        return "ie";
	if( bf.indexOf( "Netscape" ) != -1 )    return "nc";
	if( bf.indexOf( "Opera" ) != -1)        return "op";
	if( bf.indexOf( "Firefox/2" ) != -1 )   return "ff2";
	if( bf.indexOf( "Firefox/1" ) != -1 )   return "ff1"
	return "ie";
}

function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}
function attachEventListener(target, eventType, functionRef, capture)
{
  if (typeof target.addEventListener != "undefined")
  {
    target.addEventListener(eventType, functionRef, capture);
  }
  else if (typeof target.attachEvent != "undefined")
  {
    target.attachEvent("on" + eventType, functionRef);
  }
  else
  {
    eventType = "on" + eventType;

    if (typeof target[eventType] == "function")
    {
      var oldListener = target[eventType];

      target[eventType] = function()
      {
        oldListener();

        return functionRef();
      }
    }
    else
    {
      target[eventType] = functionRef;
    }
  }

  return true;
}

function getEventTarget(event)
{
  var targetElement = null;

  if (typeof event.target != "undefined")
  {
    targetElement = event.target;
  }
  else
  {
    targetElement = event.srcElement;
  }

  while (targetElement.nodeType == 3 && targetElement.parentNode != null)
  {
    targetElement = targetElement.parentNode;
  }

  return targetElement;
}
function stopDefaultAction(event)
{
  event.returnValue = false;

  if (typeof event.preventDefault != "undefined")
  {
    event.preventDefault();
  }

  return true; 
}
function detachEventListener(target, eventType, functionRef, capture)
{
  if (typeof target.removeEventListener != "undefined")
  {
    target.removeEventListener(eventType, functionRef, capture);
  }
  else if (typeof target.detachEvent != "undefined")
  {
    target.detachEvent("on" + eventType, functionRef);
  }
  else
  {
    target["on" + eventType] = null;
  }

  return true;
}
function htmlEncode (str){
   var div = document.createElement("div");
   var text = document.createTextNode(str);
   div.appendChild(text);
   return div.innerHTML;
}

function htmlDecode (str){
    var div = document.createElement("div");
   div.innerHTML = str;
   return div.innerText;
}
// -->
