function smartChallengeLoad(url){
$.ajax({
   type: "GET",
   cache: false,
   url: url,  
    beforeSend: function (XMLHttpRequest) {

},
   success: function(data){
    var obj=JSON.parse(data);    
    var img_count1="";
    var _img_count1="";
    var img_count2="";
    var _img_count2="";
    for(var i=0;i<(5-obj.lastMonth.length);i++){
    _img_count1+="<img src=\"img/number_00.gif\" alt=\"0\" width=\"23\" height=\"33\" class=\"right2px\" />";
    }
     for(var i=0;i<(5-obj.entryOfThisMonth.length);i++){
    _img_count2+="<img src=\"img/number_00.gif\" alt=\"0\" width=\"23\" height=\"33\" class=\"right2px\" />";
    }
    for(var i=0;i<obj.lastMonth.length;i++){
    img_count1+="<img src=\"img/number_0"+obj.lastMonth[i]+".gif\" alt=\""+obj.lastMonth[i]+"\" width=\"23\" height=\"33\" class=\"right2px\" />";
    }
    for(var i=0;i<obj.entryOfThisMonth.length;i++){
    img_count2+="<img src=\"img/number_0"+obj.entryOfThisMonth[i]+".gif\" alt=\""+obj.entryOfThisMonth[i]+"\" width=\"23\" height=\"33\" class=\"right2px\" />";
    }
  
   $("#jikokensu").html(_img_count1+img_count1);
   $("#kekka").html(_img_count2+img_count2);
    
   },
    error: function (xmlHttpRequest, error) {
　　　　　　　　　　　　　　
                 $(_id).html(error);
                
               
　　　　　　　　　　　　}
 });
}
function dataLoad(url,_id){
   $.ajax({
   type: "GET",
   cache: false,
   url: url,  
    beforeSend: function (XMLHttpRequest) {
 //isLoad(true);
},
   success: function(data){
    var objs=JSON.parse(data);    
    var table="<table width=\"460\" border=\"0\" cellpadding=\"1\" cellspacing=\"5\" style='border-collapse:collapse;'>";
    for(var i=0;i<objs.length;i++){
   table+="<tr><td><span class='style3'><a href='"+objs[i].link+"' target='_blank'>"+objs[i].title+"</a>&nbsp;"+objs[i].date+"</span></td></tr>";
   
   }
   table+="</table>";
   $(_id).html(table);
     // isLoad(true);
   },
    error: function (xmlHttpRequest, error) {
　　　　　　　　　　　　　　
                 $(_id).html(error);
                
               
　　　　　　　　　　　　}
 });
   }
   function topicDataLoad(url,_id){
   $.ajax({
   type: "GET",
   cache: false,
   url: url,  
    beforeSend: function (XMLHttpRequest) {
  $("#challenge_message1mainimg1").html("<center><img src=\"./img/wait.gif\"   /></center>");
},
   success: function(data){
   //alert(data);
    var objs=JSON.parse(data);  
    var date=objs[0].date;
    var date2=objs[1].date;
    var date3=objs[2].date;
    var tittle="<a href='"+objs[0].href+"' target='_blank'>"+objs[0].title+"</a>";
    var tittle22="<a href='"+objs[0].href+"' target='_blank'>続きを見る</a>";
    var tittle2="<a href='"+objs[1].href+"' target='_blank'>"+objs[1].title+"</a>";
    var tittle3="<a href='"+objs[2].href+"' target='_blank'>"+objs[2].title+"</a>";
    var content=objs[0].content;
    var img=null;   
    
    if(objs[0].img_src==null){
    img="<img class=\"imgcenter\" src='img/logo.gif'/>";
    }
    else    {
    var img_w=objs[0].img_size.width+"px";
    var img_h=objs[0].img_size.height+"px";
    //alert(img_w);
    img="<img class=\"imgcenter\" height='"+img_h+"' width='"+img_w+"' src='"+objs[0].img_src+"'/>";
    
    }
    
    $("#topics_date").html(date);
    $("#topics_tittle").html(tittle);
    $("#topics_tittle22").html(tittle22);
   $("#challenge_message1mainimg1").html(img);
   
    $("#challenge_message1text1").html(content);
    $("#topics_date2").html(date2);
    $("#topics_tittle2").html(tittle2);
     $("#topics_date3").html(date3);
    $("#topics_tittle3").html(tittle3);
    /**
      
    var table="<table width=\"460\" border=\"0\" cellpadding=\"1\" cellspacing=\"5\" style='border-collapse:collapse;'>";
  
   table+="<tr><td><img width='200px' height='120px' src='"+((objs.img_src==null)?'img/ed1078454d1dd565500ffe51.jpg':objs.img_src)+"'/></td></tr>";
     table+="<tr><td><span class='style3'>"+objs.date+"</span></td></tr>";
    table+="<tr><td><span class='style3'><a href='"+objs.href+"' target='_blank'>"+objs.title+"</a></span></td></tr>";
    table+="<tr><td><span class='style3'>"+objs.content+"</span></td></tr>";
   
  
   table+="</table>";
   $(_id).html(table);
   */
   
     // isLoad(true);
   },
    error: function (xmlHttpRequest, error) {
　　　　　　　　　　　　　　
                 $(_id).html(error);
                
               
　　　　　　　　　　　　}
 });
   }
   var objs=new Array();
   function dataLoadForStatus(url,_id){
   $.ajax({
   type: "GET",
   cache: false,
   url: url,  
    beforeSend: function (XMLHttpRequest) {
    if(objs.length==0)  $(_id).html("<center><img src=\"./img/wait.gif\" id=\"wait3\"  /></center>");
    $("#button1").attr("disabled",true);

},
   success: function(data){ 
   try{
    var objs1=JSON.parse(data);     
     objs=objs.concat(objs1);
    if(objs.length==0){
    $(_id).html("<br><br><center>「つぶやき」はありませんでした。</center>");
    return;
    }
    var table="<table width='390px' border=\"0\" cellpadding=\"0\" cellspacing=\"1\" style=\"word-break:break-all;\">";
    for(var i=0;i<objs.length;i++){
    var bg_tr="#FFFFFF";
    if(i%2==0)bg_tr="#F9F7F7";
   table+="<tr bgcolor="+bg_tr+"><td><img  src='"+objs[i].user_profile+"'  width='40px' height='40px'/></td><td>&nbsp;&nbsp;</td>";
   table+="<td ><a href='http://twitter.com/"+objs[i].user_name+"' target='_blank'>"+objs[i].user_name+"</a>&nbsp;"+objs[i].text+"</td></tr>";
   table+="<tr><td colspan=3>&nbsp;</td></tr>";
   }
   table+="</table>";
   $(_id).html(table);
   $("#button1").attr("disabled",false);
     // isLoad(true);
     }catch(e){
     //$(_id).html("");
     alert("データを取り込む途中でエラーが発生しましたので、ブラウザを再度に更新してみてください。");
     }
   },
   error: function (xmlHttpRequest, error) {
　　　　　　　　　　　　　　
                 $(_id).html(error);
                
               
　　　　　　　　　　　　}
 });
   }
