$(document).ready(function(){
           var ajaxLoading=false;
           $(".users").css("margin-right","15px");
           var himnakan_tiv;
            //      if($.client.browser=="Chrome" ){
            //          //265
            //           himnakan_tiv=$("#header").height()+$("#menuLay").height()+$("#footer").height()+2*30+80+2*10;
            //      }else{
            //          //312
            //
            //      }
           himnakan_tiv=$("#header").height()+($("#menuLay").height()+2*10)+($("#footer").height()+parseFloat($("#footer").css("margin-top").split("p")[0]))+2*25;

//      if($.client.browser=="Chrome" ){himnakan_tiv=himnakan_tiv-20;}
           $("#content").css("min-height",($(window).height()-himnakan_tiv));

//           $("#deviceInfo").css("min-height",($(window).height()-himnakan_tiv-27-2));
    //alert($(window).height()+" "+himnakan_tiv+" "+$("#deviceInfo").css("min-height"));
        //    alert($(window).height()+" "+himnakan_tiv);
          //alert($("#content").height())   ;

            $('.network').click(function(){
              if (!ajaxLoading) {
                 ajaxLoading = true;
                 var obj = $(".subNetwork");
                 var count = $(".subNetwork").find(".item").length;
//                 if(count==0){
//                     $.ajax({
//                        url:'viewNetworks.action',
//                        cache:false,
//                        type:'POST',
//                             success:function(result){
//                                 ajaxLoading = false;
//                                 $("#allNetworks").attr("src",'images/content/network_storage.png')  ;
//                                 obj.html(result);
//                                 var networkHeightInt=parseFloat($("#networks").css("height").split("p")[0]);
//                                 var contentHeightInt=parseFloat($("#content").css("height").split("p")[0]);
//                                 $("#content").css("height",contentHeightInt>networkHeightInt?contentHeightInt:networkHeightInt) ;
//                                    contentHeightInt=parseFloat($("#content").css("height").split("p")[0]);
//                                  }
//                     });
//                 } else {
                     var t= $(".subNetwork").find("input[name='isHidden']").val();
                     if($(".subNetwork").find("input[name='isHidden']").val()==1){
                                       $("#items").show();
                                       $("#allNetworks").attr("src",'images/content/network_storage.png');
                                       var li=$(".subNetwork").find(".item");
                                          li.each(function(){
                                                li.attr("disable","false");
                                          }) ;
                                      $(".subNetwork").find("input[name='isHidden']").val(0);
                                      var networkId=$(".selecting").parent().parent().find("input[name='networkId']").val();
                                      var deviceSerial=$("input[name='selectedDevice']").val();

                                      if(networkId!=null){
                                         if(deviceSerial!="") {
                                                  $.ajax({
                                                    url: "viewDeviceInfo.action",
                                                    data:{
                                                        serial:deviceSerial
                                                         },
                                                    cache:false,
                                                    type:"post",
                                                    success:function(data) {
                                                        ajaxLoading = false;
                                                        $("#deviceInfo").html(data);

                                                    }
                                                });
                                         } else {

                                                $.ajax({
                                                    url: "viewDevices.action",
                                                    data:"networkId="+networkId,
                                                    cache:false,
                                                    type:"post",
                                                    success:function(data) {
                                                        ajaxLoading = false;
                                                        $("#deviceInfo").html(data);
                                                        $(".dataTables_empty").text("There is no device in this network");
                                                      }
                                              });
                                         }
                                     }
                     }else{
                                    $("#items").hide();
                                    $("#allNetworks").attr("src",'images/content/network.png');
                                    var li=$(".subNetwork").find(".item");
                                    li.each(function(){
                                        li.attr("disable","true");
                                    }) ;
                                    $(".subNetwork").find("input[name='isHidden']").val(1);
                                    ajaxLoading = false;
                     }
                               $("#deviceInfo").html("");
                               var networkHeightInt=$("#networks").height();
                                   $("#content").css("height",networkHeightInt>($(window).height()-himnakan_tiv)?networkHeightInt:($(window).height()-himnakan_tiv)) ;
 //                }
              }
             });
});