var sLang;
var d = document;
var LL = '';
var LiL = '';
var I1 = '';
var BS = '';
var NBS = '';
var LM = '';
var HS = '';

$(function() {
	$('#TheKeyword').autocomplete('/sphx/ac.aspx', {json: true, minChars:3, maxItemsToShow:10});

	if ($('#UserID').length){
		$('#UserID').focus();
	} else {
		//$('#TheKeyword').focus();
	}

	buildAdvSearch();

	$('#butSearch').mouseover(function(){$('#TopAdvSearch').slideDown();});
	$('#butAdvSearchEM').bind('click',function(){$('#SubmitButton').val('Exact Match Search');});
	$('#butAdvHide').bind('click',function(){ $('#TopAdvSearch').slideUp('fast');});

	$(".ll").lazyload({	placeholder : "http://76.my/I/spacer.gif", threshold : 200, failurelimit : 25});
});

function buildAdvSearch(){
	var mF = "<table><tr><td><table><tr><td>Type</td><td>:</td><td><input type='radio' name='AuctionType' value='Std'>Auction&nbsp;<input type='radio' name='AuctionType' value='Sale'>For Sale</td></tr><tr><td>Category</td><td>:</td><td><select name=CategoryID><option value=''></option><option value='197'>Handphone & Communication</option><option value='51'>Computer & Software</option><option value='66'>Electronics & Appliances</option><option value='213'>Fashionable & Clothings</option><option value='230'>Jewellery</option><option value='221'>Beauty & Personal Care</option><option value='979'>Watches, Pens & Clocks</option><option value='1146'>Camera & Camcorder</option><option value='182'>Movies & Video</option><option value='784'>Gifts & Premiums</option><option value='1273'>Baby, Kids & Mum</option><option value='262'>House & Property</option><option value='251'>Home & Gardening</option><option value='22'>Cars & Transport</option><option value='885'>Office Equipment</option><option value='21'>Arts, Antiques & Collectibles</option><option value='271'>B2B & Industrial Products</option><option value='42'>Books & Comics</option><option value='1039'>Feng Shui</option><option value='238'>Food & Beverages</option><option value='351'>General & Misc</option><option value='1128'>Health & Medical</option><option value='836'>Internet</option><option value='1016'>Jobs & Freelances</option><option value='1078'>Learning & Education</option><option value='188'>Music & Song</option><option value='379'>Rental, To Let & For Hire</option><option value='488'>Services</option><option value='143'>Sports & Recreation</option><option value='641'>Ticket</option><option value='155'>Toys & Games</option><option value='196'>Travel, Tours & Hotel</option><option value='930'>Warehouse Sales !!</option><option value='822'>Special Interest</option></select></td></tr><tr><td>Price</td><td>:</td><td><input type=text name=PriceLBound size=8>&nbsp;To&nbsp;<input type=text name=PriceUBound size=8></td></tr><tr><td colspan=2></td><td><input type=submit id=butAdvSearch name=butAdvSearch value=Search>&nbsp;<input type=submit id=butAdvSearchEM name=butAdvSearchEM value='Exact Match'>&nbsp;<input type=button id=butAdvHide name=butAdvHide value=Hide></td></tr></table></td><td valign=top style='padding:0 0 0 10px'><input type=checkbox value=Y name=New> New Today <input type=checkbox value=Y name=Closing> Closing Today <input type=checkbox value=Y name=RM1> Start RM 1 <br /><input type=checkbox value=10 name=BidCount> Hot Bids <input type=checkbox value=0 name=HasReservePrice> No Reserve</td></tr><tr></tr></table>"
	$('#TopAdvSearch').html(mF);
}

var menuids=["treemenu1"]; //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
	for (var i=0; i<menuids.length; i++){
  	var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul");
    for (var t=0; t<ultags.length; t++){
			if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
				ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px"; //dynamically position first level submenus to be height of main menu item
				ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon";
			}
			else{ //else if this is a sub level menu (ul)
			  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px"; //position menu to the right of menu item that activated it
	    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon";
			}
			
	    ultags[t].parentNode.onmouseover=function(){
	    	this.getElementsByTagName("ul")[0].style.visibility="visible";
	    }
	    ultags[t].parentNode.onmouseout=function(){
	    	this.getElementsByTagName("ul")[0].style.visibility="hidden";
	   	}
		}
  }
}

if (window.addEventListener)
	window.addEventListener("load", buildsubmenus_horizontal, false);