function isLoad(real) {

if(real){
$("#wait1").css("display","inline");  
$("#wait2").css("display","inline"); 
//$("#wait3").css("display","inline"); 
}
else{
$("#wait1").css("display","none");  
$("#wait2").css("display","none");
//$("#wait3").css("display","none");
}

}
function form_init(url){
var options = {                
        beforeSubmit:  function(formData, jqForm, options) { 
         var formElement = jqForm[0]; 
         var name=formElement.name.value;
         var naiyou=formElement.naiyou.value;
         if(name==""){
           alert("ニックネームを入力してください。"); 
            return false; 
           }
           if(naiyou==""){
           alert("宣言を入力してください。"); 
            return false; 
           }
           if(naiyou.length>108){
           alert("宣言は108文字以内で記入ください。"); 
            return false; 
           }
           $("#wait4").css("display","inline"); 
           $("#Submit1").attr("disabled",true);
         return true; 
        },  
        success: function(responseText, statusText)  { 
        $("#wait4").css("display","none");  
        $("#Submit1").attr("disabled",false);
        try{
         var obj=JSON.parse(responseText); 
          if(obj.flag==1){
          location.href="thanks.html";
          //alert("Twitterへの投稿に成功しました。");
          }
          else  if(obj.flag==0){
          alert("ＤＢへの保存に失敗しました。");
          }
          else  if(obj.flag==-1){
          //alert("Twitterへの投稿に失敗しました。");
          }
          }
          catch(e){
          alert(e.message);
          }
    // alert(responseText); 
      //dataLoadForStatus("./Services/twitter_status.php","#show_twitter");
      //dataLoadForStatus("./Services/twitter_status.php?isAll=false","#show_twitter");
       // $(_id).html(responseText);
        },  
 
       
        url:       url ,   
        clearForm: true        // clear all form fields after successful submit
    }; 
 
    // bind form using 'ajaxForm' 
    $('#form1').ajaxForm(options);
   
}
