if(document.URL.indexOf('http://dapeiwang.com')>-1)
location.href=document.URL.replace('http://dapeiwang.com', "http://www.dapeiwang.com");
function Browser(){
    var ua, s, i;
    this.isIE = false;
    this.isNS = false;
    this.isOP = false;
    this.isSF = false;
    ua = navigator.userAgent.toLowerCase();
    s = "opera";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isOP = true;
        return;
    }
    s = "msie";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isIE = true;
        return;
    }
    s = "netscape6/";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isNS = true;
        return;
    }
    s = "gecko";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isNS = true;
        return;
    }
    s = "safari";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isSF = true;
        return;
    }
}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    } else if (obj.x) curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    } else if (obj.y) curtop += obj.y;
    return curtop;
}

function isEmail(str) {
    return checkData(str, /^[\w_-]+([\.\\w_-]*[\w_-]+)?@[\w-]+\.[a-zA-Z]+(\.[a-zA-Z]+)?$/);
}

function trim(str) {
    return str.replace(/(^\s*)|(\s*$)/g, "");
}

function isInt(str) {
    return checkData(str, /^-?[0-9]+$/);
}

function checkData(str, pattern) {
    if (pattern.test(str)) {
        return true;
    } else {
        return false;
    }
}

function Div(exp1, exp2)
{
    var n1 = Math.round(exp1); //四舍五入
    var n2 = Math.round(exp2); //四舍五入

    var rslt = n1 / n2; //除

    if (rslt >= 0)
    {
        rslt = Math.floor(rslt); //返回值为小于等于其数值参数的最大整数值。
    }
    else
    {
        rslt = Math.ceil(rslt); //返回值为大于等于其数字参数的最小整数。
    }

    return rslt;
}

function sleep(numberMillis) {
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;

    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
            return;
    }
}

function removeElementById(id) {
    var obj = document.getElementById(id);
    if (null==obj) return;
    obj.parentNode.removeChild(obj);
}
function removeElement(el) {
    var p=el.parentNode;
    p.removeChild(el);
}
function escapeHTML(palinText) {
//  var div = document.createElement('div');
//  var text = document.createTextNode(palinText);
//  div.appendChild(text);
//  return div.innerHTML;
    return palinText.replace(/</gi , "&lt;").replace(/>/gi , "&gt;");
}

function unescapeHTML(htmlText) {
    return htmlText.replace(/&lt;/gi , "<").replace(/&gt;/gi , ">").replace(/&#39;/gi, "\'").replace(/&#34;/gi, "\"").replace(/&amp;/gi, "&").replace(/&#37;/gi, "%").replace(/＄/gi, "$");
}

/**
function unescapeHTML(htmlText) {
    var div = document.createElement('div');
    div.innerHTML = stripTags(htmlText);
    return div.childNodes[0].nodeValue;
}
**/

function evalCallBack(callbackObj) {
    if (typeof callbackObj == "string")
        location.href=callbackObj;
    else if (callbackObj instanceof Array)
    {
        var func = callbackObj[0] + "(";
        for (i = 1; i < callbackObj.length; i++)
        {
            if (i != 1)
                func += ",";
            func += "'" + callbackObj[i].replace(/\n/g,"\\n").replace(/\r/g,"\\n").replace(/\'/g,"\\'") + "'";
        }
        func += ")";
        eval("(" + func + ")");
    } else {
        var form = eval(callbackObj);
        try
        {
            form.submit();
        }
        catch (e)
        {
        }
    }
}


function textOnfocus(text, className){
    if (text.value == text.title) 
        text.value = "";
    text.className = className;
}

function textOnblur(text, className){
    if (text.value.length < 1) {
        text.value = text.title;
        text.className = trim(className).length<1 ? "" : className;
    } else {
        if (text.value == text.title) {
            text.className = trim(className).length<1 ? "" : className;
        }
    }
}
function initText(text, className){
    text.value = text.title;
    if (trim(className).length<1)
    {
        text.className="";
    }
    else text.className = className;
}
function isPunct(src) {
    var regex = /!|"|#|\$|%|&|'|\(|\)|\*|\+|,|-|\.|\/|:|;|<|=|>|\?|@|\[|\|]|\^|_|`|\{|\||}|~/;
    return regex.test(src);
}
function isPunct2(src) {
    var regex = /%|"|#|\$|%|&|'|~/;
    return regex.test(src);
}
function copyToClipboard(txt) {
    if(window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
        alert("复制好了，按 CTRL + V 粘贴到BBS、博客里去吧！");
    } else if(navigator.userAgent.indexOf("Opera") != -1) {
        window.location = txt;
        alert("复制好了，按 CTRL + V 粘贴到BBS、博客里去吧！");
    } else if (window.netscape) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } catch (e) {
            alert("您正在使用的功能被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
        }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip)
            return;   
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans)
            return;   
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = txt;
        str.data = copytext;
        trans.setTransferData("text/unicode",str,copytext.length*2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip)
            return false;   
        clip.setData(trans,null,clipid.kGlobalClipboard);
        alert("复制好了，按 CTRL + V 粘贴到BBS、博客里去吧！");
    }
}

