
/*
function getImgSize(imgSrc, type){
	
	var newImg = new Image();
	newImg.src = imgSrc;
	
	var heightSize = newImg.height;
	var widthSize = newImg.width;
	
	if(type == 'height')
		return heightSize;
	else
		return widthSize;
}
*/

var ua = navigator.userAgent.toLowerCase();
var divw=0;
var divh=0;
var xto;

if(document.getElementById || document.all)
	document.write('<div id="imgtrailer" style="position:absolute;visibility:hidden;"></div>')

function gettrailobject(){
	if (document.getElementById)
		return document.getElementById("imgtrailer")
	else if (document.all)
		return document.all.trailimagid
}

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

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

function trailOff(){
	if (xto && xto > 0)
	{
		clearTimeout(xto);
	}

	document.onmousemove='';
	gettrailobj().visibility="hidden";
}


// function trailOn(thumbimg,imgtitle,imgid,imgsize,level){ // If later is required
function trailOn(thumbimg,thw,thh){

	var isinstore = 1;
		
	// The scr of the image
	thumbimgprev = thumbimg;
	
	// Get width & height to resize div
	//thw = getImgSize(thumbimg, 'width');
	//thh = getImgSize(thumbimg, 'height');

	// For borders, etc
	gettrailobj().left="-500px";
	divthw = parseInt(thw) + 2;
	smthw = parseInt(thw) + 2;
	halfthh = 50;
	halfthh = Math.ceil(parseInt(thh)/2);
	topx = halfthh - 9;
	smthh = parseInt(thh) + 2;

	
	if(navigator.userAgent.indexOf("Opera")!=-1)
		gettrailobject().innerHTML = '<div style=" layer-border: 1px none #919090; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #919090; layer-background-color: #919090;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 2px solid #919090;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'"></div><div class="h2" style="z-index:53; layer-width:'+thw+'px; border: 2px none #919090; padding:10px;padding:2px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div class="h2" style=" layer-width:'+thw+'px; border: 2px none #919090; padding:10px;padding:2px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div>';
	if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1)
		gettrailobject().innerHTML = '<div style=" layer-border: 1px none #919090; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #919090; layer-background-color: #919090;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 2px solid #919090;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'"></div><div class="h2" style="z-index:53; layer-width:'+thw+'px; border: 2px none #919090; padding:10px;padding:2px;z-index:51; font-family:Verdana, Helvetica, Arial;font-size:9.0pt;color:#919090">'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;<div class="h2" style=" layer-width:'+thw+'px; border: 2px none #919090; padding:10px;padding:2px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div>';
	if(navigator.userAgent.indexOf("MSIE")!=-1)
		gettrailobject().innerHTML = '<div style=" layer-border: 1px none #919090; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #919090; layer-background-color: #919090;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 2px solid #919090;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'"></div><div class="h2" style="z-index:53; layer-width:'+thw+'px; border: 2px none #919090; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div class="h2" style=" layer-width:'+thw+'px; border: 1px none #919090; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div>';


