/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

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 = 0;	// maximum image size.
var showImage = false;
var paragraphHeight = 140; //maximum size of the text (above the image).
var heightPadding = 20;

if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("trailimageid")
else if (document.all)
return document.all.trailimagid
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(imagename,athlete_name,description,showthumb,height){
	
	//if (height > 0){
		currentimageheight = height;
	//}

	document.onmousemove=followmouse;

	cameraHTML = '';

	newHTML = '<div style="padding: 5px; background-color: #FFFFFF; border: 1px solid #00a74a;">';
	
	newHTML += '<table width="100%" cellpadding=0 cellspacing=0 border=0><tr>'
	
	//Image
	if (showthumb > 0 && imagename != ''){
		newHTML = newHTML + '<td valign=top><img src="' + imagename + '" border="0" style="border: 1px solid #888888;"></td>';
		showImage = true;
	} else {
		showImage = false;
	}
	
	//Content
	if (imagename == '1') {	
		newHTML += '<td width="100%" class=hoverText style="font-size: 1em;" valign=top align=center><b>TRADING HOURS<br><br></td>';
		newHTML += '</tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;">'
		newHTML += '<table cellpadding=2 cellspacing=0 border=0 class=hoverText style="font-weight:normal;">'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;"><b>Monday</b></td><td class=hoverText style="font-weight:normal;">CLOSED</td></tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;"><b>Tuesday</b></td><td class=hoverText style="font-weight:normal;">10:00am - 5:00pm</td></tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;"><b>Wednesday</b></td><td class=hoverText style="font-weight:normal;">10:00am - 5:00pm</td></tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;"><b>Thursday</b></td><td class=hoverText style="font-weight:normal;">10:00am - 7:00pm</td></tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;"><b>Friday</b></td><td class=hoverText style="font-weight:normal;">10:00am - 5:00pm</td></tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;"><b>Saturday</b></td><td class=hoverText style="font-weight:normal;">8:00am - 3:00pm</td></tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;"><b>Sunday</b></td><td class=hoverText style="font-weight:normal;">CLOSED</td></tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;"><b>Public Holidays</b></td><td class=hoverText style="font-weight:normal;">CLOSED</td></tr>'
		newHTML += '</table>'	
		newHTML += '</td></tr></table>'
	} else if (imagename == '2') {
		newHTML += '<td width="100%" class=hoverText style="font-size: 1em;" valign=top align=center><b>Quote Basket Help<br></td>';
		newHTML += '</tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;">'
		newHTML += 'You can apply for a quotation on any number of products using our quote basket (shopping-cart style) system. Simply find the products you are interested in and click the "add to cart" icon (<img src="images/cart/add2cart.gif" border=0/>) to add it to the quote basket. Continue Browsing until you have selected all the products and when finished click the Finish Quote button. You can then select the quantities of products required and add any comments. Finally you fill in the Customer Details to submit the quote. We will contact you shortly after we receive your quote request. You can also click the View Quote link on the left to view your quote basket. Feel free to contact us if you have any queries or issues.'
		newHTML += '</td></tr></table>'
	} else {
		newHTML += '<td width="100%" class=hoverText style="font-size: 1em;" valign=top align=center><b>Shop Location<br></td>';
		newHTML += '</tr>'
		newHTML += '<tr><td class=hoverText style="font-weight:normal;">'
		newHTML += '<br>Diamond One Baseball<br>Shop 1, 156 The Boulevarde<br>Miranda NSW 2228<br><br>Phone: 02 9524 1005<br>Fax: 02 9524 1006'
		newHTML += '</td></tr></table>'
	}
		
	//newHTML = newHTML + '<span class="hoverText"><b>' + title + '</b></span><br/>';
	//newHTML = newHTML + 'Rating: ' + cameraHTML + '<br/>';
	//newHTML = newHTML + '<span class="hoverText">' + description + '</span><br/>';

	newHTML = newHTML + '</div>';

	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().visibility="visible";

}


function hidetrail(){
	gettrailobj().visibility="hidden"
	document.onmousemove=""
	gettrailobj().left="-500px"

}

function followmouse(e){
	
	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)

	paragraphHeight = Math.abs(gettrailobjnostyle().offsetHeight - currentimageheight);
	//alert(gettrailobjnostyle().offsetHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 300){
			xcoord = e.pageX - xcoord - 286; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + paragraphHeight + heightPadding)){
			ycoord += e.pageY - Math.max(0,((paragraphHeight + currentimageheight + heightPadding) + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 300){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 286; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + paragraphHeight + heightPadding)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,((paragraphHeight + currentimageheight + heightPadding) + event.clientY - docheight));
		} else {
				ycoord += truebody().scrollTop + event.clientY;		
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
}