function addBookmark(){
var url = document.location.href;
var name = document.title;
    if(window.sidebar && window.sidebar.addPanel) {
        window.sidebar.addPanel(name,url,'');
} else if(window.opera && window.print) { 
        var e=document.createElement('a');
        e.setAttribute('href',url);
        e.setAttribute('title',name);
        e.setAttribute('rel','sidebar');
        e.click();
} else if(window.external) {
        try {
            window.external.AddFavorite(url,name);
        }
        catch(e){}
}
else
        alert("To add our website to your bookmarks use CTRL+D on Windows and Linux and Command+D on the Mac.");
}

function Translate()
{
document.getElementById("TranslatePopup").style.display = "block";
document.getElementById("TranslatePopup").style.right = '27px';
document.getElementById("TranslatePopup").style.top = '32px';
setTimeout("TranslateHide()",3000);
}

function Languages()
{
document.getElementById("TranslatePopup").style.right = '27px';
document.getElementById("TranslatePopup").style.top = '175px';
document.getElementById("TranslatePopup").style.display = "block";
setTimeout("TranslateHide()",3000);
}

function TranslateHide()
{
document.getElementById("TranslatePopup").style.display = "none";
}

function validate()
{   
   if((document.getElementById('Search').value=="") || (document.getElementById('Search').value.length<=2))
   {
		alert('Please enter a valid text to search.');
		document.getElementById('Search').focus();
		return(false);
	}
}

function ResultsPage(selObject)
{
	if (selObject.options[selObject.selectedIndex].value != "")
	{ 
		location.href = "/auctions/recent_" + selObject.options[selObject.selectedIndex].value + "_1.html";
    }
}

function selchkbox()
{	
	if(document.frmpost.chkall.checked== true)
	{
	len=document.frmpost.chkpost.length;
		for(i=0;i<len;i++)
		{
		document.frmpost.chkpost[i].checked=true;	
		}
		document.frmpost.chkpost.checked=true;		
	}
	else
	{
		len=document.frmpost.chkpost.length;
		for(i=0;i<len;i++)
		{
		document.frmpost.chkpost[i].checked=false;	
		}
		document.frmpost.chkpost.checked=false;			
	}		
}

function listcount()
{
var len = '';
var memid = document.getElementById('memberid').value;

if (memid != '')
{
z=0;
len = document.frmpost.chkpost.length;
	if(len == undefined && document.frmpost.chkpost.checked==true)
	{
	z=1;
	}

	for(i=0;i<len;i++)
	{
		if(document.frmpost.chkpost[i].checked==true)
		z=1;	
	}
	if(z==0)
	{
	alert('Please select any one product before choose this one');
	return false;
	}
	else if(z==1)
	{
		if(confirm('Are you sure want to add the selected products to your list?'))
		{
		document.frmpost.adlist.value="add";
		document.frmpost.submit();
		}			
	}			
}
else
	{
	if(confirm('Please login to choose this one. Do you want to login now?'))
	document.location.href = '/login.asp';
	}
}

function addCookie()
{
var memid = document.getElementById('memberid').value;

if (memid != '')
{
z=0;
var a;
len=document.frmpost.chkpost.length;
	if(len == undefined && document.frmpost.chkpost.checked==true)
	{
	z=1;
	}
	for(i=0;i<=len-1;i++)
	{
		if(document.frmpost.chkpost[i].checked==true)
		z=1;
	}
	if(z==0)
	{
	alert('Please select any one product before choose this one');
	return false;
	}
	else if(z==1)
	{
		if(confirm('Are you sure want to add the selected products to your basket?'))
		{
		document.frmpost.adbasket.value="add";
		document.frmpost.submit();
		}
	}
}
else
	{
	if(confirm('Please login to choose this one. Do you want to login now?'))
	location.href='/login.asp'
	}
}

