/*----------------------------------------------------------
----------------------------------------------------------
// <3 BACKBONE
//
// 1. DEFAULT SCRIPT
// 2. LOGO
// 3. BLOG
//
----------------------------------------------------------
----------------------------------------------------------*/

// backbone tech
var addthis_share = { templates: { twitter: '{{title}} {{url}} via @backbonetech' } };
var addthis_config = {"data_track_clickback":true};


if($('#language-switcher-con .active').text().search('English') == -1)
{
  // backbone latam
  $('body').addClass('es');
}



$(function(){

/*----------------------------------------------------------
// DEFAULT SCRIPT
----------------------------------------------------------*/


// super header bold text
  if($('h1:contains({),h2:contains({),h3:contains({),h4:contains({),h5:contains({),h6:contains({),#recent-post ul li a:contains({),#social-media h1:contains({),#home-header-right .desc:contains({)').length)
{
  $('h1:contains({),h2:contains({),h3:contains({),h4:contains({),h5:contains({),h6:contains({),#recent-post ul li a:contains({),#social-media h1:contains({),#home-header-right .desc:contains({)').each(function()
  {
    var text = $(this).html().replace(/{/g,'<strong>').replace(/}/g,'</strong>');
    $(this).html(text);
  });
}


/*----------------------------------------------------------
// LOGO
----------------------------------------------------------*/

//$('.csstransitions #logo').css({bottom:35});
//$('.csstransitions #language-switcher').css({top:15});


/*----------------------------------------------------------
// BLOG
----------------------------------------------------------*/

if($('#blog').length)
{
  // blog footer menu
  $('.prev-num, .next-num').removeAttr('href');
  
  // substr
  $('#posts .post').each(function()
  {
    var gallery = '';
    if($('.blog-post-gallery',this).length) gallery = $('.blog-post-gallery',this).html();
    var html = $('.text',this).html().substr(0,300);
    if($('.text',this).html().length > 300) html += '…';
      
    $('.text',this).html(html);
    if(gallery.length)  $('.text .blog-post-gallery',this).empty().append(gallery);
    $('.text',this).show();
  });
  
  // fancy box img
  if($('#post-detail').length)
  {
    $('#post-detail img:not(.donothing)').each(function()
    {
      if($(this).attr('src').length)
      {
        var img = $(this).attr('src');
        var alt = $(this).attr('alt');
        $(this).replaceWith('<a rel="fancybox" href="'+img+'" title="'+alt+'"><img src="'+img+'" alt="'+alt+'" width="624"></a>');
      }
    });
    
    $('a[rel="fancybox"]').fancybox({
      'overlayShow'  : false,
      'transitionIn'  : 'elastic',
      'transitionOut'  : 'elastic',
      'titlePosition' : 'over'
    });
  }
  
  $('.post .img').each(function()
  {
    var img = $('img',this).attr('src').replace('/media/','');
    if(!img.length) $(this).hide();
  });
  
  // movable menu
  $(window).bind('load',function()
  {    
    var sidebar    = $("#blog-sub-menu"),
    target    = $("#blog-sub-menu, #blog > aside"),
    $window    = $(window),
    overall    = sidebar.offset().top + $('#posts').height() - $("#blog > aside").height(),
    offset    = sidebar.offset();
  
    $window.scroll(function()
    {  
      if($window.scrollTop() > offset.top && $window.scrollTop() < overall)
      {
        var pos = $window.scrollTop() - offset.top;
        
        if(Modernizr.touch)          target.css({'-webkit-transition-duration':'200ms','-webkit-transform':'translate3d(0px,'+pos+'px,0px)'});
        else if(Modernizr.csstransitions)  target.css({marginTop: pos});
        else                target.stop().animate({marginTop: pos});
      }
      else
      {
        if(Modernizr.touch)          target.css({'-webkit-transition-duration':'200ms','-webkit-transform':'translate3d(0px,0px,0px)'});
        else if(Modernizr.csstransitions)  target.css({marginTop: 0});
        else                target.stop().animate({marginTop: 0});
      }
    });
  });
}

});


/*-----------------------------------------------
  CHARACTER COUNT
 ------------------------------------------------*/

function limitChars(textid, limit, infodiv) {

    var text = jQuery('.' + textid).val();
    var textlength = text.length;

    if (textlength > limit) {
        jQuery('.' + textid).val(text.substr(0, limit));
        alert('Max character count has been reached');
        return false;
    }
    else {
        jQuery('#' + infodiv).html((limit - textlength) + ' characters)');
        return false;
    }
}
function minChars(textclass, min, count) {

    var html = jQuery('.' + textclass).val();
    var minlength = html.length;

    if (minlength > min) {
        return false;
    }
    else {
        jQuery('#' + count).html('(' + (min - minlength) + ' - ');
        return false;
    }
}




