PageSourceSearch

https://www.indiascienceandtechnology.gov.in/sites/default/files/j…FehdKdw4rFUJtzklmQ3SrufIAO74qVBan83BgmFs.js

js indiascienceandtechnology.gov.in collected 2026-09-24 09:18:38 UTC 97,768 bytes, 2,656 lines download raw bytes

1var fontSize = 100;
2jQuery(document).ready(function(){
3		//alert("ok");
4			if(_getCookie("fontSize") != null){
5				var fontSize = _getCookie("fontSize");
6			}else{
7				var fontSize = 100;
8			}
9			jQuery("#fontSize").css("font-size",fontSize + "%");
10});
11function _getCookie (name) {
12	var arg = name + "=";
13	var alen = arg.length;
14	var clen = document.cookie.length;
15	var i = 0;
16	while (i < clen) {
17		var j = i + alen;
18		if (document.cookie.substring(i, j) == arg) {
19			return _getCookieVal (j);
20		}
21		i = document.cookie.indexOf(" ", i) + 1;
22		if (i == 0) 
23			break;
24	}
25	return null;
26}
27function _deleteCookie (name,path,domain) {
28	if (_getCookie(name)) {
29		document.cookie = name + "=" +
30		((path) ? "; path=" + path : "") +
31		((domain) ? "; domain=" + domain : "") +
32		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
33	}
34}
35function _setCookie (name,value,expires,path,domain,secure) {
36	var vurl = true;
37	if(path != '' && path != undefined){
38		vurl = validUrl(path);
39	}
40	if(jQuery.type(name) == "string" &&  vurl){
41		document.cookie = name + "=" + escape (value) +
42		((expires) ? "; expires=" + expires.toGMTString() : "") +
43		((path) ? "; path=" + path : "") +
44		((domain) ? "; domain=" + domain : "") +
45		((secure) ? "; secure" : "");
46	}
47}
48function _getCookieVal (offset) {
49	var endstr = document.cookie.indexOf (";", offset);
50	if (endstr == -1) { endstr = document.cookie.length; }
51	return unescape(document.cookie.substring(offset, endstr));
52}
53/*********Font size resize**********/
54function set_font_size(fontType){
55	if(fontType == "increase"){
56			 if(fontSize < 130){
57			  fontSize = parseInt(fontSize) + 15;
58			 }
59		  }else if(fontType == "decrease"){
60			  if(fontSize > 70){
61				fontSize = parseInt(fontSize) - 15;
62			  }
63		  }else{
64			  fontSize = 100;
65		  }
66	_setCookie("fontSize",fontSize);
67	jQuery("#fontSize").css("font-size",fontSize + "%");
68	//jQuery("#template_three_column").css("font-size",fontSize + "%");
69} 
70;
71
72// date 24-2-2016   code for add class in mega menu  written by waliullah 
73/*
74( function($) {
75$(document).ready(function(){
76	//alert('hello');
77if($('.nav-menu li ul[class="sub-nav-group"] li ul[class="sub-nav-group"] li').find('li')){
78 alert('hello');	
79}
80			
81});
82
83} ) ( jQuery );
84*/
85// code end
86jQuery(document).ready(function(){
87	jQuery("#edit-search-block-form--2").attr("placeholder", "Search - Keyword, Phrase");
88	jQuery(".gtranslate select").attr("id","gtranslate");			   
89	jQuery("#gtranslate").before('<label class="notdisplay" for="gtranslate">Google Translate</label>');
90	//contrast
91	if(getCookie('contrast') == 0 || getCookie('contrast') == null){
92	jQuery(".light").hide();
93	jQuery(".dark").show();
94    }else{
95	jQuery(".light").show();
96	jQuery(".dark").hide();
97	
98    }
99    jQuery(".search-drop").css("display", "none");
100    jQuery(".common-right ul li ul").css("visibility", "hidden");
101
102// Fix Header
103
104	var num = 36; //number of pixels before modifying styles
105    jQuery(window).bind('scroll', function () {
106        if (jQuery(window).scrollTop() > num) {
107        jQuery('.fixed-wrapper').addClass('sticky');
108		
109    
110        } else {
111        jQuery('.fixed-wrapper').removeClass('sticky');
112    
113        }
114    });		
115			
116		
117	
118// Mobile Nav	
119jQuery('.sub-menu').append('<i class="fa fa-caret-right"></i>');
120	jQuery('.toggle-nav-bar').click(function(){	
121	jQuery('#nav').slideToggle();
122	//jQuery('#nav li').removeClass('open');
123    
124	/*jQuery("#nav li").click(function(){
125		jQuery("#nav li").removeClass('open');
126		jQuery(this).addClass('open');
127	}); */
128	
129		jQuery("#nav li").hover(
130		function() {
131		jQuery( this  ).addClass( "open" );
132		}, function() {
133		jQuery( this ).removeClass( "open" );
134		}
135		);
136		
137	});
138
139
140//Skip Content
141jQuery('a[href^="#skipCont"]').click(function() {
142jQuery('html,body').animate({ scrollTop: jQuery(this.hash).offset().top}, 500);
143//return false;
144//e.preventDefault();
145
146});
147
148// Toggle Search
149
150
151
152    jQuery("#toggleSearch").click(function(e) {
153        jQuery(".search-drop").toggle();
154        e.stopPropagation();
155    });
156
157    jQuery(document).click(function(e) {
158        if (!jQuery(e.target).is('.search-drop, .search-drop *')) {
159            jQuery(".search-drop").hide();
160        }
161    });
162
163
164});
165
166
167jQuery(document).ready(function(){
168	
169	jQuery("#main-menu div > ul" ).attr("id","nav");
170
171	dropdown1('nav','hover',10);
172
173	dropdown1("header-nav", "hover", 20);
174
175});
176
177
178jQuery(document).ready(function(){
179	
180	jQuery('.lang_select').change(function() {
181          var url = jQuery(this).val(); // get selected value
182          if (url) { // require a URL
183              window.location = url; // redirect
184          }
185          return false;
186      });
187	
188
189});
190
191
192//Drop down menu for Keyboard accessing
193
194function dropdown1(dropdownId, hoverClass, mouseOffDelay) { 
195	if(dropdown = document.getElementById(dropdownId)) {
196		var listItems = dropdown.getElementsByTagName('li');
197		for(var i = 0; i < listItems.length; i++) {
198			listItems[i].onmouseover = function() { this.className = addClass(this); }
199			listItems[i].onmouseout = function() {
200				var that = this;
201				setTimeout(function() { that.className = removeClass(that); }, mouseOffDelay);
202				this.className = that.className;
203			}
204			var anchor = listItems[i].getElementsByTagName('a');
205			anchor = anchor[0];
206			anchor.onfocus = function() { tabOn(this.parentNode); }
207			anchor.onblur = function() { tabOff(this.parentNode); }
208		}
209	}
210	
211	function tabOn(li) {
212		if(li.nodeName == 'LI') {
213			li.className = addClass(li);
214			tabOn(li.parentNode.parentNode);
215		}
216	}
217	
218	function tabOff(li) {
219		if(li.nodeName == 'LI') {
220			li.className = removeClass(li);
221			tabOff(li.parentNode.parentNode);
222		}
223	}
224	
225	function addClass(li) { return li.className + ' ' + hoverClass; }
226	function removeClass(li) { return li.className.replace(hoverClass, ""); }
227}
228
229//<![CDATA[
230jQuery(function ()
231{
232jQuery('table').wrap('<div class="scroll-table1"></div>');
233jQuery(".scroll-table1").before( "<div class='guide-text'>Swipe to view <i class='fa fa-long-arrow-right'></i></div>" );
234
235});
236//]]>
237
238
239jQuery(document).ready(function(){
240	var params = new Array();
241	var count = 0;
242	jQuery('table.views-table thead tr th').each(function () {
243		params[count] = jQuery(this).text();
244		count++;	
245	});
246	jQuery('table.views-table tbody tr').each(function () {
247		for(var j = 1; j <= count; j++){
248			jQuery('td:nth-child('+j+')', this).attr("data-label",params[j-1]);
249		}
250	});
251});
252
253
254function burstCache() {
255var url = window.location.href;
256if(base_url != url && base_url+"/" != url){
257if (!navigator.onLine) {
258document.body.innerHTML = "Loading...";
259window.location = "/";
260}
261}
262}
263window.onload = burstCache;
264
265
266
267
268
269
270;
271//Style Sheet Switcher version 1.1 Oct 10th, 2006
272
273//Author: Dynamic Drive: http://www.dynamicdrive.com
274//Usage terms: http://www.dynamicdrive.com/notice.htm
275
276//Unofficial Update to fix Safari 5.1 glitch re: alternate stylesheets or the disabled property in regards to them
277// See: http://www.dynamicdrive.com/forums/showthread.php?p=259199 for more info
278
279var manual_or_random="manual" //"manual" or "random"
280var randomsetting="3 days" //"eachtime", "sessiononly", or "x days (replace x with desired integer)". Only applicable if mode is random.
281
282//////No need to edit beyond here//////////////
283
284function getCookie(Name) { 
285	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
286	if (document.cookie.match(re)) //if cookie found
287		return document.cookie.match(re)[0].split("=")[1] //return its value
288	return null
289}
290
291function setCookie(name, value, days) {
292	var expireDate = new Date()
293	//set "expstring" to either future or past date, to set or delete cookie, respectively
294	var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
295	document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
296}
297 
298function deleteCookie(name){
299	setCookie(name, "moot")
300}
301
302function setStylesheet(title, randomize){ //Main stylesheet switcher function. Second parameter if defined causes a random alternate stylesheet (including none) to be enabled
303	var i, cacheobj, altsheets=[""];
304	if(setStylesheet.chosen)
305	try{
306		document.getElementsByTagName('head')[0].removeChild(setStylesheet.chosen);
307	}catch(e){}
308	for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
309		if(cacheobj.getAttribute("rel").toLowerCase()=="alternate stylesheet" && cacheobj.getAttribute("title")) { //if this is an alternate stylesheet with title
310		cacheobj.disabled = true
311		altsheets.push(cacheobj) //store reference to alt stylesheets inside array
312			if(cacheobj.getAttribute("title") == title){ //enable alternate stylesheet with title that matches parameter
313				cacheobj.disabled = false //enable chosen style sheet
314				setStylesheet.chosen = document.createElement('link');//cloneNode(false);
315				setStylesheet.chosen.rel = 'stylesheet';
316				setStylesheet.chosen.type = 'text/css';
317				if(cacheobj.media)
318					setStylesheet.chosen.media = cacheobj.media;
319				setStylesheet.chosen.href = cacheobj.href;
320				document.getElementsByTagName('head')[0].appendChild(setStylesheet.chosen);
321			}
322		}
323	}
324	if (typeof randomize!="undefined"){ //if second paramter is defined, randomly enable an alt style sheet (includes non)
325		var randomnumber=Math.floor(Math.random()*altsheets.length)
326		altsheets[randomnumber].disabled=false
327	}
328	return (typeof randomize!="undefined" && altsheets[randomnumber]!="")? altsheets[randomnumber].getAttribute("title") : "" //if in "random" mode, return "title" of randomly enabled alt stylesheet
329}
330
331function chooseStyle(styletitle, days){ //Interface function to switch style sheets plus save "title" attr of selected stylesheet to cookie
332	if (document.getElementById){
333		setStylesheet(styletitle)
334		setCookie("mysheet", styletitle, days)
335	}
336}
337
338function indicateSelected(element){ //Optional function that shows which style sheet is currently selected within group of radio buttons or select menu
339	if (selectedtitle!=null && (element.type==undefined || element.type=="select-one")){ //if element is a radio button or select menu
340		var element=(element.type=="select-one") ? element.options : element
341		for (var i=0; i<element.length; i++){
342			if (element[i].value==selectedtitle){ //if match found between form element value and cookie value
343				if (element[i].tagName=="OPTION") //if this is a select menu
344					element[i].selected=true
345				else{ //else if it's a radio button
346					element[i].checked=true
347				}
348			break
349			}
350		}
351	}
352}
353if (manual_or_random=="manual"){ //IF MANUAL MODE
354	var selectedtitle=getCookie("mysheet")
355	if (document.getElementById && selectedtitle!=null) //load user chosen style sheet from cookie if there is one stored
356		setStylesheet(selectedtitle)
357}else if (manual_or_random=="random"){ //IF AUTO RANDOM MODE
358	if (randomsetting=="eachtime")
359		setStylesheet("", "random")
360	else if (randomsetting=="sessiononly"){ //if "sessiononly" setting
361		if (getCookie("mysheet_s")==null) //if "mysheet_s" session cookie is empty
362			document.cookie="mysheet_s="+setStylesheet("", "random")+"; path=/" //activate random alt stylesheet while remembering its "title" value
363		else
364			setStylesheet(getCookie("mysheet_s")) //just activate random alt stylesheet stored in cookie
365	}
366	else if (randomsetting.search(/^[1-9]+ days/i)!=-1){ //if "x days" setting
367		if (getCookie("mysheet_r")==null || parseInt(getCookie("mysheet_r_days"))!=parseInt(randomsetting)){ //if "mysheet_r" cookie is empty or admin has changed number of days to persist in "x days" variable
368			setCookie("mysheet_r", setStylesheet("", "random"), parseInt(randomsetting)) //activate random alt stylesheet while remembering its "title" value
369			setCookie("mysheet_r_days", randomsetting, parseInt(randomsetting)) //Also remember the number of days to persist per the "x days" variable
370		}
371		else
372		setStylesheet(getCookie("mysheet_r")) //just activate random alt stylesheet stored in cookie
373	} 
374}
375
376jQuery(document).ready(function(){		
377	jQuery('#menu-item-278 > a, #menu-item-194 > a, #menu-item-192 >  a').click(function(){return false;});		
378	jQuery('.dark').click(function(){	
379		var thirtyDays = 1000*60*60*24*30;
380		var expireDate = new Date((new Date()).valueOf() + thirtyDays);		
381		document.cookie = 'contrast' +"="+ 1 +"; expires="+expireDate.toGMTString()+"; path=/";
382		document.cookie="username=John Doe";
383		jQuery(".light").show();
384		jQuery(".dark").hide();
385		jQuery('head').append('<link rel="stylesheet" type="text/css" media="screen" href="'+ base_url +'/'+ modulePath +'/assets/css/change.css">');
386		jQuery('head').append('<link rel="stylesheet" type="text/css" media="screen" href="'+ base_url +'/'+ themePath +'/css/site-change.css">');
387		jQuery(".national_emblem").attr("src",base_url+"/"+modulePath+"/assets/images/emblem-light.png");// high contrast
388		
389		jQuery(".ico-skip img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-skip-y.png");
390		jQuery(".ico-skip img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-skip-light.png");
391		
392		//jQuery(".ico-social img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-social-y.png");
393		//jQuery(".ico-social img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-social-light.png");
394		
395		jQuery(".ico-site-search img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-site-search-y.png");
396		jQuery(".ico-site-search img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-site-search-light.png");
397		
398		jQuery(".ico-sitemap img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-sitemap-y.png");
399		jQuery(".ico-sitemap img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-sitemap-light.png");
400		
401		jQuery(".ico-accessibility img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-accessibility-light.png");
402		jQuery(".ico-accessibility img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-accessibility-light.png");
403		
404		jQuery(".sw-logo img").attr("src",base_url+"/"+modulePath+"/assets/images/swach-bharat-y.png");
405		
406	});
407	jQuery('.light').click(function(){	
408		var thirtyDays = 1000*60*60*24*30;
409		var expireDate = new Date((new Date()).valueOf() + thirtyDays);		
410		document.cookie = 'contrast' +"="+ 0 +"; expires="+expireDate.toGMTString()+"; path=/";		
411		jQuery(".light").hide();
412		jQuery(".dark").show();		
413		jQuery("[href*='change.css']").remove();
414		jQuery(".national_emblem").attr("src",base_url+"/"+modulePath+"/assets/images/emblem-dark.png"); //normal
415		
416		jQuery(".ico-skip img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-skip.png");
417		jQuery(".ico-skip img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-skip-light.png");
418		
419		//jQuery(".ico-social img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-social.png");
420		//jQuery(".ico-social img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-social-light.png");
421		
422		jQuery(".ico-site-search img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-site-search.png");
423		jQuery(".ico-site-search img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-site-search-light.png");
424		
425		jQuery(".ico-sitemap img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-sitemap.png");
426		jQuery(".ico-sitemap img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-sitemap-light.png");
427		
428		jQuery(".ico-accessibility img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-accessibility.png");
429		jQuery(".ico-accessibility img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-accessibility-light.png");
430		
431		jQuery(".sw-logo img").attr("src",base_url+"/"+modulePath+"/assets/images/swach-bharat.png");
432
433	});
434	if(getCookie('contrast') == "1") {
435		jQuery('head').append('<link rel="stylesheet" type="text/css" media="screen" href="'+ base_url +'/'+ modulePath +'/assets/css/change.css">');
436		jQuery('head').append('<link rel="stylesheet" type="text/css" media="screen" href="'+ base_url +'/'+ themePath +'/css/site-change.css">');
437		jQuery(".national_emblem").attr("src",base_url+"/"+modulePath+"/assets/images/emblem-light.png");// high contrast
438		
439		jQuery(".ico-skip img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-skip-y.png");
440		jQuery(".ico-skip img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-skip-light.png");
441		
442		//jQuery(".ico-social img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-social-y.png");
443		//jQuery(".ico-social img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-social-light.png");
444		
445		jQuery(".ico-site-search img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-site-search-y.png");
446		jQuery(".ico-site-search img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-site-search-light.png");
447		
448		jQuery(".ico-sitemap img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-sitemap-y.png");
449		jQuery(".ico-sitemap img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-sitemap-light.png");
450		
451		jQuery(".ico-accessibility img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-accessibility-light.png");
452		jQuery(".ico-accessibility img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-accessibility-light.png");
453		
454		jQuery(".sw-logo img").attr("src",base_url+"/"+modulePath+"/assets/images/swach-bharat-y.png");
455	}
456	if(getCookie('contrast') == "0" ) {
457		jQuery("[href*='/css/change.css']").remove();
458		jQuery(".national_emblem").attr("src",base_url+"/"+modulePath+"/assets/images/emblem-dark.png"); //normal
459		
460		jQuery(".ico-skip img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-skip.png");
461		jQuery(".ico-skip img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-skip-light.png");
462		
463		//jQuery(".ico-social img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-social.png");
464		//jQuery(".ico-social img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-social-light.png");
465		
466		jQuery(".ico-site-search img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-site-search.png");
467		jQuery(".ico-site-search img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-site-search-light.png");
468		
469		jQuery(".ico-sitemap img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-sitemap.png");
470		jQuery(".ico-sitemap img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-sitemap-light.png");
471		
472		jQuery(".ico-accessibility img.top").attr("src",base_url+"/"+modulePath+"/assets/images/ico-accessibility.png");
473		jQuery(".ico-accessibility img.bottom").attr("src",base_url+"/"+modulePath+"/assets/images/ico-accessibility-light.png");
474		
475		jQuery(".sw-logo img").attr("src",base_url+"/"+modulePath+"/assets/images/swach-bharat.png");
476		
477	}
478});
479;
480/* $Id: lightbox.js,v 1.5.2.6.2.136 2010/09/24 08:39:40 snpower Exp $ */
481
482/**
483 * jQuery Lightbox
484 * @author
485 *   Stella Power, <http://drupal.org/user/66894>
486 *
487 * Based on Lightbox v2.03.3 by Lokesh Dhakar
488 * <http://www.huddletogether.com/projects/lightbox2/>
489 * Also partially based on the jQuery Lightbox by Warren Krewenki
490 *   <http://warren.mesozen.com>
491 *
492 * Permission has been granted to Mark Ashmead & other Drupal Lightbox2 module
493 * maintainers to distribute this file via Drupal.org
494 * Under GPL license.
495 *
496 * Slideshow, iframe and video functionality added by Stella Power.
497 */
498
499var Lightbox;
500(function($) {
501Lightbox = {
502  auto_modal : false,
503  overlayOpacity : 0.8, // Controls transparency of shadow overlay.
504  overlayColor : '000', // Controls colour of shadow overlay.
505  disableCloseClick : true,
506  // Controls the order of the lightbox resizing animation sequence.
507  resizeSequence: 0, // 0: simultaneous, 1: width then height, 2: height then width.
508  resizeSpeed: 'normal', // Controls the speed of the lightbox resizing animation.
509  fadeInSpeed: 'normal', // Controls the speed of the image appearance.
510  slideDownSpeed: 'slow', // Controls the speed of the image details appearance.
511  minWidth: 240,
512  borderSize : 10,
513  boxColor : 'fff',
514  fontColor : '000',
515  topPosit
515ion : '',
516  infoHeight: 20,
517  alternative_layout : false,
518  imageArray : [],
519  imageNum : null,
520  total : 0,
521  activeImage : null,
522  inprogress : false,
523  disableResize : false,
524  disableZoom : false,
525  isZoomedIn : false,
526  rtl : false,
527  loopItems : false,
528  keysClose : ['c', 'x', 27],
529  keysPrevious : ['p', 37],
530  keysNext : ['n', 39],
531  keysZoom : ['z'],
532  keysPlayPause : [32],
533
534  // Slideshow options.
535  slideInterval : 5000, // In milliseconds.
536  showPlayPause : true,
537  autoStart : true,
538  autoExit : true,
539  pauseOnNextClick : false, // True to pause the slideshow when the "Next" button is clicked.
540  pauseOnPrevClick : true, // True to pause the slideshow when the "Prev" button is clicked.
541  slideIdArray : [],
542  slideIdCount : 0,
543  isSlideshow : false,
544  isPaused : false,
545  loopSlides : false,
546
547  // Iframe options.
548  isLightframe : false,
549  iframe_width : 600,
550  iframe_height : 400,
551  iframe_border : 1,
552
553  // Video and modal options.
554  enableVideo : false,
555  flvPlayer : '/flvplayer.swf',
556  flvFlashvars : '',
557  isModal : false,
558  isVideo : false,
559  videoId : false,
560  modalWidth : 400,
561  modalHeight : 400,
562  modalHTML : null,
563
564
565  // initialize()
566  // Constructor runs on completion of the DOM loading.
567  // The function inserts html at the bottom of the page which is used
568  // to display the shadow overlay and the image container.
569  initialize: function() {
570
571    var s = Drupal.settings.lightbox2;
572    Lightbox.overlayOpacity = s.overlay_opacity;
573    Lightbox.overlayColor = s.overlay_color;
574    Lightbox.disableCloseClick = s.disable_close_click;
575    Lightbox.resizeSequence = s.resize_sequence;
576    Lightbox.resizeSpeed = s.resize_speed;
577    Lightbox.fadeInSpeed = s.fade_in_speed;
578    Lightbox.slideDownSpeed = s.slide_down_speed;
579    Lightbox.borderSize = s.border_size;
580    Lightbox.boxColor = s.box_color;
581    Lightbox.fontColor = s.font_color;
582    Lightbox.topPosition = s.top_position;
583    Lightbox.rtl = s.rtl;
584    Lightbox.loopItems = s.loop_items;
585    Lightbox.keysClose = s.keys_close.split(" ");
586    Lightbox.keysPrevious = s.keys_previous.split(" ");
587    Lightbox.keysNext = s.keys_next.split(" ");
588    Lightbox.keysZoom = s.keys_zoom.split(" ");
589    Lightbox.keysPlayPause = s.keys_play_pause.split(" ");
590    Lightbox.disableResize = s.disable_resize;
591    Lightbox.disableZoom = s.disable_zoom;
592    Lightbox.slideInterval = s.slideshow_interval;
593    Lightbox.showPlayPause = s.show_play_pause;
594    Lightbox.showCaption = s.show_caption;
595    Lightbox.autoStart = s.slideshow_automatic_start;
596    Lightbox.autoExit = s.slideshow_automatic_exit;
597    Lightbox.pauseOnNextClick = s.pause_on_next_click;
598    Lightbox.pauseOnPrevClick = s.pause_on_previous_click;
599    Lightbox.loopSlides = s.loop_slides;
600    Lightbox.alternative_layout = s.use_alt_layout;
601    Lightbox.iframe_width = s.iframe_width;
602    Lightbox.iframe_height = s.iframe_height;
603    Lightbox.iframe_border = s.iframe_border;
604    Lightbox.enableVideo = s.enable_video;
605    if (s.enable_video) {
606      Lightbox.flvPlayer = s.flvPlayer;
607      Lightbox.flvFlashvars = s.flvFlashvars;
608    }
609
610    // Make the lightbox divs.
611    var layout_class = (s.use_alt_layout ? 'lightbox2-alt-layout' : 'lightbox2-orig-layout');
612    var output = '<div id="lightbox2-overlay" style="display: none;"></div>\
613      <div id="lightbox" style="display: none;" class="' + layout_class + '">\
614        <div id="outerImageContainer"></div>\
615        <div id="imageDataContainer" class="clearfix">\
616          <div id="imageData"></div>\
617        </div>\
618      </div>';
619    var loading = '<div id="loading"><a href="#" id="loadingLink">Loading</a></div>';
620    var modal = '<div id="modalContainer" style="display: none;"></div>';
621    var frame = '<div id="frameContainer" style="display: none;"></div>';
622    var imageContainer = '<div id="imageContainer" style="display: none;"></div>';
623    var details = '<div id="imageDetails"></div>';
624    var bottomNav = '<div id="bottomNav"></div>';
625    var image = '<img id="lightboxImage" alt="" />';
626    var hoverNav = '<div id="hoverNav"><a id="prevLink" href="#"></a><a id="nextLink" href="#"></a></div>';
627    var frameNav = '<div id="frameHoverNav"><a id="framePrevLink" href="#"></a><a id="frameNextLink" href="#"></a></div>';
628    var hoverNav = '<div id="hoverNav"><a id="prevLink" title="' + Drupal.t('Previous') + '" href="#"></a><a id="nextLink" title="' + Drupal.t('Next') + '" href="#"></a></div>';
629    var frameNav = '<div id="frameHoverNav"><a id="framePrevLink" title="' + Drupal.t('Previous') + '" href="#"></a><a id="frameNextLink" title="' + Drupal.t('Next') + '" href="#"></a></div>';
630    var caption = '<span id="caption"></span>';
631    var numberDisplay = '<span id="numberDisplay"></span>';
632    var close = '<a id="bottomNavClose" title="' + Drupal.t('Close') + '" href="#"></a>';
633    var zoom = '<a id="bottomNavZoom" href="#">Bottom Nav Zoom</a>';
634    var zoomOut = '<a id="bottomNavZoomOut" href="#">Bottom Nav Zoom Out</a>';
635    var pause = '<a id="lightshowPause" title="' + Drupal.t('Pause Slideshow') + '" href="#" style="display: none;"></a>';
636    var play = '<a id="lightshowPlay" title="' + Drupal.t('Play Slideshow') + '" href="#" style="display: none;"></a>';
637
638    $("body").append(output);
639    $('#outerImageContainer').append(modal + frame + imageContainer + loading);
640    if (!s.use_alt_layout) {
641      $('#imageContainer').append(image + hoverNav);
642      $('#imageData').append(details + bottomNav);
643      $('#imageDetails').append(caption + numberDisplay);
644      $('#bottomNav').append(frameNav + close + zoom + zoomOut + pause + play);
645    }
646    else {
647      $('#outerImageContainer').append(bottomNav);
648      $('#imageContainer').append(image);
649      $('#bottomNav').append(close + zoom + zoomOut);
650      $('#imageData').append(hoverNav + details);
651      $('#imageDetails').append(caption + numberDisplay + pause + play);
652    }
653
654    // Setup onclick handlers.
655    if (Lightbox.disableCloseClick) {
656      $('#lightbox2-overlay').click(function() { Lightbox.end(); return false; } ).hide();
657    }
658    $('#loadingLink, #bottomNavClose').click(function() { Lightbox.end('forceClose'); return false; } );
659    $('#prevLink, #framePrevLink').click(function() { Lightbox.changeData(Lightbox.activeImage - 1); return false; } );
660    $('#nextLink, #frameNextLink').click(function() { Lightbox.changeData(Lightbox.activeImage + 1); return false; } );
661    $('#bottomNavZoom').click(function() { Lightbox.changeData(Lightbox.activeImage, true); return false; } );
662    $('#bottomNavZoomOut').click(function() { Lightbox.changeData(Lightbox.activeImage, false); return false; } );
663    $('#lightshowPause').click(function() { Lightbox.togglePlayPause("lightshowPause", "lightshowPlay"); return false; } );
664    $('#lightshowPlay').click(function() { Lightbox.togglePlayPause("lightshowPlay", "lightshowPause"); return false; } );
665
666    // Fix positioning.
667    $('#prevLink, #nextLink, #framePrevLink, #frameNextLink').css({ 'paddingTop': Lightbox.borderSize + 'px'});
668    $('#imageContainer, #frameContainer, #modalContainer').css({ 'padding': Lightbox.borderSize + 'px'});
669    $('#outerImageContainer, #imageDataContainer, #bottomNavClose').css({'backgroundColor': '#' + Lightbox.boxColor, 'color': '#'+Lightbox.fontColor});
670    if (Lightbox.alternative_layout) {
671      $('#bottomNavZoom, #bottomNavZoomOut').css({'bottom': Lightbox.borderSize + 'px', 'right': Lightbox.borderSize + 'px'});
672    }
673    else if (Lightbox.rtl == 1 && Drupal.settings.lightbox2.useragent.search('MSIE') !== -1) {
674      $('#bottomNavZoom, #bottomNavZoomOut').css({'left': '0px'});
675    }
676
677    // Force navigation links to always be displayed
678    if (s.force_show_nav) {
679      $('#prevLink, #nextLink').addClass("force_show_nav");
680    }
681
682  },
683
684  // initList()
685  // Loops through anchor tags looking for 'lightbox', 'lightshow' and
686  // 'lightframe', etc, references and applies onclick events to appropriate
687  // links. You can rerun after dynamically adding images w/ajax.
688  initList : function(context) {
689
690    if (context == undefined || context == null) {
691      context = document;
692    }
693
694    // Attach lightbox to any links with rel 'lightbox', 'lightshow' or
695    // 'lightframe', etc.
696    $("a[rel^='lightbox']:not(.lightbox-processed), area[rel^='lightbox']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
697      if (Lightbox.disableCloseClick) {
698        $('#lightbox').unbind('click');
699        $('#lightbox').click(function() { Lightbox.end('forceClose'); } );
700      }
701      Lightbox.start(this, false, false, false, false);
702      if (e.preventDefault) { e.preventDefault(); }
703      return false;
704    });
705    $("a[rel^='lightshow']:not(.lightbox-processed), area[rel^='lightshow']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
706      if (Lightbox.disableCloseClick) {
707        $('#lightbox').unbind('click');
708        $('#lightbox').click(function() { Lightbox.end('forceClose'); } );
709      }
710      Lightbox.start(this, true, false, false, false);
711      if (e.preventDefault) { e.preventDefault(); }
712      return false;
713    });
714    $("a[rel^='lightframe']:not(.lightbox-processed), area[rel^='lightframe']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
715      if (Lightbox.disableCloseClick) {
716        $('#lightbox').unbind('click');
717        $('#lightbox').click(function() { Lightbox.end('forceClose'); } );
718      }
719      Lightbox.start(this, false, true, false, false);
720      if (e.preventDefault) { e.preventDefault(); }
721      return false;
722    });
723    if (Lightbox.enableVideo) {
724      $("a[rel^='lightvideo']:not(.lightbox-processed), area[rel^='lightvideo']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
725        if (Lightbox.disableCloseClick) {
726          $('#lightbox').unbind('click');
727          $('#lightbox').click(function() { Lightbox.end('forceClose'); } );
728        }
729        Lightbox.start(this, false, false, true, false);
730        if (e.preventDefault) { e.preventDefault(); }
731        return false;
732      });
733    }
734    $("a[rel^='lightmodal']:not(.lightbox-processed), area[rel^='lightmodal']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
735      $('#lightbox').unbind('click');
736      // Add classes from the link to the lightbox div - don't include lightbox-processed
737      $('#lightbox').addClass($(this).attr('class'));
738      $('#lightbox').removeClass('lightbox-processed');
739      Lightbox.start(this, false, false, false, true);
740      if (e.preventDefault) { e.preventDefault(); }
741      return false;
742    });
743    $("#lightboxAutoModal:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) {
744      Lightbox.auto_modal = true;
745      $('#lightbox').unbind('click');
746      Lightbox.start(this, false, false, false, true);
747      if (e.preventDefault) { e.preventDefault(); }
748      return false;
749    });
750  },
751
752  // start()
753  // Display overlay and lightbox. If image is part of a set, add siblings to
754  // imageArray.
755  start: function(imageLink, slideshow, lightframe, lightvideo, lightmodal) {
756
757    Lightbox.isPaused = !Lightbox.autoStart;
758
759    // Replaces hideSelectBoxes() and hideFlash() calls in original lightbox2.
760    Lightbox.toggleSelectsFlash('hide');
761
762    // Stretch overlay to fill page and fade in.
763    var arrayPageSize = Lightbox.getPageSize();
764    $("#lightbox2-overlay").hide().css({
765      'width': '100%',
766      'zIndex': '10090',
767      'height': arrayPageSize[1] + 'px',
768      'backgroundColor' : '#' + Lightbox.overlayColor
769    });
770    // Detect OS X FF2 opacity + flash issue.
771    if (lightvideo && this.detectMacFF2()) {
772      $("#lightbox2-overlay").removeClass("overlay_default");
773      $("#lightbox2-overlay").addClass("overlay_macff2");
774      $("#lightbox2-overlay").css({'opacity' : null});
775    }
776    else {
777      $("#lightbox2-overlay").removeClass("overlay_macff2");
778      $("#lightbox2-overlay").addClass("overlay_default");
779      $("#lightbox2-overlay").css({'opacity' : Lightbox.overlayOpacity});
780    }
781    $("#lightbox2-overlay").fadeIn(Lightbox.fadeInSpeed);
782
783
784    Lightbox.isSlideshow = slideshow;
785    Lightbox.isLightframe = lightframe;
786    Lightbox.isVideo = lightvideo;
787    Lightbox.isModal = lightmodal;
788    Lightbox.imageArray = [];
789    Lightbox.imageNum = 0;
790
791    var anchors = $(imageLink.tagName);
792    var anchor = null;
793    var rel_parts = Lightbox.parseRel(imageLink);
794    var rel = rel_parts["rel"];
795    var rel_group = rel_parts["group"];
796    var title = (rel_parts["title"] ? rel_parts["title"] : imageLink.title);
797    var rel_style = null;
798    var i = 0;
799
800    if (rel_parts["flashvars"]) {
801      Lightbox.flvFlashvars = Lightbox.flvFlashvars + '&' + rel_parts["flashvars"];
802    }
803
804    // Set the title for image alternative text.
805    var alt = imageLink.title;
806    if (!alt) {
807      var img = $(imageLink).find("img");
808      if (img && $(img).attr("alt")) {
809        alt = $(img).attr("alt");
810      }
811      else {
812        alt = title;
813      }
814    }
815
816    if ($(imageLink).attr('id') == 'lightboxAutoModal') {
817      rel_style = rel_parts["style"];
818      Lightbox.imageArray.push(['#lightboxAutoModal > *', title, alt, rel_style, 1]);
819    }
820    else {
821      // Handle lightbox images with no grouping.
822      if ((rel == 'lightbox' || rel == 'lightshow') && !rel_group) {
823        Lightbox.imageArray.push([imageLink.href, title, alt]);
824      }
825
826      // Handle other items with no grouping.
827      else if (!rel_group) {
828        rel_style = rel_parts["style"];
829        Lightbox.imageArray.push([imageLink.href, title, alt, rel_style]);
830      }
831
832      // Handle grouped items.
833      else {
834
835        // Loop through anchors and add them to imageArray.
836        for (i = 0; i < anchors.length; i++) {
837          anchor = anchors[i];
838          if (anchor.href && typeof(anchor.href) == "string" && $(anchor).attr('rel')) {
839            var rel_data = Lightbox.parseRel(anchor);
840            var anchor_title = (rel_data["title"] ? rel_data["title"] : anchor.title);
841            img_alt = anchor.title;
842            if (!img_alt) {
843              var anchor_img = $(anchor).find("img");
844              if (anchor_img && $(anchor_img).attr("alt")) {
845                img_alt = $(anchor_img).attr("alt");
846              }
847              else {
848                img_alt = title;
849              }
850            }
851            if (rel_data["rel"] == rel) {
852              if (rel_data["group"] == rel_group) {
853                if (Lightbox.isLightframe || Lightbox.isModal || Lightbox.isVideo) {
854                  rel_style = rel_data["style"];
855                }
856                Lightbox.imageArray.push([anchor.href, anchor_title, img_alt, rel_style]);
857              }
858            }
859          }
860        }
861
862        // Remove duplicates.
863        for (i = 0; i < Lightbox.imageArray.length; i++) {
864          for (j = Lightbox.imageArray.length-1; j > i; j--) {
865            if (Lightbox.imageArray[i][0] == Lightbox.imageArray[j][0]) {
866              Lightbox.imageArray.splice(j,1);
867            }
868          }
869        }
870        while (Lightbox.imageArray[Lightbox.imageNum][0] != imageLink.href) {
871          Lightbox.imageNum++;
872        }
873      }
874    }
875
876    if (Lightbox.isSlideshow && Lightbox.showPlayPause && Lightbox.isPaused) {
877      $('#lightshowPlay').show();
878      $('#lightshowPause').hide();
879    }
880
881    // Calculate top and left offset for the lightbox.
882    var arrayPageScroll = Lightbox.getPageScroll();
883    var lightboxTop = arrayPageScroll[1] + (Lightbox.topPosition == '' ? (arrayPageSize[3] / 10) : Lightbox.topPosition) * 1;
884    var lightboxLeft = arrayPageScroll[0];
885    $('#frameContainer, #modalContainer, #lightboxImage').hide();
886    $('#hoverNav, #prevLink, #nextLink, #frameHoverNav, #framePrevLink, #frameNextLink').hide();
887    $('#imageDataContainer, #numberDisplay, #bottomNavZoom, #bottomNavZoomOut').hide();
888    $('#outerImageContainer').css({'width': '250px', 'height': '250px'});
889    $('#lightbox').css({
890      'zIndex': '10500',
891      'top': lightboxTop + 'px',
892      'left': lightboxLeft + 'px'
893    }).show();
894
895    Lightbox.total = Lightbox.imageArray.length;
896    Lightbox.changeData(Lightbox.imageNum);
897  },
898
899  // changeData()
900  // Hide most elements and preload image in preparation for resizing image
901  // container.
902  changeData: function(imageNum, zoomIn) {
903
904    if (Lightbox.inprogress === false) {
905      if (Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) {
906        if (imageNum >= Lightbox.total) imageNum = 0;
907        if (imageNum < 0) imageNum = Lightbox.total - 1;
908      }
909
910      if (Lightbox.isSlideshow) {
911        for (var i = 0; i < Lightbox.slideIdCount; i++) {
912          window.clearTimeout(Lightbox.slideIdArray[i]);
913        }
914      }
915      Lightbox.inprogress = true;
916      Lightbox.activeImage = imageNum;
917
918      if (Lightbox.disableResize && !Lightbox.isSlideshow) {
919        zoomIn = true;
920      }
921      Lightbox.isZoomedIn = zoomIn;
922
923
924      // Hide elements during transition.
925      $('#loading').css({'zIndex': '10500'}).show();
926      if (!Lightbox.alternative_layout) {
927        $('#imageContainer').hide();
928      }
929      $('#frameContainer, #modalContainer, #lightboxImage').hide();
930      $('#hoverNav, #prevLink, #nextLink, #frameHoverNav, #framePrevLink, #frameNextLink').hide();
931      $('#imageDataContainer, #numberDisplay, #bottomNavZoom, #bottomNavZoomOut').hide();
932
933      // Preload image content, but not iframe pages.
934      if (!Lightbox.isLightframe && !Lightbox.isVideo && !Lightbox.isModal) {
935        $("#lightbox #imageDataContainer").removeClass('lightbox2-alt-layout-data');
936        imgPreloader = new Image();
937        imgPreloader.onerror = function() { Lightbox.imgNodeLoadingError(this); };
938
939        imgPreloader.onload = function() {
940          var photo = document.getElementById('lightboxImage');
941          photo.src = Lightbox.imageArray[Lightbox.activeImage][0];
942          photo.alt = Lightbox.imageArray[Lightbox.activeImage][2];
943
944          var imageWidth = imgPreloader.width;
945          var imageHeight = imgPreloader.height;
946
947          // Resize code.
948          var arrayPageSize = Lightbox.getPageSize();
949          var targ = { w:arrayPageSize[2] - (Lightbox.borderSize * 2), h:arrayPageSize[3] - (Lightbox.borderSize * 6) - (Lightbox.infoHeight * 4) - (arrayPageSize[3] / 10) };
950          var orig = { w:imgPreloader.width, h:imgPreloader.height };
951
952          // Image is very large, so show a smaller version of the larger image
953          // with zoom button.
954          if (zoomIn !== true) {
955            var ratio = 1.0; // Shrink image with the same aspect.
956            $('#bottomNavZoomOut, #bottomNavZoom').hide();
957            if ((orig.w >= targ.w || orig.h >= targ.h) && orig.h && orig.w) {
958              ratio = ((targ.w / orig.w) < (targ.h / orig.h)) ? targ.w / orig.w : targ.h / orig.h;
959              if (!Lightbox.disableZoom && !Lightbox.isSlideshow) {
960                $('#bottomNavZoom').css({'zIndex': '10500'}).show();
961              }
962            }
963
964            imageWidth  = Math.floor(orig.w * ratio);
965            imageHeight = Math.floor(orig.h * ratio);
966          }
967
968          else {
969            $('#bottomNavZoom').hide();
970            // Only display zoom out button if the image is zoomed in already.
971            if ((orig.w >= targ.w || orig.h >= targ.h) && orig.h && orig.w) {
972              // Only display zoom out button if not a slideshow and if the
973              // buttons aren't disabled.
974              if (!Lightbox.disableResize && Lightbox.isSlideshow === false && !Lightbox.disableZoom) {
975                $('#bottomNavZoomOut').css({'zIndex': '10500'}).show();
976              }
977            }
978          }
979
980          photo.style.width = (imageWidth) + 'px';
981          photo.style.height = (imageHeight) + 'px';
982          Lightbox.resizeContainer(imageWidth, imageHeight);
983
984          // Clear onLoad, IE behaves irratically with animated gifs otherwise.
985          imgPreloader.onload = function() {};
986        };
987
988        imgPreloader.src = Lightbox.imageArray[Lightbox.activeImage][0];
989        imgPreloader.alt = Lightbox.imageArray[Lightbox.activeImage][2];
990      }
991
992      // Set up frame size, etc.
993      else if (Lightbox.isLightframe) {
994        $("#lightbox #imageDataContainer").addClass('lightbox2-alt-layout-data');
995        var src = Lightbox.imageArray[Lightbox.activeImage][0];
996        $('#frameContainer').html('<iframe id="lightboxFrame" style="display: none;" src="'+src+'"></iframe>');
997
998        // Enable swf support in Gecko browsers.
999        if (Drupal.settings.lightbox2.useragent.search('Mozilla') !== -1 && src.indexOf('.swf') != -1) {
1000          setTimeout(function () {
1001            document.getElementById("lightboxFrame").src = Lightbox.imageArray[Lightbox.activeImage][0];
1002          }, 1000);
1003        }
1004
1005        if (!Lightbox.iframe_border) {
1006          $('#lightboxFrame').css({'border': 'none'});
1007          $('#lightboxFrame').attr('frameborder', '0');
1008        }
1009        var iframe = document.getElementById('lightboxFrame');
1010        var iframeStyles = Lightbox.imageArray[Lightbox.activeImage][3];
1011        iframe = Lightbox.setStyles(iframe, iframeStyles);
1012        Lightbox.resizeContainer(parseInt(iframe.width, 10), parseInt(iframe.height, 10));
1013      }
1014      else if (Lightbox.isVideo || Lightbox.isModal) {
1015        $("#lightbox #imageDataContainer").addClass('lightbox2-alt-layout-data');
1016        var container = document.getElementById('modalContainer');
1017        var modalStyles = Lightbox.imageArray[Lightbox.activeImage][3];
1018        container = Lightbox.setStyles(container, modalStyles);
1019        if (Lightbox.isVideo) {
1020          Lightbox.modalHeight =  parseInt(container.height, 10) - 10;
1021          Lightbox.modalWidth =  parseInt(container.width, 10) - 10;
1022          Lightvideo.startVideo(Lightbox.imageArray[Lightbox.activeImage][0]);
1023        }
1024        Lightbox.resizeContainer(parseInt(container.width, 10), parseInt(container.height, 10));
1025      }
1026    }
1027  },
1028
1029  // imgNodeLoadingError()
1030  imgNodeLoadingError: function(image) {
1031    var s = Drupal.settings.lightbox2;
1032    var original_image = Lightbox.imageArray[Lightbox.activeImage][0];
1033    if (s.display_image_size !== "") {
1034      original_image = original_image.replace(new RegExp("."+s.display_image_size), "");
1035    }
1036    Lightbox.imageArray[Lightbox.activeImage][0] = original_image;
1037    image.onerror = function() { Lightbox.imgLoadingError(image); };
1038    image.src = original_image;
1039  },
1040
1041  // imgLoadingError()
1042  imgLoadingError: function(image) {
1043    var s = Drupal.settings.lightbox2;
1044    Lightbox.imageArray[Lightbox.activeImage][0] = s.default_image;
1045    image.src = s.default_image;
1046  },
1047
1048  // resizeContainer()
1049  resizeContainer: function(imgWidth, imgHeight) {
1050
1051    imgWidth = (imgWidth < Lightbox.minWidth ? Lightbox.minWidth : imgWidth);
1052
1053    this.widthCurrent = $('#outerImageContainer').width();
1054    this.heightCurrent = $('#outerImageContainer').height();
1055
1056    var widthNew = (imgWidth  + (Lightbox.borderSize * 2));
1057    var heightNew = (imgHeight  + (Lightbox.borderSize * 2));
1058
1059    // Scalars based on change from old to new.
1060    this.xScale = ( widthNew / this.widthCurrent) * 100;
1061    this.yScale = ( heightNew / this.heightCurrent) * 100;
1062
1063    // Calculate size difference between new and old image, and resize if
1064    // necessary.
1065    wDiff = this.widthCurrent - widthNew;
1066    hDiff = this.heightCurrent - heightNew;
1067
1068    $('#modalContainer').css({'width': imgWidth, 'height': imgHeight});
1069    // Detect animation sequence.
1070    if (Lightbox.resizeSequence) {
1071      var animate1 = {width: widthNew};
1072      var animate2 = {height: heightNew};
1073      if (Lightbox.resizeSequence == 2) {
1074        animate1 = {height: heightNew};
1075        animate2 = {width: widthNew};
1076      }
1077      $('#outerImageContainer').animate(animate1, Lightbox.resizeSpeed).animate(animate2, Lightbox.resizeSpeed, 'linear', function() { Lightbox.showData(); });
1078    }
1079    // Simultaneous.
1080    else {
1081      $('#outerImageContainer').animate({'width': widthNew, 'height': heightNew}, Lightbox.resizeSpeed, 'linear', function() { Lightbox.showData(); });
1082    }
1083
1084    // If new and old image are same size and no scaling transition is necessary
1085    // do a quick pause to prevent image flicker.
1086    if ((hDiff === 0) && (wDiff === 0)) {
1087      if (Drupal.settings.lightbox2.useragent.search('MSIE') !== -1) {
1088        Lightbox.pause(250);
1089      }
1090      else {
1091        Lightbox.pause(100);
1092      }
1093    }
1094
1095    var s = Drupal.settings.lightbox2;
1096    if (!s.use_alt_layout) {
1097      $('#prevLink, #nextLink').css({'height': imgHeight + 'px'});
1098    }
1099    $('#imageDataContainer').css({'width': widthNew + 'px'});
1100  },
1101
1102  // showData()
1103  // Display image and begin preloading neighbors.
1104  showData: function() {
1105    $('#loading').hide();
1106
1107    if (Lightbox.isLightframe || Lightbox.isVideo || Lightbox.isModal) {
1108      Lightbox.updateDetails();
1109      if (Lightbox.isLightframe) {
1110        $('#frameContainer').show();
1111        if (Drupal.settings.lightbox2.useragent.search('Safari') !== -1 || Lightbox.fadeInSpeed === 0) {
1112          $('#lightboxFrame').css({'zIndex': '10500'}).show();
1113        }
1114        else {
1115          $('#lightboxFrame').css({'zIndex': '10500'}).fadeIn(Lightbox.fadeInSpeed);
1116        }
1117      }
1118      else {
1119        if (Lightbox.isVideo) {
1120          $("#modalContainer").html(Lightbox.modalHTML).click(function(){return false;}).css('zIndex', '10500').show();
1121        }
1122        else {
1123          var src = unescape(Lightbox.imageArray[Lightbox.activeImage][0]);
1124          if (Lightbox.imageArray[Lightbox.activeImage][4]) {
1125            $(src).appendTo("#modalContainer");
1126            $('#modalContainer').css({'zIndex': '10500'}).show();
1127          }
1128          else {
1129            // Use a callback to show the new image, otherwise you get flicker.
1130            $("#modalContainer").hide().load(src, function () {$('#modalContainer').css({'zIndex': '10500'}).show();});
1131          }
1132          $('#modalContainer').unbind('click');
1133        }
1134        // This might be needed in the Lightframe section above.
1135        //$('#modalContainer').css({'zIndex': '10500'}).show();
1136      }
1137    }
1138
1139    // Handle display of image content.
1140    else {
1141      $('#imageContainer').show();
1142      if (Drupal.settings.lightbox2.useragent.search('Safari') !== -1 || Lightbox.fadeInSpeed === 0) {
1143        $('#lightboxImage').css({'zIndex': '10500'}).show();
1144      }
1145      else {
1146        $('#lightboxImage').css({'zIndex': '10500'}).fadeIn(Lightbox.fadeInSpeed);
1147      }
1148      Lightbox.updateDetails();
1149      this.preloadNeighborImages();
1150    }
1151    Lightbox.inprogress = false;
1152
1153    // Slideshow specific stuff.
1154    if (Lightbox.isSlideshow) {
1155      if (!Lightbox.loopSlides && Lightbox.activeImage == (Lightbox.total - 1)) {
1156        if (Lightbox.autoExit) {
1157          Lightbox.slideIdArray[Lightbox.slideIdCount++] = setTimeout(function () {Lightbox.end('slideshow');}, Lightbox.slideInterval);
1158        }
1159      }
1160      else {
1161        if (!Lightbox.isPaused && Lightbox.total > 1) {
1162          Lightbox.slideIdArray[Lightbox.slideIdCount++] = setTimeout(function () {Lightbox.changeData(Lightbox.activeImage + 1);}, Lightbox.slideInterval);
1163        }
1164      }
1165      if (Lightbox.showPlayPause && Lightbox.total > 1 && !Lightbox.isPaused) {
1166        $('#lightshowPause').show();
1167        $('#lightshowPlay').hide();
1168      }
1169      else if (Lightbox.showPlayPause && Lightbox.total > 1) {
1170        $('#lightshowPause').hide();
1171        $('#lightshowPlay').show();
1172      }
1173    }
1174
1175    // Adjust the page overlay size.
1176    var arrayPageSize = Lightbox.getPageSize();
1177    var arrayPageScroll = Lightbox.getPageScroll();
1178    var pageHeight = arrayPageSize[1];
1179    if (Lightbox.isZoomedIn && arrayPageSize[1] > arrayPageSize[3]) {
1180      var lightboxTop = (Lightbox.topPosition == '' ? (arrayPageSize[3] / 10) : Lightbox.topPosition) * 1;
1181      pageHeight = pageHeight + arrayPageScroll[1] + lightboxTop;
1182    }
1183    $('#lightbox2-overlay').css({'height': pageHeight + 'px', 'width': arrayPageSize[0] + 'px'});
1184
1185    // Gecko browsers (e.g. Firefox, SeaMonkey, etc) don't handle pdfs as
1186    // expected.
1187    if (Drupal.settings.lightbox2.useragent.search('Mozilla') !== -1) {
1188      if (Lightbox.imageArray[Lightbox.activeImage][0].indexOf(".pdf") != -1) {
1189        setTimeout(function () {
1190          document.getElementById("lightboxFrame").src = Lightbox.imageArray[Lightbox.activeImage][0];
1191        }, 1000);
1192      }
1193    }
1194  },
1195
1196  // updateDetails()
1197  // Display caption, image number, and bottom nav.
1198  updateDetails: function() {
1199
1200    $("#imageDataContainer").hide();
1201
1202    var s = Drupal.settings.lightbox2;
1203
1204    if (s.show_caption) {
1205      var caption = Lightbox.filterXSS(Lightbox.imageArray[Lightbox.activeImage][1]);
1206      if (!caption) caption = '';
1207      $('#caption').html(caption).css({'zIndex': '10500'}).show();
1208    }
1209
1210    // If image is part of set display 'Image x of x'.
1211    var numberDisplay = null;
1212    if (s.image_count && Lightbox.total > 1) {
1213      var currentImage = Lightbox.activeImage + 1;
1214      if (!Lightbox.isLightframe && !Lightbox.isModal && !Lightbox.isVideo) {
1215        numberDisplay = s.image_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
1216      }
1217      else if (Lightbox.isVideo) {
1218        numberDisplay = s.video_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
1219      }
1220      else {
1221        numberDisplay = s.page_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total);
1222      }
1223      $('#numberDisplay').html(numberDisplay).css({'zIndex': '10500'}).show();
1224    }
1225    else {
1226      $('#numberDisplay').hide();
1227    }
1228
1229    $("#imageDataContainer").hide().slideDown(Lightbox.slideDownSpeed, function() {
1230      $("#bottomNav").show();
1231    });
1232    if (Lightbox.rtl == 1) {
1233      $("#bottomNav").css({'float': 'left'});
1234    }
1235    Lightbox.updateNav();
1236  },
1237
1238  // updateNav()
1239  // Display appropriate previous and next hover navigation.
1240  updateNav: function() {
1241
1242    $('#hoverNav').css({'zIndex': '10500'}).show();
1243    var prevLink = '#prevLink';
1244    var nextLink = '#nextLink';
1245
1246    // Slideshow is separated as we need to show play / pause button.
1247    if (Lightbox.isSlideshow) {
1248      if ((Lightbox.total > 1 && Lightbox.loopSlides) || Lightbox.activeImage !== 0) {
1249        $(prevLink).css({'zIndex': '10500'}).show().click(function() {
1250          if (Lightbox.pauseOnPrevClick) {
1251            Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
1252          }
1253          Lightbox.changeData(Lightbox.activeImage - 1); return false;
1254        });
1255      }
1256      else {
1257        $(prevLink).hide();
1258      }
1259
1260      // If not last image in set, display next image button.
1261      if ((Lightbox.total > 1 && Lightbox.loopSlides) || Lightbox.activeImage != (Lightbox.total - 1)) {
1262        $(nextLink).css({'zIndex': '10500'}).show().click(function() {
1263          if (Lightbox.pauseOnNextClick) {
1264            Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
1265          }
1266          Lightbox.changeData(Lightbox.activeImage + 1); return false;
1267        });
1268      }
1269      // Safari browsers need to have hide() called again.
1270      else {
1271        $(nextLink).hide();
1272      }
1273    }
1274
1275    // All other types of content.
1276    else {
1277
1278      if ((Lightbox.isLightframe || Lightbox.isModal || Lightbox.isVideo) && !Lightbox.alternative_layout) {
1279        $('#frameHoverNav').css({'zIndex': '10500'}).show();
1280        $('#hoverNav').css({'zIndex': '10500'}).hide();
1281        prevLink = '#framePrevLink';
1282        nextLink = '#frameNextLink';
1283      }
1284
1285      // If not first image in set, display prev image button.
1286      if ((Lightbox.total > 1 && Lightbox.loopItems) || Lightbox.activeImage !== 0) {
1287        // Unbind any other click handlers, otherwise this adds a new click handler
1288        // each time the arrow is clicked.
1289        $(prevLink).css({'zIndex': '10500'}).show().unbind().click(function() {
1290          Lightbox.changeData(Lightbox.activeImage - 1); return false;
1291        });
1292      }
1293      // Safari browsers need to have hide() called again.
1294      else {
1295        $(prevLink).hide();
1296      }
1297
1298      // If not last image in set, display next image button.
1299      if ((Lightbox.total > 1 && Lightbox.loopItems) || Lightbox.activeImage != (Lightbox.total - 1)) {
1300        // Unbind any other click handlers, otherwise this adds a new click handler
1301        // each time the arrow is clicked.
1302        $(nextLink).css({'zIndex': '10500'}).show().unbind().click(function() {
1303          Lightbox.changeData(Lightbox.activeImage + 1); return false;
1304        });
1305      }
1306      // Safari browsers need to have hide() called again.
1307      else {
1308        $(nextLink).hide();
1309      }
1310    }
1311
1312    // Don't enable keyboard shortcuts so forms will work.
1313    if (!Lightbox.isModal) {
1314      this.enableKeyboardNav();
1315    }
1316  },
1317
1318
1319  // enableKeyboardNav()
1320  enableKeyboardNav: function() {
1321    $(document).bind("keydown", this.keyboardAction);
1322  },
1323
1324  // disableKeyboardNav()
1325  disableKeyboardNav: function() {
1326    $(document).unbind("keydown", this.keyboardAction);
1327  },
1328
1329  // keyboardAction()
1330  keyboardAction: function(e) {
1331    if (e === null) { // IE.
1332      keycode = event.keyCode;
1333      escapeKey = 27;
1334    }
1335    else { // Mozilla.
1336      keycode = e.keyCode;
1337      escapeKey = e.DOM_VK_ESCAPE;
1338    }
1339
1340    key = String.fromCharCode(keycode).toLowerCase();
1341
1342    // Close lightbox.
1343    if (Lightbox.checkKey(Lightbox.keysClose, key, keycode)) {
1344      Lightbox.end('forceClose');
1345    }
1346    // Display previous image (p, <-).
1347    else if (Lightbox.checkKey(Lightbox.keysPrevious, key, keycode)) {
1348      if ((Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) || Lightbox.activeImage !== 0) {
1349        Lightbox.changeData(Lightbox.activeImage - 1);
1350      }
1351
1352    }
1353    // Display next image (n, ->).
1354    else if (Lightbox.checkKey(Lightbox.keysNext, key, keycode)) {
1355      if ((Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) || Lightbox.activeImage != (Lightbox.total - 1)) {
1356        Lightbox.changeData(Lightbox.activeImage + 1);
1357      }
1358    }
1359    // Zoom in.
1360    else if (Lightbox.checkKey(Lightbox.keysZoom, key, keycode) && !Lightbox.disableResize && !Lightbox.disableZoom && !Lightbox.isSlideshow && !Lightbox.isLightframe) {
1361      if (Lightbox.isZoomedIn) {
1362        Lightbox.changeData(Lightbox.activeImage, false);
1363      }
1364      else if (!Lightbox.isZoomedIn) {
1365        Lightbox.changeData(Lightbox.activeImage, true);
1366      }
1367      return false;
1368    }
1369    // Toggle play / pause (space).
1370    else if (Lightbox.checkKey(Lightbox.keysPlayPause, key, keycode) && Lightbox.isSlideshow) {
1371
1372      if (Lightbox.isPaused) {
1373        Lightbox.togglePlayPause("lightshowPlay", "lightshowPause");
1374      }
1375      else {
1376        Lightbox.togglePlayPause("lightshowPause", "lightshowPlay");
1377      }
1378      return false;
1379    }
1380  },
1381
1382  preloadNeighborImages: function() {
1383
1384    if ((Lightbox.total - 1) > Lightbox.activeImage) {
1385      preloadNextImage = new Image();
1386      preloadNextImage.src = Lightbox.imageArray[Lightbox.activeImage + 1][0];
1387    }
1388    if (Lightbox.activeImage > 0) {
1389      preloadPrevImage = new Image();
1390      preloadPrevImage.src = Lightbox.imageArray[Lightbox.activeImage - 1][0];
1391    }
1392
1393  },
1394
1395  end: function(caller) {
1396    var closeClick = (caller == 'slideshow' ? false : true);
1397    if (Lightbox.isSlideshow && Lightbox.isPaused && !closeClick) {
1398      return;
1399    }
1400    // To prevent double clicks on navigation links.
1401    if (Lightbox.inprogress === true && caller != 'forceClose') {
1402      return;
1403    }
1404    Lightbox.disableKeyboardNav();
1405    $('#lightbox').hide();
1406    $("#lightbox2-overlay").fadeOut();
1407    Lightbox.isPaused = true;
1408    Lightbox.inprogress = false;
1409    Lightbox.imageArray = [];
1410    Lightbox.imageNum = 0;
1411    // Replaces calls to showSelectBoxes() and showFlash() in original
1412    // lightbox2.
1413    Lightbox.toggleSelectsFlash('visible');
1414    if (Lightbox.isSlideshow) {
1415      for (var i = 0; i < Lightbox.slideIdCount; i++) {
1416        window.clearTimeout(Lightbox.slideIdArray[i]);
1417      }
1418      $('#lightshowPause, #lightshowPlay').hide();
1419    }
1420    else if (Lightbox.isLightframe) {
1421      $('#frameContainer').empty().hide();
1422    }
1423    else if (Lightbox.isVideo || Lightbox.isModal) {
1424      if (!Lightbox.auto_modal) {
1425        $('#modalContainer').hide().html("");
1426      }
1427      Lightbox.auto_modal = false;
1428    }
1429  },
1430
1431
1432  // getPageScroll()
1433  // Returns array with x,y page scroll values.
1434  // Core code from - quirksmode.com.
1435  getPageScroll : function() {
1436
1437    var xScroll, yScroll;
1438
1439    if (self.pageYOffset || self.pageXOffset) {
1440      yScroll = self.pageYOffset;
1441      xScroll = self.pageXOffset;
1442    }
1443    else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {  // Explorer 6 Strict.
1444      yScroll = document.documentElement.scrollTop;
1445      xScroll = document.documentElement.scrollLeft;
1446    }
1447    else if (document.body) {// All other Explorers.
1448      yScroll = document.body.scrollTop;
1449      xScroll = document.body.scrollLeft;
1450    }
1451
1452    arrayPageScroll = [xScroll,yScroll];
1453    return arrayPageScroll;
1454  },
1455
1456  // getPageSize()
1457  // Returns array with page width, height and window width, height.
1458  // Core code from - quirksmode.com.
1459  // Edit for Firefox by pHaez.
1460
1461  getPageSize : function() {
1462
1463    var xScroll, yScroll;
1464
1465    if (window.innerHeight && window.scrollMaxY) {
1466      xScroll = window.innerWidth + window.scrollMaxX;
1467      yScroll = window.innerHeight + window.scrollMaxY;
1468    }
1469    else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac.
1470      xScroll = document.body.scrollWidth;
1471      yScroll = document.body.scrollHeight;
1472    }
1473    else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari.
1474      xScroll = document.body.offsetWidth;
1475      yScroll = document.body.offsetHeight;
1476    }
1477
1478    var windowWidth, windowHeight;
1479
1480    if (self.innerHeight) { // All except Explorer.
1481      if (document.documentElement.clientWidth) {
1482        windowWidth = document.documentElement.clientWidth;
1483      }
1484      else {
1485        windowWidth = self.innerWidth;
1486      }
1487      windowHeight = self.innerHeight;
1488    }
1489    else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode.
1490      windowWidth = document.documentElement.clientWidth;
1491      windowHeight = document.documentElement.clientHeight;
1492    }
1493    else if (document.body) { // Other Explorers.
1494      windowWidth = document.body.clientWidth;
1495      windowHeight = document.body.clientHeight;
1496    }
1497    // For small pages with total height less than height of the viewport.
1498    if (yScroll < windowHeight) {
1499      pageHeight = windowHeight;
1500    }
1501    else {
1502      pageHeight = yScroll;
1503    }
1504    // For small pages with total width less than width of the viewport.
1505    if (xScroll < windowWidth) {
1506      pageWidth = xScroll;
1507    }
1508    else {
1509      pageWidth = windowWidth;
1510    }
1511    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
1512    return arrayPageSize;
1513  },
1514
1515
1516  // pause(numberMillis)
1517  pause : function(ms) {
1518    var date = new Date();
1519    var curDate = null;
1520    do { curDate = new Date(); }
1521    while (curDate - date < ms);
1522  },
1523
1524
1525  // toggleSelectsFlash()
1526  // Hide / unhide select lists and flash objects as they appear above the
1527  // lightbox in some browsers.
1528  toggleSelectsFlash: function (state) {
1529    if (state == 'visible') {
1530      $("select.lightbox_hidden, embed.lightbox_hidden, object.lightbox_hidden").show();
1531    }
1532    else if (state == 'hide') {
1533      $("select:visible, embed:visible, object:visible").not('#lightboxAutoModal select, #lightboxAutoModal embed, #lightboxAutoModal object').addClass("lightbox_hidden");
1534      $("select.lightbox_hidden, embed.lightbox_hidden, object.lightbox_hidden").hide();
1535    }
1536  },
1537
1538
1539  // parseRel()
1540  parseRel: function (link) {
1541    var parts = [];
1542    parts["rel"] = parts["title"] = parts["group"] = parts["style"] = parts["flashvars"] = null;
1543    if (!$(link).attr('rel')) return parts;
1544    parts["rel"] = $(link).attr('rel').match(/\w+/)[0];
1545
1546    if ($(link).attr('rel').match(/\[(.*)\]/)) {
1547      var info = $(link).attr('rel').match(/\[(.*?)\]/)[1].split('|');
1548      parts["group"] = info[0];
1549      parts["style"] = info[1];
1550      if (parts["style"] != undefined && parts["style"].match(/flashvars:\s?(.*?);/)) {
1551        parts["flashvars"] = parts["style"].match(/flashvars:\s?(.*?);/)[1];
1552      }
1553    }
1554    if ($(link).attr('rel').match(/\[.*\]\[(.*)\]/)) {
1555      parts["title"] = $(link).attr('rel').match(/\[.*\]\[(.*)\]/)[1];
1556    }
1557    return parts;
1558  },
1559
1560  // setStyles()
1561  setStyles: function(item, styles) {
1562    item.width = Lightbox.iframe_width;
1563    item.height = Lightbox.iframe_height;
1564    item.scrolling = "auto";
1565
1566    if (!styles) return item;
1567    var stylesArray = styles.split(';');
1568    for (var i = 0; i< stylesArray.length; i++) {
1569      if (stylesArray[i].indexOf('width:') >= 0) {
1570        var w = stylesArray[i].replace('width:', '');
1571        item.width = jQuery.trim(w);
1572      }
1573      else if (stylesArray[i].indexOf('height:') >= 0) {
1574        var h = stylesArray[i].replace('height:', '');
1575        item.height = jQuery.trim(h);
1576      }
1577      else if (stylesArray[i].indexOf('scrolling:') >= 0) {
1578        var scrolling = stylesArray[i].replace('scrolling:', '');
1579        item.scrolling = jQuery.trim(scrolling);
1580      }
1581      else if (stylesArray[i].indexOf('overflow:') >= 0) {
1582        var overflow = stylesArray[i].replace('overflow:', '');
1583        item.overflow = jQuery.trim(overflow);
1584      }
1585    }
1586    return item;
1587  },
1588
1589
1590  // togglePlayPause()
1591  // Hide the pause / play button as appropriate.  If pausing the slideshow also
1592  // clear the timers, otherwise move onto the next image.
1593  togglePlayPause: function(hideId, showId) {
1594    if (Lightbox.isSlideshow && hideId == "lightshowPause") {
1595      for (var i = 0; i < Lightbox.slideIdCount; i++) {
1596        window.clearTimeout(Lightbox.slideIdArray[i]);
1597      }
1598    }
1599    $('#' + hideId).hide();
1600    $('#' + showId).show();
1601
1602    if (hideId == "lightshowPlay") {
1603      Lightbox.isPaused = false;
1604      if (!Lightbox.loopSlides && Lightbox.activeImage == (Lightbox.total - 1)) {
1605        Lightbox.end();
1606      }
1607      else if (Lightbox.total > 1) {
1608        Lightbox.changeData(Lightbox.activeImage + 1);
1609      }
1610    }
1611    else {
1612      Lightbox.isPaused = true;
1613    }
1614  },
1615
1616  triggerLightbox: function (rel_type, rel_group) {
1617    if (rel_type.length) {
1618      if (rel_group && rel_group.length) {
1619        $("a[rel^='" + rel_type +"\[" + rel_group + "\]'], area[rel^='" + rel_type +"\[" + rel_group + "\]']").eq(0).trigger("click");
1620      }
1621      else {
1622        $("a[rel^='" + rel_type +"'], area[rel^='" + rel_type +"']").eq(0).trigger("click");
1623      }
1624    }
1625  },
1626
1627  detectMacFF2: function() {
1628    var ua = navigator.userAgent.toLowerCase();
1629    if (/firefox[\/\s](\d+\.\d+)/.test(ua)) {
1630      var ffversion = new Number(RegExp.$1);
1631      if (ffversion < 3 && ua.indexOf('mac') != -1) {
1632        return true;
1633      }
1634    }
1635    return false;
1636  },
1637
1638  checkKey: function(keys, key, code) {
1639    return (jQuery.inArray(key, keys) != -1 || jQuery.inArray(String(code), keys) != -1);
1640  },
1641
1642  filterXSS: function(str, allowed_tags) {
1643    var output = "";
1644    var prefix = Drupal.settings.pathPrefix;
1645    if (!prefix) prefix = '';
1646    $.ajax({
1647      url: Drupal.settings.basePath + prefix + '?q=system/lightbox2/filter-xss',
1648      data: {
1649        'string' : str,
1650        'allowed_tags' : allowed_tags
1651      },
1652      type: "POST",
1653      async: false,
1654      dataType:  "json",
1655      success: function(data) {
1656        output = data;
1657      }
1658    });
1659    return output;
1660  }
1661
1662};
1663
1664// Initialize the lightbox.
1665Drupal.behaviors.initLightbox = {
1666  attach: function(context) {
1667
1668  $('body:not(.lightbox-processed)', context).addClass('lightbox-processed').each(function() {
1669    Lightbox.initialize();
1670    return false; // Break the each loop.
1671  });
1672
1673  // Attach lightbox to any links with lightbox rels.
1674  Lightbox.initList(context);
1675  $('#lightboxAutoModal', context).triggerHandler('click');
1676  }
1677};
1678})(jQuery);
1679;
1680/**
1681 * @file
1682 * Adds some show/hide to the admin form to make the UXP easier.
1683 */
1684(function($){
1685  Drupal.behaviors.video = {
1686    attach: function (context, settings) {
1687      //lets see if we have any jmedia movies
1688      if($.fn.media) {
1689        $('.jmedia').media();
1690      }
1691	
1692      if(settings.video) {
1693        $.fn.media.defaults.flvPlayer = settings.video.flvplayer;
1694      }
1695	
1696      //lets setup our colorbox videos
1697      $('.video-box').each(function() {
1698        var url = $(this).attr('href');
1699        var data = $(this).metadata();
1700        var width = data.width;
1701        var height= data.height;
1702        var player = settings.video.player; //player can be either jwplayer or flowplayer.
1703        $(this).colorbox({
1704          html: '<a id="video-overlay" href="'+url+'" style="height:'+height+'; width:'+width+'; display: block;"></a>',
1705          onComplete:function() {
1706            if(player == 'flowplayer') {
1707              flowplayer("video-overlay", settings.video.flvplayer, {
1708                clip: {
1709                  autoPlay: settings.video.autoplay,
1710                  autoBuffering: settings.video.autobuffer
1711                }
1712              });
1713            } else {
1714              $('#video-overlay').media({
1715                flashvars: {
1716                  autostart: settings.video.autoplay
1717                },
1718                width:width,
1719                height:height
1720              });
1721            }
1722          }
1723        });
1724      });
1725    }
1726  };
1727
1728  // On change of the thumbnails when edit.
1729  Drupal.behaviors.videoEdit = {
1730    attach : function(context, settings) {
1731      function setThumbnail(widget, type) {
1732        var thumbnails = widget.find('.video-thumbnails input');
1733        var defaultthumbnail = widget.find('.video-use-default-video-thumb');
1734        var largeimage = widget.find('.video-preview img');
1735
1736        var activeThumbnail = thumbnails.filter(':checked');
1737        if (activeThumbnail.length > 0 && type != 'default') {
1738          var smallimage = activeThumbnail.next('label.option').find('img');
1739          largeimage.attr('src', smallimage.attr('src'));
1740          defaultthumbnail.attr('checked', false);
1741        }
1742        else if(defaultthumbnail.is(':checked')) {
1743          thumbnails.attr('checked', false);
1744          largeimage.attr('src', defaultthumbnail.data('defaultimage'));
1745        }
1746        else {
1747          // try to select the first thumbnail.
1748          if (thumbnails.length > 0) {
1749            thumbnails.first().attr('checked', 'checked');
1750            setThumbnail(widget, 'thumb');
1751          }
1752        }
1753      }
1754
1755      $('.video-thumbnails input', context).change(function() {
1756        setThumbnail($(this).parents('.video-widget'), 'thumb');
1757      });
1758
1759      $('.video-use-default-video-thumb', context).change(function() {
1760        setThumbnail($(this).parents('.video-widget'), 'default');
1761      });
1762
1763      $('.video-widget', context).each(function() {
1764        setThumbnail($(this), 'both');
1765      });
1766    }
1767  }
1768})(jQuery);
1769;
1770Drupal.TBMegaMenu = Drupal.TBMegaMenu || {};
1771
1772(function ($) {
1773  Drupal.TBMegaMenu.oldWindowWidth = 0;
1774  Drupal.TBMegaMenu.displayedMenuMobile = false;
1775  Drupal.TBMegaMenu.supportedScreens = [980];
1776  Drupal.TBMegaMenu.menuResponsive = function () {
1777    var windowWidth = window.innerWidth ? window.innerWidth : $(window).width();
1778    var navCollapse = $('.tb-megamenu').children('.nav-collapse');
1779    if (windowWidth < Drupal.TBMegaMenu.supportedScreens[0]) {
1780      navCollapse.addClass('collapse');
1781      if (Drupal.TBMegaMenu.displayedMenuMobile) {
1782        navCollapse.css({height: 'auto', overflow: 'visible'});
1783      } else {
1784        navCollapse.css({height: 0, overflow: 'hidden'});
1785      }
1786    } else {
1787      // If width of window is greater than 980 (supported screen).
1788      navCollapse.removeClass('collapse');
1789      if (navCollapse.height() <= 0) {
1790        navCollapse.css({height: 'auto', overflow: 'visible'});
1791      }
1792    }
1793  };
1794  
1795  Drupal.behaviors.tbMegaMenuAction = {
1796    attach: function(context) {
1797      $('.tb-megamenu-button', context).once('menuIstance', function () {
1798        var This = this;
1799        $(This).click(function() {
1800          if(parseInt($(this).parent().children('.nav-collapse').height())) {
1801            $(this).parent().children('.nav-collapse').css({height: 0, overflow: 'hidden'});
1802            Drupal.TBMegaMenu.displayedMenuMobile = false;
1803          }
1804          else {
1805            $(this).parent().children('.nav-collapse').css({height: 'auto', overflow: 'visible'});
1806            Drupal.TBMegaMenu.displayedMenuMobile = true;
1807          }
1808        });
1809      });
1810      
1811      
1812      var isTouch = 'ontouchstart' in window && !(/hp-tablet/gi).test(navigator.appVersion);
1813      if(!isTouch){
1814        $(document).ready(function($){
1815          var mm_duration = 0;
1816          $('.tb-megamenu').each (function(){
1817            if ($(this).data('duration')) {
1818              mm_duration = $(this).data('duration');
1819            }
1820          });
1821          var mm_timeout = mm_duration ? 100 + mm_duration : 500;
1822          $('.nav > li, li.mega').hover(function(event) {
1823            var $this = $(this);
1824            if ($this.hasClass ('mega')) {
1825              $this.addClass ('animating');
1826              clearTimeout ($this.data('animatingTimeout'));
1827              $this.data('animatingTimeout', setTimeout(function(){$this.removeClass ('animating')}, mm_timeout));
1828              clearTimeout ($this.data('hoverTimeout'));
1829              $this.data('hoverTimeout', setTimeout(function(){$this.addClass ('open')}, 100));  
1830            } else {
1831              clearTimeout ($this.data('hoverTimeout'));
1832              $this.data('hoverTimeout', 
1833              setTimeout(function(){$this.addClass ('open')}, 100));
1834            }
1835          },
1836          function(event) {
1837            var $this = $(this);
1838            if ($this.hasClass ('mega')) {
1839              $this.addClass ('animating');
1840              clearTimeout ($this.data('animatingTimeout'));
1841              $this.data('animatingTimeout', 
1842              setTimeout(function(){$this.removeClass ('animating')}, mm_timeout));
1843              clearTimeout ($this.data('hoverTimeout'));
1844              $this.data('hoverTimeout', setTimeout(function(){$this.removeClass ('open')}, 100));
1845            } else {
1846              clearTimeout ($this.data('hoverTimeout'));
1847              $this.data('hoverTimeout', 
1848              setTimeout(function(){$this.removeClass ('open')}, 100));
1849            }
1850          });
1851        });
1852      }
1853      
1854      $(window).resize(function() {
1855        var windowWidth = window.innerWidth ? window.innerWidth : $(window).width();
1856        if(windowWidth != Drupal.TBMegaMenu.oldWindowWidth){
1857          Drupal.TBMegaMenu.oldWindowWidth = windowWidth;
1858          Drupal.TBMegaMenu.menuResponsive();
1859        }
1860      });
1861    },
1862  }
1863})(jQuery);
1864
1865;
1866Drupal.TBMegaMenu = Drupal.TBMegaMenu || {};
1867
1868(function ($) {
1869  Drupal.TBMegaMenu.createTouchMenu = function(items) {
1870      items.children('a').each( function() {
1871	var $item = $(this);
1872        var tbitem = $(this).parent();
1873        $item.click( function(event){
1874          if ($item.hasClass('tb-megamenu-clicked')) {
1875            var $uri = $item.attr('href');
1876            window.location.href = $uri;
1877          }
1878          else {
1879            event.preventDefault();
1880            $item.addClass('tb-megamenu-clicked');
1881            if(!tbitem.hasClass('open')){	
1882              tbitem.addClass('open');
1883            }
1884          }
1885        }).closest('li').mouseleave( function(){
1886          $item.removeClass('tb-megamenu-clicked');
1887          tbitem.removeClass('open');
1888        });
1889     });
1890     /*
1891     items.children('a').children('span.caret').each( function() {
1892	var $item = $(this).parent();
1893        $item.click(function(event){
1894          tbitem = $item.parent();
1895          if ($item.hasClass('tb-megamenu-clicked')) {
1896            Drupal.TBMegaMenu.eventStopPropagation(event);
1897            if(tbitem.hasClass('open')){	
1898              tbitem.removeClass('open');
1899              $item.removeClass('tb-megamenu-clicked');
1900            }
1901          }
1902          else {
1903            Drupal.TBMegaMenu.eventStopPropagation(event);
1904            $item.addClass('tb-megamenu-clicked');
1905            if(!tbitem.hasClass('open')){	
1906              tbitem.addClass('open');
1907              $item.removeClass('tb-megamenu-clicked');
1908            }
1909          }
1910        });
1911     });
1912     */
1913  }
1914  
1915  Drupal.TBMegaMenu.eventStopPropagation = function(event) {
1916    if (event.stopPropagation) {
1917      event.stopPropagation();
1918    }
1919    else if (window.event) {
1920      window.event.cancelBubble = true;
1921    }
1922  }  
1923  Drupal.behaviors.tbMegaMenuTouchAction = {
1924    attach: function(context) {
1925      var isTouch = 'ontouchstart' in window && !(/hp-tablet/gi).test(navigator.appVersion);
1926      if(isTouch){
1927        $('html').addClass('touch');
1928        Drupal.TBMegaMenu.createTouchMenu($('.tb-megamenu ul.nav li.mega').has('.dropdown-menu'));
1929      }
1930    }
1931  }
1932})(jQuery);
1933;
1934/**
1935 * @file
1936 * Some basic behaviors and utility functions for Views.
1937 */
1938(function ($) {
1939
1940  Drupal.Views = {};
1941
1942  /**
1943   * JQuery UI tabs, Views integration component.
1944   */
1945  Drupal.behaviors.viewsTabs = {
1946    attach: function (context) {
1947      if ($.viewsUi && $.viewsUi.tabs) {
1948        $('#views-tabset').once('views-processed').viewsTabs({
1949          selectedClass: 'active'
1950        });
1951      }
1952
1953      $('a.views-remove-link').once('views-processed').click(function(event) {
1954        var id = $(this).attr('id').replace('views-remove-link-', '');
1955        $('#views-row-' + id).hide();
1956        $('#views-removed-' + id).attr('checked', true);
1957        event.preventDefault();
1958      });
1959      /**
1960    * Here is to handle display deletion
1961    * (checking in the hidden checkbox and hiding out the row).
1962    */
1963      $('a.display-remove-link')
1964        .addClass('display-processed')
1965        .click(function() {
1966          var id = $(this).attr('id').replace('display-remove-link-', '');
1967          $('#display-row-' + id).hide();
1968          $('#display-removed-' + id).attr('checked', true);
1969          return false;
1970        });
1971    }
1972  };
1973
1974  /**
1975 * Helper function to parse a querystring.
1976 */
1977  Drupal.Views.parseQueryString = function (query) {
1978    var args = {};
1979    var pos = query.indexOf('?');
1980    if (pos != -1) {
1981      query = query.substring(pos + 1);
1982    }
1983    var pairs = query.split('&');
1984    for (var i in pairs) {
1985      if (typeof(pairs[i]) == 'string') {
1986        var pair = pairs[i].split('=');
1987        // Ignore the 'q' path argument, if present.
1988        if (pair[0] != 'q' && pair[1]) {
1989          args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
1990        }
1991      }
1992    }
1993    return args;
1994  };
1995
1996  /**
1997 * Helper function to return a view's arguments based on a path.
1998 */
1999  Drupal.Views.parseViewArgs = function (href, viewPath) {
2000
2001    // Provide language prefix.
2002    if (Drupal.settings.pathPrefix) {
2003      var viewPath = Drupal.settings.pathPrefix + viewPath;
2004    }
2005    var returnObj = {};
2006    var path = Drupal.Views.getPath(href);
2007    // Ensure we have a correct path.
2008    if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
2009      var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
2010      returnObj.view_args = args;
2011      returnObj.view_path = path;
2012    }
2013    return returnObj;
2014  };
2015
2016  /**
2017 * Strip off the protocol plus domain from an href.
2018 */
2019  Drupal.Views.pathPortion = function (href) {
2020    // Remove e.g. http://example.com if present.
2021    var protocol = window.location.protocol;
2022    if (href.substring(0, protocol.length) == protocol) {
2023      // 2 is the length of the '//' that normally follows the protocol.
2024      href = href.substring(href.indexOf('/', protocol.length + 2));
2025    }
2026    return href;
2027  };
2028
2029  /**
2030 * Return the Drupal path portion of an href.
2031 */
2032  Drupal.Views.getPath = function (href) {
2033    href = Drupal.Views.pathPortion(href);
2034    href = href.substring(Drupal.settings.basePath.length, href.length);
2035    // 3 is the length of the '?q=' added to the url without clean urls.
2036    if (href.substring(0, 3) == '?q=') {
2037      href = href.substring(3, href.length);
2038    }
2039    var chars = ['#', '?', '&'];
2040    for (var i in chars) {
2041      if (href.indexOf(chars[i]) > -1) {
2042        href = href.substr(0, href.indexOf(chars[i]));
2043      }
2044    }
2045    return href;
2046  };
2047
2048})(jQuery);
2049;
2050(function ($) {
2051
2052/**
2053 * A progressbar object. Initialized with the given id. Must be inserted into
2054 * the DOM afterwards through progressBar.element.
2055 *
2056 * method is the function which will perform the HTTP request to get the
2057 * progress bar state. Either "GET" or "POST".
2058 *
2059 * e.g. pb = new progressBar('myProgressBar');
2060 *      some_element.appendChild(pb.element);
2061 */
2062Drupal.progressBar = function (id, updateCallback, method, errorCallback) {
2063  var pb = this;
2064  this.id = id;
2065  this.method = method || 'GET';
2066  this.updateCallback = updateCallback;
2067  this.errorCallback = errorCallback;
2068
2069  // The WAI-ARIA setting aria-live="polite" will announce changes after users
2070  // have completed their current activity and not interrupt the screen reader.
2071  this.element = $('<div class="progress" aria-live="polite"></div>').attr('id', id);
2072  this.element.html('<div class="bar"><div class="filled"></div></div>' +
2073                    '<div class="percentage"></div>' +
2074                    '<div class="message">&nbsp;</div>');
2075};
2076
2077/**
2078 * Set the percentage and status message for the progressbar.
2079 */
2080Drupal.progressBar.prototype.setProgress = function (percentage, message) {
2081  if (percentage >= 0 && percentage <= 100) {
2082    $('div.filled', this.element).css('width', percentage + '%');
2083    $('div.percentage', this.element).html(percentage + '%');
2084  }
2085  $('div.message', this.element).html(message);
2086  if (this.updateCallback) {
2087    this.updateCallback(percentage, message, this);
2088  }
2089};
2090
2091/**
2092 * Start monitoring progress via Ajax.
2093 */
2094Drupal.progressBar.prototype.startMonitoring = function (uri, delay) {
2095  this.delay = delay;
2096  this.uri = uri;
2097  this.sendPing();
2098};
2099
2100/**
2101 * Stop monitoring progress via Ajax.
2102 */
2103Drupal.progressBar.prototype.stopMonitoring = function () {
2104  clearTimeout(this.timer);
2105  // This allows monitoring to be stopped from within the callback.
2106  this.uri = null;
2107};
2108
2109/**
2110 * Request progress data from server.
2111 */
2112Drupal.progressBar.prototype.sendPing = function () {
2113  if (this.timer) {
2114    clearTimeout(this.timer);
2115  }
2116  if (this.uri) {
2117    var pb = this;
2118    // When doing a post request, you need non-null data. Otherwise a
2119    // HTTP 411 or HTTP 406 (with Apache mod_security) error may result.
2120    $.ajax({
2121      type: this.method,
2122      url: this.uri,
2123      data: '',
2124      dataType: 'json',
2125      success: function (progress) {
2126        // Display errors.
2127        if (progress.status == 0) {
2128          pb.displayError(progress.data);
2129          return;
2130        }
2131        // Update display.
2132        pb.setProgress(progress.percentage, progress.message);
2133        // Schedule next timer.
2134        pb.timer = setTimeout(function () { pb.sendPing(); }, pb.delay);
2135      },
2136      error: function (xmlhttp) {
2137        pb.displayError(Drupal.ajaxError(xmlhttp, pb.uri));
2138      }
2139    });
2140  }
2141};
2142
2143/**
2144 * Display errors on the page.
2145 */
2146Drupal.progressBar.prototype.displayError = function (string) {
2147  var error = $('<div class="messages error"></div>').html(string);
2148  $(this.element).before(error).hide();
2149
2150  if (this.errorCallback) {
2151    this.errorCallback(this);
2152  }
2153};
2154
2155})(jQuery);
2156;
2157(function ($) {
2158
2159/**
2160 * Attaches sticky table headers.
2161 */
2162Drupal.behaviors.tableHeader = {
2163  attach: function (context, settings) {
2164    if (!$.support.positionFixed) {
2165      return;
2166    }
2167
2168    $('table.sticky-enabled', context).once('tableheader', function () {
2169      $(this).data("drupal-tableheader", new Drupal.tableHeader(this));
2170    });
2171  }
2172};
2173
2174/**
2175 * Constructor for the tableHeader object. Provides sticky table headers.
2176 *
2177 * @param table
2178 *   DOM object for the table to add a sticky header to.
2179 */
2180Drupal.tableHeader = function (table) {
2181  var self = this;
2182
2183  this.originalTable = $(table);
2184  this.originalHeader = $(table).children('thead');
2185  this.originalHeaderCells = this.originalHeader.find('> tr > th');
2186  this.displayWeight = null;
2187
2188  // React to columns change to avoid making checks in the scroll callback.
2189  this.originalTable.bind('columnschange', function (e, display) {
2190    // This will force header size to be calculated on scroll.
2191    self.widthCalculated = (self.displayWeight !== null && self.displayWeight === display);
2192    self.displayWeight = display;
2193  });
2194
2195  // Clone the table header so it inherits original jQuery properties. Hide
2196  // the table to avoid a flash of the header clone upon page load.
2197  this.stickyTable = $('<table class="sticky-header"/>')
2198    .insertBefore(this.originalTable)
2199    .css({ position: 'fixed', top: '0px' });
2200  this.stickyHeader = this.originalHeader.clone(true)
2201    .hide()
2202    .appendTo(this.stickyTable);
2203  this.stickyHeaderCells = this.stickyHeader.find('> tr > th');
2204
2205  this.originalTable.addClass('sticky-table');
2206  $(window)
2207    .bind('scroll.drupal-tableheader', $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
2208    .bind('resize.drupal-tableheader', { calculateWidth: true }, $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
2209    // Make sure the anchor being scrolled into view is not hidden beneath the
2210    // sticky table header. Adjust the scrollTop if it does.
2211    .bind('drupalDisplaceAnchor.drupal-tableheader', function () {
2212      window.scrollBy(0, -self.stickyTable.outerHeight());
2213    })
2214    // Make sure the element being focused is not hidden beneath the sticky
2215    // table header. Adjust the scrollTop if it does.
2216    .bind('drupalDisplaceFocus.drupal-tableheader', function (event) {
2217      if (self.stickyVisible && event.clientY < (self.stickyOffsetTop + self.stickyTable.outerHeight()) && event.$target.closest('sticky-header').length === 0) {
2218        window.scrollBy(0, -self.stickyTable.outerHeight());
2219      }
2220    })
2221    .triggerHandler('resize.drupal-tableheader');
2222
2223  // We hid the header to avoid it showing up erroneously on page load;
2224  // we need to unhide it now so that it will show up when expected.
2225  this.stickyHeader.show();
2226};
2227
2228/**
2229 * Event handler: recalculates position of the sticky table header.
2230 *
2231 * @param event
2232 *   Event being triggered.
2233 */
2234Drupal.tableHeader.prototype.eventhandlerRecalculateStickyHeader = function (event) {
2235  var self = this;
2236  var calculateWidth = event.data && event.data.calculateWidth;
2237
2238  // Reset top position of sticky table headers to the current top offset.
2239  this.stickyOffsetTop = Drupal.settings.tableHeaderOffset ? eval(Drupal.settings.tableHeaderOffset + '()') : 0;
2240  this.stickyTable.css('top', this.stickyOffsetTop + 'px');
2241
2242  // Save positioning data.
2243  var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
2244  if (calculateWidth || this.viewHeight !== viewHeight) {
2245    this.viewHeight = viewHeight;
2246    this.vPosition = this.originalTable.offset().top - 4 - this.stickyOffsetTop;
2247    this.hPosition = this.originalTable.offset().left;
2248    this.vLength = this.originalTable[0].clientHeight - 100;
2249    calculateWidth = true;
2250  }
2251
2252  // Track horizontal positioning relative to the viewport and set visibility.
2253  var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
2254  var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition;
2255  this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
2256  this.stickyTable.css({ left: (-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });
2257
2258  // Only perform expensive calculations if the sticky header is actually
2259  // visible or when forced.
2260  if (this.stickyVisible && (calculateWidth || !this.widthCalculated)) {
2261    this.widthCalculated = true;
2262    var $that = null;
2263    var $stickyCell = null;
2264    var display = null;
2265    var cellWidth = null;
2266    // Resize header and its cell widths.
2267    // Only apply width to visible table cells. This prevents the header from
2268    // displaying incorrectly when the sticky header is no longer visible.
2269    for (var i = 0, il = this.originalHeaderCells.length; i < il; i += 1) {
2270      $that = $(this.originalHeaderCells[i]);
2271      $stickyCell = this.stickyHeaderCells.eq($that.index());
2272      display = $that.css('display');
2273      if (display !== 'none') {
2274        cellWidth = $that.css('width');
2275        // Exception for IE7.
2276        if (cellWidth === 'auto') {
2277          cellWidth = $that[0].clientWidth + 'px';
2278        }
2279        $stickyCell.css({'width': cellWidth, 'display': display});
2280      }
2281      else {
2282        $stickyCell.css('display', 'none');
2283      }
2284    }
2285    this.stickyTable.css('width', this.originalTable.outerWidth());
2286  }
2287};
2288
2289})(jQuery);
2290;
2291(function ($) {
2292
2293Drupal.googleanalytics = {};
2294
2295$(document).ready(function() {
2296
2297  // Attach mousedown, keyup, touchstart events to document only and catch
2298  // clicks on all elements.
2299  $(document.body).bind("mousedown keyup touchstart", function(event) {
2300
2301    // Catch the closest surrounding link of a clicked element.
2302    $(event.target).closest("a,area").each(function() {
2303
2304      // Is the clicked URL internal?
2305      if (Drupal.googleanalytics.isInternal(this.href)) {
2306        // Skip 'click' tracking, if custom tracking events are bound.
2307        if ($(this).is('.colorbox') && (Drupal.settings.googleanalytics.trackColorbox)) {
2308          // Do nothing here. The custom event will handle all tracking.
2309          //console.info("Click on .colorbox item has been detected.");
2310        }
2311        // Is download tracking activated and the file extension configured for download tracking?
2312        else if (Drupal.settings.googleanalytics.trackDownload && Drupal.googleanalytics.isDownload(this.href)) {
2313          // Download link clicked.
2314          ga("send", {
2315            "hitType": "event",
2316            "eventCategory": "Downloads",
2317            "eventAction": Drupal.googleanalytics.getDownloadExtension(this.href).toUpperCase(),
2318            "eventLabel": Drupal.googleanalytics.getPageUrl(this.href),
2319            "transport": "beacon"
2320          });
2321        }
2322        else if (Drupal.googleanalytics.isInternalSpecial(this.href)) {
2323          // Keep the internal URL for Google Analytics website overlay intact.
2324          ga("send", {
2325            "hitType": "pageview",
2326            "page": Drupal.googleanalytics.getPageUrl(this.href),
2327            "transport": "beacon"
2328          });
2329        }
2330      }
2331      else {
2332        if (Drupal.settings.googleanalytics.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
2333          // Mailto link clicked.
2334          ga("send", {
2335            "hitType": "event",
2336            "eventCategory": "Mails",
2337            "eventAction": "Click",
2338            "eventLabel": this.href.substring(7),
2339            "transport": "beacon"
2340          });
2341        }
2342        else if (Drupal.settings.googleanalytics.trackOutbound && this.href.match(/^\w+:\/\//i)) {
2343          if (Drupal.settings.googleanalytics.trackDomainMode !== 2 || (Drupal.settings.googleanalytics.trackDomainMode === 2 && !Drupal.googleanalytics.isCrossDomain(this.hostname, Drupal.settings.googleanalytics.trackCrossDomains))) {
2344            // External link clicked / No top-level cross domain clicked.
2345            ga("send", {
2346              "hitType": "event",
2347              "eventCategory": "Outbound links",
2348              "eventAction": "Click",
2349              "eventLabel": this.href,
2350              "transport": "beacon"
2351            });
2352          }
2353        }
2354      }
2355    });
2356  });
2357
2358  // Track hash changes as unique pageviews, if this option has been enabled.
2359  if (Drupal.settings.googleanalytics.trackUrlFragments) {
2360    window.onhashchange = function() {
2361      ga("send", {
2362        "hitType": "pageview",
2363        "page": location.pathname + location.search + location.hash
2364      });
2365    };
2366  }
2367
2368  // Colorbox: This event triggers when the transition has completed and the
2369  // newly loaded content has been revealed.
2370  if (Drupal.settings.googleanalytics.trackColorbox) {
2371    $(document).bind("cbox_complete", function () {
2372      var href = $.colorbox.element().attr("href");
2373      if (href) {
2374        ga("send", {
2375          "hitType": "pageview",
2376          "page": Drupal.googleanalytics.getPageUrl(href)
2377        });
2378      }
2379    });
2380  }
2381
2382});
2383
2384/**
2385 * Check whether the hostname is part of the cross domains or not.
2386 *
2387 * @param string hostname
2388 *   The hostname of the clicked URL.
2389 * @param array crossDomains
2390 *   All cross domain hostnames as JS array.
2391 *
2392 * @return boolean
2393 */
2394Drupal.googleanalytics.isCrossDomain = function (hostname, crossDomains) {
2395  /**
2396   * jQuery < 1.6.3 bug: $.inArray crushes IE6 and Chrome if second argument is
2397   * `null` or `undefined`, https://bugs.jquery.com/ticket/10076,
2398   * https://github.com/jquery/jquery/commit/a839af034db2bd934e4d4fa6758a3fed8de74174
2399   *
2400   * @todo: Remove/Refactor in D8
2401   */
2402  if (!crossDomains) {
2403    return false;
2404  }
2405  else {
2406    return $.inArray(hostname, crossDomains) > -1 ? true : false;
2407  }
2408};
2409
2410/**
2411 * Check whether this is a download URL or not.
2412 *
2413 * @param string url
2414 *   The web url to check.
2415 *
2416 * @return boolean
2417 */
2418Drupal.googleanalytics.isDownload = function (url) {
2419  var isDownload = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i");
2420  return isDownload.test(url);
2421};
2422
2423/**
2424 * Check whether this is an absolute internal URL or not.
2425 *
2426 * @param string url
2427 *   The web url to check.
2428 *
2429 * @return boolean
2430 */
2431Drupal.googleanalytics.isInternal = function (url) {
2432  var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
2433  return isInternal.test(url);
2434};
2435
2436/**
2437 * Check whether this is a special URL or not.
2438 *
2439 * URL types:
2440 *  - gotwo.module /go/* links.
2441 *
2442 * @param string url
2443 *   The web url to check.
2444 *
2445 * @return boolean
2446 */
2447Drupal.googleanalytics.isInternalSpecial = function (url) {
2448  var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
2449  return isInternalSpecial.test(url);
2450};
2451
2452/**
2453 * Extract the relative internal URL from an absolute internal URL.
2454 *
2455 * Examples:
2456 * - https://mydomain.com/node/1 -> /node/1
2457 * - https://example.com/foo/bar -> https://example.com/foo/bar
2458 *
2459 * @param string url
2460 *   The web url to check.
2461 *
2462 * @return string
2463 *   Internal website URL
2464 */
2465Drupal.googleanalytics.getPageUrl = function (url) {
2466  var extractInternalUrl = new RegExp("^(https?):\/\/" + window.location.host, "i");
2467  return url.replace(extractInternalUrl, '');
2468};
2469
2470/**
2471 * Extract the download file extension from the URL.
2472 *
2473 * @param string url
2474 *   The web url to check.
2475 *
2476 * @return string
2477 *   The file extension of the passed url. e.g. "zip", "txt"
2478 */
2479Drupal.googleanalytics.getDownloadExtension = function (url) {
2480  var extractDownloadextension = new RegExp("\\.(" + Drupal.settings.googleanalytics.trackDownloadExtensions + ")([\?#].*)?$", "i");
2481  var extension = extractDownloadextension.exec(url);
2482  return (extension === null) ? '' : extension[1];
2483};
2484
2485})(jQuery);
2486;
2487/**
2488 * @file
2489 * Handles AJAX fetching of views, including filter submission and response.
2490 */
2491(function ($) {
2492
2493  /**
2494   * Attaches the AJAX behavior to exposed filter forms and key views links.
2495   */
2496  Drupal.behaviors.ViewsAjaxView = {};
2497  Drupal.behaviors.ViewsAjaxView.attach = function() {
2498    if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
2499      $.each(Drupal.settings.views.ajaxViews, function(i, settings) {
2500        Drupal.views.instances[i] = new Drupal.views.ajaxView(settings);
2501      });
2502    }
2503  };
2504
2505  Drupal.views = {};
2506  Drupal.views.instances = {};
2507
2508  /**
2509   * JavaScript object for a certain view.
2510   */
2511  Drupal.views.ajaxView = function(settings) {
2512    var selector = '.view-dom-id-' + settings.view_dom_id;
2513    this.$view = $(selector);
2514
2515    // Retrieve the path to use for views' ajax.
2516    var ajax_path = Drupal.settings.views.ajax_path;
2517
2518    // If there are multiple views this might've ended up showing up multiple
2519    // times.
2520    if (ajax_path.constructor.toString().indexOf("Array") != -1) {
2521      ajax_path = ajax_path[0];
2522    }
2523
2524    // Check if there are any GET parameters to send to views.
2525    var queryString = window.location.search || '';
2526    if (queryString !== '') {
2527      // Remove the question mark and Drupal path component if any.
2528      var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, '');
2529      if (queryString !== '') {
2530        // If there is a '?' in ajax_path, clean url are on and & should be
2531        // used to add parameters.
2532        queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString;
2533      }
2534    }
2535
2536    this.element_settings = {
2537      url: ajax_path + queryString,
2538      submit: settings,
2539      setClick: true,
2540      event: 'click',
2541      selector: selector,
2542      progress: {
2543        type: 'throbber'
2544      }
2545    };
2546
2547    this.settings = settings;
2548
2549    // Add the ajax to exposed forms.
2550    this.$exposed_form = $('#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'));
2551    this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));
2552
2553    // Store Drupal.ajax objects here for all pager links.
2554    this.links = [];
2555
2556    // Add the ajax to pagers.
2557    this.$view
2558      .once(jQuery.proxy(this.attachPagerAjax, this));
2559
2560    // Add a trigger to update this view specifically. In order to trigger a
2561    // refresh use the following code.
2562    //
2563    // @code
2564    // jQuery('.view-name').trigger('RefreshView');
2565    // @endcode
2566    // Add a trigger to update this view specifically.
2567    var self_settings = this.element_settings;
2568    self_settings.event = 'RefreshView';
2569    var self = this;
2570    this.$view.once('refresh', function () {
2571      self.refreshViewAjax = new Drupal.ajax(self.selector, self.$view, self_settings);
2572    });
2573  };
2574
2575  Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {
2576    var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);
2577    button = button[0];
2578
2579    // Call the autocomplete submit before doing AJAX.
2580    $(button).click(function () {
2581      if (Drupal.autocompleteSubmit) {
2582        Drupal.autocompleteSubmit();
2583      }
2584    });
2585
2586    this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings);
2587  };
2588
2589  /**
2590   * Attach the ajax behavior to each link.
2591   */
2592  Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
2593    this.$view.find('ul.pager > li > a, ol.pager > li > a, th.views-field a, .attachment .views-summary a')
2594      .each(jQuery.proxy(this.attachPagerLinkAjax, this));
2595  };
2596
2597  /**
2598   * Attach the ajax behavior to a single link.
2599   */
2600  Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
2601    var $link = $(link);
2602    var viewData = {};
2603    var href = $link.attr('href');
2604    // Don't attach to pagers inside nested views.
2605    if ($link.closest('.view')[0] !== this.$view[0] &&
2606      $link.closest('.view').parent().hasClass('attachment') === false) {
2607      return;
2608    }
2609
2610    // Provide a default page if none has been set. This must be done
2611    // prior to merging with settings to avoid accidentally using the
2612    // page landed on instead of page 1.
2613    if (typeof(viewData.page) === 'undefined') {
2614      viewData.page = 0;
2615    }
2616
2617    // Construct an object using the settings defaults and then overriding
2618    // with data specific to the link.
2619    $.extend(
2620      viewData,
2621      this.settings,
2622      Drupal.Views.parseQueryString(href),
2623      // Extract argument data from the URL.
2624      Drupal.Views.parseViewArgs(href, this.settings.view_base_path)
2625    );
2626
2627    // For anchor tags, these will go to the target of the anchor rather
2628    // than the usual location.
2629    $.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path));
2630
2631    this.element_settings.submit = viewData;
2632    this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);
2633    this.links.push(this.pagerAjax);
2634  };
2635
2636  Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {
2637    // Scroll to the top of the view. This will allow users
2638    // to browse newly loaded content after e.g. clicking a pager
2639    // link.
2640    var offset = $(response.selector).offset();
2641    // We can't guarantee that the scrollable object should be
2642    // the body, as the view could be embedded in something
2643    // more complex such as a modal popup. Recurse up the DOM
2644    // and scroll the first element that has a non-zero top.
2645    var scrollTarget = response.selector;
2646    while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {
2647      scrollTarget = $(scrollTarget).parent();
2648    }
2649    // Only scroll upward.
2650    if (offset.top - 10 < $(scrollTarget).scrollTop()) {
2651      $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
2652    }
2653  };
2654
2655})(jQuery);
2656;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.