

var ua = navigator.userAgent.toLowerCase();
var divw=0;
var divh=0;

if (document.getElementById || document.all)
	document.write('<div id="imgtrailer" style="position:absolute;visibility:hidden;z-index:5000;font-family:arial,verdana;font-size:12px;"></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()
	{
	document.onmousemove='';
	gettrailobj().visibility="hidden";
	}

function trailOn(thumbimg,thw,thh)
	{
	if(ua.indexOf('opera') == -1 && ua.indexOf('safari') == -1)
		{
		gettrailobj().left="-500px";

		divthw = parseInt(thw) + 2;
		gettrailobject().innerHTML = '<div style="background-color: #ffffff; layer-background-color: #ffffff; border: 1px none #808080; padding:10px; width:'+divthw+'px;"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px solid #808080;">'+'<img src="'+thumbimg+'" border="0" width="'+thw+'" height="'+thh+'"></div></div>';
		gettrailobj().visibility="visible";
		divw = parseInt(thw)+25;
		divh = parseInt(thh)+130;
		document.onmousemove=followmouse;
		}
	}
function trailOn2(thumbimg)
	{
	if(ua.indexOf('opera') == -1 && ua.indexOf('safari') == -1)
		{
		gettrailobj().left="-500px";
		gettrailobj().visibility="visible";
		document.onmousemove=followmouse;
		 requestAJAX('includes/ajax2.php?listing_ID='+thumbimg, 'imgtrailer');
		}
	}	

function show(thumbimg)
	{

           
		 requestAJAX2('admin/includes/ajax3.php?listing_ID='+thumbimg, 'imgtrailer2');
	
	}		
	
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)
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 - 30));
	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 - 30));
	else
		ycoord = truebody().scrollTop+15+event.clientY;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
	}
/////////////////////////////////////////////////////////////////
 function jumpSelect(Obj)
 {eval("window.location='"+Obj.options[Obj.selectedIndex].value+"'");}
/////////////////////////////////////////////////////////////////////////
 
 function requestAJAX(query, elid)
	{ 
	var req = null; 
	document.getElementById(elid).innerHTML = "Started...";
	if (window.XMLHttpRequest)
		{
		req = new XMLHttpRequest();
		} 
	else if (window.ActiveXObject) 
		{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			}
		catch (e)
			{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch (e) {}
			}
	      	}
	req.onreadystatechange = function()
		{ 
		document.getElementById(elid).innerHTML = '<div style="background-color:#151515; layer-background-color: #151515; border: 1px none #808080; padding:2px;"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px solid #808080;font-family:arial,verdana;">Loading...</div></div>';
		if(req.readyState == 4)
			{
			if(req.status == 200)
				{
				document.getElementById(elid).innerHTML = '<div style="background-color: #151515; layer-background-color: #151515; border: 1px none #808080; padding:2px;"><div style="background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px solid #808080;padding:4px;font-family:arial,verdana;">'+req.responseText+'</div.</div>';	
				}	
			else	
				{
				document.getElementById(elid).innerHTML = "Error: returned status code " + req.status + " " + req.statusText;
				}	
			} 
		}; 
	req.open("GET", query, true); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	req.send(null); 
	} 

 function requestAJAX2(query, elid)
	{ 
	var req = null; 

	document.getElementById(elid).innerHTML = "Started...";
	
	if (window.XMLHttpRequest)
		{
		req = new XMLHttpRequest();
		} 
	else if (window.ActiveXObject) 
		{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
			}
		catch (e)
			{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch (e) {}
			}
	      	}
	req.onreadystatechange = function()
		{ 
		document.getElementById(elid).innerHTML = 'Loading...';
		if(req.readyState == 4)
			{
			if(req.status == 200)
				{
				document.getElementById(elid).innerHTML = req.responseText;	
				}	
			else	
				{
				document.getElementById(elid).innerHTML = "Error: returned status code " + req.status + " " + req.statusText;
				}	
			} 
		}; 
	req.open("GET", query, true); 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	req.send(null); 
	} 
	var newwindow = '';
function openpic(file,width,height)

{
	if (!newwindow.closed && newwindow.location) {
			newwindow.location.href = file;
			newwindow.resizeTo(width,height);
          
		}
		else {
			newwindow=window.open(file,"Details","menubar=0,resizable=0,scrollbars=0,width="+width+",height="+height+"");
			if (!newwindow.opener) newwindow.opener = self;
		}
		if (window.focus) {newwindow.focus()}
		return false;

 

}