checkHover=0;

sfHover = function() {
	var sfEls = document.getElementById("side_nav_menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

var XMLHttpRequestObject = false; 

if (window.XMLHttpRequest) 
{
	XMLHttpRequestObject = new XMLHttpRequest();
} 
else if (window.ActiveXObject) 
{
	XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}


function confirmEarlyClose(id, option, token)
{
	if(option==1)
	{
		var response = confirm("Are you sure you want to close the auction now?\r\n\r\nThis action cannot be reversed, and you will have to relist if you need to put the item up for auction again.\r\n\r\nPLEASE NOTE: By closing this auction, you are declaring the current highest bidder as the winner of this auction.");
	}
	else
	{
		var response = confirm("Are you sure you want to cancel the auction now?\r\n\r\nThis action cannot be reversed, and you will have to relist if you need to put the item up for auction again.\r\n\r\nPLEASE NOTE: By cancelling this auction, you are declaring no winners for this auction and declaring that this item is no longer being put up for auction.");	
	}

	if(response)
	{
		window.location = "http://www.auctionequipment.com/index.php?option=com_auctionequipment&task=closeAuction&aid=" + id + "&choice=" + option + "&token=" + token;
	}
}

function clearBox()
{
	if(document.getElementById("zip").value == "Zip")
	{
		document.getElementById("zip").value = "";
	}
	else
	{
		if(document.getElementById("zip").value == "")
		{
			document.getElementById("zip").value = "Zip";
		}
	}
}

function clearthis(id)
{
	if(document.getElementById(id).value == "Zip")
	{
		document.getElementById(id).value = "";
	}
	else
	{
		if(document.getElementById(id).value == "")
		{
			document.getElementById(id).value = "Zip";
		}
	}
}

function checkLen(txtid, divid)
{
	if(document.getElementById(txtid).value.length>=300)
	{
		document.getElementById(txtid).value=document.getElementById(txtid).value.substring(0,300);
		document.getElementById(divid).style.color="red";
	}
	else
	{
		document.getElementById(divid).style.color="black";
	}
	
	document.getElementById(divid).innerHTML=300-document.getElementById(txtid).value.length;

}

function reloadThis(pageasking, newused)
{
	if(pageasking==1)
	{
		if(newused==-1)
		{
			window.location = "new-auctions.html";
		}
		if(newused==0)
		{
			window.location = "new-auctions.html?nu=Pre-Owned";
		}
		if(newused==1)
		{
			window.location = "new-auctions.html?nu=New";
		}
	}

	if(pageasking==2)
	{
		if(newused==-1)
		{
			window.location = "auctions-in-your-area.html";
		}
		if(newused==0)
		{
			window.location = "auctions-in-your-area.html?nu=Pre-Owned";
		}
		if(newused==1)
		{
			window.location = "auctions-in-your-area.html?nu=New";
		}
	}

	if(pageasking==3)
	{
		if(newused==-1)
		{
			window.location = "most-popular-auctions.html";
		}
		if(newused==0)
		{
			window.location = "most-popular-auctions.html?nu=Pre-Owned";
		}
		if(newused==1)
		{
			window.location = "most-popular-auctions.html?nu=New";
		}
	}
}

function showPreview(id)
{
	document.getElementById("list" + id).style.backgroundColor = "#FFFF55";
	//document.getElementById("preview").style.display = "none";
	document.getElementById("preview").innerHTML = "";

	if(XMLHttpRequestObject)
	{
		XMLHttpRequestObject.open("GET", "/components/com_auctionequipment/preview.php?id=" + id); 
		XMLHttpRequestObject.send(); 

        	XMLHttpRequestObject.onreadystatechange = function() 
      	  	{ 
      			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) 
			{ 
     	        		document.getElementById("preview").innerHTML = XMLHttpRequestObject.responseText; 
	          	} 
		}
	}

	Effect.Appear('preview', { duration: 0.6 });

}

function hidePreview(id)
{
	document.getElementById("list" + id).style.backgroundColor = "#FFFFFF";
	//document.getElementById("preview").style.display = "block";
	if(XMLHttpRequestObject)
	{
		XMLHttpRequestObject.open("GET", "/components/com_auctionequipment/preview.php"); 
		XMLHttpRequestObject.send(); 

        	XMLHttpRequestObject.onreadystatechange = function() 
      	  	{ 
      			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) 
			{ 
     	        		document.getElementById("preview").innerHTML = XMLHttpRequestObject.responseText; 
	          	} 
		}
	}

	Effect.Fade('preview', { duration: 0.6 });
}

function changePay()
{
	obj = document.getElementById("changePay");

	//alert(obj.options[obj.selectedIndex].value);
	

	window.location = "/?option=com_auctionequipment&task=affiliatesCommission&y=" + obj.options[obj.selectedIndex].value.substr(3, 4) + "&m=" + obj.options[obj.selectedIndex].value.substr(0, 2);
}

function changePayAdmin(id)
{
	obj = document.getElementById("changePay");

	//alert(obj.options[obj.selectedIndex].value);
	

	window.location = "/administrator/?option=com_auctionequipment&task=showCommission&id=" + id + "&y=" + obj.options[obj.selectedIndex].value.substr(3, 4) + "&m=" + obj.options[obj.selectedIndex].value.substr(0, 2);
}

function selected(item)
{
	if(checkHover==1&&item=="cate")
	{

	}
	else
	{
		document.getElementById(item).style.backgroundImage="url(images/arrow_hover.png)";
	}
}

function deselected(item)
{
	if(checkHover!=1||(item=="cate"&&checkHover==0))
	{
		document.getElementById(item).style.backgroundImage="url(images/arrow.png)";
	}
	else
	{
		if(item=="cate")
		{
			document.getElementById(item).style.backgroundImage="url(images/arrow_selected.png)";
		}
		else
		{
			document.getElementById(item).style.backgroundImage="url(images/arrow.png)";
		}	
	}
}

function toggleCats()
{
	if(document.getElementById("allcats").style.display=="none"||document.getElementById("allcats").style.display=="")
	{
		document.getElementById("allcats").style.display="block";
		document.getElementById("cate").style.backgroundImage="url(images/arrow_selected.png)";
		checkHover=1;
	}
	else
	{
		document.getElementById("allcats").style.display="none";
		document.getElementById("cate").style.backgroundImage="url(images/arrow_arrow.png)";
		checkHover=0;
	}
}