else if (window.attachEvent)
	window.attachEvent("onload", buildsubmenus_horizontal);
	
function clear_search_value(id)
{
	if(document.getElementById(id).value == "Search items here"){
    if(document.getElementById(id).value!=""){
    	document.getElementById(id).value="";
		}
	}
}

function SetLanguageTJS(s) {
sLang = s;
}

function ll_js_OpenEditor(h) {
var ContextWindow = window.open('/Auc/de.asp?h='+h,'de','width=600,height=550,resizable=yes,scrollbars=yes,toolbar=no,status=no');
ContextWindow.opener = this;
ContextWindow.focus();
}

function PopUpNewWindow1(TheURL) {
window.open(TheURL,"newwin","width=300,height=300,location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=1,toolbar=0");
}

function PopUpNewWindow2(TheURL) {
window.open(TheURL,"newwin","location=0,menubar=1,resizable=0,scrollbars=1,status=0,titlebar=1,toolbar=1");
}

function PageNavigate(PagePath) {
if (PagePath.value.length != 0)
 self.location = PagePath.value;
}

function DoPaging(sm9Class,sPath,nFirst,nLast,nCurrent,sMisc) {
var NextPage;
var thetime=new Date();
var arrMisc=sMisc.split("=");

sTJS_CheckPage = 'Check out this page :';
sTJS_Previous = 'Previous';
sTJS_Next = 'Next';
if (sLang == 'M' ) {
	sTJS_CheckPage = 'Lihat mukasurat ini :';
	sTJS_Previous = 'Terdahulu';
	sTJS_Next = 'Berikut';
}
if (sLang == 'C' ) {
	sTJS_CheckPage = '浏览此页 :';
	sTJS_Previous = '上一页';
	sTJS_Next = '下一页';
}

d.write('<table bgcolor=#EEEEEE width="80%" border=0 cellspacing=1 cellpadding=1><tbody><form action=' + sPath + '><tr>');
d.write('<td height=20 align=left ' + sm9Class + '><div class=pages align=center><b>');

	d.write('Page ' + nCurrent + ' Of ' + nLast + '</b></div></td>');
d.write('<td height=20 align=center ' + sm9Class + '><div class=pages align=center><span class=bgcolor>' + sTJS_CheckPage + '</span>');
if (nCurrent > 1) {
	NextPage = nCurrent - 1;
	d.write('<A HREF=' + sPath + '?' + sMisc + '&D=' + NextPage + '&T=181818>' + sTJS_Previous + '</A> ');
}
for (i=nCurrent-10;i<=nCurrent+10;i++) {
	if (i == nCurrent)
		d.write('<span class=current>' + i + '</span> ');
	else if ((i <= nLast) && (i >= 1))
		d.write('<A HREF=' + sPath + '?' + sMisc + '&D=' + i + '&T=181818>' + i + '</A> ');
}
if (nCurrent + 1 > nLast)
	NextPage = nLast - 1;
else {
	NextPage = nCurrent + 1;
	d.write('<A HREF=' + sPath + '?' + sMisc + '&D=' + NextPage + '&T=181818>' + sTJS_Next + '</A> ');
}
d.write('</div></td>');
d.write('<td height=20 align=Right ' + sm9Class + '><div class=pages align=center><b>');
d.write('<input type=Hidden name=' + arrMisc[0] + ' value="' + arrMisc[1] + '">');
d.write('View Page: <input type=Hidden name=T value="181818"><input maxlength=5 size=2 type=text name=D value=1><input type=Submit value=Go></b><br />');
d.write('</div></tr></form></tbody></table>');
}

function DoListPaging(sm9Class,sPath,nFirst,nLast,nCurrent,sMisc) {
	var NextPage;
	var thetime=new Date();
	var arrMisc=sMisc.split("=");

	for (i=nCurrent-4;i<=nCurrent+4;i++) {
		if (i == nCurrent)
			d.write('<span class=current>' + i + '</span> ');
		else if ((i <= nLast) && (i >= 1))
		{
			if (i <= 100)
				d.write('<A HREF=/Auc/List/List-' + arrMisc[1] + '-' + i + '-181818.htm>' + i + '</A> ');
			else
				d.write('<SPAN>' + i + '</SPAN> ');
		}
	}

	if (nLast < 100) 
		d.write('<span class=PagingText>of</span> <A HREF=/Auc/List/List-' + arrMisc[1] + '-' + nLast + '-181818.htm>' + nLast + '</A> ');
	else
		d.write('<span class=PagingText>of</span> <SPAN>' + nLast + '</SPAN> ');
}