function sendquery()
{
z=0;
var a;
len=document.frmpost.chkpost.length;
	if(len == undefined && document.frmpost.chkpost.checked==true)
	{
	z=1;
	}
	for(i=0;i<len;i++)
	{
		if(document.frmpost.chkpost[i].checked==true)
		z=z+1;
	}
	if(z==0)
	{
	alert('Please select one auction to bid.');
	return false;
	}
	else if(z>1)
	{
	alert('Please select only one auction at a time.');
	return false;
	}
	else if(z==1)
	{
		if(confirm('Are you sure want to bid the selected auction?'))
		{
			for(i=0;i<len;i++)
			{
				if (document.frmpost.chkpost[i].checked)
				{
				a = document.frmpost.chkpost[i].value;
				}
			}
			if (a==undefined)
			{
			a=document.frmpost.chkpost.value;				
			}
		location.href = "/auctions/auctiondetail_" + a + "_.html";
	}
}

}

function openBasket()
{
var memid = document.getElementById('memberid').value;

if (memid != '')
{
location.href="/Auctions/ViewBasket.asp";
}
else
	{
	if(confirm('Please login to choose this one. Do you want to login now?'))
	location.href='/login.asp';
	}
}

var xmlHttp

function ShowCountries(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="country-state.asp";
url=url+"?regionid="+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	document.getElementById("BCountry").innerHTML=xmlHttp.responseText;
	ShowStates('0');
	}
}

function ShowStates(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="country-state.asp";
url=url+"?countryid="+str;
xmlHttp.onreadystatechange=StateResults;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function StateResults() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	document.getElementById("BState").innerHTML=xmlHttp.responseText;
	}
}

function AddToList(aid)
{ 
var memid = document.getElementById('memberid').value;

if (memid != '')
{
	if(confirm('Are you sure want to add this product to your list?'))
	{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="addtolist.asp";
	url=url+"?auctionid="+aid;
	xmlHttp.onreadystatechange=AddToListState;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}			
}
else
	{
	if(confirm('Please login to choose this one. Do you want to login now?'))
	document.location.href = '/login.asp';
	}
}

function AddToListState() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	alert('Product successfully added to your list.');
	}
}

