//-----------------------------------------------------------
// 文件名称: Web25175_Hotel2.tipinputhelp.v1.1.js
// 页面名称: Web25175_Hotel2.tipinputhelp.v1.1
//　
// 描    述: 批量帮助提示
// 版　　本: 1.1
// 兼容情况: IE6+,Chrome,Mozilla, Netscape, Firefox,Maxthon3+,
// 创建标识: Add By 吴希 2011-12-07
//------------------------------------------------------------------------------------------
InputHelp = function() {
    this.Init();
}
InputHelp.prototype = {
    Init: function() {
        this.Fun = this;
    },
    Load: function(id) {
        var Fun = this.Fun
        var ele = uiGet(id);
        if (ele != null) {
            ele.style.cursor = "pointer";
            ele.onclick = function() {
                Fun.Show(ele);
            }
        }
    },
    Show: function(ele) {
        var div = uiGet("TipInputHelp");
        if (div) {
            if (div.style.visibility == "visible") {
                div.style.visibility = "hidden";
            } else {
                div.style.top = uiGetPosition(ele).y + uiGetPosition(ele).height + 3 + "px";
                div.style.left = uiGetPosition(ele).x + "px";
                div.style.visibility = "visible";
            }
        } else {
            div = document.createElement("div");
            div.id = "TipInputHelp";
            with(div.style) {
                fontSize = "9px";
                borderTop = "gray 1px solid";
                borderRight = "gray 1px solid";
                borderLeft = "gray 1px solid";
                borderBottom = "gray 1px solid";
                paddingTop = "4px";
                paddingLeft = "4px";
                paddingRight = "4px";
                zIndex = "100";
                filter = "progid:dximagetransform.microsoft.shadow(color=gray,direction=120)";
                visibility = "visible";
                paddingBottom = "4px";
                position = "absolute";
                backgroundColor = "#ffffff";
                top = uiGetPosition(ele).y + uiGetPosition(ele).height + 3 + "px";
                left = uiGetPosition(ele).x + "px";
            }
            var content = "";
            content += '<table width="330" height="100" border="0" cellpadding="3" cellspacing="0">';
            content += '<tr>';
            content += '        <td  align="left" valign="top" style="background-color:#F79E97;font-size:12px;height:18px">';
            content += '         <div style="width:330px; height:18px;padding-bottom:5px">';
            content += '              <div style="float:left; width:100px;border:1px solid #F79E97; padding:1px;">帮助</div>';
            content += '             <div style="float:right; width:25px; border:1px solid gray; padding:1px;padding-left:3px; padding-right:3px; background-color:#FBC4BF;cursor:pointer" onclick="TipInputHelp.Hide()">关闭</div>';
            content += '         </div>';
            content += '       </td>';
            content += '   </tr>';
            content += '  <tr>';
            content += '    <td  align="left" valign="top">';
            content += '    <ul>';
            content += '        <li  style="font-size:12px">公式一：&lt;?&gt; ;说明：按录入项进行编码;</li>';
            content += '        <li  style="font-size:12px">公式二：&lt;数字-?&gt; 说明：按数字+录入项进行编码;';
            content += '         <ul>';
            content += '           <li  style="font-size:12px">例如：&lt;100-?&gt;：从 100 至 100+录入项</li>';
            content += '         </ul>';
            content += '       </li>';
            content += '     </ul>';
            content += '    </td>';
            content += '</tr>';
            content += '</table>';
            div.innerHTML = content;
            document.body.appendChild(div);
            

        }
    },
    Hide: function() {
        var div = uiGet("TipInputHelp");
        if (div) {
            div.style.visibility = "hidden";
        }
    },
    SetCursor:function(ele){
        this.cursor=ele;
        if (ele.createTextRange) {
            ele.caretPos = document.selection.createRange().duplicate();
        }
    },
    Insert:function(value)
    {
        if (document.all) {
            if (this.cursor.createTextRange && this.cursor.caretPos) {
                var caretPos = this.cursor.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '   ' ? value + '   ': value;
            } else {
                this.cursor.value = textFeildValue;
            }
        } else {
            if (this.cursor.setSelectionRange) {
                var rangeStart = this.cursor.selectionStart;
                var rangeEnd = this.cursor.selectionEnd;
                var tempStr1 = this.cursor.value.substring(0, rangeStart);
                var tempStr2 = this.cursor.value.substring(rangeEnd);
                textObj.value = tempStr1 + value + tempStr2;
            } else {
                alert("很抱歉！当前的浏览器不支持 setSelectionRange");
            }
        }
    }
}
var TipInputHelp = new InputHelp();

