/*
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,25]; //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 defaultimageheight = 40;	// maximum image size.
var defaultimagewidth = 40;	// maximum image size.

var timer;

function gettrailobj(){
if (document.getElementById)
return document.getElementById("preview_div").style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("preview_div")
}


function gettrailloader_container(){
if (document.getElementById)
return document.getElementById("loader_container").style
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hidetrail(){	
	gettrailobj().display= "none";
	document.onmousemove=""
	gettrailobj().left="-1500px"
	clearTimeout(timer);
}

function showtrail(imagename,title,width,height){

	//i = s.backgroundImage.replace("little","middle") //imagename.src.replace("little","middle")
	i = 'public/contenitore/Immagini/prodotti/' + imagename.replace(".jpg", "") + '/' + imagename 
	t = title
	w = 1 //width.width // width.width
	h = 1 //height.width
	show(i,t,w,h)
	
}

function showtrailmarchiimport(posizione,imagename,title,width,height){

	//i = s.backgroundImage.replace("little","middle") //imagename.src.replace("little","middle")
	i = '../public/contenitore/importFOTO/marchi/' + posizione + '/' + imagename 
	t = title
	w = 1 //width.width // width.width
	h = 1 //height.width
	showmarchi(i,t,w,h)
}

function showtrailmarchi(posizione,imagename,title,width,height){

	//i = s.backgroundImage.replace("little","middle") //imagename.src.replace("little","middle")
	i = '../public/contenitore/immagini/marchi/' + posizione + '/' + imagename 
	t = title
	w = 1 //width.width // width.width
	h = 1 //height.width
	showmarchi(i,t,w,h)
}

function showtrailmarchilitte(posizione,imagename,title,width,height){

	//i = s.backgroundImage.replace("little","middle") //imagename.src.replace("little","middle")
	i = '../public/contenitore/immagini/marchi/' + posizione + '/' + imagename 
	t = title
	w = 1 //width.width // width.width
	h = 1 //height.width
	showmarchi(i,t,w,h)
}

function showtrailmarchitree(posizione,imagename,title,width,height){

	//i = s.backgroundImage.replace("little","middle") //imagename.src.replace("little","middle")
	i = '../public/contenitore/immagini/marchi/' + posizione + '/' + imagename 
	t = title
	w = 1 //width.width // width.width
	h = 1 //height.width
	showmarchi(i,t,w,h)
}



function showtrailprodottiimport(posizione,imagename,title,width,height){

	//i = s.backgroundImage.replace("little","middle") //imagename.src.replace("little","middle")
	i = '../public/contenitore/importFOTO/prodotti/' + posizione + '/' + imagename 
	t = title
	w = 1 //width.width // width.width
	h = 1 //height.width
	show(i,t,w,h)
}

function showtrailprodotti(posizione,imagename,title,width,height){

	//i = s.backgroundImage.replace("little","middle") //imagename.src.replace("little","middle")
	i = '../public/contenitore/immagini/prodotti/' + posizione + '/' + imagename 
	t = title
	w = 1 //width.width // width.width
	h = 1 //height.width
	show(i,t,w,h)
}

function showtrailprodottilitte(posizione,imagename,title,width,height){

	//i = s.backgroundImage.replace("little","middle") //imagename.src.replace("little","middle")
	i = '../public/contenitore/immagini/prodotti/' + posizione + '/' + imagename 
	t = title
	w = 1 //width.width // width.width
	h = 1 //height.width
	show(i,t,w,h)
}

function show(imagename,title,width,height){
 
    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)



	if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) ) { //&& (docwidth>650 && docheight>500)
		( width == 0 ) ? width = defaultimagewidth: '';
		( height == 0 ) ? height = defaultimageheight: '';
			
		width+=2
		height+=2
		defaultimageheight = height
		defaultimagewidth = width
	
		document.onmousemove=followmouse2; 

		
		newHTML = '<div class="border_preview" style="width:'+  width +'px;height:'+ height +'px"><div id="loader_container"><div id="loader"><div align="center">Loading template preview...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
		
    	newHTML = newHTML + '<div class="preview_temp_load"><img onload="javascript:remove_loading();" src="' + imagename + '" border="1"></div>';
		newHTML = newHTML + '</div>'; 
		
		if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1 ){
			newHTML = newHTML+'<iframe src="about:blank" scrolling="no" frameborder="0" width="'+width+'" height="'+height+'"></iframe>';
		}		

		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="block";
		
	}
}

function showmarchi(imagename,title,width,height){
 
    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)



	if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) ) { //&& (docwidth>650 && docheight>500)
		( width == 0 ) ? width = defaultimagewidth: '';
		( height == 0 ) ? height = defaultimageheight: '';
			
		width+=2
		height+=2
		defaultimageheight = height
		defaultimagewidth = width
	
		document.onmousemove=followmouse2a; 

		
		newHTML = '<div class="border_preview" style="width:'+  width +'px;height:'+ height +'px"><div id="loader_container"><div id="loader"><div align="center">Loading template preview...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
		
    	newHTML = newHTML + '<div class="preview_temp_load"><img onload="javascript:remove_loading();" src="' + imagename + '" border="1"></div>';
		newHTML = newHTML + '</div>'; 
		
		if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Opera")==-1 ){
			newHTML = newHTML+'<iframe src="about:blank" scrolling="no" frameborder="0" width="'+width+'" height="'+height+'"></iframe>';
		}		

		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="block";
		
	}
}

function remove_loading()
{
    gettrailloader_container.display="none";
    gettrailloader_container().top="-500px"
    
}
function followmouse2(e){

var posx = 0; 
var posy = 0;

if (!e) var e = window.event; if (e.pageX || e.pageY) 
{ 
    posx = e.pageX; 
    posy = e.pageY; 
} 
else if (e.clientX || e.clientY) 
{ 
    posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
} 
//alert(posx + ", " + posy); 




	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 (event.clientX>docwidth/2)
    
    if (posx>docwidth/2)
    {
        gettrailobj().left = posx-660+"px" //"20px"
        gettrailobj().top=(posy-150)+"px"
    }
    else
    {
        gettrailobj().left=  posx+10+"px" //"300px"
        gettrailobj().top=(posy-150)+"px"
    }
    
    
}

function readAttrbibutetblSelect()
{
    var mye = document.getElementById("gotomyzip")

    if (mye != null)
    {window.open(mye)}
    
}


function followmouse2a(e){

var posx = 0; 
var posy = 0;

if (!e) var e = window.event; if (e.pageX || e.pageY) 
{ 
    posx = e.pageX; 
    posy = e.pageY; 
} 
else if (e.clientX || e.clientY) 
{ 
    posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
} 
//alert(posx + ", " + posy); 




	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 (event.clientX>docwidth/2)
    
    if (posx>docwidth/2)
    {
        gettrailobj().left = posx-460+"px" //"20px"
        gettrailobj().top=(posy-50)+"px"
    }
    else
    {
        gettrailobj().left=  posx+10+"px" //"300px"
        gettrailobj().top=(posy-50)+"px"
    }
    
    
}
