if(
  (navigator.userAgent.match(/iPhone/i)) ||
  (navigator.userAgent.match(/iPod/i)) ||
  (navigator.userAgent.match(/Android/i)) ||
  (navigator.userAgent.match(/webOS/i))) {  
  for (var k=0;k < document.styleSheets.length; k++) {
    if (document.styleSheets[k].href != null && document.styleSheets[k].href.lastIndexOf("webkit") == -1) {
      document.styleSheets[k].disabled = true;
    }
  }
  window.scrollTo(0,1);
}


$(document).ready(function(){

  $('.gallery a').lightBox();

});


// add outgoing clicks to GA
jQuery(function($){
  $("a[href*='http://']:not([href*='"+location.hostname+"'])").click(function(){
    _gaq.push(['_trackEvent', 'UserAction','External Link',$(this).attr('href')]);
  });
  
 	// enable html5 placeholder support for legacy browsers
	$("[placeholder]").textPlaceholder();
	
});

/* Homepage
   ----------------------------------------------------*/
jQuery(function($){
  //if($('#header_image li').length > 0) {
  //  var $items = $('#header_image li');
   // $items.hide();
    //rand = Math.floor(Math.random() * $items.length);
  //  $items.each(function(i,e){
   //   if(i == rand) $(this).show();
   // });
 // }
  
});




$(function() {
	$(".item").hide();
	$('#feature #itemfeature1').addClass('current').show();
	$('.thumb').prepend('<span class="overlay"></span>');
//	$('.overlay').css({display:'inline' });
	  $('.overlay').css({opacity:'0.8'});
//	$('li.current .overlay').css({display:'none' });
	  $('li.current .overlay').css({opacity:'0.0'});
	$('li.thumb').hover(function(){
//		$(this).find("span").css({display:'none' });
		    $(this).find("span").css({opacity:'0.0'});
	},
		function(){
		  if ($(this).hasClass('current')){
//			$(this).find("span").css({display:'none' });
			      $(this).find("span").css({opacity:'0.0'});
		  }else{	
//		 	$(this).find("span").css({display:'inline'});
		      	      $(this).find("span").css({opacity:'0.8'});
		  }
	});
	
   	$('li.thumb').click(function() {
 if($(this).hasClass('current')) {
      // do nothing
    } else {
		var image = $(this).attr("id");
		$('li.thumb').removeClass("current");
//		$('li.thumb .overlay').css({display:'inline'});
		      $('li.thumb .overlay').css({opacity:'0.8'});
		$(this).addClass("current");
//		$('li.current .overlay').css({display:'none' });
		      $('li.current .overlay').css({opacity:'0.0'});
		$("#feature .current").fadeOut(1000, function(){
	});
	
	$('#feature .current').removeClass("current");
	$('#feature #item'+image).addClass("current").fadeIn('slow');
	
	var posx = '0';
	var posx = $(this).position().left;
//	var wid	= '89';
//	$('#arrow').animate({left:posx - '305'});
	$('#arrow').animate({left:posx + 67});

    return false;
    }
    });

});


/* Blog Posts
   ----------------------------------------------------*/
jQuery(function($){
  var html = '',
      feeds = [],
      blogs = [
        'http://blogs.nd.edu/agencynd/feed/',
        'http://blogs.nd.edu/donschindler/category/agencynd/feed/',
        'http://www.weedygarden.net/category/agencynd/feed/',
        'http://blogs.nd.edu/web-musings/AgencyND/agencynd/feed/',
        'http://blogs.nd.edu/the-copywriting-irish/category/agencynd/feed/',
        'http://blogs.nd.edu/jeremyfriesen/category/agencynd/feed/',
        'http://conductor.nd.edu/news/category/agencynd.atom'
      ];
      
  getFeeds(blogs);
});

/* Team
   ----------------------------------------------------*/
jQuery(function($){
  var $team = $('#home-team li');
  var rand = Math.floor(Math.random() * $team.length);
  
  $team.hide();
  $($team[rand]).show();
  
});

/* Flickr Stream
   ----------------------------------------------------*/
