$(function()
{

/*----------------------------------------------------------
// Social Media Box
----------------------------------------------------------*/

if($('#social-media').length)
{
  // navigation
  $('#social-media-nav ul li').click(function(e)
  {
    e.preventDefault();
    var rel = $('a',this).attr('rel');
    
    $('#social-media-nav li.active').removeClass('active');  
    $(this).addClass('active');
    
    $('#social-media .item.active').removeClass('active').hide();
    $('#social-media .item.'+rel).addClass('active').fadeIn();
  });
  
  // combine tweets
  /*
  $(window).bind('load',function()
  {
    $('#tweets-clark .twtr-tweet').appendTo('#tweets-bcliberals .twtr-tweets');
  });
  */

}

/*----------------------------------------------------------
// Home - Slideshow
----------------------------------------------------------*/

if($('.home #slideshow').length)
{
  $('#slideshow .item').each(function()
  {
    var code = $('.youtube-code',this).html();
    var id = parseInt($(this).attr('id').replace('item-',''));
    if(code.length)
    {      
      // video config
      $(this).addClass('has-video');
      $('.img', this).attr('href','#');
      $(this).find(".slideshow-vid-play").show();
      $(this).bind('click',function()
      {
        if(!$('.youtube',this).hasClass('video-playing'))
        {
          $('.img',this).hide();
          $('.youtube',this).html('<object width="540" height="330" id="player-'+id+'"><param value="http://www.youtube.com/v/'+code+'&amp;hl=en&amp;autoplay=1fs=1&amp;rel=0&amp;showinfo=0&amp;autohide=0" name="movie"><param value="wmode" name="opaque"><param value="true" name="allowFullScreen"><param value="always" name="allowscriptaccess"><embed width="540" height="330" wmode="opaque" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://www.youtube.com/v/'+code+'&amp;hl=en&amp;autoplay=1&amp;fs=1&amp;rel=0&amp;showinfo=0&amp;autohide=0"></object>').show();
          $('.youtube',this).addClass('video-playing');
        }
      });
    }
    else
    {
      // image config
      $(this).addClass('has-image');
      $('.youtube',this).remove();
      $('.img img',this).hide();
      var img = $('.img img',this).attr('src');
      $('.img',this).css({background:'url("'+img+'") no-repeat 50% 50%'});
    }
  });
  
  var total = $('.home #slideshow .item').length;
  var width = $('.home #slideshow .screen').width();
  var totalWidth = width * total;
  var container = $('.home #slideshow .container');
  var timer;
  var npos = 0;
  var speed = 7000;
  
  // slideshow
  $('.home #slideshow .container').css({width:totalWidth});
  
  // navigation
  $('.home #slideshow .prev').live('click',function(e)
  {
    e.preventDefault();
    
    var current = $('#slideshow .item').eq(npos);
    
    if(current.hasClass('has-video'))
    {
      current.find('.img').show();
      current.find('.youtube').removeClass('video-playing').hide().empty();
    }
    
    //clearTimeout(timer);
    //timer = setTimeout(fn,speed);
    
    npos--;
    if(npos < 0) npos = total-1;
    slide();
  });
  
  $('.home #slideshow .next').live('click',function(e)
  {
    e.preventDefault();
    
    var current = $('#slideshow .item').eq(npos);
    
    if(current.hasClass('has-video'))
    {
      current.find('.img').show();
      current.find('.youtube').removeClass('video-playing').hide().empty();
    }
    
    //clearTimeout(timer);
    //timer = setTimeout(fn,speed);
    
    
    npos++;
    if(npos > total-1) npos = 0;
    slide();
  });
  
  /*
  var fn = function next()
  {
    $('.home #slideshow .next').click();
  }
  */

  // autoplay
  //timer = setTimeout(fn,speed);

  function slide()
  {
    var pos = -(npos * width);
    
    if(Modernizr.touch)
    {
      $('.home #slideshow .container').css({"-webkit-transform":'translate('+pos+'px,0)'});
    }
    else if(Modernizr.csstransitions)
    {
      $('.home #slideshow .container').css({left:pos});
    }
    else
    {
      $('.home #slideshow .container').animate({left:pos},500);
    }
  }
  
  /*
  $('#slideshow .item.has-video > .left').live('click',function(e)
  {
    clearTimeout(timer);
  });
  
  $('#slideshow .prev, #slideshow .next').live('click',function(e)
  {
    clearTimeout(timer);
    timer = setTimeout(fn,speed);
  });
  */
}

/*----------------------------------------------------------
// Feedback Tab
----------------------------------------------------------*/

if($('#feedback').length)
{
  // feedback button
  $('#feedback .feedback-tab').click(function(e)
  {
    e.preventDefault();
    
    if($('#feedback').hasClass('active'))
    {
      if(!Modernizr.csstransitions){
        $('#feedback').animate({left:0},500);
      }
        
      $('#feedback').removeClass('active');
    }
    else
    {
      if(!Modernizr.csstransitions){
        $('#feedback').animate({left:-255},500);
      }
    
      $('#feedback').addClass('active');
    }
  });
}

});









