var ua = navigator.userAgent.toLowerCase();
var divw=0;
var divh=0;
var h=0;
var w=0;
var t;

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 hideorviewtrail(type)
	{
	if (type == '0'){
	clearTimeout(t)
	var variableslide=3000;
    t=setTimeout("fullhide()",variableslide)
    //alert("for hide")
    }
    else {
    //gettrailobj().height="350px";
	//gettrailobj().width="350px";
    //gettrailobj().visibility="visible";
    clearTimeout(t)
	//alert("its for view")
	
    }
	//document.onmousemove='';
	//gettrailobj().visibility="hidden";
	}
	
function fullhide()
	{
	document.onmousemove='';
	gettrailobj().visibility="hidden";
	//trailOn(,,,,,,,,0,0);
	gettrailobj().left="0px";
	gettrailobj().top="0px";
	gettrailobj().height="0px";
	gettrailobj().width="0px";
	}	

function trailOn(id,thumbimg,imgtitle,imgscription,imgsize,filesize,credit,level,thw,thh)
	{
	clearTimeout(t)
    gettrailobj().height="350px";
	gettrailobj().width="350px";
	if(ua.indexOf('opera') == -1 && ua.indexOf('safari') == -1)
		{
		
		//alert(event.clientX);
		gettrailobj().left="500px";
		divthw = parseInt(thw) + 2;
		//alert(divthw);
		//gettrailobject().innerHTML = '<table onmouseout="hideorviewtrail(0);" onmouseover="hideorviewtrail(1);" border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="250px" dir="rtl" height="250px"><tr><td height="250"><font face="Tahoma" style="font-size: 8pt"><div style="background-color: #000000; layer-background-color: #000000; border: 0pt none #000000; padding: 0pt; width:'+divthw+'px;"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px solid #000000; background-image: url(images/img_load.gif); background-repeat: no-repeat;"><center><img src="'+thumbimg+'" border="0" width="'+thw+'" height="'+thh+'"></center><div style="padding:3px"><b>Title: </b>'+imgtitle+'<br><b>Description: </b>'+imgscription+'<br></div></div></div></td></tr></table>';
		//gettrailobject().innerHTML = '<table valign="top" onmouseout="hideorviewtrail(0);" onmouseover="hideorviewtrail(1);" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="350px" dir="rtl" height="200px"><tr><td bgcolor="#ffffff" height="20"><iframe style="border-style: solid; border-width: 1" width="350" height="200" id="tempiframe" name="tempiframe" src="details.aspx?id='+id+'"></iframe><font color="#000000" face="Tahoma" style="font-size: 8pt"><center>'+imgsize+'</center></td></tr><tr><td height="180" back-color="#000000" valign="top"><font face="Tahoma" style="font-size: 8pt"><div style="background-color: #ffffff; layer-background-color: #ffffff; border: 0pt none #000000; padding: 0pt; width:'+divthw+'px; height:180px; "><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 0px solid #000000;"><center><img src="'+thumbimg+'" border="0" vspace="10"></center><div align="left" style="padding:3px"><left><a href="details.aspx?id='+imgtitle+'"><b>مشاهده توضیحات</b></a><br><a href="articles.aspx?id='+imgscription+'"><b>مشاهده مقاله</b></a><br></left></div></div></div></td></tr></table>';
		gettrailobject().innerHTML = '<table valign="top" onmouseout="hideorviewtrail(0);" onmouseover="hideorviewtrail(1);" border="1" bgcolor="#ffffff" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="350px" dir="rtl"><tr><td bgcolor="#ffffff"><iframe style="border-right: black 0px solid; border-top: black 0px solid; margin: 0px; border-left: black 0px solid; border-bottom: black 0px solid;" frameborder="0" marginwidth="10" marginheight="10" width="350" height="350" id="tempiframe" name="tempiframe" src="details.aspx?id='+id+'" scrolling="no"></iframe><font color="#000000" face="Tahoma" style="font-size: 8pt"></td></tr></table>';
		gettrailobj().visibility="visible";
		divw = parseInt(thw)+75;
		divh = parseInt(thh)+100;
		followmouse();
		//document.onmousemove=followmouse;
		
		}
	}

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 docwidth=truebody().clientWidth;
	var docheight=truebody().clientHeight;
if(typeof e != "undefined")
	{
	alert('one');
	//w='one';
	if(docwidth < e.pageX+divw)
		xcoord = e.pageX-divw;
	else
		xcoord = e.pageX;
	if(docheight < e.pageY+divh)
		//ycoord = e.pageY-Math.max(0,(divh + e.pageY - docheight - truebody().scrollTop - 30));
		ycoord = e.pageY-divh;
	else
		ycoord = e.pageY;
	}
else if (typeof window.event != "undefined")
    //alert('two');
	{
	//truebody().scrollLeft+event.clientX+divw
	w=truebody().scrollLeft+event.clientX+divw;
	h=event.clientY+divh;//truebody().scrollTop+
	//w='two';
	//truebody().scrollLeft+
	if(docwidth < truebody().scrollLeft+ event.clientX+divw)
		//xcoord = truebody().scrollLeft-5+event.clientX-divw;
		////xcoord = truebody().scrollLeft + event.clientX+5;
		xcoord = truebody().scrollLeft + event.clientX-divw-5;
	else
		//xcoord = truebody().scrollLeft+15+event.clientX;
		xcoord = truebody().scrollLeft+event.clientX-divw-5;
//truebody().scrollTop+
//ycoord = event.clientY- truebody().scrollTop + divh + 50
	if(docheight < truebody().scrollTop+event.clientY+divh)
	ycoord = 5+truebody().scrollTop+event.clientY-Math.max(0,(divh + event.clientY - docheight - 30));
		//ycoord = event.clientY-divh-50 -truebody().scrollTop ; //+divh; //divh;
	else
	ycoord = truebody().scrollTop+5+event.clientY;
		//ycoord =event.clientY + 50; //divh;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
//alert(w);
//alert(docwidth);	
//alert(xcoord);
//alert(event.clientX);
//h=event.clientY
//alert(h);

//alert(truebody().scrollTop);
//alert(event.clientY);
//alert(divh);

//alert(docheight);
//alert(ycoord);
	}
