<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
    function sendsms()                                                                                                            
        {                                                                                                                             
                var  msg= document.getElementById("msg_txt").value;                                                               
        var  mob_num= document.getElementById("mob").value;
            var args,mbs;
                args = encodeURIComponent(msg);
                mbs = encodeURIComponent(mob_num);
                
                var stxhr = new XHR();                                                                                                
                stxhr.get('<%=luci.dispatcher.build_url("admin", "services", "sms","sms_read_del")%>/send_sms' + '/' + args + '/' + mbs, null,  
                        function(x, mArray)                                                                                           
                        {
                          var status = document.getElementById('msg_txt');                                               
                          status.value = "";
                        }                                                                                                             
                        );                                                                                                            
                                                                                                                                      
        }   

    function readsms()
    {
        var sms_id = document.getElementById("sms_read").value;
        var stxhr = new XHR();
        stxhr.get('<%=luci.dispatcher.build_url("admin", "services", "sms","sms_read_del")%>/read_sms' + '/' + sms_id, null,
                                                                                             
                        function(x, mArray)                                                  
                        {                                                                            
                                 var status = document.getElementById('readsms_text');               
                        if (mArray.smsdetail)                                               
                        {                                                                            
                                status.innerHTML = String.format('%s', mArray.smsdetail[0]);        
                        }                                                                            
                        else                                                                         
                        {                                                                            
                                status.innerHTML = 'No Response';                                    
                        }                                                                            
                                                                                                     
                        }                                                                                                     
                        );    
        
    }

        function deletesms()
        {

                var sms_id = document.getElementById("sms_del").value;
                var stxhr = new XHR();
                stxhr.get('<%=luci.dispatcher.build_url("admin", "services", "sms","sms_read_del")%>/delete_sms' + '/' + sms_id, null,

                        function(x, mArray)
                        {
                                 var status = document.getElementById('delsms_text');
                        if (mArray.smsdetail)                                   
                        {
                                                        
                                status.innerHTML = String.format('%s', mArray.smsdetail[0]);
                        }                                                                    
                        else                                                                 
                        {   
                                status.innerHTML = 'No Response';
                        } 

                        }
                        );
        }
//]]></script>

<div id="coil_detail_status">
    <fieldset class="cbi-section">                                                                                                
            SEND SMS:<br/>                                                                                                        
                Mobile Number: <input type="text" name="mob" id="mob" placeholder="<%:#91xxxxxxxxxx %>"/>
        <input type="button" value="<%:SendSms%>" class="cbi-button cbi-button-apply" onclick="sendsms()" /><br/>             
                Message Area:<br/><input type="text" maxlength="1024" name="msg_txt" id="msg_txt" placeholder="Up to 1024 Character" style="margin: 10px; width: 600px"/>
        </fieldset>             
        <fieldset class="cbi-section">
                READ SMS:<br/>
        <select class="cbi-input-select" style="width: 100px;" id="sms_read" name="sms_read">                                                                                
            <option value="1" id="1">1</option>                                                                                                          
            <option value="2" id="2">2</option>
        <option value="3" id="3">3</option>placeholder="Up to 159 Character" 
        <option value="4" id="4">4</option>
        <option value="5" id="5">5</option>
        <option value="6" id="6">6</option>
        <option value="7" id="7">7</option>
        <option value="8" id="8">8</option>
        <option value="9" id="9">9</option>
        <option value="10" id="10">10</option>
        <option value="all" id="11">ALL</option>
        </select> 
                <input type="button" value="<%:ReadSms%>" class="cbi-button cbi-button-apply" onclick="readsms()"/><br/>
        <textarea readonly="" rows="1" id="readsms_text" style="margin: 10px; width: 600px; height: 100px; resize: none;">
        </textarea>                                                               
        </fieldset>
     <fieldset class="cbi-section">
                DELETE SMS:<br/>
        <select class="cbi-input-select" style="width: 100px;" id="sms_del" name="sms_del">
                <option value="1" id="1">1</option>
                <option value="2" id="2">2</option>                                         
                <option value="3" id="3">3</option>                                                                             
                <option value="4" id="4">4</option>                                                                             
                <option value="5" id="5">5</option>                                                                             
                <option value="6" id="6">6</option>                                                                             
                <option value="7" id="7">7</option>                                                                             
                <option value="8" id="8">8</option>                                                                             
                <option value="9" id="9">9</option>                                                                             
                <option value="10" id="10">10</option>                                                                            
                <option value="all" id="11">ALL</option>                                                                          
                </select>
                <input type="button" value="<%:DeleteSms%>" class="cbi-button cbi-button-apply" onclick="deletesms()" /><br/>
        <textarea readonly="" rows="1" id="delsms_text" style="margin: 10px; width: 800px; height: 30px; resize: none;">                           
                </textarea>
        </fieldset>  
</div> 
<script type="text/javascript">//<![CDATA[
        cbi_validate_field('mob', true, 'phonedigit');
//]]></script>  