/*	Current
	// display only image 
	if(navigator.userAgent.indexOf("Opera")!=-1)
		gettrailobject().innerHTML = '<div style="background-color: #919090; layer-background-color: #919090; border: 1px none #ffffff; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #ffffff; layer-background-color: #ffffff;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #ffffff;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'" >
		
		<div id="div_2" style="border-width:0px;margin:0px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;font-family:Verdana, Helvetica, Arial;font-size:8.5pt;">'+imgtitle+'<br></div>
		
		
		
		</div><div class="h2" style="z-index:53;background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+'</div><div class="h2" style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div>';
	if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1)
		gettrailobject().innerHTML = '<div style="background-color: #919090; layer-background-color: #919090; border: 1px none #ffffff; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #ffffff; layer-background-color: #ffffff;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #ffffff;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'" ><div id="div_2" style="border-width:0px;margin:0px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;font-family:Verdana, Helvetica, Arial;font-size:8.5pt;">'+imgtitle+'<br></div></div><div class="h2" style="z-index:53;background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51; font-family:Verdana, Helvetica, Arial;font-size:9.0pt;color:#ffffff">'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+'</div><div class="h2" style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div>';
	if(navigator.userAgent.indexOf("MSIE")!=-1)
		gettrailobject().innerHTML = '<div style="background-color: #919090; layer-background-color: #919090; border: 1px none #ffffff; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #FFFFFF; layer-background-color: #FFFFFF;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #ffffff;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'"><div id="div_2" style="margin:0px;width:'+thw+'px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;font-family:Verdana, Helvetica, Arial;font-size:8.5pt;">'+imgtitle+'<br></div></div><div class="h2" style="z-index:53;background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+'</div><div class="h2" style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(thw>=233?'</nobr>':'')+'</div></div></div>';
*/	
		
		
/*
		// Display other vars is later is required [imgid,imgsize,level]
		if (navigator.userAgent.indexOf("Opera")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: #919090; layer-background-color: #919090; border: 1px none #ffffff; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #ffffff; layer-background-color: #ffffff;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #ffffff;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'" ><div id="div_2" style="border-width:0px;margin:0px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;font-family:Verdana, Helvetica, Arial;font-size:8.5pt;">'+imgtitle+'<br></div></div><div class="h2" style="z-index:53;background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(isinstore == 0?'Gramagem: '+level:'')+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+'</div><div class="h2" style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(isinstore == 0?'Gramagem: '+level:'')+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div>';
		if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: #919090; layer-background-color: #919090; border: 1px none #ffffff; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #ffffff; layer-background-color: #ffffff;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #ffffff;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'" ><div id="div_2" style="border-width:0px;margin:0px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;font-family:Verdana, Helvetica, Arial;font-size:8.5pt;">'+imgtitle+'<br></div></div><div class="h2" style="z-index:53;background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51; font-family:Verdana, Helvetica, Arial;font-size:9.0pt;color:#ffffff">'+(thw>=233?'<nobr>':'')+(isinstore == 0?'Gramagem: '+level:'')+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+'</div><div class="h2" style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(isinstore == 0?'Gramagem: '+level:'')+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div>';
		if (navigator.userAgent.indexOf("MSIE")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: #919090; layer-background-color: #919090; border: 1px none #ffffff; padding:10px; width:'+divthw+'px;height:100%;z-index:51"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF;width:'+thw+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: #FFFFFF; layer-background-color: #FFFFFF;z-index:51;position:absolute;width:'+thw+'px;height:'+smthh+'px;text-align:center"><img  src="'+thumbimgprev+'"  width="'+smthw+'" height="'+smthh+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+thw+'px;top:'+topx+'px;text-align: center;"><img src="http://www.1000olhos.pt/giftshopimg/loadingnew.gif"></div><div style="margin:0px;padding:0px;z-index:53;position:absolute;width:'+thw+'px;"><div style="border: 1px solid #ffffff;width:'+thw+'px;"><img name="btcontainer" id="btcontainer" src="http://www.1000olhos.pt/giftshopimg/sep.gif" border="0" width="'+thw+'" height="'+thh+'"><div id="div_2" style="margin:0px;width:'+thw+'px;z-index:53;layer-background-color: #FFFFFF;background-color:#ffffff;padding:3px;font-family:Verdana, Helvetica, Arial;font-size:8.5pt;">'+imgtitle+'<br></div></div><div class="h2" style="z-index:53;background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(isinstore == 0?'Gramagem: '+level:'')+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div><div style="visibility:hidden"><div style="height:'+thh+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgtitle+'<br>'+'</div><div class="h2" style="background-color: #919090; layer-background-color: #919090;width:'+thw+'px; border: 1px none #ffffff; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(thw>=233?'<nobr>':'')+(isinstore == 0?'Gramagem: '+level:'')+(thw>=233?'</nobr>':'')+'<br>'+imgsize+'</div></div></div>';
*/
		
		//setTimeOut
	xto = setTimeout("xtimeOut('"+thumbimg+"')",100);
	gettrailobj().visibility="visible";
	divw = parseInt(thw)+25;
	divh = parseInt(thh)+135;
	document.onmousemove=followmouse;
}

function truncImgTitle(title,max){
	if (title.length>max){
		var subtitle = title.substr(0,max);
		var posf = subtitle.lastIndexOf("&");
		if (posf == -1) {
			return subtitle + '...';
		}
		else{
			if (subtitle.lastIndexOf(";") > posf) {
				return subtitle + '...';
			}
			else{
				return title.substr(0,posf)+'...';
			}
		}
	}
	else{
		return title;
	}
}

function xtimeOut(thumbimgg){
	if (document.getElementById)
		document.getElementById('btcontainer').src = thumbimgg;
	else if (document.all)
		document.all.btcontainer.src = thumbimgg;
}

function followmouse(e){
	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)
	
	// 
	var topX;
	topX = 600;
	
	// IE bug
	if(navigator.userAgent.indexOf("MSIE")!=-1)
		topX = 15;
	
	if(typeof e != "undefined"){
	if(docwidth < 15+e.pageX+divw)
		xcoord = e.pageX-divw-5;
	else
		xcoord = 15+e.pageX;
	if(docheight < 15+e.pageY+divh)
		ycoord = 15+e.pageY-Math.max(0,(divh + e.pageY - docheight - truebody().scrollTop - topX));
	else
		ycoord = 15+e.pageY;
	}
	else if (typeof window.event != "undefined"){
		if(docwidth < 15+truebody().scrollLeft+event.clientX+divw)
			xcoord = truebody().scrollLeft-5+event.clientX-divw;
		else
			xcoord = truebody().scrollLeft+15+event.clientX;
				
	if(docheight < 15+truebody().scrollTop+event.clientY+divh)
		ycoord = 15+truebody().scrollTop+event.clientY-Math.max(0,(divh + event.clientY - docheight - topX));
	else
			ycoord = truebody().scrollTop+15+event.clientY;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
}

	Array.prototype.in_array = function ( obj ) {
		var len = this.length;
		for ( var x = 0 ; x <= len ; x++ ) {
			if ( this[x] == obj ) return true;
		}
		return false;
}

function getObj(id){
	if (document.getElementById)
		return document.getElementById(id);
	else if (document.all)
		return document.all[id];
}
