﻿/* Fix All Png in the document : start /////////////////////////////////////// */
$(function(){
       $(document).pngFix();
});
/* Fix All Png in the document : end //////////////////////////////////////// */

    
// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(function( $ ){
	
	$('#slideshow').serialScroll({
		items:'li',// Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'#slideshowscreen img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'#slideshowscreen img.next',// Selector to the 'next' button (absolute too)
		offset:-150, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:1, //as we are centering it, start at the 2nd
		duration:1200,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true,// Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		stop:true,
		lock:false,
		cycle:true, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: true //click on the images to scroll to them
		
		
		//axis:'xy',// The default is 'y' scroll on both ways
		//navigation:'#navigation li a',
		//queue:false,// We scroll on both axes, scroll both at the same time.
		//event:'click',// On which event to react (click is the default, you probably won't need to specify it)
		//stop:false,// Each click will stop any previous animations of the target. (false by default)
		//lock:true, // Ignore events if already animating (true by default)		
		//start: 0, // On which element (index) to begin ( 0 is the default, redundant in this case )		
		//cycle:true,// Cycle endlessly ( constant velocity, true is the default )
		//step:1, // How many items to scroll each time ( 1 is the default, no need to specify )
		//jump:false, // If true, items become clickable (or w/e 'event' is, and when activated, the pane scrolls to them)
		//lazy:false,// (default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
		//interval:1000, // It's the number of milliseconds to automatically go to the next
		//constant:true, // constant speed
		
	});
    
    $("#slideshow a").click(function() {
       var url = $(this).attr("href");
       window.location = url;
    });
    
});

/* ---------------------------- Search Results Tabs -------------------------------- */
$(function(){
   if( $("#tab_01").length > 0 ) {
      $(".tab_site").click(function(){
         $("#tab_02").hide();
         $("#tab_03").hide();
         $("#tab_01").fadeIn("Slow");
         $(".tabbed_nav li:nth-child(2)").removeClass('selected');
         $(".tabbed_nav li:nth-child(3)").removeClass('selected');
         $(".tabbed_nav li:nth-child(1)").addClass('selected');
      })
      
      $(".tab_pa").click(function(){
         $("#tab_01").hide();
         $("#tab_03").hide();
         $("#tab_02").fadeIn("Slow");
         $(".tabbed_nav li:nth-child(1)").removeClass('selected');
         $(".tabbed_nav li:nth-child(3)").removeClass('selected');
         $(".tabbed_nav li:nth-child(2)").addClass('selected');
      })
      
      $(".tab_uncvtnl").click(function(){
         $("#tab_01").hide();
         $("#tab_02").hide();
         $("#tab_03").fadeIn("Slow");
         $(".tabbed_nav li:nth-child(1)").removeClass('selected');
         $(".tabbed_nav li:nth-child(2)").removeClass('selected');
         $(".tabbed_nav li:nth-child(3)").addClass('selected');
      })
   }
   
    var status = true;      
    $("#hide").click(function(){
        if(status == true) {
            $("#search_option").fadeOut("fast");
            $("#hide").empty();
            $("#hide").append("Show");
            $("#hide").removeClass("hide");
            $("#hide").addClass("hide_off");
            status = false;
        }else if(status == false) {
            $("#search_option").fadeIn("fast");
            $("#hide").empty();
            $("#hide").append("Hide");
            $("#hide").removeClass("hide_off");
            $("#hide").addClass("hide");
            status = true;
        }
    });
});


/* ---------------------------- Quick Login Box ------------------------------------------ */
$(function(){
    if($("#login_div").length) {
        
        $('.login').click(function() {
            
            $("#login_div").fadeIn("slow");
            var input_first = $("#login_div input:first");
            var status = false; 
            setTimeout( function() {  
               if(input_first.val() == "") {
                  status = true;
                  checkFields(input_first);
               }
            }, 5000);    
            
            function checkFields(input_first) {
               if(input_first.val() == "") {
                  $("#login_div").fadeOut("slow")
               }
            }
        });
        
        $('#close').click(function() {
            $("#login_div").fadeOut("slow");
        });
    }
});

/* ---------------------------- Article ------------------------------------------------ */
/* Remove the align="left" attribute */
$(function(){
   $(".left_column .article .article_content img").attr("align","");
});

/* ---------------------------- Bookmarking IE6 ---------------------------------------- */
$(function(){
   var cssObj = {
     "cursor":"pointer"
   }
   
   if($.browser.msie && $.browser.version=="6.0") {
       $(".article_tools").css(cssObj);
       
       if($(".icon_share").length > 0) { 
          $(".icon_share,.bookmarking").hover(function() {
             $(".bookmarking").addClass('active');
             $(".bookmarking").fadeIn("slow");
          },function() {
             $(".bookmarking").removeClass('active');
             setTimeout(function() {
                  $('.bookmarking:not(.active)').fadeOut(function() {
               });
             }, 800);
          });
       }
   }
});


$(function(){
 // $(".section_06 table").css("width","420px");
});

$(function(){ 
  $(".sub_nav .arrow_right").html("&nbsp;");
});


/* Insert double <br> for year pager in order to create space between the 2 lines */ 
/* File: IssueListArchive.ascx  */
/* Page: /PE/Archive.html */
$(function(){ 
  var count = 0;
  if($(".issue_year").length > 0) {
    $(".issue_year a").each(function(i) { 
       count++;
       if(count == 12) {
           $(this).after("<br><br>");
           count = 0;
       }
    }) 
  }
});
// -- end 