(function($, window, document, undefined) {
  $.fn.quicksearch = function (target, opt) {
    
    var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({ 
      delay: 100,
      selector: null,
      stripeRows: null,
      loader: null,
      noResults: '',
      bind: 'keyup',
      onBefore: function () { 
        return;
      },
      onAfter: function () { 
        return;
      },
      show: function () {
        this.style.display = "";
      },
      hide: function () {
        this.style.display = "none";
      },
      prepareQuery: function (val) {
        return val.toLowerCase().split(' ');
      },
      testQuery: function (query, txt, _row) {
        for (var i = 0; i < query.length; i += 1) {
          if (txt.indexOf(query[i]) === -1) {
            return false;
          }
        }
        return true;
      }
    }, opt);
    
    this.go = function () {
      
      var i = 0, 
      noresults = true, 
      query = options.prepareQuery(val),
      val_empty = (val.replace(' ', '').length === 0);
      
      for (var i = 0, len = rowcache.length; i < len; i++) {
        if (val_empty || options.testQuery(query, cache[i], rowcache[i])) {
          options.show.apply(rowcache[i]);
          noresults = false;
        } else {
          options.hide.apply(rowcache[i]);
        }
      }
      
      if (noresults) {
        this.results(false);
      } else {
        this.results(true);
        this.stripe();
      }
      
      this.loader(false);
      options.onAfter();
      
      return this;
    };
    
    this.stripe = function () {
      
      if (typeof options.stripeRows === "object" && options.stripeRows !== null)
      {
        var joined = options.stripeRows.join(' ');
        var stripeRows_length = options.stripeRows.length;
        
        jq_results.not(':hidden').each(function (i) {
          $(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]);
        });
      }
      
      return this;
    };
    
    this.strip_html = function (input) {
      var output = input.replace(new RegExp('<[^<]+>', 'g'), "");
      output = $.trim(output.toLowerCase());
      return output;
    };
    
    this.results = function (bool) {
      if (typeof options.noResults === "string" && options.noResults !== "") {
        if (bool) {
          $(options.noResults).hide();
        } else {
          $(options.noResults).show();
        }
      }
      return this;
    };
    
    this.loader = function (bool) {
      if (typeof options.loader === "string" && options.loader !== "") {
         (bool) ? $(options.loader).show() : $(options.loader).hide();
      }
      return this;
    };
    
    this.cache = function () {
      
      jq_results = $(target);
      
      if (typeof options.noResults === "string" && options.noResults !== "") {
        jq_results = jq_results.not(options.noResults);
      }
      
      var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults);
      cache = t.map(function () {
        return e.strip_html(this.innerHTML);
      });
      
      rowcache = jq_results.map(function () {
        return this;
      });
      
      return this.go();
    };
    
    this.trigger = function () {
      this.loader(true);
      options.onBefore();
      
      window.clearTimeout(timeout);
      timeout = window.setTimeout(function () {
        e.go();
      }, options.delay);
      
      return this;
    };
    
    this.cache();
    this.results(true);
    this.stripe();
    this.loader(false);
    
    return this.each(function () {
      $(this).bind(options.bind, function () {
        val = $(this).val();
        e.trigger();
      });
    });
    
  };

}(jQuery, this, document));