/*----------------------------------------------------------
----------------------------------------------------------
// <3 BACKBONE
//
// 1. DEFAULT SCRIPT
// 2. LOGO
// 3. BLOG
//
----------------------------------------------------------
----------------------------------------------------------*/

// backbone tech
var addthis_share = { templates: { twitter: '{{title}} {{url}} via @backbonetech' } };
var addthis_config = {"data_track_clickback":true};

$(function()
{

/*----------------------------------------------------------
// DEFAULT SCRIPT
----------------------------------------------------------*/


// super header bold text
  if($('h1:contains({),h2:contains({),h3:contains({),h4:contains({),h5:contains({),h6:contains({),#recent-post ul li a:contains({),#social-media h1:contains({),#home-header-right .desc:contains({)').length)
{
  $('h1:contains({),h2:contains({),h3:contains({),h4:contains({),h5:contains({),h6:contains({),#recent-post ul li a:contains({),#social-media h1:contains({),#home-header-right .desc:contains({)').each(function()
  {
    var text = $(this).html().replace(/{/g,'<strong>').replace(/}/g,'</strong>');
    $(this).html(text);
  });
}

if($('#language-switcher-con .active').text().search('English') == -1)
{
  // backbone latam
  $('body').addClass('es');
}


/*----------------------------------------------------------
// LOGO
----------------------------------------------------------*/

//$('.csstransitions #logo').css({bottom:35});
//$('.csstransitions #language-switcher').css({top:15});


/*----------------------------------------------------------
// BLOG
----------------------------------------------------------*/

if($('#blog').length)
{
  // blog footer menu
  $('.prev-num, .next-num').removeAttr('href');
  
  // substr
  $('#posts .post').each(function()
  {
    var gallery = '';
    if($('.blog-post-gallery',this).length) gallery = $('.blog-post-gallery',this).html();
    var html = $('.text',this).html().substr(0,300);
    if($('.text',this).html().length > 300) html += 'â€¦';
      
    $('.text',this).html(html);
    if(gallery.length)  $('.text .blog-post-gallery',this).empty().append(gallery);
    $('.text',this).show();
  });
  
  // fancy box img
  if($('#post-detail').length)
  {
    $('#post-detail img:not(.donothing)').each(function()
    {
      if($(this).attr('src').length)
      {
        var img = $(this).attr('src');
        var alt = $(this).attr('alt');
        $(this).replaceWith('<a rel="fancybox" href="'+img+'" title="'+alt+'"><img src="'+img+'" alt="'+alt+'" width="624"></a>');
      }
    });
    
    $('a[rel="fancybox"]').fancybox({
      'overlayShow'  : false,
      'transitionIn'  : 'elastic',
      'transitionOut'  : 'elastic',
      'titlePosition' : 'over'
    });
  }
  
  $('.post .img').each(function()
  {
    var img = $('img',this).attr('src').replace('/media/','');
    if(!img.length) $(this).hide();
  });
  
  // movable menu
  $(window).bind('load',function()
  {    
    var sidebar    = $("#blog-sub-menu"),
    target    = $("#blog-sub-menu, #blog > aside"),
    $window    = $(window),
    overall    = sidebar.offset().top + $('#posts').height() - $("#blog > aside").height(),
    offset    = sidebar.offset();
  
    $window.scroll(function()
    {  
      if($window.scrollTop() > offset.top && $window.scrollTop() < overall)
      {
        var pos = $window.scrollTop() - offset.top;
        
        if(Modernizr.touch)          target.css({'-webkit-transition-duration':'200ms','-webkit-transform':'translate3d(0px,'+pos+'px,0px)'});
        else if(Modernizr.csstransitions)  target.css({marginTop: pos});
        else                target.stop().animate({marginTop: pos});
      }
      else
      {
        if(Modernizr.touch)          target.css({'-webkit-transition-duration':'200ms','-webkit-transform':'translate3d(0px,0px,0px)'});
        else if(Modernizr.csstransitions)  target.css({marginTop: 0});
        else                target.stop().animate({marginTop: 0});
      }
    });
  });
}

});


/*-----------------------------------------------
  CHARACTER COUNT
 ------------------------------------------------*/

function limitChars(textid, limit, infodiv) {

    var text = jQuery('.' + textid).val();
    var textlength = text.length;

    if (textlength > limit) {
        jQuery('.' + textid).val(text.substr(0, limit));
        alert('Max character count has been reached');
        return false;
    }
    else {
        jQuery('#' + infodiv).html((limit - textlength) + ' characters)');
        return false;
    }
}
function minChars(textclass, min, count) {

    var html = jQuery('.' + textclass).val();
    var minlength = html.length;

    if (minlength > min) {
        return false;
    }
    else {
        jQuery('#' + count).html('(' + (min - minlength) + ' - ');
        return false;
    }
}