function DoImgTD(sTDWidth, sWidth,sHeight,sSrc,sProductID,sTitle,sPrice,sFullTitle) 
{
	var sLang;
	if (sLang == 'F' ) 
	{
		rExp = /sex/gi;
		if (sTitle.search(rExp) < 0 ) 
		{
			d.write('<td width="' + sTDWidth + '" valign="top" align="center">');
			d.write('<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">');
			d.write('<TR><TD align=center>');
			d.write('<a target="_self" href="' + LL + 'Auc/Vi.asp?P=' + sProductID + '" alt=' + sFullTitle + '><img  alt="' + sFullTitle + '" border=0 width=' + sWidth + ' height=' + sHeight + ' src="http://76.my/UserImages/Items/' + sSrc + '" style="padding-top: 15px;padding-right: 0px;	padding-bottom: 0px;padding-left: 0px;"></a>');
			d.write('</TD></TR>');
			d.write('<TR><TD height="5"><img src="' + I1 + 'images/spacer.gif" border="0" height="5" /></TD></TR>');
			d.write('<TR><TD height="5" valign="top" align=center><font style="font:11px Arial; font-weight:normal; font-style:normal; color:#000000;">');	
			d.write('<a target="_self" href="' + LL + 'Auc/Vi.asp?P=' + sProductID + '" Title="' + sFullTitle + '">' + sTitle + '</a>');
			d.write('</TD></TR>');
			d.write('<TR><TD height="5"><img src="' + I1 + 'images/spacer.gif" border="0" height="5" /></TD></TR>');
			d.write('<TR><TD align=center><font style="font:11px Arial; font-weight:normal; font-style:normal;"><font color=#CC0000>' + sPrice + '</font></font></TD></TR>');
			d.write('</TABLE>');
			d.write('</td>');
		}
		else 
		{
			d.write('<td width="' + sTDWidth + '" valign=top align=center >&nbsp;');
			d.write('<img src="' + I1 + 'images/spacer.gif" border="0" height="5" /><br />');
			d.write('</td>');
		}
	}
	else 
	{
		d.write('<td width="' + sTDWidth + '" valign=top align=center>');
		d.write('<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">');
		d.write('<TR><TD align=center>');
		d.write('<a target="_self" href="' + LL + 'Auc/Vi.asp?P=' + sProductID + '" alt=' + sFullTitle + '><img title="' + sFullTitle + '" alt="' + sFullTitle + '" border=0 width=' + sWidth + ' height=' + sHeight + ' src="http://76.my/UserImages/Items/' + sSrc + '" style="padding-top: 15px;padding-right: 0px;	padding-bottom: 0px;padding-left: 0px;"></a>');
		d.write('</TD></TR>');
		d.write('<TR><TD height="5"><img src="' + I1 + 'images/spacer.gif" border="0" height="5" /></TD></TR>');
		d.write('<TR><TD height="5" valign="top" align=center><font style="font:11px Arial; font-weight:normal; font-style:normal; color:#000000;">');	
		d.write('<a target="_self" href="' + LL + 'Auc/Vi.asp?P=' + sProductID + '" Title="' + sFullTitle + '">' + sTitle + '</a>');
		d.write('</TD></TR>');
		d.write('<TR><TD height="5"><img src="' + I1 + 'images/spacer.gif" border="0" height="5" /></TD></TR>');
		d.write('<TR><TD align=center><font style="font:11px Arial; font-weight:normal; font-style:normal;"><font color=#CC0000>' + sPrice + '</font></font></TD></TR>');
		d.write('</TABLE>');
		d.write('</td>');
	}
}

function build_468x60(text1, text2, dest, C1, C2, C3, C4) {
d.write( size130x30(text1, text2, dest, C1, C2, C3, C4,'468','60','18','14') + '');
}

function build_130x30(text1, text2, dest, C1, C2, C3, C4) {
d.write( size130x30(text1, text2, dest, C1, C2, C3, C4,'160','35','11','9') + '');
}