function ShowBidHistory(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="bidhistory.asp";
url=url+"?auctionid="+str;
xmlHttp.onreadystatechange=stateChangedState;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChangedState() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	document.getElementById("BidsHistory").innerHTML=xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function ClearText(obj)
{
	if (obj.value == 'Area...' || obj.value == 'City...')
	{
	obj.value = '';	
	}
}

function Show(val)
{
document.getElementById(val).style.display = "block";
document.getElementById(val+'More').style.display = "none";
document.getElementById(val+'Less').style.display = "block";
}

function Hide(val)
{
document.getElementById(val).style.display = "none";
document.getElementById(val+'More').style.display = "block";
document.getElementById(val+'Less').style.display = "none";
}

function Currency(t)
{
var patt = /(\d*)\.{1}(\d{0,2})/;
var donepatt = /^(\d*)\.{1}(\d{2})$/;
var str = t.value;
var result;
if (!str.match(donepatt))
{
result = str.match(patt);
if (result!= null)
{
t.value = t.value.replace(/[^\d]/gi,'');
str = result[1] + '.' + result[2] ;
t.value = str;
}else{
if (t.value.match(/[^\d]/gi))
t.value = t.value.replace(/[^\d]/gi,'');}
}
}

function Browse()
{
var sk = document.getElementById('Search1').value;
var cat = document.getElementById('categoryid1').value;
	if (sk != "")
	{
	sk = sk.replace(" ", "-");		
	}
	if (document.getElementById('CountryId') != null)
	{
	var ctry = document.getElementById('CountryId').value;
	}
	else
		{
		var ctry = "0";
		}
document.frmpost.action = "results_" + sk + "_1_" + ctry + "_" + cat + ".html";
}

function BB()
{
	if (document.getElementById('BBK') != null)
	{
	Show('divKeyword');
	}

	if (document.getElementById('BBL') != null)
	{
	Show('divLocation');
	}
	
	if (document.getElementById('BBP') != null)
	{
	Show('divPrice');
	}
}

function PageNo(val)
{
var sk = document.getElementById('TSearch').value;
var cat = document.getElementById('TCategoryId').value;
	if (sk != "")
	{
	sk = sk.replace(" ", "-");		
	}
	if (document.getElementById('CountryId') != null)
	{
	var ctry = document.getElementById('CountryId').value;
	}
	else
		{
		var ctry = "0";
		}

document.frmpost.action = "results_" + sk + "_" + val + "_" + ctry + "_" + cat + ".html";
document.frmpost.submit();
}

function AuctionPageNo(val)
{
var pcid = document.getElementById('pcid').value;
var pcname = document.getElementById('pcname').value;
pcname = pcname.replace(" ","-");
document.frmpost.action = "auction_" + pcname + "_" + pcid + "_" + val + ".html";
document.frmpost.submit();
}

function RecentPageNo(val)
{
var Recent = document.getElementById('RecentSearch').value;

document.frmpost.action = "recent_" + Recent + "_" + val + ".html";
document.frmpost.submit();
}

function RelatedPageNo(val)
{
var R = document.getElementById('Related').value;
var RS = document.getElementById('RelatedSearch').value;
var VN = document.getElementById('ValName').value;

document.frmpost.action = "related_keyword_" + R + "_" + RS + "_" + VN + "_" + val + ".html";
document.frmpost.submit();
}


function AdvancePageNo(val)
{
document.getElementById('Page').value = val;
document.frmAdvSearch.submit();
}

function imageviewdisplay(val)
{
var val = parseInt(document.getElementById('CurImg').value) + parseInt(val);
val = document.getElementById('imgsrc'+val).value;
document.getElementById('imageview').src = val;
document.getElementById('zoom1').href = val;
document.getElementById('zoom2').href = val;
document.getElementById('zoom3').href = val;

}

function oimages(val)
{
var TotImgs = parseInt(document.getElementById('TotImgs').value);	
var CurImg = parseInt(document.getElementById('CurImg').value);

	if (val == 'p')
	{
		if (CurImg != '0')
		{
		TCurImg = CurImg - 1;
		document.getElementById('image1').src = document.getElementById('imgsrc'+(TCurImg)).value;
		document.getElementById('image2').src = document.getElementById('imgsrc'+(TCurImg + 1)).value;
		document.getElementById('image3').src = document.getElementById('imgsrc'+(TCurImg + 2)).value;
		CurImg = CurImg - 1;
		document.getElementById('CurImg').value = CurImg;
		}
	}

	if (val == 'n')
	{
		if (CurImg < (TotImgs-2))
		{
		document.getElementById('image1').src = document.getElementById('imgsrc'+(CurImg + 1)).value;
		document.getElementById('image2').src = document.getElementById('imgsrc'+(CurImg + 2)).value;
		document.getElementById('image3').src = document.getElementById('imgsrc'+(CurImg + 3)).value;
		CurImg = CurImg + 1;
		document.getElementById('CurImg').value = CurImg;
		}
	}
}

function validateDetail(MaxBid)
{
var memid = document.getElementById('memberid').value;
var BidAmt = document.getElementById('BidAmount').value;

if (BidAmt == '')
{
BidAmt = 0;
}
BidAmt = parseFloat(BidAmt);
MaxBid = parseFloat(MaxBid);
if (memid != '')
{
	if(BidAmt <= MaxBid)
	{
	alert('You should bid minimum of $' + (MaxBid+1));
	return false;
	}
	else
		{
			if(confirm('Are you sure want to Bid?'))
			{
			}
			else
				{
				return false;
				}
		}
}
else
	{
	if(confirm('Please login to Bid this auction. Do you want to login now?'))
	{
	document.location.href = '/login.asp';
	return false;
	}
	else
		{
		return false;	
		}
	}
}

function FullCatShow(val)
{
document.getElementById('divMoreCats').style.display = "block";
document.getElementById('More').style.display = "none";
document.getElementById('Less').style.display = "block";
}

function FullCatHide(val)
{
document.getElementById('divMoreCats').style.display = "none";
document.getElementById('More').style.display = "block";
document.getElementById('Less').style.display = "none";
}