/* Center Overlay
------------------------------------------------*/

(function($){
     $.fn.extend({
          center: function (options) {
               var options =  $.extend({ // Default values
                    inside:window, // element, center into window
                    transition: 0, // millisecond, transition time
                    minX:0, // pixel, minimum left element value
                    minY:50, // pixel, minimum top element value
                    vertical:true, // booleen, center vertical
                    withScrolling:true, // booleen, take care of element inside scrollTop when minX < 0 and window is small or when window is big
                    horizontal:true // booleen, center horizontal
               }, options);
               return this.each(function() {
                    var props = {position:'absolute'};
                    if (options.vertical) {
                         
                         //Resizing image based on viewport's height
                         if($(this).find('#slideshow-image').length) {
                            $(this).find('#slideshow-image').width("auto").height( $(window).height()*90/100 );
                         }
                      
                         var top = ($(options.inside).height() - $(this).outerHeight()) / 2;
                         if (options.withScrolling) top += $(options.inside).scrollTop() || 0;
                         top = (top > options.minY ? top : options.minY);
                         $.extend(props, {top: top+'px'});
                      

                    }
                    if (options.horizontal) {
                      
                          //Resizing image based on viewport's height
                          if($(this).find('#slideshow-image').length) {                      
                             $(this).find('#slideshow-image').width("auto").height( $(window).height()*90/100 );
                          }
                      
                          var left = ($(options.inside).width() - $(this).outerWidth()) / 2;
                          if (options.withScrolling) left += $(options.inside).scrollLeft() || 0;
                          left = (left > options.minX ? left : options.minX);
                          $.extend(props, {left: left+'px'});
                    }
                    if (options.transition > 0) $(this).animate(props, options.transition);
                    else $(this).css(props);

                    return $(this);
               });
          }
     });
})(jQuery);




/* Photo Gallery
------------------------------------------------*/    

