var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=1; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 265;	// maximum image size.
var t_id = 0;
var currentimagewidth = 318;	// 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 truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function GetDocumentElementByID(objID) {
	var ie = document.all;
	var dom = document.getElementById;
  if ( ie ) {
    return document.all[objID];
  }
  else if ( dom ) {
    return document.getElementById(objID);
  }
}
var offsetfrommouse=[15,15];
var displayduration=0;
var currentimageheight = 200;
if (document.getElementById || document.all){
	document.write('<div id="trailimageid">');
	document.write('</div>');
}

function gettrailobj(){
if (document.getElementById)
return document.getElementById("preview_div").style
else if (document.all)
return document.all.trailimagid.style
}
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(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 200){
			xcoord = e.pageX - xcoord - 200;
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
		
			if ( document.body ){
				scrollTop = Math.max(truebody().scrollTop, document.body.scrollTop);
			} else {
				scrollTop = truebody().scrollTop;
			}
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - scrollTop));
		} else {
			ycoord += e.pageY;
		}
	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 200){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 200;
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
}
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 hidetrail(){
	gettrailobj().innerHTML = " ";
	gettrailobj().display="none"
	document.onmousemove=""
	gettrailobj().left="-200px"
}
function showtrail(imagename,title,showthumb){
	i = imagename
	t = title
	s = showthumb
	timer = setTimeout("show('"+i+"',t,s);",200);
}
function show(imagename,title,showthumb){
	
	document.onmousemove=followmouse;
	t_id = setInterval(animate,20);
	
	newHTML = '<div class="border_preview"><div id="loader_container"><div id="loader" style="position:relative;"><div align="center">Loading ...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
	
	if (showthumb > 0){
    newHTML = newHTML + '<div align="center" style="padding: 8px 10px 17px 10px;"><img onload="javascript:remove_loading();" src="' + imagename + '" border="0" width="300" height="300"></div>';
    newHTML = newHTML + '<h2 class="Heading2" align="center">' + title + '</h2>'
	newHTML = newHTML + '</div>';
	framewidth = currentimagewidth+33;
	if ((navigator.userAgent.indexOf("Firefox")==-1) && (navigator.userAgent.indexOf("Opera")==-1) ) {	newHTML = newHTML+'<iframe src="about:blank/index.htm" scrolling="no" frameborder="0" width="'+framewidth+'" height="'+currentimageheight+'"></iframe>';}
 newHTML = newHTML + '<h2 class="Heading2" align="center">' + title + '</h2>'
	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) / 2;
	
	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+200;
	}
	if (xcoord<0) {
		xcoord += browserSpecOffset+offsetfrommouse[0];
		
	}

	gettrailobj().left = (xcoord-400)+"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 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 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);
}
function showtrail(imagename,title){
var height=200;
var width=200;
	if (height > 0){
		currentimageheight = height;
	}
	document.onmousemove=followmouse;
	newHTML = '<div style="padding: 5px; width:200; background-color: #FFF; border: 1px solid #888;">';
	
			newHTML = newHTML + '<img src="' + imagename + '"';
			
			newHTML = newHTML + ' height="' + height + '" width="' + width + '"';
			
			newHTML = newHTML + ' border="0"/>';
			newHTML = newHTML  + '<br><b align="center"><div align="center">' + title + '</div></b>';
			
	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display="inline";
}


function valuesOf(a)
{
    var doc=document.getElementById('imgkod');
            doc.innerHTML= "<img src='noautoreg_q_.htm"+Math.round(Math.random() * 100)+"'>";
    return 1;
}
	    