$(function()
{
  if($('.home #showcase').length)
  {
    // variables
    var total =     $('#showcase .item').length;
    var singleWidth =   $('#showcase .item').outerWidth(true);
    var totalWidth =   singleWidth * total;
    var container =   $('#showcase .container');
    var is_transition = false;
    var npos = 0;
    var time = 7000;
    var today = new Date();
    var timer;
    var speed = 500;
    
    // showcase
    $('#showcase .container').css({width:totalWidth});
    
    // item
    $('#showcase .item').each(function(i)
    {
      // date
      var pubdate = new Date($('.time',this).html());
    
      diff = today - pubdate;
      days = Math.round(diff/(1000*60*60*24));
      if(days < 60){
        $(this).addClass('new');
      }
      
      // info
      //var category = $('.category',this).html().replace(///g,'<span class="divider">/</span>');
     
      //$('.category',this).html(category);
      
      // image
      var img =   $('img',this).attr('src');
      $(this).css({background:'url("'+img+'") no-repeat 0% 0%'});
      $('<a id="'+i+'"></a>').appendTo('#showcase footer nav');
    });
    
    // browsers
    if(Modernizr.touch){
      touch();
    }else{
      browsers();
    }
  }
  
  /*-------------------------------------------------------------
  // TOUCH SCREEN MOBILE SCRIPT
  -------------------------------------------------------------*/

  function touch()
  {
    $('#showcase .shadow').remove();
    
    container.swipe({
      triggerOnTouchEnd : true,
      swipeStatus : swipeStatus,
      allowPageScroll:"vertical",
      threshold:200
    });
    
    // dot nav
    $('#showcase footer nav a').click(function(e)
    {  
      e.preventDefault();
      npos = parseInt($(this).attr('id'));
      scrollImages(singleWidth*npos,speed);
      updateT(npos);
    });
    
    // navigation
    $('#showcase .prev').click(function(e){
      e.preventDefault();
      prevT();
      updateT(npos);
    });
      
    $('#showcase .next').click(function(e){
      e.preventDefault();
      nextT();
      updateT(npos);
    });
    
    updateT(0);
  }

  function swipeStatus(event, phase, direction, distance)
  {
    if( phase=="move" && (direction=="left" || direction=="right") )
    {
      var duration=0;
      if (direction == "left")
        scrollImages((singleWidth * npos) + distance, duration);
      
      else if (direction == "right")
        scrollImages((singleWidth * npos) - distance, duration);  
    }
    else if ( phase == "cancel")
    {
      scrollImages(singleWidth * npos, speed);
    }
    else if ( phase =="end" )
    {
      if (direction == "right")
        prevT();
        
      else if (direction == "left")
        nextT();
        
      updateT(npos);
    }
  }
  
  function prevT()
  {
    npos = Math.max(npos-1, 0);
    scrollImages(singleWidth*npos,speed);
  }
  
  function nextT()
  {
    npos = Math.min(npos+1, total-1);
    scrollImages(singleWidth*npos,speed);
  }
    
  function scrollImages(distance, duration)
  {
    container.css("-webkit-transition-duration", (duration/1000).toFixed(1) + "s");
    var value = (distance<0 ? "" : "-") + Math.abs(distance).toString();
    container.css("-webkit-transform", "translate3d("+value +"px,0px,0px)");
  }
  
  function updateT(index)
  {
    // dots
    $('#showcase footer nav a.active').removeClass('active');
    $('#showcase footer nav a').eq(index).addClass('active');
    
    // new tag css3
    if($('#showcase .item').eq(index).hasClass('new'))  $('#showcase .new-tag').addClass('active');
    else                        $('#showcase .new-tag').removeClass('active');
    
    // global h3
    var h3 = $('#showcase .item:eq('+index+') h3').html().toLowerCase();
    $('#showcase-title').html(h3);
    
    // link
    var href = $('#showcase .item:eq('+index+') a').attr('href');
    $('#showcase .see-more').attr('href',href);
  }
  
  
  /*-------------------------------------------------------------
  // BROWSER SCRIPT
  -------------------------------------------------------------*/
  
  function browsers()
  {
    // autoplay
    timer = setTimeout(next,time);
    
    // dot nav
    $('#showcase footer nav a').click(function(e)
    {
      clearTimeout(timer);
      timer = setTimeout(next,time);
      
      e.preventDefault();
      if(!is_transition)
      {
        npos = parseInt($(this).attr('id'));
        update(npos);
      }
    });
    
    // navigation
    $('#showcase .prev').click(function(e){
      e.preventDefault();
      prev();
    });
      
    $('#showcase .next').click(function(e){
      e.preventDefault();
      next();
    });
    
    update(0);
  }
  
  function prev()
  {
    clearTimeout(timer);
    timer = setTimeout(next,time);
        
    if(!is_transition)
    {    
      npos--;
      if(npos < 0) npos = total -1;
      update(npos);
    }
  }
  
  function next()
  {
    clearTimeout(timer);
    timer = setTimeout(next,time);
    
    if(!is_transition)
    {
      npos++;
      if(npos > total-1) npos = 0;
      update(npos);
    }
  }  
    
  function update(index)
  {
    is_transition = true;
    
    // animate
    if(Modernizr.touch || !Modernizr.csstransitions)
    {
      container.animate({left:-index*singleWidth},500); // jQuery
    }
    else
    {
      container.css({left:-index*singleWidth}); // CSS3
    }
  
    // dots
    $('#showcase footer nav a.active').removeClass('active');
    $('#showcase footer nav a').eq(index).addClass('active');
    
    // new tag css3
    if($('#showcase .item').eq(index).hasClass('new'))  $('#showcase .new-tag').addClass('active');
    else                        $('#showcase .new-tag').removeClass('active');
    
    
    // global h3
    var h3 = $('#showcase .item:eq('+index+') h3').html().toLowerCase();
    
    if(Modernizr.touch)
    {
      $('#showcase-title').html(h3);
      is_transition = false;
    }
    else
    {
      // animation
      /*
      $('#showcase-title').animate({width:0},200,function()
      {
        $(this).html(h3).animate({width:550},200,function()
        {
          is_transition = false;
        });
      });
      */
      
      $('#showcase-title').html(h3);
      is_transition = false;
    }
    
    // link
    var href = $('#showcase .item:eq('+index+') a').attr('href');
    $('#showcase .see-more').attr('href',href);
  }
});