function size130x30(text1, text2, dest, C1, C2, C3, C4,D5,D6,P7,P8) {
if (C1 == null || C1 == '') { C1	= '#3377C1'};	//	Text 1
if (C2 == null || C2 == '') { C2	= '#666666'};	//	Text 2
if (C3 == null || C3 == '') { C3	= '#C5C5C5'};	//	Border
if (C4 == null || C4 == '') { C4	= '#FFFFFF'};	// Background

x= '<a rel="nofollow" href="' + dest + '" title="' + text1 + ' - ' + text2 + '" target="_new">';
x+='<table width=' + D5 + ' height=' + D6 + ' style="cursor:pointer;border:1px solid ' + C3 + ';width:' + D5 + 'px;height:' + D6 + 'px;" cellpadding="0" cellspacing="0" border="0" bgcolor="' + C4 + '" onclick="javascript:window.open(\'' + dest + '\');"><tr><td align="center">';
x+='<font style="cursor:pointer;font:' + P7 + 'px Arial;color:' + C1 + ';"><b>' + text1 + '</b><br /></font>';
x+='<font style="cursor:pointer;font:' + P8 + 'px Tahoma;color:' + C2 + ';"><marquee behaviour="slide" scrollAmount="3" style="cursor:pointer;">' + text2 + '</marquee></font>';
x+='</td></tr></table>';
x+='</a>';
return x;
} 

<!--NEW-->
function DoBanImg(sID,sImg,sW,sH) {
d.write ('<td align=center><a target="_blank" rel="nofollow" href="/Auc/Ad/redir.asp?id='+sID+'"><img src="http://76.my/'+sImg+'" width='+sW+' height='+sH+' border=0 /></a></td>');
}
function DoBanTxt(text1, text2, dest, C1, C2, C3, C4) {
d.write ('<td align=center>');
build_130x30(text1, text2, dest, C1, C2, C3, C4);
d.write ('</td>');
}

function showMenu(){
statusMenu = document.getElementById('hiddenStatusMenu');
if(statusMenu.value == 0){
statusMenu.value=1;
Effect.toggle('searchmenu','appear'); return false;
}
}

function hideMenu(){
statusMenu = document.getElementById('hiddenStatusMenu');
if(statusMenu.value == 1){
statusMenu.value=0;
Effect.toggle('searchmenu','appear'); return false;
}
}


function DoMarquee(L1,T1,L2,T2,L3,T3,L4,T4,L5,T5,L6,T6,L7,T7,L8,T8,L9,T9,L10,T10,L11,T11,L12,T12,L13,T13) {
sTJS_LatestNews = 'Latest News:';
if (sLang == 'M' ) {
	sTJS_LatestNews = 'Berita Terkini:';
}
if (sLang == 'C' ) {
	sTJS_LatestNews = '最新消息:';
}

sURL = '<a href="';
sSpacer = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
d.write('<table width="100%" border="0"><tr><td width="10%"><font face="Tahoma" style="font-size:11px;">' + sTJS_LatestNews + '</font></td>');
d.write('<td><marquee behaviour="slide" scrollAmount="3" valign="center"><font face="Tahoma" style="font-size:11px;">');
if (L1.length > 0 )
	d.write(sURL + L1 + '">' + T1 + '</a>' + sSpacer);
if (L2.length > 0 )
	d.write(sURL + L2 + '">' + T2 + '</a>' + sSpacer);
if (L3.length > 0 )
	d.write(sURL + L3 + '">' + T3 + '</a>' + sSpacer);
if (L4.length > 0 )
	d.write(sURL + L4 + '">' + T4 + '</a>' + sSpacer);
if (L5.length > 0 )
	d.write(sURL + L5 + '">' + T5 + '</a>' + sSpacer);
if (L6.length > 0 )
	d.write(sURL + L6 + '">' + T6 + '</a>' + sSpacer);
if (L7.length > 0 )
	d.write(sURL + L7 + '">' + T7 + '</a>' + sSpacer);
if (L8.length > 0 )
	d.write(sURL + L8 + '">' + T8 + '</a>' + sSpacer);
if (L9.length > 0 )
	d.write(sURL + L9 + '">' + T9 + '</a>' + sSpacer);
if (L10.length > 0 )
	d.write(sURL + L10 + '">' + T10 + '</a>' + sSpacer);
if (L11.length > 0 )
	d.write(sURL + L11 + '">' + T11 + '</a>' + sSpacer);
if (L12.length > 0 )
	d.write(sURL + L12 + '">' + T12 + '</a>' + sSpacer);
if (L13.length > 0 )
	d.write(sURL + L13 + '">' + T13 + '</a>' + sSpacer);
d.write('</font></marquee></td></tr></table>');
}


