<!--

/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

/*
Amended by Goz 01/08
Added new functions and DOM-traversal logic
*/

var infoString = 'Click to Enlarge: '; // String to be prepended to tooltip

var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always
var currentimageheight = 250;	// maximum image size

function jsk_gettrailobj() {
	if (document.getElementById) {
		return (document.getElementById("div_trailContainer").style);
	}
	else if (document.all) {
		return (document.all.div_trailContainer.style);
	}
}

function jsk_gettrailobjnostyle() {
	if (document.getElementById) {
		return (document.getElementById("div_trailContainer"));
	}
	else if (document.all) {
		return (document.all.div_trailContainer);
	}
}

function jsk_truebody() {
	return ((!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body);
}


function jsk_viewBigger(refImg) {
	// Used to view a pop-up larger image
	
	var rePattern, matches;
	
	var imgTitle = refImg.title;
	var imgDesc = refImg.alt;
	
	rePattern = /^(https?:\/\/[^\/]+)(.+?)(\.(gif|png|jpg))$/i; // Take care with (/g)lobal!
	matches = rePattern.exec(refImg.src); // Require explicit RE object for Safari 2 / Mac
	
	if (matches) {
		var imgSrc = matches[2] + '_lg' + matches[3];
	}
	else {
		return (false);
	}

	rePattern = /^(floatBox_img[0-9]+_)F(.+?)\*(.+?)_L(.+?)\*(.+?)$/i; // Take care with (/g)lobal!
	matches = rePattern.exec(refImg.id); // Require explicit RE object for Safari 2 / Mac
	
	if (matches) {
		var imgWidth = parseInt(matches[4]);
		var imgHeight = parseInt(matches[5]);
			
//		var imgWindow = openWindow('/public/sides/viewBigger.php?src='+imgSrc+'&width='+imgWidth+'&height='+imgHeight+'&title='+imgTitle+'&alt='+imgDesc,'IMGWIN',imgWidth,imgHeight);

		// Non-PHP environment
		var imgWindow = openWindow(imgSrc,'_blank',imgWidth,imgHeight);
	}
	else {
		return (false);
	}
}

function jsk_showtrail(refImg) {
	// Used to display floating thumbnail image
	var rePattern, matches;

	var imgTitle = eval("refImg.title.replace(/^"+infoString+"/i,'');"); // Strip out info string
	var imgDesc = refImg.alt;
	
	rePattern = /^(https?:\/\/[^\/]+)(.+?)(\.(gif|png|jpg))$/i; // Take care with (/g)lobal!
	matches = rePattern.exec(refImg.src); // Require explicit RE object for Safari 2 / Mac
	
	if (matches) {
		var imgSrc = matches[2] + '_lbox' + matches[3];
	}
	else {
		return (false);
	}
	
	rePattern = /^(floatBox_img[0-9]+_)F(.+?)\*(.+?)_L(.+?)\*(.+?)$/i; // Take care with (/g)lobal!
	matches = rePattern.exec(refImg.id); // Require explicit RE object for Safari 2 / Mac
	
	if (!matches) { return (false); } // Problem!
	
	var imgWidth = parseInt(matches[2]);
	var imgHeight = parseInt(matches[3]);
	
	currentimageheight = imgHeight; // Used for jsk_followmouse()
	document.onmousemove = jsk_followmouse;

	newHTML = '';
	newHTML = newHTML + '<div style="padding: 5px; background-color: #FFFFFF; border: 1px solid #cccccc;">';
	newHTML = newHTML + '<h3>' + imgTitle + '</h3>';
	if (imgDesc != '') { newHTML = newHTML + '<div class="cBlue subsubcontent">' + imgDesc + '</div>'; }
	newHTML = newHTML + '<div style="padding: 8px 2px 2px 2px; text-align: center;">';
	newHTML = newHTML + '<img src="' + imgSrc + '" border="0" alt="' + imgTitle + ': ' + imgDesc + '" title="' + imgTitle + ': ' + imgDesc + '" width="' + imgWidth + '" height="' + imgHeight + '" align="top" /></div>';
	newHTML = newHTML + '</div>';

	jsk_gettrailobjnostyle().innerHTML = newHTML;
	jsk_gettrailobj().display = "inline";
}

function jsk_showtrailText(refObj, refTxt) {
	// Used to display floating text only
	var objTitle = refObj.title;
	var objDesc = refObj.accessKey;
	
	rePattern = /^(floatText_txt[0-9]+_)F(.+?)\*(.+?)$/i; // Take care with (/g)lobal!
	matches = rePattern.exec(refObj.id); // Require explicit RE object for Safari 2 / Mac
	
	if (!matches) { return (false); } // Problem!
	
	var objWidth = parseInt(matches[2]);
	var objHeight = parseInt(matches[3]);
	
	document.onmousemove = jsk_followmouse;

	newHTML = '';
	newHTML = newHTML + '<div style="padding: 5px; background-color: #FFFFFF; border: 1px solid #cccccc;">';
	newHTML = newHTML + '<h3>' + objTitle + '</h3>';
	if (objDesc != '') { newHTML = newHTML + '<div class="cBlue subsubcontent">' + objDesc + '</div>'; }
	newHTML = newHTML + '<div style="padding: 8px 2px 2px 2px; text-align: left;">';
	newHTML = newHTML + '<div style="height: '+objHeight+'px; width: '+objWidth+'px;">' + refTxt + '</div>';
	newHTML = newHTML + '</div>';

	jsk_gettrailobjnostyle().innerHTML = newHTML;
	jsk_gettrailobj().display = "inline";
}

function jsk_hidetrail() {
	// Used to hide floating thumbnail
	jsk_gettrailobj().innerHTML = " ";
	jsk_gettrailobj().display = "none";
	jsk_gettrailobj().visibility = "hidden";
	document.onmousemove = null;
}

function jsk_followmouse(e){
	// Used to track floating thumbnail to mouse pointer
	var xcoord=offsetfrommouse[0];
	var ycoord=offsetfrommouse[1];

	var docwidth = (document.all) ? (jsk_truebody().scrollLeft+jsk_truebody().clientWidth) : (pageXOffset+window.innerWidth-15);
	var docheight = (document.all) ? (Math.min(jsk_truebody().scrollHeight, jsk_truebody().clientHeight)) : (Math.min(window.innerHeight));

	if (typeof e != "undefined") {
		if (docwidth - e.pageX < 380) {
			xcoord = e.pageX - xcoord - 400; // Move to the left side of the cursor
		}
		else {
			xcoord += e.pageX;
		}
		
		if (docheight - e.pageY < (currentimageheight + 110)) {
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - jsk_truebody().scrollTop));
		}
		else {
			ycoord += e.pageY;
		}
	}
	else if (typeof window.event != "undefined") {
		if (docwidth - event.clientX < 380) {
			xcoord = event.clientX + jsk_truebody().scrollLeft - xcoord - 400; // Move to the left side of the cursor
		}
		else {
			xcoord += jsk_truebody().scrollLeft+event.clientX;
		}
		
		if (docheight - event.clientY < (currentimageheight + 110)) {
			ycoord += event.clientY + jsk_truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		}
		else {
			ycoord += jsk_truebody().scrollTop + event.clientY;
		}
	}

	if (ycoord < 0) { ycoord = ycoord*-1; }
	jsk_gettrailobj().left=xcoord+"px";
	jsk_gettrailobj().top=ycoord+"px";
	
	jsk_gettrailobj().visibility = "visible";
}

function jsk_applyEvents() {
	// Function to scan DOM tree and apply events to qualifiying imgs
	// Requires events.js
	if (!document.getElementsByTagName && !document.all) { return; }

	var elems = (document.all) ? document.all : document.getElementsByTagName('*');
	for (var i=0; i<elems.length; i++) {
		var elem = elems[i];
		if (elem.id.match(/^floatBox_img/i)) {
			// Qualifying image found
			addObjEvent(elem,'mouseover',function(){ jsk_showtrail(this); });
			addObjEvent(elem,'mouseout',function(){ jsk_hidetrail(); });
			addObjEvent(elem,'click',function(){ jsk_viewBigger(this); });

			// Prepend info string to tooltip
			elem.title = infoString + elem.title;
			
			// Style cursor
			elem.style.cursor = 'pointer';
		}
		else if (elem.id.match(/^floatText_txt/i)) {
			// Qualifying object found
			addObjEvent(elem,'mouseout',function(){ jsk_hidetrail(); }); // Auto-hide
			
			// Style cursor
			elem.style.cursor = 'pointer';
		}
	}
}

// Initialize
// Requires functions.js
addEvent(jsk_applyEvents,'load');

//-->