﻿var AuthorsList = AuthorsList ? AuthorsList : function() {
    var public =
    {
       countryName:null,
       call:function(countryCode)
      {
       $('#authores_webgates .webgates-items').empty();
       $('#authores_webgates .webgates-items').hide();
       $('#authores_webgates .loading').show();
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
       //alert(countryCode);
        service.call("CountryAuthors", { countryCode: countryCode }, this.callback);
      },
      call2:function(countryCode,callback)
      {
      
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
       //alert(countryCode);
        service.call("getCountry", { countryCode: countryCode }, callback);
      },
      invated:function(confId)
      {
       
       $('#authors_invated').empty();
        $('#invated_loading').show();
         //alert(confId);
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call');
        service.call("InvatedAuthors", { confId : confId }, this.callback2);
      },
      
      callback:function(output)
      {
       
         //alert('callback '+"http://www.icgst-amc.com/Flags/"+output.Id+".gif");
         $("#country_flag").attr('src',"http://www.icgst-amc.com/Flags/"+output.Id+".gif");
         $('#commti_url').attr('href','http://www.icgst-amc.com/institute/Community.aspx?InstId=3&cr='+output.Id)
         //if(output.Authors!=null)
         // alert(output.Name);
         var authors = output.Authors;
          
        // alert(output.Authors.length);
          $('#authores_webgates .webgates-items').show();
          $('#authores_webgates .loading').hide();
         //http://www.icgst-amc.com
        
           if(authors!=null && authors.length>0)
             authors.sort(function() {return 0.5 - Math.random()}) 
          $.each(authors, function(index, author) {
          
              
              if(index<3)
              {
               //alert("http://www.icgst-amc.com"+author.Photo.replace('~/',''));
               var photo ='http://www.icgst-amc.com/institute/Handler1.ashx?url='+ author.Photo;
              // alert(photo);
               $('#authores_webgates .webgates-items').append('<div class="webgates-item">'+
                 '<img class="smal-img fleft" alt="" src="'+photo+'" />'+
                 '<a href="http://www.icgst-amc.com/institute/Community.aspx?InstId=3&aid='+author.Id+'" ><span style="font-weight:bold;" >'+author.Title+' '+author.FirstName+' '+author.LastName+',</a> </span> <div class="subtitle" >'+author.Affiliation+'</div> <p style="text-align:justify">'+author.Biography+'</p>'+
		         '<div class="more"></div>'+
		         '</div>');
		         }
          
          }); 
          
          $('#authores_webgates .webgates-items p').expander({
             slicePoint:       130,  // default is 100
    
             expandText:         '[ read more ]', // default is 'read more...'
             collapseTimer:    0, // re-collapses after 5 seconds; default is 0, so no re-collapsing
             userCollapseText: '[ ^ less ]'  // default is '[collapse expanded text]'
           });
      },
      callback2:function(output)
      {
          var authors = output;
         // alert('callback '+ authors.length);
          $('#invated_loading').hide();
          $('#authors_invated').show();
          $.each(authors, function(index, author) {                       
             $('#div_invited').show();
               //alert("http://www.icgst-amc.com"+author.Photo.replace('~/',''));
               var photo ='http://www.icgst-amc.com/institute/Handler1.ashx?url='+ author.Photo;
               if(author.TopicUrl=='none'|| author.TopicUrl=='')
               author.TopicUrl = "#";
               // alert(photo);
               $('#authors_invated').append(' <li style="float:left;margin-right:10px;border-right:1px solid #ccc;width:160px;">'+
                 '<img class="middle-img" alt="" src="'+photo+'" />'+
                 '<a href="http://www.icgst-amc.com/institute/Community.aspx?InstId=3&aid='+author.Id+'" >'+
                 '<span class="names" style="clear:both;display:block;font-size:.8em;">'+author.Title+' '+author.FirstName+' '+author.LastName+', </span></a>'+
                 
                 '<div class="subtitle" >'+author.Affiliation+'</div> '+	
                 '<h4 class="ui-corner-all" style="margin:5px;padding:0px;padding:5px;clear:both;background-color:#e7e7e7;display:block;width:100px;">Session Topic:</h4>'+
                 '<a href="'+author.TopicUrl+'" style="color:#002B5F;text-align:left;">'+author.TopicName+'</a>'+ 	         
		         '</li>');
		         
          }); 
        
      }
       
    }

    return public;
} ();
