﻿/**
* 清除字符串中的HTML
*/
String.prototype.stripHTML = function () {
var reTag = /<(?:.|\s)*?>/g;
return this.replace(reTag, "");
};

//删除字符串两端的空格
String.prototype.trim = function()  {  
  return  this.replace(/(^\s*)|(\s*$)/g,"");  
}  
//删除字符串左端的空格
String.prototype.trimStart = function(){  
return  this.replace(/(^\s*)/g,  "");  
}  
  //删除字符串右端的空格
String.prototype.trimEnd = function(){  
  return  this.replace(/(\s*$)/g,  "");  
} 

/**
* 可变字符字符串
*/
this.StringBuilder = function () {
    this.__strings__ = new Array;
}
this.StringBuilder.prototype.append = function (str) {
    this.__strings__.push(str);
};
this.StringBuilder.prototype.toString = function () {
    return this.__strings__.join("");
};
/**
* 格式化字符串
*/
String.format = function(){
    if( arguments.length == 0 ){
        return null; 
    }
    var str = arguments[0]; 
    for(var i=1;i<arguments.length;i++){
       var re = new RegExp('\\{' + (i-1) + '\\}','gm');
       str = str.replace(re, arguments[i]);
    }
    return str;
}
function IsNull(value){
	return (typeof(value) == "undefined" || value == null);
}
/**
* 设置Cookie
*/
function setCookie(name, value, hours) {
  var expire = "";
  if(hours != "") {
    expire = new Date((new Date()).getTime() + hours * 60 * 60 * 1000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value);
}
/**
* 读取Cookie
*/
function getCookie(name){
    var re = new RegExp(name+"=[^;]+", "i");
    if (document.cookie && document.cookie != '') { 
        var arr = document.cookie.match(re);
        if(arr){
	        return unescape(arr[0].split("=")[1]);
        }
    } 
    return "";
}
function goURL(url){
  window.location = url;
}
/*父窗口打开网址*/
function openURL(url){
    if(url&& window.parent){
      window.parent.location.href = url;
    }
}
/*判断浏览器版本*/
var isIE = navigator.userAgent.indexOf("MSIE") > 0;
var isFirefox = navigator.userAgent.indexOf("Firefox") > 0;
var isSafari = navigator.userAgent.indexOf("Safari") > 0;
var isCamino = navigator.userAgent.indexOf("Camino") > 0;
var isMozilla = navigator.userAgent.indexOf("Gecko") > 0;
var isIE6 = isIE7 = false;
if(isIE){
    if(navigator.appVersion.match(/MSIE 7./i)=='MSIE 7.'){
       isIE7 = true;
    }
    if(navigator.appVersion.match(/MSIE 6./i)=='MSIE 6.'){
       isIE6 = true;
    }
}

/* 显示IFrame 遮罩窗口 iheight:窗口高度 iwidth:窗口宽度 bwidth:边框大小*/
function frameDialog(url, iheight, iwidth, bwidth){
      var borderWidth = "4px";
      if(bwidth!=null)
         borderWidth = bwidth;
	  window.scrollTo(0, 0);
      var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
      var height = document.documentElement.clientHeight + document.documentElement.scrollTop;
      var layer = document.createElement('div'); 
      layer.style.zIndex = 9998;
      layer.id = 'layer';
      layer.style.position = 'absolute';
      layer.style.top = '0px';
      layer.style.left = '0px';
      if(document.documentElement.scrollHeight > height){
        layer.style.height = document.documentElement.scrollHeight + 'px';
      }else{
        layer.style.height = height + 'px';
      }
      layer.style.width = width + 'px';
      layer.style.backgroundColor = 'black';
      layer.style.opacity = '.6';
      layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=60)");
      document.body.style.position = 'static';
      document.body.appendChild(layer);  
      var size = { 'height': iheight, 'width': iwidth };
      var iframe = document.createElement('iframe');
      iframe.name = 'moduleEditor';
      iframe.id = 'moduleEditor';
      if (url.indexOf('?')>0)
         url=url+"&ttime="+Date();
  
      iframe.src = url;
      iframe.style.height = size.height + 'px';
      iframe.style.width = size.width + 'px';
      iframe.style.position = 'absolute';
      iframe.style.zIndex = 9999;
      iframe.style.backgroundColor = 'white';
	  iframe.style.border = '0px solid silver';
	  iframe.style.borderWidth = borderWidth;
	  iframe.frameborder = '0px';	
	  iframe.style.marginWidth = '0px';
      iframe.style.top = ((height + document.documentElement.scrollTop) / 2) - (size.height / 2) + 'px';
      iframe.style.left = (width / 2) - (size.width / 2) + 'px';
      document.body.appendChild(iframe);  
}
/* 关闭IFrame 遮罩窗口*/
function closeEditor(){      
      document.body.removeChild(document.getElementById('moduleEditor'));
      document.body.removeChild(document.getElementById('layer'));
      document.body.style.position = '';
}
/*图片尺寸修改*/
function changeImg(img,maxW,maxH){
                //如果图像是未加载完成进行循环检测
                if(img.readyState!="complete")  {
                    setTimeout("resizeImage(img)",500);
                    return false;
                }
                var maxWidth = maxW;//设置图片宽度界限 
                var maxHeight = maxH;//设置图片高度界限 
                var heightWidth = img.height / img.width;//设置高宽比 
                var widthHeight = img.width / img.height;//设置宽高比 
                if(img.width > maxWidth){ 
                    img.width = maxWidth; 
                    img.height = maxWidth * heightWidth; 
                } 
                if(img.height > maxHeight){ 
                    img.height = maxHeight; 
                    img.width = maxHeight * widthHeight; 
    }
}
/*滚动广告*/
function scrollBanner(timer, moveNumber){  
function move(o){ 
var st = document.documentElement.scrollTop + o.t;  
var sl = document.documentElement.scrollLeft + (o.c == 0 ?o.a:document.documentElement.clientWidth - o.a - o.offsetWidth); 
var tc = st - o.offsetTop,lc = sl - o.offsetLeft;  
with(o.style){ 
top = o.offsetTop + (tc != 0?tc/Math.abs(tc):0) * Math.min(Math.abs(tc),moveNumber) +"px";  
left = o.offsetLeft +(lc != 0?lc/Math.abs(lc):0) * Math.min(Math.abs(lc),moveNumber) + "px"; 
}  
if(o.person){ 
with(o.person.style){  
top = o.offsetTop + "px"; 
left = o.offsetLeft + o.offsetWidth - o.person.offsetWidth + "px";  
} 
}  
} 
var hidden = function(){  
var o= this.parent; 
window.clearInterval(o.interval);  
o.parentNode.removeChild(o); 
this.parentNode.removeChild(this);  
} 
this.add = function(to,t,a,c,lo){  
/* 
to为object对象  
t为距离顶端距离 
当c   =   0的时候，a为距离左边的距离  
当c   !=   0的时候，a为距离右边的距离 
lo为关闭按钮  
*/ 
var div,exec = function(){  
move(to); 
};  
to.person = lo; 
to.t = t;  
to.a = a; 
to.c = c;

with(to.style){ 
position = "absolute";  
display = "block"; 
top = document.documentElement.scrollTop + t;  
left = document.documentElement.scrollLeft + (c == 0?a:document.documentElement.clientWidth - a - to.offsetWidth); 
}
if(lo!=null){  
if("undefined"!=typeof lo){ 
with(lo.style){  
position = "absolute"; 
display = "block";  
} 
lo.onmousedown = hidden;  
lo.parent = to; 
}
}  
exec(); 
to.interval = window.setInterval(exec,timer);  
}; 
}

jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};
window.onerror = function(){return true;}


/* 显示IFrame 遮罩窗口 iheight:窗口高度 iwidth:窗口宽度 bwidth:边框大小*/
function DivDialog(){
      var borderWidth = "1px";
	  window.scrollTo(0, 0);
      var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
      var height = document.documentElement.clientHeight + document.documentElement.scrollTop;
      var layer = document.createElement('div'); 
      layer.style.zIndex = 9998;
      layer.id = 'layer';
      layer.style.position = 'absolute';
      layer.style.top = '0px';
      layer.style.left = '0px';
      if(document.documentElement.scrollHeight > height){
        layer.style.height = document.documentElement.scrollHeight + 'px';
      }else{
        layer.style.height = height + 'px';
      }
      layer.style.width = 2000 + 'px';
      layer.style.backgroundColor = 'silver';
      layer.style.opacity = '0.1';
      layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=15)");
      document.body.style.position = 'static';
      document.body.appendChild(layer);
      

}