/*
jQuery(function($){
  $('#content a.flickr').flickrGallery();
});

(function($){
  $.fn.flickrGallery = function(){
    return this.each(function(){
      var limit = 100,
        $this = $(this),
        random = ($this.hasClass('random')) ? true : false,
        url = $this.attr('href') + '&jsoncallback=?',
        params = {format:'json'},
        classes = this.className;

      if(classes.search("limit-") != -1) {
        classArray = classes.split(' ');
        $.each(classArray, function(index, value) {
          if(value.search("limit-") != -1) {
            limit = value.replace("limit-", "");
          }
        });
      }
      $.getJSON(url, params, function(json) {
        if(json.items) {
          var ul = '<ul class="gallery">',
            base = [];
          for(i=0;i<json.items.length;i++) {base[i] = i;}
          if(random == true) base.shuffle();
          $.each(base, function(i, n) {
            var item = json.items[n];
            img = item.media.m;
            large = img.replace('_m.jpg','.jpg');
            thumb = img.replace('_m.jpg','_t.jpg');
            if(i < limit) ul += '<li><a href="'+ large +'"  title="'+ item.title +'" data-link="'+ item.link +'"><img src="'+ img +'" title="'+ item.title +'" /></a></li>';
          });
          ul += '</ul>';
          $(ul).insertAfter($this);
          //$('.gallery a').lightBox();
        }
      });
      $this.hide();
    });
  }
})(jQuery);

*/
/* Twitter Stream
   ----------------------------------------------------*/
jQuery(function($){
  $('#home-twitter a.twitter').twitterStream();
});
(function($){
  $.fn.twitterStream = function(){
    return this.each(function(){
      var $this = $(this),
          $tweetbox = $('#home-twitter'),
          limit = 4,
          index = 0,
          i = 0,
          txt = '';

      $.ajax({
        type: "GET",
        url: 'http://twitter.com/statuses/user_timeline/ndwebteam.json?&callback=?',
        dataType: 'json',
        success: function(data) {
          user = data[0].user;
          
          for(i=0; i<limit; index++) {
            var twit = '',
                text = linkify(data[index].text);
            if(text.substr(0,1) != '@') {
              txt += '<div class="tweet"><p class="text">' + text + '</p>';
              txt += '<p class="date"><a href="http://twitter.com/ndwebteam/status/' + data[index].id_str + '">' + tweetDate('timeline', data[index].created_at) + '</a></p></div>';
              i++;
            }
            
            //twit += txt;
            //twit += '<img src="'+ user.profile_image_url +'" alt="'+ user.name +'" />';        
            //twit += '<div class="tweeter"><h3><a href="http://twitter.com/'+ user.screen_name +'">'+ user.screen_name +'</a></h3><p>'+ user.name +'</p></div></div>';
          }
          $tweetbox.html(txt);
        }
      });
    });
  }
})(jQuery);

function tweetDate(api, theDate) {
  if(api == 'timeline') {
    // we have to do this because IE can't parse the date format returned by the timeline api
    var badDate = theDate.split(" ");
    var theDate = badDate[0]+" "+badDate[1]+" "+badDate[2]+" "+badDate[5]+" "+badDate[3]+" "+badDate[4];
  }
  var dateobj = new Date(theDate);
  return dateobj.format("UTC:h:MM TT, mmmm dS");
}

function linkify(text) {
  var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  return text.replace(exp,"<a href='$1'>$1</a>"); 
}

/* Portfolio
   ----------------------------------------------------*/
$(document).ready(function() {
  $('ul.portfolio a').mouseover(function(){
    var $img = $($(this).attr('rel'));
    t = $(this).position().top - 30;
    //l = $(this).position().left - 20;
    $img.css('top',t);
    $img.attr('href', $(this).attr('href'));
    $img.fadeIn();
  }).mouseout(function(){$('a.preview').fadeOut();});
  
  // Portfolio Thumbnails
  if($('#port_thumbs ul li').length == 0) $('#port_thumbs').css('display','none');
  $('#port_thumbs a').click(function() {
    var newimg = $($(this).attr('href')).attr('src');
    $('#port_img_primary').attr('src',newimg);
    return false;
  });
  
  $('#toggle').click(function() {
    $("#port_wrapper").toggle("normal");
    $(this).toggleClass("hidden");
    return false;
  });
});

/* Utilities
   ----------------------------------------------------*/
function log() {
  if (window && window.console && window.console.log) {
    for(var i=0, len = arguments.length; i < len; i++) {
      console.log(arguments[i]);
    }
  }
};

Array.prototype.shuffle = function (){
    var i = this.length, j, temp;
    if ( i == 0 ) return;
    while ( --i ) {
        j = Math.floor( Math.random() * ( i + 1 ) );
        temp = this[i];
        this[i] = this[j];
        this[j] = temp;
    }
};