function validateImageFile(imageElementId, imageRequired, fileNameId, imageErrorEleId,errorMessage){
    if(typeof imageRequired == "undefined"){
        imageRequired = true;
    }
    if(typeof errorMessage == "undefined"){
        errorMessage = '图片格式错误. 请上传后缀为 JPG, JPEG, GIF, 或 PNG 格式的图片.';
    }
    var imageUrl = document.getElementById(imageElementId).value;

      if(imageUrl == ""){
        if(imageRequired){
            document.getElementById(imageErrorEleId).innerHTML = errorMessage;
         setInputFocus(imageElementId);
        }
        return (!imageRequired);
      }
     
        var isValidFileCheckForIE = true;
      if ( navigator.appVersion.indexOf("MSIE") >= 0) {
        var arVersion = navigator.appVersion.split("MSIE")
        var version = parseFloat(arVersion[1])
        if (version < 7.0) {
           
          isValidFileCheckForIE = (imageUrl.indexOf(":") == 1); 
        }
       }  
              
    if(!isValidFileCheckForIE){
      document.getElementById(imageErrorEleId).innerHTML = '请指定一个正确的路径';
        setInputFocus(imageElementId);
      return false;
    } 
     
    if(!(imageUrl == "") && isValidFileCheckForIE) {
        
      var ext = imageUrl;
      var result = ext.lastIndexOf('.'); 
        
      if (result != -1) {
        ext = ext.substr(result+1).toLowerCase();
      }
      else{
        ext="";
      }
      ext=ext.toLowerCase();
      if((ext == "jpeg") || (ext == "jpg") || (ext == "gif") || (ext == "png")){
        
        if(typeof fileNameId != "undefined" && fileNameId !=null){

         var fileNameEle = document.getElementById(fileNameId);
           fileNameEle.value = imageUrl;
        }
        if(typeof imageErrorEleId != "undefined" && imageErrorEleId !=null){
         document.getElementById(imageErrorEleId).innerHTML = '';
        }
        return true;
      }
      if(typeof imageErrorEleId != "undefined" && imageErrorEleId !=null){
          document.getElementById(imageErrorEleId).innerHTML = errorMessage;  
      }
      
      setInputFocus(imageElementId);
      
      return false;
    }  
}
function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
function IsURL(str_url){
  var strRegex = "^((https|http|ftp|rtsp|mms)?://)" 
  + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@ 
        + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184 
        + "|" // 允许IP和DOMAIN（域名）
        + "([0-9a-z_!~*'()-]+\.)*" // 域名- www. 
        + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名 
        + "[a-z]{2,6})"; // first level domain- .com or .museum 
        + "(:[0-9]{1,4})?" // 端口- :80 
        + "((/?)|" // a slash isn't required if there is no file name 
        + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; 
        var re=new RegExp(strRegex); 
        if (re.test(str_url)){
            return (true); 
        }else{ 
            return (false); 
        }
    }
    
    function IsURL(urlString)
{
        var regExp = /(http[s]?|ftp):\/\/[^\/\.]+?\..+[\w\W]$/i;;
        if (urlString.match(regExp))return true;
        else return false;        
}

    function setInputFocus(elementId){
    theInput=$(elementId);
        if(typeof(theInput.length) == "undefined")
            theInput.focus();
        else if(theInput.length > 1)
            theInput[0].focus();
        else
            theInput.focus();
    }

