﻿var ConferenceList = ConferenceList ? ConferenceList : function() {
    var public =
    {
       confid:null,
       countryName:null,
       call:function(conf_id)
      {
       $('#conf_fee').empty();
        $('#fee_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("conferenceFee", { confId: conf_id }, this.callback);
      },
       call2:function(subId)
      {
      // alert(subId);
       $('#journal_loading').show();
        $('#subject_img').attr('src','');
         $('#subject_title').text('');
        
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call');
         //alert(subId);
        service.call("LoadJournal", { subId: subId }, this.callback2);
      },
       call3:function(confId)
      {
       // alert(confId);
       $('#session_loading').show();
       
      $('#session_loading').show();
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call3');
         service.call("LoadSessionSubjects", { conf_id: confId }, this.callback3);
      },  
      call4:function(confId)
      {
       // alert(confId);
       //$('#session_loading').show();
       
      $('#public_link_list').empty();
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert(confId);
         service.call("LoadPublickLinks", { confId: confId }, this.callback_publicLink);
      },          
      loadsession:function(confId)
       {
      
        public.confid = confId;
        $('#session_loading').show();
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert('call3');
        $('#session_list').empty();
         service.call("LoadSessionSubjects", { conf_id: confId }, this.callback4);
  
      },
      loadUpcompingEvent:function()
       {
       $('#up_events_panel').empty();
        //alert('upcomming');
       
       
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
       
        
         service.call("loadUpComingEvents", {}, this.callback5);
  
      },
      loadUpcompingEventWidget:function()
       {
       
        //alert('upcomming');
       
       
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
       
        
         service.call("loadUpComingEvents", {}, this.confwidget);
  
      },
      loadvideos:function(cid)
      {
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert(cid);       
         service.call("loadConfVideos", { confid: cid }, this.bindvideos);
      },
      loadpapersvideos:function(cid)
      {
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
        //alert(cid);       
         service.call("loadPapersConfVideos", { confid: cid }, this.bindpapersvideos);
      }
      ,
       loadPastEvent:function()
       {
       $('#past_events').empty();
        //alert('upcomming');
       
       
        var jsonp = true;
        var service = new WindowsSerices("http://www.icgst-amc.com/icgst/ICGSTService.asmx", jsonp ? WSDataType.jsonp : WSDataType.json);
       
        
         service.call("loadPastEvents", {}, this.callback6);
  
      },
      
      callback:function(output)
      {
           var fees = output;
          //alert('callback '+ fees.length);
          $('#fee_loading').hide();
          $('#conf_fee').show();
          $.each(fees, function(index, fee) {                       
             
              
               $('#conf_fee').append('<li>'+
               '<strong> '+fee.Title+' : </strong><span>'+fee.Price+' </span><span>'+fee.Currency+'</span>'+
               '</li>');
		         
          }); 
        
      },
       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;
       var logo =  'http://www.icgst-amc.com/institute/Handler1.ashx?url='+ journal.LogoUrl;
        // $('#conf_img').attr('src',logo);
        //12/12/2012
         
             
         $('#conf_title').text(journal.Title);         
         $('#conf_desc').text(journal.Description);
         $('#conf_address').text(journal.Address);
         $('#conf_fromdate').text(journal.StartDate);
         $('#conf_todate').text(journal.EndDate);
         $('#sdlDate').text(journal.SubmissionDeadlineDate);
         $('#rnDate').text(journal.RegistrationDate);
         $('#rDate').text(journal.ReviewDate);
         $('#fvDate').text(journal.FinalSubmissionDate);
         $('#pDate').text(journal.ProgramDate);
          $('#conf_img').attr('src',logo);
         var dob = Date.parse(journal.StartDate);
         var now = Date.parse($('#page-container').find('input[type="hidden"]').val());
        //alert(now)
        if (dob < now)
        {
            $('#menu_submission').hide();
         }
         else
         {
            $('#menu_submission').show();
         }

         
      },
      callback3:function(journals)
      {
      //alert('callback 3');
        
        $('#session_loading').hide();
         //$('#sessions_widgets_container')
         var str="";
         $.each(journals, function(index, journal) {  
         var submit_url = "http://www.icgst-amc.com/institute/author/ConferenceSubmit.aspx?sId="+journal.SessionId;
         //alert(journal.SessionId);
         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;
         
         $('#sessions_widgets_container').append('<div  class="ui-widget-content ui-corner-all  session-widget" style="margin-bottom:2px;display:inline-block;border:1px solid #e7e7e7;position:relative;width:96%;margin-top:2px;margin-left:10px">'+
           '<h3 id="subject_title"   class="ui-corner-all collapse"  style="color:#fff;background-color:#444;cursor:pointer;"><span class="arrow-green-next" style="padding:2px;padding-left:32px;" > '+journal.Abbreviation+' : '+journal.Title+'</span><span class="arrow-green-down" style="display:none;padding:2px;padding-left:32px;"> '+journal.Abbreviation+' : '+journal.Title+'</span>'+
           '</h3>'+
           '<div style="display:inline-block;display:none;" class="session-container">'+
              '<div  class="ui-widget-content ui-corner-all fleft" style="margin-bottom:20px;border:1px solid #e7e7e7;position:relative;margin-top:0px;">'+
       ' <h3 class="radius-div " style="height:20px;line-height:20px;display:block;"><span class="header-title">Standard Styles:</span></h3> '+
            '<ul class="styles-ui">'+
          '<li >'+
             '<a href="http://www.icgst-amc.com/institute/Handler2.ashx?url=~/InstituteFiles/3/CopyrightForm/ICGST_Copyright.doc" >'+
               '<img src="../images/copyright.png" height="40" width="30"/>'+
               '<p style="">Copyright</p>'  +             
             '</a>'+
          '</li>'+
          '<li>'+
            ' <a href="'+pdf+'" >'+
              '<img src="../images/pdf.jpeg" height="40" width="40"/>'+
             '<p style=""> PDF</p>'+
            '</a>'+
          '</li>'+
            '<li >'+
            ' <a href="'+word+'" >'+
              '<img src="../images/word.jpeg" height="40" width="40"/>'+
              '<p>Word</p>' +               
             '</a>'+
          '</li>'+
          '<li>'+
             '<a href="'+latext+'" >'+
             '<img src="../images/latex.png" height="40" width="40"/>'+
              '<p>Latex  </p>'+            
            ' </a>'+
          '</li>'+
          '<li>'+
             '<a href="'+referee+'" >'+
               '<img src="../images/document_50.png" height="40" width="40"/>'+
               '<p> Referees Letter </p>'+            
             '</a>'+
          '</li>'+
        '</ul></div><div  class="ui-widget-content ui-corner-all fleft" style="margin-bottom:20px;border:1px solid #e7e7e7;position:relative;margin-top:0px;">'+
        '<h3 class="radius-div " style="height:20px;line-height:20px;display:block;"><span class="header-title">Paper Submission:</span></h3>  '+
        '<p>To submit a paper to the conference, simply log in your <a href="http://www.icgst-amc.com/institute/login.aspx?InstId=3">AMC</a> account and then follow the direct paper submission link'+
         '</p>'+
         '<div>'+
           '<a style="margin:10px; margin-left:30px;font-size:12px" class="arrow-orange"  href="'+submit_url+'">Paper Direct Submit</a></div> <br />'+
         '<p style="margin:0px;">TO create new account please </p><a  style="margin-left:30px;font-size:12px" class="arrow-orange" href="http://www.icgst-amc.com/Institute/register.aspx?InstId=3">Sign Up</a>'+
      '</div></div></div>');
             
//               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);
      
        
       
         
         });
          $('.collapse').click(function(){
         
             $(this).find('span').toggle();
             $(this).parents('.session-widget').find('.session-container').toggle();
             
          });
      
      
      //alert('out 3');
     
      
      },
      callback4:function(journals)
      {
      //alert('callback 3');
        
         $('#session_loading').hide();
         //$('#sessions_widgets_container')
         var str="";
         $.each(journals, function(index, journal) {  
             $('#session_list').append('<li  class="arrow ui-corner-all "><a id="A1" href="session.aspx?confid='+public.confid+'&sub_id='+journal.Id+'&ses_id='+journal.SessionId+'" style="font-weight:bold;font-size:.9em;color:#000">'+journal.Abbreviation+'</a></li>');
         });
       },
  
     callback5:function(journals)
      {
      //alert('callback 5 '+journals.length);
        
         
         var str=""; 
         
         $.each(journals, function(index, journal) {  
           var style ="display:none";
              var cls = 'class="active-indexer"';
            if(index==0)
             style="";
            else
              cls ="";
             //alert(journal.Address)
             var logo ='http://www.icgst-amc.com/institute/Handler1.ashx?url='+ journal.LogoUrl;
              var str ='<div id="conf_id_'+index+'" class="radius event_item" style="float:left;'+style+'"  >'+
			      '<a href="conferences/conference.aspx?confid='+journal.Id+'"><img class="middle-img fleft" alt="" src="'+logo+'" style="margin:5px;" /></a>'+
                  '<span class=names style="display:block"><a href="conferences/conference.aspx?confid='+journal.Id+'" style="text-decoration:none">'+journal.Title+'</a></span>'+
                  '<h3 style="margin:0px;padding:2px;float:left">'+journal.Address+'</h3>'+                  
                  '<h3 style="margin:0px;padding:2px;margin-left:10px"><span style="line-height:20px;padding-top:5px;margin-left:5px;padding:0px;"><p style="color:#C13504;display:inline;padding:0px;margin:0px; ">From</p>: '+journal.StartDate+'</span><span>  <p style="color:#C13504;foat:left;display:inline;padding:0px;margin:0px;">  To</p>: '+journal.EndDate+'</span></h3>'+                  
                  '<p style="display:block;text-align:justify">'+journal.Description+'</p>'+
		          '<div class="more"><a href="conferences/conference.aspx?confid='+journal.Id+'">more</a></div>'+
			   '</div>'
			  // alert(str);
             $('#up_events_panel').append(str);
             var pindex= index+1;
             
              var mstr = ' <li style="padding:0px; margin:0px; float:left;min-width:20px;"><a style="text-align:center;line-height:30px;display:block;width:30px;" '+cls+' id="indexer_active_'+index+'" href="javascript:void(0)" rel="#conf_id_'+index+'" >'+pindex+'</a></li>'    
              $('#active_event').append(mstr);
              
              $("#indexer_active_"+index).click(function(){
               $('#active_event li a').removeClass('active-indexer');
               $(this).addClass('active-indexer'); 
               var rel = $(this).attr('rel');
               //alert(rel);
               $('#up_events_panel .event_item').hide();
               $(rel).show();
              
              });
         });
       },
       callback6:function(journals)
      {
     // alert('callback 6 '+journals.length);
        
         
         var str=""; 
         if(journals!=null && journals.length>0)
         {
           journals.sort(function(a,b){return a.EndDate - b.EndDate})
         }
         $.each(journals, function(index, journal) {  
             var style ="display:none";
             var cls = 'class="active-indexer"';
            if(index==0)
             style="";
            else
              cls ="";
            
             var logo =  'http://www.icgst-amc.com/institute/Handler1.ashx?url='+ journal.LogoUrl;
             var str ='<div id="conf_down_prev_id_'+index+'" class="radius event_item" style="float:left;'+style+'"  >'+
			      '<a href="conferences/conference.aspx?confid='+journal.Id+'" style="text-decoration:none"><img class="middle-img fleft" alt="" src="'+logo+'" style="margin:5px;" /></a>'+
                   '<span class=names style="display:block"><a href="conferences/conference.aspx?confid='+journal.Id+'" style="text-decoration:none">'+journal.Title+'</a></span>'+
                  '<h3 style="margin:0px;padding:2px;float:left;">'+journal.Address+'</h3>'+                  
                  '<h3 style="margin:0px;padding:2px;margin-left:10px"><span style="line-height:20px;padding-top:5px;margin-left:5px;padding:0px;"><p style="color:#C13504;display:inline;padding:0px;margin:0px; ">From</p>: '+journal.StartDate+'</span><span>  <p style="color:#C13504;foat:left;display:inline;padding:0px;margin:0px;">  To</p>: '+journal.EndDate+'</span></h3>'+                  
                  '<p style="text-align:justify">'+journal.Description+'</p>'+
		          '<div class="more"><a href="conferences/conference.aspx?confid='+journal.Id+'">more</a></div>'+
			   '</div>'
			  // alert(str);
             $('#past_events').append(str);
             var pindex= index+1;
             
              var mstr = ' <li style="padding:0px; margin:0px; float:left;min-width:20px;"><a style="text-align:center;line-height:30px;display:block;width:30px;" '+cls+' id="indexer_down_con_prev_'+index+'" href="javascript:void(0)" rel="#conf_down_prev_id_'+index+'" >'+pindex+'</a></li>'    
              $('#past_conf').append(mstr);
              
              $("#indexer_down_con_prev_"+index).click(function(){
               $('#past_conf li a').removeClass('active-indexer');
               $(this).addClass('active-indexer'); 
               var rel = $(this).attr('rel');
               //alert(rel);
               $('#past_events .event_item').hide();
               $(rel).show();
              
              });
         });
         
         
       },
       callback_publicLink:function(publicLinks){
       //alert(publicLinks);
       
           $.each(publicLinks, function(index, link) { 
           $('#div_public_link').show(); 
           $('#public_link_list').append('<li class="arrow-orange fleft"  style="width:45%;margin-right:5px; "><a href="'+link.lLink+'" > '+link.lText+'</a> </li>');
           });
       },
        bindvideos:function(videos){
            
           $.each(videos, function(index, video) {  
            //prompt('',video.Url);
            $('#div_conf_video').show();
                var id="";
               if(id= video.Url.split('&v=').length>0)
                 id= video.Url.split('&v=')[1];            
                $('#conf_videos').append('<li id="vedio_index_'+index+'"><a href="'+video.Url+'" rel="prettyPhoto" title="'+video.Title+'"><img src="http://img.youtube.com/vi/'+id+'/default.jpg" width="100" height="100" alt="" /><img class="pointer2" src="../Images/play.png" /></a></li>');
           });

            $('#conf_videos li a').click(function(){
               
               $('#video_obj').hide();
               var current = $(this);
                var src = $(this).attr('href');           
               $('#alert_container').show(100);
               $('#video_popup').animate({
                  width: "10%",
                 height:"10%"           
                   
                  }, 10 ).animate({
                  width: "55%"                    
                   
                  }, 1000 ).animate({                
                 height:"400px"           
                   
                  }, 1000, function(){                                    
                           var id="",url="";
                           try{
                           if(id= src.split('&v=').length>0)
                           {
                              id= src.split('&v=')[1];
                              url ='http://www.youtube.com/v/'+id+'?version=3&feature=player_detailpage';
                           }              
                           if(id==undefined)
                               url = src1;                            
                           //$('#video_embed').attr('src',url); 
                           $('#video_obj').empty(); 
                           $('#video_obj').html('<embed id="video_embed" style="width:100%;height:100%" type="application/x-shockwave-flash" src="'+url+'" pluginspage="http://www.adobe.com/go/getflashplayer" allowfullscreen="true" allowScriptAccess="always" />');              
                           $('#video_obj').show();                                               
                           $('#video_close').show();
                             // alert($('#video_obj').html()); 
                           }
                           catch(err)
                           {
                           alert(err);
                           }
                    })

                return false;
            })
      
       },
         bindpapersvideos:function(videos){
           //alert(videos);
           
           $.each(videos, function(index, video) {  
            //prompt('',video.Url);
            $('#div_papers_videos').show();
                var id="";
               if(id= video.Url.split('&v=').length>0)
                 id= video.Url.split('&v=')[1];            
                $('#papers_video').append('<li id="papers_vedio_index_'+index+'"><a href="'+video.Url+'" rel="prettyPhoto" title="'+video.Title+'"><img src="http://img.youtube.com/vi/'+id+'/default.jpg" width="100" height="100" alt="" /><img class="pointer2" src="../Images/play.png" /></a></li>');
           });

            $('#papers_video li a').click(function(){
               
               $('#video_obj').hide();
               var current = $(this);
                var src = $(this).attr('href');           
               $('#alert_container').show(100);
               $('#video_popup').animate({
                  width: "10%",
                 height:"10%"           
                   
                  }, 10 ).animate({
                  width: "55%"                    
                   
                  }, 1000 ).animate({                
                 height:"400px"           
                   
                  }, 1000, function(){                                    
                           var id="",url="";
                           try{
                           if(id= src.split('&v=').length>0)
                           {
                              id= src.split('&v=')[1];
                              url ='http://www.youtube.com/v/'+id+'?version=3&feature=player_detailpage';
                           }              
                           if(id==undefined)
                               url = src1;                            
                           //$('#video_embed').attr('src',url); 
                           $('#video_obj').empty(); 
                           $('#video_obj').html('<embed id="video_embed" style="width:100%;height:100%" type="application/x-shockwave-flash" src="'+url+'" pluginspage="http://www.adobe.com/go/getflashplayer" allowfullscreen="true" allowScriptAccess="always" />');              
                           $('#video_obj').show();                                               
                           $('#video_close').show();
                             // alert($('#video_obj').html()); 
                           }
                           catch(err)
                           {
                           alert(err);
                           }
                    })

                return false;
            })
      
       },
       confwidget:function(journals)
       {
        var str=""; 
         $('.loading').hide();
         $.each(journals, function(index, journal) {  
           var style ="display:none";
              var cls = 'class="active-indexer"';
            if(index==0)
             style="";
            else
              cls ="";
             var logo ='http://www.icgst-amc.com/institute/Handler1.ashx?url='+ journal.LogoUrl;
            
			   var str='<li>'+
		    '<div class="webgates-item">'+
            '<a href="http://www.icgst.com/conferences/conference.aspx?confid='+journal.Id+'"><img class="smal-img fleft" alt="" src="'+logo+'" />'+
             '<span  style="font-size:.8em;font-weight:bold">'+journal.Title+'</span><p style="color:#222;font-size:.8">'+journal.Address+'</p>'+
             '<span style="margin:0px;padding:0px;font-size:.8em;color:#222">From : '+journal.StartDate+'</span><span style="margin:0px;padding:0px;font-size:.8em;color:#222">   To: '+journal.EndDate+'</span>'+
              '<p style="margin:0px;padding:0px;font-size:.8em;color:#444"> '+journal.Description+'</p>'+
		     
		     
		   '</a></div>'+
		   '</li>';
			  // alert(str);
             $('#list_conferenece').append(str);
            
             
              
             
              
            
         });
          $('#list_conferenece .webgates-item p').expander({
             slicePoint:       130,  // default is 100
    
             expandText:         '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]'
           });
       }
       
    }

    return public;
} ();