/*
 * 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:    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 ? "a"  : "p",
        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);
};

function getFeeds(blogs) {
  var blogs = blogs,
      feeds = [];
      
  $.each(blogs, function(index, feed){
    var url = feed;
		var options = {
			limit: 10,
			header: true,
			titletag: 'h4',
			date: true,
			content: true,
			snippet: true,
			showerror: true,
			errormsg: '',
			key: null
		};  

		// Check for valid url
		if(url == null) return false;

		// Create Google Feed API address
		var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + url;
		if (options.limit != null) api += "&num=" + options.limit;
		if (options.key != null) api += "&key=" + options.key;

		// Send request
		$.getJSON(api, function(data){
			// Check for error
			if (data.responseStatus == 200) {
				// Process the feeds
				feeds[index] = _callback(data.responseData.feed, options);
				
				feeds.sort(function(a, b){
          var dateA=new Date(a.entryDate), dateB=new Date(b.entryDate);
          return dateB-dateA;
        });
        
        populateContent(feeds);
			
			} else {

				// Handle error if required
				if (options.showerror)
					if (options.errormsg != '') {
						var msg = options.errormsg;
					} else {
						var msg = data.responseDetails;
					};
					alert('<div class="rssError"><p>'+ msg +'</p></div>');
			};
		});

  });

  var populateContent = function(feeds) {
    var $blogContainer = $('#home-blogs'),
        html = '<ul class="blogs">';

    $.each(feeds, function(index, item) {
      if(typeof(item) != 'undefined') { // something is going on here and needs fixing
        html += '<li><a href="'+ item.link +'"><h4 class="pubdate">'+ item.pubDate +'</h4><h2>'+item.title+'</h2><h5 class="author">Posted by '+ item.author +'</h5><p>'+ item.content +' <span> Read Full Post</span></p></a></li>';
      }
    });
    
    html += '</ul>';
    $blogContainer.html(html);
  };

	// Callback function to create HTML result
	var _callback = function(feeds, options) {
		if (!feeds) {
			return false;
		}

    var feed = {};
    
		// Add feeds
		for (var i=0; i<feeds.entries.length; i++) {
			
			// Get individual feed
			var entry = feeds.entries[i];

			// Format published date
			feed.entryDate = new Date(entry.publishedDate);
			//var pubDate = entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString();
			feed.pubDate = dateFormat(feed.entryDate, "mmm. d, yyyy");
			feed.link = entry.link;
			feed.title = entry.title;
			feed.author = entry.author;
			if (options.content) {
				// Use feed snippet if available and optioned
				if (options.snippet && entry.contentSnippet != '') {
					feed.content = entry.contentSnippet;
				} else {
					feed.content = entry.content;
				}
			}
      return feed;
    }
	};
	
};

/**
 * @see http://github.com/NV/placeholder.js
 */
jQuery.fn.textPlaceholder = function () {
	return this.each(function(){
		var that = this;
		if (that.placeholder && 'placeholder' in document.createElement(that.tagName)) return;
		var placeholder = that.getAttribute('placeholder');
		var input = jQuery(that);

		if (that.value === '' || that.value == placeholder) {
			input.addClass('text-placeholder');
			that.value = placeholder;
		}
		input.focus(function(){
			if (input.hasClass('text-placeholder')) {
				this.value = '';
				input.removeClass('text-placeholder')
			}
		});
		input.blur(function(){
			if (this.value === '') {
				input.addClass('text-placeholder');
				this.value = placeholder;
			} else {
				input.removeClass('text-placeholder');
			}
		});
		that.form && jQuery(that.form).submit(function(){
			if (input.hasClass('text-placeholder')) {
				that.value = '';
			}
		});
	});
};



/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */
(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'/stylesheets/images/lightbox-ico-loading.gif',imageBtnPrev:'/stylesheets/images/lightbox-btn-prev.gif',imageBtnNext:'/stylesheets/images/lightbox-btn-next.gif',imageBtnClose:'/stylesheets/images/lightbox-btn-close.gif',imageBlank:'/stylesheets/images/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}
function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}
_set_image_to_view();}
function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}
function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}
$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}
if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}
function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}
if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}
_enable_keyboard_navigation();}
function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}
function _disable_keyboard_navigation(){$(document).unbind();}
function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}
key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}
if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}
if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}
function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}
if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}
function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}
while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);



