var pauseSlider
$(document).ready(function() {	

   $('#viewGalery').click(function(event){

        $.ajax({
            type: "POST",
            url: "gallery-details.php",
            success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
         });
   
   }); 
   
    
    $('#addNewsComment').click(function(event){

          var idNewsComment = $('#newsId').attr('value');
          var comment = $('#commentbox').attr('value');
		  var idReviewComment = $('#reviewId').attr('value');
		  var parameter = "newsComment=" + comment ;
          var idPreviewComment = $('#previewId').attr('value'); 
		  var idVideoComment = $('#videoId').attr('value'); 
		  var idPodcastComment = $('#podcastId').attr('value'); 
		  var idGoddessComment = $('#goddessId').attr('value');
		  var idEventComment = $('#eventId').attr('value');	
    
		  if(idGoddessComment != undefined)
		  parameter = parameter + "&idGoddessComment=" + idGoddessComment;
		  
		  if(idVideoComment != undefined)
		  parameter = parameter + "&idViodeoComment=" + idVideoComment;
          
          if(idPreviewComment != undefined)
		  parameter = parameter + "&idPreviewComment=" + idPreviewComment;
		 		  
		  if(idNewsComment !=  undefined)
		  parameter = parameter + "&idNewsComment=" + idNewsComment;

		  if(idReviewComment != undefined)
		  parameter = parameter + "&idReviewComment=" + idReviewComment ;
		  
		  if(idPodcastComment != undefined)
		  parameter = parameter + "&idPodcastComment=" + idPodcastComment ;
		  
		  if(idEventComment != undefined)
		  parameter = parameter + "&idEventComment=" + idEventComment ;
		  
		  		   
         $.ajax({
             type: "POST",
             url: "postComment.php",
             data: parameter,
             success: function(msg){
			     $('#commentList').html(msg);
                 $('#commentbox').attr('value', '');
             }
             
          });            
     }); 
    
    $('#loginComments').click(function(event){

        var userName = $('#userComm').attr('value');
        var passWord = $('#passComm').attr('value');
            
        var parameter = "userName=" + userName + "&passWord=" + passWord;

             $.ajax({
                type: "POST",
                url: "dataManager/validateForumUser.php",
                data: parameter,
                 success: function(msg){
                     
                    if(msg == 'wrong'){
                        
                        var notice = '<div class=\"notice\">'
                                      + '<div class=\"notice-body\">' 
                                          + '<img src=\"/images/info.png\" alt=\"\" />'
                                          + '<h3>wrong username or password</h3>'
                                          + '<p>Please try again</p>'
                                      + '</div>'
                                      + '<div class=\"notice-bottom\">'
                                      + '</div>'
                                  + '</div>';
                                  
                            $( notice ).purr(
                                {    
                                   
                                }
                            ); 
                       
                    }else{             
                      $('#login_f').toggle().html(msg).fadeIn("500");
                      $('#userComm').attr('value','');
                      $('#passComm').attr('value','');
                      $('#commentPostArea').show();
                      $('#loginC').hide();                                      
                      }                       
                    }
                });
            });
    
    
    $('.eventsList').click(function(event){
        $.ajax({
            type: "POST",
            url: "eventsList.php",
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
         });        
    });
    
    $('#allVideos').click(function(event){
        $.ajax({
            type: "POST",
            url: "videosList.php",
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
         });
    });
    
    
    $('.goddessPodcast').click(function(event){
       $.ajax({
            type: "POST",
            url: "goddessList.php",
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
         });
    });
    
    
    $('.viewGoddess').click(function(event){
        var idGoddess = $(this).attr('id');
        var goddesParameter = "idGoddess=" + idGoddess;
        $.ajax({
            type: "POST",
            url: "goddess-details.php",
            data: goddesParameter,
             success: function(msg){
                   $('.sideTbgRight').show();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
         });
    });
    
    $('.event-link').click(function(event){
        var idEvent = $(this).attr('id');
        var eventParameter = "idEvent="+idEvent;
        $.ajax({
            type: "POST",
            url: "events-details.php",
            data: eventParameter,
             success: function(msg){
                  $('.sideTbgRight').show();                
                   $('#bg2').html(msg).fadeIn("500");   
                }
            });
    });
    
    $('.viewPodcast').click(function(event){
        var idPodcast = $(this).attr('id');
        var podcastParameter = "idPodcast=" + idPodcast;
        $.ajax({
            type: "POST",
            url: "podcast-details.php",
            data: podcastParameter,
             success: function(msg){
                   $('.sideTbgRight').show();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });
   });    
    
   $('.morePodcast').click(function(event){
      $.ajax({
            type: "POST",
            url: "podcastList.php",
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });
   });    
    
    $('.aboutUs').click(function(event){
         $.ajax({
            type: "POST",
            url: "aboutUs.php",
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });
    });
    
    $('#viewGameNight').click(function(event){
	
	      $.ajax({
            type: "POST",
            url: "gamenight-details.php",
             success: function(msg){
                   $('.sideTbgRight').show();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });	
	});
	
	$('.contactUs').click(function(event){
          $.ajax({
            type: "POST",
            url: "contactus.php",
             success: function(msg){
                   $('.sideTbgRight').show();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });
    });
    
    $('.viewNews').click(function(event){
         var idNews = $(this).attr('id');
         var newsParameter = "idNews=" + idNews;
                  
          $.ajax({
            type: "POST",
            url: "news-details.php",
            data: newsParameter,
             success: function(msg){
                   $('.sideTbgRight').show();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });     
     });     
     
$('.allNews').click(function(event){         
          var listRequest = "r=r" ;         
          $.ajax({
            type: "POST",
            url: "newsList.php",
            data: listRequest,
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("100");   
                }
            });    
     });
     
     $("#forumViewLoad").click(function(event){
            $("#userNameH").attr('value','');
             $("#passWordH").attr('value','');             
                    
             var r = "r"
             $.post(
                  "dataManager/loadSessionData.php", 
                  { r: r },
                  function(data){
                      
                      var userName = data.userName;
                      var passWord = data.passWord;
                    
                      if(userName == null){
                           window.location = 'forum/index.php';                     
                      }else{
                          
                          $("#userNameH").attr('value',userName);
                          $("#passWordH").attr('value',passWord);
                          document.getElementById('hiddenSubm').click();                      
                      }
                      
                  }
                  , 'json');
      });    
          
     $('.forumView').click(function(event){
         
         $("#userNameH").attr('value','');
         $("#passWordH").attr('value','');        
                
         var r = "r"
         $.post(
              "dataManager/loadSessionData.php", 
              { r: r },
              function(data){
                  
                  var userName = data.userName;
                  var passWord = data.passWord;
              
                  if(userName == null){
                       window.location = 'forum/index.php';                     
                  }else{
                      
                      $("#userNameH").attr('value',userName);
                      $("#passWordH").attr('value',passWord);
                      document.getElementById('hiddenSubm').click();                  
                  }
                  
              }
              , 'json');     
     });   
  
    
    $('.viewReview').click(function(event){            

         var idReview = $(this).attr('id');
         var reviewParameter = "idReview=" + idReview;
                  
          $.ajax({
            type: "POST",
            url: "review-details.php",
            data: reviewParameter,
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });    
     });
     
     
     $('.moreReviews').click(function(event){
         var listRequest = "r=r" ;         
          $.ajax({
            type: "POST",
            url: "reviewList.php",
            data: listRequest,
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("100");   
                }
            });    
     });
            
            
   $('.viewPreview').click(function(event){       
       var idPreview = $(this).attr('id');
         var previewParameter = "idPreview=" + idPreview;                  
          $.ajax({
            type: "POST",
            url: "preview-details.php",
            data: previewParameter,
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });            
      });
      
      
      $('.morePreviews').click(function(event){          
         var listRequest = "r=r" ;         
          $.ajax({
            type: "POST",
            url: "previewList.php",
            data: listRequest,
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("100");   
                }
            });    
       });
      
      
   $('#suggestBox2').keyup(function(e) { 
       if(e.keyCode == 13) {           
         var namePart = $(this).attr('value');
         var parameter = "namepart=" + namePart;         
         if(namePart != ''){
         $.ajax({
            type: "POST",
            url: "searchDetails.php",
            data: parameter,
             success: function(msg){
                   $('.sideTbgRight').hide();
                   $('#bg2').hide().html(msg).fadeIn("500");   
                }
            });
         }         
      }
   });
   
   $('.passWordImp').keyup(function(e) {
       if(e.keyCode == 13) {
         loginLocalForum();
        }       
      });    

    
    $('#loginBtn').click(function (event){        
       loginLocalForum(); 
    });
	
	$('#sliderBack').click(function(event){
	   makeBackWardSlider();	
	}); 

   $('#sliderPause').click(function(event){
      pauseSlider();
   });  

	$('#sliderFordward').click(function(event){
	  fordwardSlider();	
	});		
    
    function loginLocalForum(){
        
         var userName = $('#username').attr('value');
        var passWord = $('#password').attr('value');
        
        var parameter = "userName=" + userName + "&passWord=" + passWord;
        
        $.ajax({
            type: "POST",
            url: "dataManager/validateForumUser.php",
            data: parameter,
             success: function(msg){
                 
                if(msg == 'wrong'){
                    
                    var notice = '<div class="notice">'
                                  + '<div class="notice-body">' 
                                      + '<img src="/images/info.png" alt="" />'
                                      + '<h3>wrong username or password</h3>'
                                      + '<p>Please try again</p>'
                                  + '</div>'
                                  + '<div class="notice-bottom">'
                                  + '</div>'
                              + '</div>';
                              
                        $( notice ).purr(
                            {                             
                               
                            }
                        );             
                 
                }else             
                  $('#login_f').toggle().html(msg).fadeIn("500");
                  $('#loginC').hide();
                   $('#commentPostArea').show();
                   
                }
            });
    }
    
    function seWhat(){
        
        var userName = $('#username').attr('value');
        var passWord = $('#password').attr('value');        
        var parameter = "userName=" + userName + "&passWord=" + passWord;
        
        $.ajax({
            type: "POST",
            url: "dataManager/validateForumUser.php",
            data: parameter,
             success: function(msg){                 
                if(msg == 'wrong'){                    
                    var notice = '<div class="notice">'
                                  + '<div class="notice-body">' 
                                      + '<img src="/images/info.png" alt="" />'
                                      + '<h3>wrong username or password</h3>'
                                      + '<p>Please try again</p>'
                                  + '</div>'
                                  + '<div class="notice-bottom">'
                                  + '</div>'
                              + '</div>';
                              
                        $( notice ).purr({});                 
                }else {
                  $('#login_f').toggle().html(msg).fadeIn("500");
                }
                }
            });         
    }
    
    
    $(".newsTruncate").truncate( 300); 
    $(".newsCondensedTruncate").truncate(180); 
    $('#news-container').tabs({ fxSlide: true, fxFade: true, fxSpeed: 'normal' });   
	$('#news-container2').tabs({ remote: true, fxSlide: true });
    $('#slider1').s3Slider({ timeOut: 4000 });
 
var profiles =
    {
        window800:
        {
            height:800,
            width:800,
            status:1
        },
        window200:
        {
            height:200,
            width:200,
            status:1,
            resizable:0
        },
        windowCenter:
        {
            height:300,
            width:400,
            center:1
        },
        windowNotNew:
        {
            height:480,
            width:450,
            center:1,
            createnew:0
        }
    };
   $(function(){
	   $(".popupwindow").popupwindow(profiles);
   });
});