﻿var JournalList = JournalList ? JournalList : function() {
   var public =
    {
       countryName:null,
       subId:null,
       call:function()
      {
       
        $('#slider-wrapper').empty();
        $('.slider-menu-wrapper .paper-list').empty();
        $('.slider .loading').show();
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call');
        service.call("LoadJournals", { }, this.callback);
      },
      call2:function(subId)
      {
      // alert(subId);
       $('#journal_loading').show();
        $('#subject_img').attr('src','');
         $('#subject_title').text('');
         $('#ISSN').text('');
         $('#desc').text('');
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call');
        service.call("LoadJournal", { subId: subId }, this.callback2);
      },
      call3:function(subId)
      {
      // alert(subId);
       $('#ds_link').attr("href","http://www.icgst-amc.com/institute/author/directsubmit.aspx?subid="+subId);
       $('#journal_loading').show();
        $('#subject_img').attr('src','');
         $('#subject_title').text('');
         $('#ISSN').text('');
         $('#desc').text('');
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call3');
        service.call("LoadJournal", { subId: subId }, this.callback3);
      },
       call4:function(subId)
      {
      // alert(subId);
       $('#journal_loading').show();
        $('#subject_img').attr('src','');
         $('#subject_title').text('');
         $('#ISSN').text('');
         $('#desc').text('');
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call');
        service.call("LoadJournal", { subId: subId }, this.callback4);
      },
       call5:function(subId)
      {
       $('#div_conference_gallery').hide();
        $('#images_gallery').empty();          
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call '+subId);
        service.call("LoadGallery", { subId: subId}, this.callback_gallery);
      },
      callback:function(output)
      {
         //alert('callback');
         var journals = output;
         $('.slider .loading').hide();
         $('#slider-wrapper').show();
         $('.slider-menu-wrapper .paper-list').empty();
        
         $('.slider-menu-wrapper .paper-list').append(' <li id="logo-index-blank"  tyle=""><img style="border: medium none;" src="Images//alhram.jpg" class="icon" alt="Eden" title="Eden" /></li>');
         
         $.each(journals, function(index, journal) {
          
               var active = "";
               if(index==0)
               {
                 active='active';
               }
              $('#slider-wrapper').append( '<div id="slider-item'+journal.Id+'" class="slider-wrapper-item '+active+'" >'+
               '<div class=slider-context>'+
               '<div class="subject radius2">'+journal.Abbreviation+'</div><span class="subtitle" style="color:#555">ISSN: '+journal.ISSN+'</span>'+
               '<a href="journals/journal.aspx?subid='+journal.Id+'"><span class=header-slider>'+journal.Title+ '</span></a>'+
               '<p><a href="journals/journal.aspx?subid='+journal.Id+'" style="color:#333;" >'+journal.Description+'</a></p>'+
               '<div class="more" ><a href="journals/journal.aspx?subid='+journal.Id+'" >more</a></div>'+
               '</div>'+             
              '</div>');
              
              
               var logo =  'http://www.icgst-amc.com/institute/Handler1.ashx?url='+ journal.LogoUrl;
               //alert(' <li id="logo-index-'+index+'" class="'+active+'" ><a rel="#slider-item'+journal.Id+'" href="javascript:void(0)"><img style="border: medium none;" src="'+logo+'" class="icon"  /><div style="margin:0 auto;width:100%;text-align:center;"> </div><img  class="'+active+'" src="Images/pointer.png" /></li>');
               $('.slider-menu-wrapper .paper-list').append(' <li id="logo-index-'+index+'" class="'+active+'" ><a rel="#slider-item'+journal.Id+'" href="javascript:void(0)"><img style="border: medium none;" src="'+logo+'" class="icon"  /><div style="margin:0 auto;width:100%;text-align:center;"> </div><img  class="'+active+'" src="Images/pointer.png" /></a></li>');
		        //alert(index);
		         $('#logo-index-'+index).click(function(){
         
                 $('.slider-menu-wrapper .paper-list li').removeClass('active');
                 $(this).addClass('active');
                 var next_active= $(this).find('a').attr('rel');
                 $('#slider-wrapper .active').fadeOut('slow',function(){
                  
                    // alert( $(this).attr('rel'));
                    
                      $('#slider-wrapper .active').removeClass('active');  
                    
                     $(next_active).fadeIn('slow',function(){
                         $(next_active).addClass('active');   
                        
                      });                                     
                 });
                              
                 
               });
		       
		        
          
          }); 
          
            $('#slider-wrapper p').expander({
             slicePoint:       150,  // default is 100
    
             expandText:         '', // 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]'
           });
           
           // alert($('.slider-menu-wrapper .paper-list li').length);
		       
      },
      callback4:function(output)
      {
      $('#journal_loading').hide();
     // alert('out 2');
      var journal = output;
      var logo =  'http://www.icgst-amc.com/institute/Handler1.ashx?url='+ journal.LogoUrl;
         $('#subject_img').attr('src',logo);
        // alert('ICGST Journal of '+journal.Title);
         $('#subject_title').text('Session of '+journal.Title);
         $('#ISSN').text("ISSN: "+journal.ISSN);
         $('#desc').text(journal.Description);
        var sId = getParameterByName('ses_id');
       
        
         var submit_url = "http://www.icgst-amc.com/institute/author/ConferenceSubmit.aspx?sId="+sId;
         
         var referee =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.RefereeLater;
         var pdf =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.PDF;
         var word =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.Word;
         var latext = 'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.Latext;
        // alert(referee);
        // alert(submit_url);
         $('#pdf').attr('href',pdf);
         $('#word').attr('href',word);
         $('#latex').attr('href',latext);
         $('#latter').attr('href',referee);
         $('#sen_submit_url').attr('href',submit_url);
        
      },
       callback2:function(output)
      {
      $('#journal_loading').hide();
     // alert('out 2');
      var journal = output;
      var logo =  'http://www.icgst-amc.com/institute/Handler1.ashx?url='+ journal.LogoUrl;
         $('#subject_img').attr('src',logo);
        // alert('ICGST Journal of '+journal.Title);
         $('#subject_title').text('ICGST Journal of '+journal.Title);
         $('#ISSN').text("ISSN: "+journal.ISSN);
         $('#desc').text(journal.Description);
        var sId = getParameterByName('ses_id');
       
        
         var submit_url = "http://www.icgst-amc.com/institute/author/ConferenceSubmit.aspx?sId="+sId;
         
         var referee =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.RefereeLater;
         var pdf =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.PDF;
         var word =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.Word;
         var latext = 'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.Latext;
        // alert(referee);
        // alert(submit_url);
         $('#pdf').attr('href',pdf);
         $('#word').attr('href',word);
         $('#latex').attr('href',latext);
         $('#latter').attr('href',referee);
         $('#sen_submit_url').attr('href',submit_url);
        
      },
      callback3:function(output)
      {
      $('#journal_loading').hide();
      $('#journal_header').show();
    //  alert('out 3');
      var journal = output;
      var logo =  'http://www.icgst-amc.com/institute/Handler1.ashx?url='+ journal.LogoUrl;
         $('#subject_img').attr('src',logo);
         $('#subject_title').text(journal.Title);
         $('#ISSN').text("ISSN: "+journal.ISSN);
         $('#desc').text(journal.Description);
         var referee =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.RefereeLater;
         var pdf =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.PDF;
         var word =  'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.Word;
         var latext = 'http://www.icgst-amc.com/institute/Handler2.ashx?url='+ journal.Latext;
        
         $('#pdf_link').attr("href",pdf)
         $('#wrod_link').attr("href",word)
         $('#latext_link').attr("href",latext)
         $('#rl_link').attr("href",referee)
      },
      callback_gallery:function(images)
      {
      //alert(images);
      $('#div_conference_gallery').hide();
       if(images==null|| images==undefined)
             return;
        $.each(images, function(index, image) {
         $('#div_conference_gallery').show();  
         var style="";
         //alert(image.Path);
         if(index>5)
              style='style="display:none"'; 
            var img_url = 'http://www.icgst-amc.com/institute/Handler1.ashx?url=~/'+ image.Path
            var icon_url = 'http://www.icgst-amc.com/institute/Handler1.ashx?url=~/'+ image.Path.replace('.','_icon.');
            $('#images_gallery').append('<a href="'+img_url+'"  '+style+' rel="lightbox-journals" ><img src="'+img_url+'" style="width:64px;height:64px;margin:5px;" alt=""></a>');		                  
           });
           //prompt('', $('#images_gallery').html())
       }
       
    }
    
    return public;
} ();