function $() {
    var elements = new Array();
    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];

        if (typeof element == 'string')
            element = document.getElementById(element);

        if (arguments.length == 1)
            return element;

        elements.push(element);
    }

    return elements;
}
function showTopicTab(index){
    for(var i=0; i<2; i++){
        if(i != index){
            hideElmt("tab" + i + "data");               
            var tab = document.getElementById("tab" + i);           
            if(tab != null){
                tab.className = "";
            }
        }
    }
    var tab = document.getElementById("tab" + index);   
    if(tab){
        tab.className = "selected";
    }
    showElmt("tab" + index + "data");
}
function hideElmt(elemID) {
  var elem = document.getElementById(elemID);
  elem.style.display = 'none';
}
function showElmt(elemID) {
  var elem = document.getElementById(elemID);
  elem.style.display = '';
}

//getbyClassName
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 DrawImage(ImgD,FitWidth,FitHeight){
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
         if(image.width/image.height>= FitWidth/FitHeight){
             if(image.width>FitWidth){
                 ImgD.width=FitWidth;
                 ImgD.height=(image.height*FitWidth)/image.width;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             }
         } else{
             if(image.height>FitHeight){
                 ImgD.height=FitHeight;
                 ImgD.width=(image.width*FitHeight)/image.height;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             } 
        }
     }
 }
 //去左右空格
String.prototype.trim　= function()      
{      
    // 用正则表达式将前后空格      
    // 用空字符串替代。      
    var t = this.replace(/(^\s*)|(\s*$)/g, "");    
    return t.replace(/(^　*)|(　*$)/g, "");    
} 
function highlight(obj, isTeen) {
    obj.className='sb-item-border';
}

function hideSelection(obj){
    obj.className= '';
}
function checkuploadfile(fileElm)
    { 
var fileext=fileElm.value.substring(fileElm.value.lastIndexOf("."),fileElm.value.length);   
    fileext=fileext.toLowerCase();   
if ((fileext!='.jpg')&&(fileext!='.gif')&&(fileext!='.jpeg')&&(fileext!='.bmp'))   
       {   
        alert("对不起，系统仅支持标准格式的照片，请您调整格式后重新上传，谢谢 !"); 
        return false;
        }
        return true;
}

//拖动
function dragdiv(o,s)  
{  
    if (typeof o == "string") o = document.getElementById(o);  
    o.orig_x = parseInt(o.style.left) - document.body.scrollLeft;  
    o.orig_y = parseInt(o.style.top) - document.body.scrollTop;  
    o.orig_index = o.style.zIndex;  
          
    o.onmousedown = function(a)  
    {  
       // this.style.cursor = "move";  
        this.style.zIndex = 10000;  
        var d=document;  
        if(!a)a=window.event;  
        var x = a.clientX+d.body.scrollLeft-o.offsetLeft;  
        var y = a.clientY+d.body.scrollTop-o.offsetTop;  
        d.ondragstart = "return false;"  
        d.onselectstart = "return false;"  
        d.onselect = "document.selection.empty();"  
                  
     /*   if(o.setCapture)  
            o.setCapture();  
        else if(window.captureEvents)  
            window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  
*/
        d.onmousemove = function(a)  
        {  
            if(!a)a=window.event;  
            o.style.left = a.clientX+document.body.scrollLeft-x;  
            o.style.top = a.clientY+document.body.scrollTop-y;  
            o.orig_x = parseInt(o.style.left) - document.body.scrollLeft;  
            o.orig_y = parseInt(o.style.top) - document.body.scrollTop;  
        }  

        d.onmouseup = function()  
        {  
          /*  if(o.releaseCapture)  
                o.releaseCapture();  
            else if(window.captureEvents)  
                window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);  
         */
            d.onmousemove = null;  
            d.onmouseup = null;  
            d.ondragstart = null;  
            d.onselectstart = null;  
            d.onselect = null;  
            o.style.cursor = "normal";  
            o.style.zIndex = o.orig_index;  
        }  
    }  
      
    if (s)  
    {  
        var orig_scroll = window.onscroll?window.onscroll:function (){};  
        window.onscroll = function ()  
        {  
            orig_scroll();  
            o.style.left = o.orig_x + document.body.scrollLeft;  
            o.style.top = o.orig_y + document.body.scrollTop;  
        }  
    }  
}  

