app/jquery/jquery-thickbox.js
author Lennard de Rijk <ljvderijk@gmail.com>
Thu, 13 Aug 2009 11:52:43 -0700
changeset 2769 279d26439495
parent 1327 f6f70eb8d8bf
permissions -rw-r--r--
Added export for Org Admins and Mentors, but only one per User.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1212
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
/*
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
 * Thickbox 3.1 - One Box To Rule Them All.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
 * By Cody Lindley (http://www.codylindley.com)
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
 * Copyright (c) 2007 cody lindley
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
*/
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
1327
f6f70eb8d8bf Now using the correct path to the loading animation in jquery-thickbox.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1212
diff changeset
     8
var tb_pathToImage = "/soc/content/images/loadingAnimation.gif";
1212
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
//on page load call tb_init
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
$(document).ready(function(){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
	imgLoader = new Image();// preload image
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
	imgLoader.src = tb_pathToImage;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
//add thickbox to href & area elements that have a class of .thickbox
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
function tb_init(domChunk){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
	$(domChunk).click(function(){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
	var t = this.title || this.name || null;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
	var a = this.href || this.alt;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
	var g = this.rel || false;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
	tb_show(t,a,g);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
	this.blur();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
	return false;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
	});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
	try {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
			$("body","html").css({height: "100%", width: "100%"});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
			$("html").css("overflow","hidden");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
				$("#TB_overlay").click(tb_remove);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
			}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
		}else{//all others
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
			if(document.getElementById("TB_overlay") === null){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
				$("#TB_overlay").click(tb_remove);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
			}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
		}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
		if(tb_detectMacXFF()){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
		}else{
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
		}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
		if(caption===null){caption="";}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
		$('#TB_load').show();//show loader
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
		var baseURL;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
			baseURL = url.substr(0, url.indexOf("?"));
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
	   }else{
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
			baseURL = url;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
	   }
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
	   var urlType = baseURL.toLowerCase().match(urlString);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
			TB_PrevCaption = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
			TB_PrevURL = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
			TB_PrevHTML = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
			TB_NextCaption = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
			TB_NextURL = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
			TB_NextHTML = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
			TB_imageCount = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
			TB_FoundURL = false;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
			if(imageGroup){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
				TB_TempArray = $("a[@rel="+imageGroup+"]").get();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    81
					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
						if (!(TB_TempArray[TB_Counter].href == url)) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    83
							if (TB_FoundURL) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    84
								TB_NextCaption = TB_TempArray[TB_Counter].title;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    85
								TB_NextURL = TB_TempArray[TB_Counter].href;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    86
								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
							} else {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    88
								TB_PrevCaption = TB_TempArray[TB_Counter].title;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    89
								TB_PrevURL = TB_TempArray[TB_Counter].href;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    91
							}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    92
						} else {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    93
							TB_FoundURL = true;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    94
							TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    95
						}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    96
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    97
			}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    98
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    99
			imgPreloader = new Image();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   100
			imgPreloader.onload = function(){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   101
			imgPreloader.onload = null;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   102
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   103
			// Resizing large images - orginal by Christian Montoya edited by me.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   104
			var pagesize = tb_getPageSize();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   105
			var x = pagesize[0] - 150;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   106
			var y = pagesize[1] - 150;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   107
			var imageWidth = imgPreloader.width;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   108
			var imageHeight = imgPreloader.height;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   109
			if (imageWidth > x) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   110
				imageHeight = imageHeight * (x / imageWidth);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   111
				imageWidth = x;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   112
				if (imageHeight > y) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   113
					imageWidth = imageWidth * (y / imageHeight);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   114
					imageHeight = y;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   115
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   116
			} else if (imageHeight > y) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   117
				imageWidth = imageWidth * (y / imageHeight);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   118
				imageHeight = y;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   119
				if (imageWidth > x) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   120
					imageHeight = imageHeight * (x / imageWidth);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   121
					imageWidth = x;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   122
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   123
			}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   124
			// End Resizing
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   125
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   126
			TB_WIDTH = imageWidth + 30;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   127
			TB_HEIGHT = imageHeight + 60;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   128
			$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   129
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   130
			$("#TB_closeWindowButton").click(tb_remove);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   131
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   132
			if (!(TB_PrevHTML === "")) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   133
				function goPrev(){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   134
					if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev);}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   135
					$("#TB_window").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   136
					$("body").append("<div id='TB_window'></div>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   137
					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   138
					return false;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   139
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   140
				$("#TB_prev").click(goPrev);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   141
			}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   142
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   143
			if (!(TB_NextHTML === "")) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   144
				function goNext(){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   145
					$("#TB_window").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   146
					$("body").append("<div id='TB_window'></div>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   147
					tb_show(TB_NextCaption, TB_NextURL, imageGroup);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   148
					return false;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   149
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   150
				$("#TB_next").click(goNext);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   151
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   152
			}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   153
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   154
			document.onkeydown = function(e){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   155
				if (e == null) { // ie
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   156
					keycode = event.keyCode;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   157
				} else { // mozilla
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   158
					keycode = e.which;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   159
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   160
				if(keycode == 27){ // close
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   161
					tb_remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   162
				} else if(keycode == 190){ // display previous image
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   163
					if(!(TB_NextHTML == "")){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   164
						document.onkeydown = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   165
						goNext();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   166
					}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   167
				} else if(keycode == 188){ // display next image
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   168
					if(!(TB_PrevHTML == "")){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   169
						document.onkeydown = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   170
						goPrev();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   171
					}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   172
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   173
			};
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   174
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   175
			tb_position();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   176
			$("#TB_load").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   177
			$("#TB_ImageOff").click(tb_remove);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   178
			$("#TB_window").css({display:"block"}); //for safari using css instead of show
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   179
			};
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   180
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   181
			imgPreloader.src = url;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   182
		}else{//code to show html
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   183
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   184
			var queryString = url.replace(/^[^\?]+\??/,'');
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   185
			var params = tb_parseQuery( queryString );
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   186
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   187
			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   188
			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   189
			ajaxContentW = TB_WIDTH - 30;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   190
			ajaxContentH = TB_HEIGHT - 45;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   191
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   192
			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   193
					urlNoQuery = url.split('TB_');
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   194
					$("#TB_iframeContent").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   195
					if(params['modal'] != "true"){//iframe no modal
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   196
						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   197
					}else{//iframe modal
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   198
					$("#TB_overlay").unbind();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   199
						$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   200
					}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   201
			}else{// not an iframe, ajax
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   202
					if($("#TB_window").css("display") != "block"){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   203
						if(params['modal'] != "true"){//ajax no modal
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   204
						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   205
						}else{//ajax modal
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   206
						$("#TB_overlay").unbind();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   207
						$("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   208
						}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   209
					}else{//this means the window is already up, we are just loading new content via ajax
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   210
						$("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   211
						$("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   212
						$("#TB_ajaxContent")[0].scrollTop = 0;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   213
						$("#TB_ajaxWindowTitle").html(caption);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   214
					}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   215
			}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   216
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   217
			$("#TB_closeWindowButton").click(tb_remove);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   218
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   219
				if(url.indexOf('TB_inline') != -1){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   220
					$("#TB_ajaxContent").append($('#' + params['inlineId']).children());
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   221
					$("#TB_window").unload(function () {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   222
						$('#' + params['inlineId']).append( $("#TB_ajaxContent").children() ); // move elements back when you're finished
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   223
					});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   224
					tb_position();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   225
					$("#TB_load").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   226
					$("#TB_window").css({display:"block"});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   227
				}else if(url.indexOf('TB_iframe') != -1){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   228
					tb_position();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   229
					if($.browser.safari){//safari needs help because it will not fire iframe onload
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   230
						$("#TB_load").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   231
						$("#TB_window").css({display:"block"});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   232
					}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   233
				}else{
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   234
					$("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   235
						tb_position();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   236
						$("#TB_load").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   237
						tb_init("#TB_ajaxContent a.thickbox");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   238
						$("#TB_window").css({display:"block"});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   239
					});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   240
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   241
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   242
		}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   243
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   244
		if(!params['modal']){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   245
			document.onkeyup = function(e){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   246
				if (e == null) { // ie
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   247
					keycode = event.keyCode;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   248
				} else { // mozilla
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   249
					keycode = e.which;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   250
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   251
				if(keycode == 27){ // close
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   252
					tb_remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   253
				}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   254
			};
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   255
		}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   256
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   257
	} catch(e) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   258
		//nothing here
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   259
	}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   260
}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   261
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   262
//helper functions below
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   263
function tb_showIframe(){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   264
	$("#TB_load").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   265
	$("#TB_window").css({display:"block"});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   266
}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   267
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   268
function tb_remove() {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   269
	$("#TB_imageOff").unbind("click");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   270
	$("#TB_closeWindowButton").unbind("click");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   271
	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   272
	$("#TB_load").remove();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   273
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   274
		$("body","html").css({height: "auto", width: "auto"});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   275
		$("html").css("overflow","");
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   276
	}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   277
	document.onkeydown = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   278
	document.onkeyup = "";
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   279
	return false;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   280
}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   281
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   282
function tb_position() {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   283
$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   284
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   285
		$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   286
	}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   287
}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   288
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   289
function tb_parseQuery ( query ) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   290
   var Params = {};
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   291
   if ( ! query ) {return Params;}// return empty object
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   292
   var Pairs = query.split(/[;&]/);
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   293
   for ( var i = 0; i < Pairs.length; i++ ) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   294
      var KeyVal = Pairs[i].split('=');
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   295
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   296
      var key = unescape( KeyVal[0] );
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   297
      var val = unescape( KeyVal[1] );
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   298
      val = val.replace(/\+/g, ' ');
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   299
      Params[key] = val;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   300
   }
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   301
   return Params;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   302
}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   303
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   304
function tb_getPageSize(){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   305
	var de = document.documentElement;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   306
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   307
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   308
	arrayPageSize = [w,h];
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   309
	return arrayPageSize;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   310
}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   311
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   312
function tb_detectMacXFF() {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   313
  var userAgent = navigator.userAgent.toLowerCase();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   314
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   315
    return true;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   316
  }
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   317
}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   318
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   319