function TB_overlaySize(){
        if (window.innerHeight && window.scrollMaxY) {	
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            yScroll = document.body.offsetHeight;
        }
        $("#TB_overlay").css("height",yScroll +"px");
    }

    function TB_remove() {
        $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').remove();});
        $("#TB_load").remove();
        return false;
    }

    function doFourth(code)
    {
        var url="web.action?action=dofourth&code="+code;
        $.getJSON(url+"&rnd="+new Date(),function(data)
        { 
            if(data.success == true)
            {
                alert("下发成功,请注意查收！");
            }
            else
            {
                alert("下发失败，请重复");

            }
        });
        
    }
    
    function doThrid(code)
    {
        var url="web.action?action=dothrid&code="+code;

        $.getJSON(url+"&rnd="+new Date(),function(data)
        { 
            //alert(data);
            if(data.success == true)
            {
                alert("操作成功，你可以将图片保存到你的电脑");
                $("#thrid").removeClass("li_n");
                $("#thrid").addClass("li_y");
                $("#thrid").html("操作成功，你可以将图片保存到你的电脑");
                $("#largeImg").attr({ src: data.info, alt: "你要的照片" });//,width:240
                $("#mydown").attr({ href: data.info });//,width:240
                $('#codeBtn').attr('disabled','');
                //$("#hCode").val(code);

                $("#largeImg").load(function(){
                   var image = $(this);
                   var width = 240;
                   var height = 320;
                   //alert(image.width());
                    if(image.width()>width)
                    {
                        image.width(width);
                        image.height(width/image.width()*image.height());
                    }
                    if(image.height()>height)
                    {
                        image.height(height);
                        image.width(height/image.height()*image.width());
                    }

                }) ;
                //$("#isConfirm").val(data.isConfirm);
                // 1 要提示，即可以push  
                if(data.isConfirm=="1")
                {
                    $("#hCode").val(code);
                    if(confirm("是否立即下载到手机？"))
                    {
                        //window.location=urlreturn;
                        //$("#"+objid).slideUp(500); 
                        $.ajax({
                            //beforeSend:function(){$("#loading").html("<font color='red'>(正在执行.......)</font>");},
                            type: "POST",
                            dataType: 'json',
                            url: "web.action?action=dofourth&code="+code,
                            timeout: 5000,
                            //data:   "id="+objid,
                            success: function(){$("#loading").html("<font color='red'>(成功)</font>");alert("下发成功,请注意查收！");},
                            error: function(){$("#loading").html("<font color='red'>(失败)</font>");alert("下发失败，请重复");} 
                        });
                         
                    }
                    else 
                    {
                        $("#largeImg").load(function(){
                       var image = $(this);
                       var width = 240;
                       var height = 320;
                        if(image.width()>width)
                        {
                            image.width(width);
                            image.height(width/image.width()*image.height());
                        }
                        if(image.height()>height)
                        {
                            image.height(height);
                            image.width(height/image.height()*image.width());
                        }

                        }) ;
                        return;
                    }
                }
                else
                {   
                    //$("#hrefPhone").unbind("click");
                    $("#hrefPhone").remove();
                    $('#codeBtn').attr('disabled','');

                }

            }
            else
            {
                alert(data.errors);
                $("#thrid").addClass("li_n");
                $("#thrid").html(""+data.errors);
                $('#codeBtn').attr('disabled','');

            }
        });
        
    }
    function doSecond()
    {
        //var addTopMenu = { 
            //datatype:'json', 
           // post:'post',
            //success:    function(data) {    alert(data);    } 
        //}; 
        //$('#phoneForm').ajaxForm(addTopMenu); 
        
        var phone=$("#txtPhone").val();
        phone=$.trim(phone);
        var imgPath=$("#imgPath").val();
        imgPath=$.trim(imgPath);

        
        var url="web.action?action=getSmsInfo&txtPhone="+phone+"&imgPath="+imgPath;

        $.getJSON(url+"&rnd="+new Date(),function(data)
        { 
            if(data.success == true)
            {
                $("#second").removeClass("li_n");
                $("#second").addClass("li_y");
                $("#second").html("<h3>"+data.info+"</h3>");
                $('#phoneBtn').attr('disabled','');
               
            }
            else
            {
                $("#second").addClass("li_n");
                $("#second").html("操作失败!请重新从第一步开始");
                $('#phoneBtn').attr('disabled','');

            }
        });
    
    }

   

    function doajaxFileUpload(){
       
        $.ajaxFileUpload({
            url: "ext2Upload.action?rnd="+new Date(),
            secureuri: false,
            fileElementId: "file",
            dataType: "json",
            success: function(data,status){
                //if(typeof(data.success) != 'undefined')
                if(data.success == true)
                {
                    //alert(data.data);
                    $("#first").removeClass("li_n");
                    $("#first").addClass("li_y");
                    $("#first").html("请进行第二步操作!");
                    var path=data.data;

                    $("#largeImg").attr({ src: path, alt: "你的照片" });//,width:240
                    //alert($("#file").val());
                    $("#imgPath").val(path);
                    
                    
                    $('#imgBtn').attr('disabled','');

                    //$(function(){$("#largeImg").ImageAutoSize(240,320);})

                    //$("img").each(function(i){  
                       // alert("img");
                    //})

                     $("#largeImg").load(function(){
                        var image = $(this);
                        var width = 240;
                        var height = 320;
                        if(image.width()>width)
                        {
                            image.width(width);
                            image.height(width/image.width()*image.height());
                        }
                        if(image.height()>height)
                        {
                            image.height(height);
                            image.width(height/image.height()*image.width());
                        }

                      });
                      $("#imgA").attr({ src: "images/photograph/a.jpg", alt: "正确的照片" });
                    $("#imgB").attr({ src: "images/photograph/b.jpg", alt: "错误的照片" });
                    $("#imgC").attr({ src: "images/photograph/c.jpg", alt: "错误的照片" });
                    
                }
                else
                {
                    alert(data.errors);
                    $("#first").addClass("li_n");
                    $("#first").html("操作失败!失败原因:"+data.errors);
                    $('#imgBtn').attr('disabled','');

                    $("#imgA").attr({ src: "images/photograph/a.jpg", alt: "正确的照片" });
                    $("#imgB").attr({ src: "images/photograph/b.jpg", alt: "错误的照片" });
                    $("#imgC").attr({ src: "images/photograph/c.jpg", alt: "错误的照片" });

                }
            },
            error: function (data, status, e)
            {
                $("#first").addClass("li_n");
                $("#first").html("操作失败，请重新上传图片!");
                $('#imgBtn').attr('disabled','');
            }
        });
    }

    jQuery.fn.ImageAutoSize = function(width,height)
    {
        $("img",this).each(function()
        {
            var image = $(this);
            if(image.width()>width)
            {
                image.width(width);
                image.height(width/image.width()*image.height());
            }
            if(image.height()>height)
            {
                image.height(height);
                image.width(height/image.height()*image.width());
            }
        });
    }
       
    
    //点击清空所有输入框
    function cleartextbox()
    {
        var els = $(":input");
        els.each(function(i)           
       { 
          var textname = $(this).attr("id");
          if (textname == undefined) textname = "";
          var index = textname.indexOf("txt");
          if (index == NaN) index = -1;              
          if (index > -1)
          {
             $(this).val("");                 
          }   
       }
         ); 
     }
    

    function SubjectCtrl( focus ) 
    {
        
        if ( focus==1 ) {
            if($("#txtPhone").val()=="请输入你的手机号码")
            {
                $("#txtPhone").val("");
                $("#txtPhone").css("color" ,"#000000");
            }

        }
        else{
            if ( $("#txtPhone").val()=="" ) {
                $("#txtPhone").val("请输入你的手机号码");
                $("#txtPhone").css("color" ,"#999999");
            }
        }
    }

    function codeCtrl( focus ) 
    {
        
        if ( focus==1 ) {
            if($("#txtCode").val()=="请输入提取码")
            {
                $("#txtCode").val("");
                $("#txtCode").css("color" ,"#000000");
            }

        }
        else{
            if ( $("#txtCode").val()=="" ) {
                $("#txtCode").val("请输入提取码");
                $("#txtCode").css("color" ,"#999999");
            }
        }
    }


    function clickButton()
    {    
        var url = 'http://192.168.0.70:8080/mms/flow.action?action=getSelectList';
        //var params = {name:$('#name').attr('value')};
         //jQuery.post(url,  callbackFun, 'json');
 
         jQuery.getJSON(url,  callbackFun);

    }

    function callbackFun(data)
    {
         alert(data.results);//对应HelloWorld类的message属性
             //获取数据后渲染页面
    }