var preloader = "<div class='preloader'></div>";
var prev;
var next;

  //Navigation (prev/next)
  function navigation() {
    
     //Preloader effect
     $("#carousel-popup #main-photo img").animate({opacity:'0.2'});
     $("#carousel-popup #main-photo").append(preloader);
       if(next.length==0) {
         $(".overlay-next").hide();
       } else {
         $(".overlay-next").show();
       }
       if(prev.length==0) {
         $(".overlay-prev").hide();
        } else {
         $(".overlay-prev").show();
       }
    }

   function cleanup() {
     $("#popup-nav").empty();
        $('.popup-container,.overlay').stop().fadeOut();

        $("#carousel-popup .carousel-popup").stop().fadeOut(500,function(){
           $("#carousel-popup #main-photo").empty();
     });

     $(".preloader").remove();
   }

   function buildgallery() {

    if($('.photo-gallery').length) {
      
      if($('#carousel-popup').length) {
         $('#carousel-popup').insertAfter('body > .bcc-page');
         $('.photo-gallery .item').live('click',function(e){
           e.preventDefault();
      
            $("#popup-nav").append('<div class="overlay-prev"></div><div class="overlay-next"></div>');
    
            var img = new Image();
            var bigimg = $(this).find(".large").attr("src");
            var title = $(this).find(".title").text();
            var desc = $(this).find(".desc").text();
            next = $(this).next();
            prev = $(this).prev();
            navigation();
            $('#carousel-popup .overlay,#carousel-popup,.carousel-popup').fadeIn();
            $(preloader).appendTo('#carousel-popup');
      
         $(img).hide().load(function() {
            $("#carousel-popup #main-photo img").animate({opacity:'1'});
            $("#carousel-popup #main-photo").empty().append(this);
            $(this).fadeIn();
            $(".fs-preloader").remove();
               
            $('#carousel-popup,#carousel-container,#carousel-container .carousel-popup').fadeIn();
           
            //Add title to photo and adjust width according to the image size
            $('.carousel-popup h3').text(title);
            $(".carousel-popup h3").css("width",$("#main-photo img").width()+"px");
           
            //Set height to fix CSS3 shadow on Chrome/Safari
            $("#main-photo").css("height",$("#main-photo img").height()+"px");
            $('#carousel-popup .popup-container:visible').center();
         }).attr("src",bigimg);
           
    });
    
    $(window).bind('resize', function() {
      $('#carousel-popup .popup-container:visible').center();
    });
  }
    //Create carousel thumbnails
    $('.photo-gallery .item').each(function(i){   
    $(this).css("cssText","background:url("+$(this).find('.small').attr('src').replace(/ /g,"%20").replace(/'/g,"%27").replace("(","%28").replace(")","%29")+") no-repeat 50% 50%");
    });  
      
   //Carousel
   var $_total = $('.photo-gallery .item').length;
   var $_total2 = Math.ceil($_total / 4);
   var $slideshow_width = $('.photo-gallery .screen').width();
   var $_total_width = $_total2 * $slideshow_width;
   var $_first = $('.photo-gallery .item:first');
   var $npos = 0;

   if($_total_width < $('.photo-gallery .navigation').width()){
      $_total_width = $('.photo-gallery .navigation').width();
   }
      
   $(".photo-gallery .screen").css("width","20000em");        
        
   $('.photo-gallery .prev').live('click',function(e){
    e.preventDefault();
    $npos--;
    if($npos < 0) $npos = 0;
    $('.photo-gallery .screen').animate({left:$npos * -($slideshow_width+11)}, 500);
   });
        
   $('.photo-gallery .next').live('click',function(e){

    e.preventDefault();
    $npos++;
    if($npos >= $_total2) $npos = 0;
    $('.photo-gallery .screen').animate({left:$npos * -($slideshow_width+11)}, 500);
   });
    }}

  $(document).ready(function() {
    //Binding event to overlay next/prev buttons
    $(".overlay-prev").live('click',function() {
       navigation();
       prev.click();  
    });
    
    $(".overlay-next").live('click',function() {
       navigation();
       next.click();
    });  

    $('.overlay,.popup-close').live('click',function(event) {
       event.preventDefault();
       cleanup();
    });

  /* Close .ready() */  
  });


//Digital Brigade

$(document).ready(function(){
   
   if($("#digital-brigade").length) {
      /*($.cookie('remember') != 'true') ? $("#db-bar").show() : false;*/
      $("#digital-brigade .close").click(function(e) {
         e.preventDefault();
         $("#db-bar").fadeOut();   
         /*$.cookie('remember', true, { expires: 30 });*/
      });
      $(".rr-btn").click(function() {
         $("#db-bar").fadeOut();   
         /*$.cookie('remember', true, { expires: 30 });*/
      });
   }
});


 /**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);



$(document).ready(function() {

    // Main Nav Hover function
    $('.bcc-nav li').hoverIntent({
        timeout:300,
        over:function(){
            $(this).find("a.more").addClass("active");
            $(this).find(".level2-wrapper").show(250);
        },
        out:function(){
            $(this).find("a.more").removeClass("active");
            $(this).find(".level2-wrapper").hide(250);

        }
    });
    
    // Add more arrow to section that has sub sections
    $(".bcc-nav li").each(function() {
       if($(this).find(".lcol").text().length) {
          $(this).find("a:first").addClass("more");
       } else {
          $(this).find(".absolute").hide();
       }
       //Bold Our
       var formatted = $(this).find("a:first").text().replace(/Our/gi,"<span class='light'>Our</span>");
       $(this).find("a:first").html(formatted);
    });
  
    //Unbind click for each menu that has dropdown
    $(".bcc-nav a.more.active").live('click',function(e) {
        e.preventDefault;return false;
    });
  
    //Dynamic width for the social footer
    $(".bcc-footer .item").each(function() {
      if($(this).find(".caption").text().length > 9) {
         $(this).find(".caption").css({"width":"110px","margin":"9px 0px 0px 11px"});  
      }
    });
  
    //Display attach image
    if($(".attach-img").length) {
      $(".attach-img").each(function() {
         ($(this).attr("src") == "") ? $(this).hide() : false;
      });
    }
  
    //Recent News
    if($(".attach-img.news").length) {
      $(".attach-img.news").each(function() {
         ($(this).attr("src") == "") ? $(this).attr("src","/media/templates/bc-libs-ph-logo.png").fadeIn() : false;
      });
    }
  
    //MLAs Bio
    if($(".mla-bio").length) {
        $(".mla-bio").each(function() {
          var bioimg = "url("+$(this).attr("rel").replace(/ /g,"%20")+")";
          $(this).css({"background-image":bioimg});
          ($(this).attr("rel") == "") ? $(this).css({"background-image":"url(/media/templates/bio-ph-big.jpg)"}).fadeIn() : false;
      });
    }
  
    //Cpath validation
    if($("#cpath-title").length) {
      ($("#cpath-title").attr("title")==$("#cpath-title").prev().attr("title")) ? $("#cpath-title").prev().hide():false;
    }
  
    //Wrap Quote style
    if($(".Quote").length) {
       $(".Quote").prepend('<img src="/media/templates/quote-start.jpg" alt="" class="start"/>').append('<img src="/media/templates/quote-end.jpg" alt="" class="end"/>');
    }
    
    //MLA body text JS
    if($("#body-short").length) { 
       //$("#body-short").html($("#body-full-html").html().substring(0,250) + ' [...] <a href="#" class="more-arrow" id="showmore">SHOW MORE</a>');
       $("#body-short").html($("#body-full-html").html().substring(0,250)).append('[...] <a href="#" class="more-arrow" id="showmore">SHOW MORE</a>');
                             
       $("#showmore").live('click',function(e) {
           e.preventDefault();
           $("#body-short,#showmore").hide(400,function() {$("#body-full").show(400);});
       });
       $("#showless").live('click',function(e) {
           e.preventDefault();
           $("#body-full").hide(400,function() {$("#body-short,#showmore").show(400);});
       });
    }
  
   //YouTube Player
   if($("#youtube-player").length) {
     if($("#youtube-player").attr("rel")!="") {
         $("#youtube-player").html('<object width="540" height="330" id="object-8779"><param value="http://www.youtube.com/v/'+$("#youtube-player").attr("rel")+'&hl=en&autoplay=1fs=1&rel=0&showinfo=0&autohide=0" name="movie"><param value="wmode" name="opaque"><param value="true" name="allowFullScreen"><param value="always" name="allowscriptaccess"><embed width="540" height="330" wmode="opaque" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://www.youtube.com/v/'+$("#youtube-player").attr("rel")+'&hl=en&autoplay=1&fs=1&rel=0&showinfo=0&autohide=0"></object>').addClass("mb10").fadeIn(); 
     }
   }
 
  
//close.ready()  
});

/**
* jQuery Cookie plugin
*
* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

/* CAROUSEL SCRIPTS */
function carousel(totalperpage) {
  
  $('.the-carousel-gallery').each(function()
  {
    //Carousel
    var $_total = $(this).find('.item:visible').length;
    var items = $('.the-carousel-gallery .item:visible');
    var itemsperpage = totalperpage;
    var $_total2 = Math.ceil($_total / itemsperpage);
    var $slideshow_width = $('.the-carousel-gallery .navigation').width();
    var $_total_width = $_total2 * $slideshow_width;
    var $_first = $(this).find('.item:first');
    var $npos = 0;

     if($_total_width < $(this).find('.navigation').width())
     {
      $_total_width = $(this).find('.navigation').width();
     }
      
    //Add a wrapper every X items
    
    for(var i = 0; i < items.length; i+=itemsperpage) {
      items.slice(i, i+itemsperpage).wrapAll("<div class='wrapper'></div>");
    }  
    
    $(this).find(".screen").css("width","20000em");        
        
     $(this).find('.prev').live('click',function(e)
     {
      e.preventDefault();
  
      $npos--;
      if($npos < 0) $npos = $_total2-1;
      $(this).parents('.the-carousel-gallery').find('.screen').stop().animate({left:$npos * -($slideshow_width)}, 500);
       
      $(this).parents('.the-carousel-gallery').find(".item-li.active").removeClass("active");
      $(this).parents('.the-carousel-gallery').find(".item-li").eq($npos).addClass("active");
     });
        
     $(this).find('.next').live('click',function(e)
     {
      e.preventDefault();
      $npos++;
      if($npos >= $_total2) $npos = 0;
  
      $(this).parents('.the-carousel-gallery').find('.screen').stop().animate({left:$npos * -($slideshow_width)}, 500);
      $(this).parents('.the-carousel-gallery').find(".item-li.active").removeClass("active");
      $(this).parents('.the-carousel-gallery').find(".item-li").eq($npos).addClass("active");
     });
    
    //Pagination
    
    if($(".pagination").length) {        
      
       if($(".item-li").length){
           $(".item-li").remove();
       }
      
       for( i=$_total2; i > 0; i--) {
          $("<li class='item-li' rel="+(i-1)+"><a>"+i+"</a></li>").insertAfter($(this).find(".prev-li"));  
       };  
  
       $(this).find(".item-li:first").addClass("active");
  
       $(this).find(".item-li").live('click',function() {

        var pos = $(this).attr("rel");
    
        $(this).parents('.the-carousel-gallery').find(".item-li.active").removeClass("active");
        $(this).addClass("active");
        $(this).parents('.the-carousel-gallery').find('.screen').stop().animate({left:pos * -($slideshow_width)}, 500);
       });
      
        //Remove pagination if there's only one page
     //   $(".pagination").each(function() {
       //   ($(this).find(".item-li").length ==1) ? $(".paging-nav").hide(): $(".paging-nav").show();
     //   });
    } 
    
  //end each()  
});  
 
}


var openPopup = window.open;

function show_msg(msg) { alert(msg); }

function validateForm() {
	missing_required = 0;

	for (i = 0; i < arguments.length; i++) {
		if(arguments[i] == '') {
			missing_required = 1;
		}
	}

	if(missing_required) {
		alert("A required form field is missing.");
		return false;
	} else {
		return true;
	}
}

function expCustomLink(myURL) {
	location.href = myURL;
}

function setUrl(path) {
	document.location.href = path;
}

function expArticleLink(sectionId, articleId) {
	location.href = '/index.php?section_id=' + sectionId + '&section_copy_id=' + articleId;
}

function expPopupWindow(url, widthVal, heightVal, resizableVal, scrollbarsVal, toolbarVal, locationVal, directoriesVal, statusVal, menubarVal, copyHistoryVal) {

	var attributes = "width="  	 	 + widthVal       +
				 	 ",height=" 	 + heightVal      +
				 	 ",resizable="  + resizableVal  +
				 	 ",scrollbars="  + scrollbarsVal  +
				 	 ",toolbar=" 	 + toolbarVal 	  +
				 	 ",location=" 	 + locationVal 	  +
				 	 ",directories=" + directoriesVal +
				 	 ",status=" 	 + statusVal 	  +
				 	 ",menubar=" 	 + menubarVal 	  +
				 	 ",copyhistory=" + copyHistoryVal;

	window.open(url, 'WindowName', attributes);
}

function xprLog(msg) {
    if (window.console) console.log(msg);
}

if (document.addEventListener) {  
    document.addEventListener("DOMContentLoaded", function () { if (typeof onXprPageLoad == 'function') onXprPageLoad(); }, false);
} else if (document.attachEvent) {  
    document.attachEvent('DOMContentLoaded', function () { if (typeof onXprPageLoad == 'function') onXprPageLoad(); });
}  

