var offsetfrommouse=[40,40]; //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 = 291;	// maximum image size.
var t_id = 0;
var currentimagewidth = 378;	// maximum image size.
var timer;

var pos=0;
var dir=2;
var len=0;

function getSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	}
	return [myWidth,myHeight];
}
function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;
	}
	return[scrOfX,scrOfY];
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("preview_div").style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("preview_div")
else if (document.all)
return document.all.trailimagid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hidetrail(){	
	gettrailobj().display= "none";
	document.onmousemove=""
	//gettrailobj().left="-500px"
	clearTimeout(timer);
}

function showtrail(imagename,title,location, year,showthumb){
	i = imagename
	t = title
	l = location
	y = year
	s = showthumb
	show(i,t,l,y,s);
	//timer = setTimeout("show('"+i+"',t,l,y,s);",0);
}
function show(imagename,title,location,year,showthumb){
	
	followmouse(1);
	//t_id = setInterval(animate,20);
	
	//newHTML = '<div class="border_preview">';
	if (showthumb > 0){
    newHTML = '<div align="left" style="position:relati; left:45px;"><a href="' +location+ 
	'"><img src="' + imagename + '"border="0" width="355" height="558"></a></div>';
    newHTML = newHTML +'<div align="center" class="short_tips"><a href="javascript:hidetrail()">';
	newHTML = newHTML + title+ '</a></div><div align="left" class="short_tips">';
	framewidth = currentimagewidth+20;
	//if ((navigator.userAgent.indexOf("Firefox")==-1) && (navigator.userAgent.indexOf("Opera")==-1) ) {	newHTML = newHTML+'<iframe src="about:blank" scrolling="no" frameborder="0" width="'+framewidth+'" height="'+currentimageheight+'"></iframe>';}
	//if ((navigator.userAgent.indexOf("Firefox")==-1) && (navigator.userAgent.indexOf("Opera")==-1) ) {	newHTML = newHTML+'<iframe src="about:blank" scrolling="no" frameborder="0" width="'+framewidth+'" height="300"></iframe>';}

	var obj_id = gettrailobjnostyle()
	obj_id.innerHTML = newHTML;

	gettrailobj().display="block";

}

function followmouse(e){

	/**var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]**/

	var windowWidth = getSize()[0];
	/**var windowHeight = getSize()[1];
	var windowScrollX = getScrollXY()[0];
	var windowScrollY = getScrollXY()[1];
	
	var browserSpecOffset = 0;
	
	ycoord = windowScrollY+(windowHeight-currentimageheight)/3;
	
	if ((typeof e != "undefined") && (navigator.userAgent.indexOf("Opera")==-1)) {
		xcoord += e.pageX;
		browserSpecOffset = 50;
	}
	
	if ((typeof window.event != "undefined") && (navigator.userAgent.indexOf("Opera")==-1)){
		xcoord += event.clientX;
		browserSpecOffset = 30;
	}
	
	if (navigator.userAgent.indexOf("Opera")!=-1) {
		xcoord += window.event.clientX;
		browserSpecOffset = 50;
	}
	
	if (xcoord+currentimagewidth+browserSpecOffset>windowWidth) {
		xcoord += currentimagewidth-windowWidth + 350;
	}
	
	if (xcoord<0) {
		xcoord += browserSpecOffset+offsetfrommouse[0] +350;
	}**/

	//gettrailobj().left = xcoord+"px";
	//gettrailobj().top = ycoord+"px";
	
	var xcoord = 600;
	var ycoord = 155;
	
	if(windowWidth == 1024 || windowWidth == 1003) {
		xcoord = 450;
	}
	else if(windowWidth == 1280) {
		xcoord = 600;
	}
	
	gettrailobj().left = xcoord+"px";
	gettrailobj().top = ycoord+"px"; 
	
	
}
}

function animate()
{
	var elem = document.getElementById('progress');
	if(elem != null) {
		if (pos==0) len += dir;
		if (len>32 || pos>79) pos += dir;
		if (pos>79) len -= dir;
		if (pos>79 && len==0) pos=0;
		elem.style.left = pos;
		elem.style.width = len;
	}
	
}

function remove_loading() {
	this.clearInterval(t_id);
	var targelem = document.getElementById('loader_container');
	targelem.style.display='none';
	targelem.style.visibility='hidden';
	//var t_id = setInterval(animate,60);
}


	    