/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <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(at)cherne(dot)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 ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){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.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);



/*
 * zClip :: jQuery ZeroClipboard v1.1.1
 * http://steamdev.com/zclip
 *
 * Copyright 2011, SteamDev
 * Released under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Date: Wed Jun 01, 2011
 */

(function(a){a.fn.zclip=function(c){if(typeof c=="object"&&!c.length){var b=a.extend({path:"ZeroClipboard.swf",copy:null,beforeCopy:null,afterCopy:null,clickAfter:true,setHandCursor:true,setCSSEffects:true},c);return this.each(function(){var e=a(this);if(e.is(":visible")&&(typeof b.copy=="string"||a.isFunction(b.copy))){ZeroClipboard.setMoviePath(b.path);var d=new ZeroClipboard.Client();if(a.isFunction(b.copy)){e.bind("zClip_copy",b.copy)}if(a.isFunction(b.beforeCopy)){e.bind("zClip_beforeCopy",b.beforeCopy)}if(a.isFunction(b.afterCopy)){e.bind("zClip_afterCopy",b.afterCopy)}d.setHandCursor(b.setHandCursor);d.setCSSEffects(b.setCSSEffects);d.addEventListener("mouseOver",function(f){e.trigger("mouseenter")});d.addEventListener("mouseOut",function(f){e.trigger("mouseleave")});d.addEventListener("mouseDown",function(f){e.trigger("mousedown");if(!a.isFunction(b.copy)){d.setText(b.copy)}else{d.setText(e.triggerHandler("zClip_copy"))}if(a.isFunction(b.beforeCopy)){e.trigger("zClip_beforeCopy")}});d.addEventListener("complete",function(f,g){if(a.isFunction(b.afterCopy)){e.trigger("zClip_afterCopy")}else{if(g.length>500){g=g.substr(0,500)+"...nn("+(g.length-500)+" characters not shown)"}e.removeClass("hover");alert("Copied text to clipboard:nn "+g)}if(b.clickAfter){e.trigger("click")}});d.glue(e[0],e.parent()[0]);a(window).bind("load resize",function(){d.reposition()})}})}else{if(typeof c=="string"){return this.each(function(){var f=a(this);c=c.toLowerCase();var e=f.data("zclipId");var d=a("#"+e+".zclip");if(c=="remove"){d.remove();f.removeClass("active hover")}else{if(c=="hide"){d.hide();f.removeClass("active hover")}else{if(c=="show"){d.show()}}}})}}}})(jQuery);var ZeroClipboard={version:"1.0.7",clients:{},moviePath:"ZeroClipboard.swf",nextId:1,$:function(a){if(typeof(a)=="string"){a=document.getElementById(a)}if(!a.addClass){a.hide=function(){this.style.display="none"};a.show=function(){this.style.display=""};a.addClass=function(b){this.removeClass(b);this.className+=" "+b};a.removeClass=function(d){var e=this.className.split(/s+/);var b=-1;for(var c=0;c<e.length;c++){if(e[c]==d){b=c;c=e.length}}if(b>-1){e.splice(b,1);this.className=e.join(" ")}return this};a.hasClass=function(b){return !!this.className.match(new RegExp("s*"+b+"s*"))}}return a},setMoviePath:function(a){this.moviePath=a},dispatch:function(d,b,c){var a=this.clients[d];if(a){a.receiveEvent(b,c)}},register:function(b,a){this.clients[b]=a},getDOMObjectPosition:function(c,a){var b={left:0,top:0,width:c.width?c.width:c.offsetWidth,height:c.height?c.height:c.offsetHeight};if(c&&(c!=a)){b.left+=c.offsetLeft;b.top+=c.offsetTop}return b},Client:function(a){this.handlers={};this.id=ZeroClipboard.nextId++;this.movieId="ZeroClipboardMovie_"+this.id;ZeroClipboard.register(this.id,this);if(a){this.glue(a)}}};ZeroClipboard.Client.prototype={id:0,ready:false,movie:null,clipText:"",handCursorEnabled:true,cssEffects:true,handlers:null,glue:function(d,b,e){this.domElement=ZeroClipboard.$(d);var f=99;if(this.domElement.style.zIndex){f=parseInt(this.domElement.style.zIndex,10)+1}if(typeof(b)=="string"){b=ZeroClipboard.$(b)}else{if(typeof(b)=="undefined"){b=document.getElementsByTagName("body")[0]}}var c=ZeroClipboard.getDOMObjectPosition(this.domElement,b);this.div=document.createElement("div");this.div.className="zclip";this.div.id="zclip-"+this.movieId;$(this.domElement).data("zclipId","zclip-"+this.movieId);var a=this.div.style;a.position="absolute";a.left=""+c.left+"px";a.top=""+c.top+"px";a.width=""+c.width+"px";a.height=""+c.height+"px";a.zIndex=f;if(typeof(e)=="object"){for(addedStyle in e){a[addedStyle]=e[addedStyle]}}b.appendChild(this.div);this.div.innerHTML=this.getHTML(c.width,c.height)},getHTML:function(d,a){var c="";var b="id="+this.id+"&width="+d+"&height="+a;if(navigator.userAgent.match(/MSIE/)){var e=location.href.match(/^https/i)?"https://":"http://";c+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+e+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+d+'" height="'+a+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+b+'"/><param name="wmode" value="transparent"/></object>'}else{c+='<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+d+'" height="'+a+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+b+'" wmode="transparent" />'}return c},hide:function(){if(this.div){this.div.style.left="-2000px"}},show:function(){this.reposition()},destroy:function(){if(this.domElement&&this.div){this.hide();this.div.innerHTML="";var a=document.getElementsByTagName("body")[0];try{a.removeChild(this.div)}catch(b){}this.domElement=null;this.div=null}},reposition:function(c){if(c){this.domElement=ZeroClipboard.$(c);if(!this.domElement){this.hide()}}if(this.domElement&&this.div){var b=ZeroClipboard.getDOMObjectPosition(this.domElement);var a=this.div.style;a.left=""+b.left+"px";a.top=""+b.top+"px"}},setText:function(a){this.clipText=a;if(this.ready){this.movie.setText(a)}},addEventListener:function(a,b){a=a.toString().toLowerCase().replace(/^on/,"");if(!this.handlers[a]){this.handlers[a]=[]}this.handlers[a].push(b)},setHandCursor:function(a){this.handCursorEnabled=a;if(this.ready){this.movie.setHandCursor(a)}},setCSSEffects:function(a){this.cssEffects=!!a},receiveEvent:function(d,f){d=d.toString().toLowerCase().replace(/^on/,"");switch(d){case"load":this.movie=document.getElementById(this.movieId);if(!this.movie){var c=this;setTimeout(function(){c.receiveEvent("load",null)},1);return}if(!this.ready&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){var c=this;setTimeout(function(){c.receiveEvent("load",null)},100);this.ready=true;return}this.ready=true;try{this.movie.setText(this.clipText)}catch(h){}try{this.movie.setHandCursor(this.handCursorEnabled)}catch(h){}break;case"mouseover":if(this.domElement&&this.cssEffects){this.domElement.addClass("hover");if(this.recoverActive){this.domElement.addClass("active")}}break;case"mouseout":if(this.domElement&&this.cssEffects){this.recoverActive=false;if(this.domElement.hasClass("active")){this.domElement.removeClass("active");this.recoverActive=true}this.domElement.removeClass("hover")}break;case"mousedown":if(this.domElement&&this.cssEffects){this.domElement.addClass("active")}break;case"mouseup":if(this.domElement&&this.cssEffects){this.domElement.removeClass("active");this.recoverActive=false}break}if(this.handlers[d]){for(var b=0,a=this.handlers[d].length;b<a;b++){var g=this.handlers[d][b];if(typeof(g)=="function"){g(this,f)}else{if((typeof(g)=="object")&&(g.length==2)){g[0][g[1]](this,f)}else{if(typeof(g)=="string"){window[g](this,f)}}}}}}};


/*
 * Date Format 1.2.3
 * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
 * MIT license
 *
 * Includes enhancements by Scott Trenda <scott.trenda.net>
 * and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */

var dateFormat = function () {
  var  token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])1?|[LloSZ]|"[^"]*"|'[^']*'/g,
    timezone = /b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]d{4})?)b/g,
    timezoneClip = /[^-+dA-Z]/g,
    pad = function (val, len) {
      val = String(val);
      len = len || 2;
      while (val.length < len) val = "0" + val;
      return val;
    };

  // Regexes and supporting functions are cached through closure
  return function (date, mask, utc) {
    var dF = dateFormat;

    // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
    if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/d/.test(date)) {
      mask = date;
      date = undefined;
    }

    // Passing date through Date applies Date.parse, if necessary
    date = date ? new Date(date) : new Date;
    if (isNaN(date)) throw SyntaxError("invalid date");

    mask = String(dF.masks[mask] || mask || dF.masks["default"]);

    // Allow setting the utc argument via the mask
    if (mask.slice(0, 4) == "UTC:") {
      mask = mask.slice(4);
      utc = true;
    }

    var  _ = utc ? "getUTC" : "get",
      d = date[_ + "Date"](),
      D = date[_ + "Day"](),
      m = date[_ + "Month"](),
      y = date[_ + "FullYear"](),
      H = date[_ + "Hours"](),
      M = date[_ + "Minutes"](),
      s = date[_ + "Seconds"](),
      L = date[_ + "Milliseconds"](),
      o = utc ? 0 : date.getTimezoneOffset(),
      flags = {
        d:    d,
        dd:   pad(d),
        ddd:  dF.i18n.dayNames[D],
        dddd: dF.i18n.dayNames[D + 7],
        m:    m + 1,
        mm:   pad(m + 1),
        mmm:  dF.i18n.monthNames[m],
        mmmm: dF.i18n.monthNames[m + 12],
        yy:   String(y).slice(2),
        yyyy: y,
        h:    H % 12 || 12,
        hh:   pad(H % 12 || 12),
        H:    H,
        HH:   pad(H),
        M:    pad(M),
        MM:   pad(M),
        s:    s,
        ss:   pad(s),
        l:    pad(L, 3),
        L:    pad(L > 99 ? Math.round(L / 10) : L),
        t:    H < 12 ? "am"  : "pm",
        tt:   H < 12 ? "am" : "pm",
        T:    H < 12 ? "A"  : "P",
        TT:   H < 12 ? "AM" : "PM",
        Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
        o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
        S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
      };

    return mask.replace(token, function ($0) {
      return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
    });
  };
}();