function replaceTextarea1(str){
    var reg=new RegExp("\r\n","g");
    str = str.replace(reg,"<br>");
    str=str.replace(/\&/g,"%26");
    return str;
}


function replaceTextarea2(str){
    var reg=new RegExp("<br>","g");
    str = str.replace(reg,"\r\n");
    var reg=new RegExp("<BR>","g");
    str = str.replace(reg,"\r\n");
    return str;
}
 function setCookie(name,value,rr){
    var exp  = new Date();   
    exp.setTime(exp.getTime() + rr); 
    document.cookie = "_"+name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
}
function getCookie(name)
{ 
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); 
     if(arr != null) return unescape(arr[2]); return ""; 

} 
function getkeywords(context){
var str =context
var maxLength = 0;
var keywordslist=new Array("西服","风衣","大衣","夹克","马甲","棉衣","羽绒服","毛衣","针织衫","T恤","衬衫","蕾丝衫","吊带","背心","打底衫","卫衣","休闲裤","牛仔裤","正装裤","打底裤","半身裙","连衣裙","牛仔裙","运动衣","运动套装","运动裤","运动裙","内衣","内裤","文胸","平底单鞋","中跟单鞋","高跟单鞋","休闲皮鞋","雪地靴","短靴","及踝靴","中筒靴","棉靴","高筒靴","过膝靴","凉鞋","凉拖","凉靴","篮球鞋","跑步鞋","网球鞋","足球鞋","训练鞋","羽毛球鞋","乒乓球鞋","板鞋","家居鞋","休闲鞋","休闲皮鞋","帆布鞋","布鞋","增高鞋","功能鞋","单肩包","斜挎包","手提包","单肩包","手包","多功能包","钱包","双肩包","公文包","旅行包","配件小包","项链","耳环","耳钉","戒指","发饰","手镯","手链","脚链","胸针","手表","DIY原创","帽子","头巾","太阳镜","围巾","披肩","领带","领结","皮带","背带","腰带","手套","手帕","外套","上衣","裤子","裙子","运动装","单鞋","靴子","凉鞋","运动鞋","女包","男包","钱包","首饰","头饰","颈饰","腰饰","明星","模特","街拍","化妆","家居","玩偶","数码","女装","男装","女鞋","男鞋","箱包","配饰");
var keywords=",,";
var i=0;
while(str!=''&&i<(keywordslist.length-1)){ //循环迭代开始，并判断字符串是否为空
var oldStr = str;
var getStr=keywordslist[i];
str = str.replace(new RegExp(getStr,"g"),""); 
if((oldStr.length-str.length)/(getStr.length) >= maxLength) {
maxLength = (oldStr.length-str.length)/(getStr.length);
keywords=getStr+","+keywords;
}
if(i<(keywordslist.length-1))
i++;
}
//return keywords;
if (keywords==",,")
keywords="服装搭配,服饰搭配,搭配网";
var ll=keywords.split(',');
return ll[0]+","+ll[1]+","+ll[2]; //弹出结果
}
var smail_title="";
var smail_body="";