// Some common format strings
dateFormat.masks = {
  "default":      "ddd mmm dd yyyy HH:MM:ss",
  shortDate:      "m/d/yy",
  mediumDate:     "mmm d, yyyy",
  longDate:       "mmmm d, yyyy",
  fullDate:       "dddd, mmmm d, yyyy",
  shortTime:      "h:MM TT",
  mediumTime:     "h:MM:ss TT",
  longTime:       "h:MM:ss TT Z",
  isoDate:        "yyyy-mm-dd",
  isoTime:        "HH:MM:ss",
  isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
  isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
  dayNames: [
    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
    "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
  ],
  monthNames: [
    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
    "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  ]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
  return dateFormat(this, mask, utc);
};




jQuery.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return jQuery.getUrlVars()[name];
  }
});

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(); });
}  



/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <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(at)cherne(dot)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 ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){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.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);



/*
 * zClip :: jQuery ZeroClipboard v1.1.1
 * http://steamdev.com/zclip
 *
 * Copyright 2011, SteamDev
 * Released under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Date: Wed Jun 01, 2011
 */

(function(a){a.fn.zclip=function(c){if(typeof c=="object"&&!c.length){var b=a.extend({path:"ZeroClipboard.swf",copy:null,beforeCopy:null,afterCopy:null,clickAfter:true,setHandCursor:true,setCSSEffects:true},c);return this.each(function(){var e=a(this);if(e.is(":visible")&&(typeof b.copy=="string"||a.isFunction(b.copy))){ZeroClipboard.setMoviePath(b.path);var d=new ZeroClipboard.Client();if(a.isFunction(b.copy)){e.bind("zClip_copy",b.copy)}if(a.isFunction(b.beforeCopy)){e.bind("zClip_beforeCopy",b.beforeCopy)}if(a.isFunction(b.afterCopy)){e.bind("zClip_afterCopy",b.afterCopy)}d.setHandCursor(b.setHandCursor);d.setCSSEffects(b.setCSSEffects);d.addEventListener("mouseOver",function(f){e.trigger("mouseenter")});d.addEventListener("mouseOut",function(f){e.trigger("mouseleave")});d.addEventListener("mouseDown",function(f){e.trigger("mousedown");if(!a.isFunction(b.copy)){d.setText(b.copy)}else{d.setText(e.triggerHandler("zClip_copy"))}if(a.isFunction(b.beforeCopy)){e.trigger("zClip_beforeCopy")}});d.addEventListener("complete",function(f,g){if(a.isFunction(b.afterCopy)){e.trigger("zClip_afterCopy")}else{if(g.length>500){g=g.substr(0,500)+"...nn("+(g.length-500)+" characters not shown)"}e.removeClass("hover");alert("Copied text to clipboard:nn "+g)}if(b.clickAfter){e.trigger("click")}});d.glue(e[0],e.parent()[0]);a(window).bind("load resize",function(){d.reposition()})}})}else{if(typeof c=="string"){return this.each(function(){var f=a(this);c=c.toLowerCase();var e=f.data("zclipId");var d=a("#"+e+".zclip");if(c=="remove"){d.remove();f.removeClass("active hover")}else{if(c=="hide"){d.hide();f.removeClass("active hover")}else{if(c=="show"){d.show()}}}})}}}})(jQuery);var ZeroClipboard={version:"1.0.7",clients:{},moviePath:"ZeroClipboard.swf",nextId:1,$:function(a){if(typeof(a)=="string"){a=document.getElementById(a)}if(!a.addClass){a.hide=function(){this.style.display="none"};a.show=function(){this.style.display=""};a.addClass=function(b){this.removeClass(b);this.className+=" "+b};a.removeClass=function(d){var e=this.className.split(/s+/);var b=-1;for(var c=0;c<e.length;c++){if(e[c]==d){b=c;c=e.length}}if(b>-1){e.splice(b,1);this.className=e.join(" ")}return this};a.hasClass=function(b){return !!this.className.match(new RegExp("\s*"+b+"\s*"))}}return a},setMoviePath:function(a){this.moviePath=a},dispatch:function(d,b,c){var a=this.clients[d];if(a){a.receiveEvent(b,c)}},register:function(b,a){this.clients[b]=a},getDOMObjectPosition:function(c,a){var b={left:0,top:0,width:c.width?c.width:c.offsetWidth,height:c.height?c.height:c.offsetHeight};if(c&&(c!=a)){b.left+=c.offsetLeft;b.top+=c.offsetTop}return b},Client:function(a){this.handlers={};this.id=ZeroClipboard.nextId++;this.movieId="ZeroClipboardMovie_"+this.id;ZeroClipboard.register(this.id,this);if(a){this.glue(a)}}};ZeroClipboard.Client.prototype={id:0,ready:false,movie:null,clipText:"",handCursorEnabled:true,cssEffects:true,handlers:null,glue:function(d,b,e){this.domElement=ZeroClipboard.$(d);var f=99;if(this.domElement.style.zIndex){f=parseInt(this.domElement.style.zIndex,10)+1}if(typeof(b)=="string"){b=ZeroClipboard.$(b)}else{if(typeof(b)=="undefined"){b=document.getElementsByTagName("body")[0]}}var c=ZeroClipboard.getDOMObjectPosition(this.domElement,b);this.div=document.createElement("div");this.div.className="zclip";this.div.id="zclip-"+this.movieId;$(this.domElement).data("zclipId","zclip-"+this.movieId);var a=this.div.style;a.position="absolute";a.left=""+c.left+"px";a.top=""+c.top+"px";a.width=""+c.width+"px";a.height=""+c.height+"px";a.zIndex=f;if(typeof(e)=="object"){for(addedStyle in e){a[addedStyle]=e[addedStyle]}}b.appendChild(this.div);this.div.innerHTML=this.getHTML(c.width,c.height)},getHTML:function(d,a){var c="";var b="id="+this.id+"&width="+d+"&height="+a;if(navigator.userAgent.match(/MSIE/)){var e=location.href.match(/^https/i)?"https://":"http://";c+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+e+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+d+'" height="'+a+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+b+'"/><param name="wmode" value="transparent"/></object>'}else{c+='<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+d+'" height="'+a+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+b+'" wmode="transparent" />'}return c},hide:function(){if(this.div){this.div.style.left="-2000px"}},show:function(){this.reposition()},destroy:function(){if(this.domElement&&this.div){this.hide();this.div.innerHTML="";var a=document.getElementsByTagName("body")[0];try{a.removeChild(this.div)}catch(b){}this.domElement=null;this.div=null}},reposition:function(c){if(c){this.domElement=ZeroClipboard.$(c);if(!this.domElement){this.hide()}}if(this.domElement&&this.div){var b=ZeroClipboard.getDOMObjectPosition(this.domElement);var a=this.div.style;a.left=""+b.left+"px";a.top=""+b.top+"px"}},setText:function(a){this.clipText=a;if(this.ready){this.movie.setText(a)}},addEventListener:function(a,b){a=a.toString().toLowerCase().replace(/^on/,"");if(!this.handlers[a]){this.handlers[a]=[]}this.handlers[a].push(b)},setHandCursor:function(a){this.handCursorEnabled=a;if(this.ready){this.movie.setHandCursor(a)}},setCSSEffects:function(a){this.cssEffects=!!a},receiveEvent:function(d,f){d=d.toString().toLowerCase().replace(/^on/,"");switch(d){case"load":this.movie=document.getElementById(this.movieId);if(!this.movie){var c=this;setTimeout(function(){c.receiveEvent("load",null)},1);return}if(!this.ready&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){var c=this;setTimeout(function(){c.receiveEvent("load",null)},100);this.ready=true;return}this.ready=true;try{this.movie.setText(this.clipText)}catch(h){}try{this.movie.setHandCursor(this.handCursorEnabled)}catch(h){}break;case"mouseover":if(this.domElement&&this.cssEffects){this.domElement.addClass("hover");if(this.recoverActive){this.domElement.addClass("active")}}break;case"mouseout":if(this.domElement&&this.cssEffects){this.recoverActive=false;if(this.domElement.hasClass("active")){this.domElement.removeClass("active");this.recoverActive=true}this.domElement.removeClass("hover")}break;case"mousedown":if(this.domElement&&this.cssEffects){this.domElement.addClass("active")}break;case"mouseup":if(this.domElement&&this.cssEffects){this.domElement.removeClass("active");this.recoverActive=false}break}if(this.handlers[d]){for(var b=0,a=this.handlers[d].length;b<a;b++){var g=this.handlers[d][b];if(typeof(g)=="function"){g(this,f)}else{if((typeof(g)=="object")&&(g.length==2)){g[0][g[1]](this,f)}else{if(typeof(g)=="string"){window[g](this,f)}}}}}}};


/*
 * Date Format 1.2.3
 * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
 * MIT license
 *
 * Includes enhancements by Scott Trenda <scott.trenda.net>
 * and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */

var dateFormat = function () {
  var  token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])1?|[LloSZ]|"[^"]*"|'[^']*'/g,
    timezone = /b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]d{4})?)b/g,
    timezoneClip = /[^-+dA-Z]/g,
    pad = function (val, len) {
      val = String(val);
      len = len || 2;
      while (val.length < len) val = "0" + val;
      return val;
    };

  // Regexes and supporting functions are cached through closure
  return function (date, mask, utc) {
    var dF = dateFormat;

    // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
    if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/d/.test(date)) {
      mask = date;
      date = undefined;
    }

    // Passing date through Date applies Date.parse, if necessary
    date = date ? new Date(date) : new Date;
    if (isNaN(date)) throw SyntaxError("invalid date");

    mask = String(dF.masks[mask] || mask || dF.masks["default"]);

    // Allow setting the utc argument via the mask
    if (mask.slice(0, 4) == "UTC:") {
      mask = mask.slice(4);
      utc = true;
    }

    var  _ = utc ? "getUTC" : "get",
      d = date[_ + "Date"](),
      D = date[_ + "Day"](),
      m = date[_ + "Month"](),
      y = date[_ + "FullYear"](),
      H = date[_ + "Hours"](),
      M = date[_ + "Minutes"](),
      s = date[_ + "Seconds"](),
      L = date[_ + "Milliseconds"](),
      o = utc ? 0 : date.getTimezoneOffset(),
      flags = {
        d:    d,
        dd:   pad(d),
        ddd:  dF.i18n.dayNames[D],
        dddd: dF.i18n.dayNames[D + 7],
        m:    m + 1,
        mm:   pad(m + 1),
        mmm:  dF.i18n.monthNames[m],
        mmmm: dF.i18n.monthNames[m + 12],
        yy:   String(y).slice(2),
        yyyy: y,
        h:    H % 12 || 12,
        hh:   pad(H % 12 || 12),
        H:    H,
        HH:   pad(H),
        M:    pad(M),
        MM:   pad(M),
        s:    s,
        ss:   pad(s),
        l:    pad(L, 3),
        L:    pad(L > 99 ? Math.round(L / 10) : L),
        t:    H < 12 ? "am"  : "pm",
        tt:   H < 12 ? "am" : "pm",
        T:    H < 12 ? "A"  : "P",
        TT:   H < 12 ? "AM" : "PM",
        Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
        o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
        S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
      };

    return mask.replace(token, function ($0) {
      return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
    });
  };
}();

// Some common format strings
dateFormat.masks = {
  "default":      "ddd mmm dd yyyy HH:MM:ss",
  shortDate:      "m/d/yy",
  mediumDate:     "mmm d, yyyy",
  longDate:       "mmmm d, yyyy",
  fullDate:       "dddd, mmmm d, yyyy",
  shortTime:      "h:MM TT",
  mediumTime:     "h:MM:ss TT",
  longTime:       "h:MM:ss TT Z",
  isoDate:        "yyyy-mm-dd",
  isoTime:        "HH:MM:ss",
  isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
  isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
  dayNames: [
    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
    "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
  ],
  monthNames: [
    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
    "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  ]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
  return dateFormat(this, mask, utc);
};




jQuery.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
      hash = hashes[i].split('=');
      vars.push(hash[0]);
      vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    return jQuery.getUrlVars()[name];
  }
});

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(); });
}  

