window.fbAsyncInit=function(){FB.init({appId:"285101601546621",status:!0,cookie:!0,xfbml:!0});FB.Event.subscribe("edge.create",function(a){"http://www.facebook.com/uBid.com.my"==a&&check_like_and_reload()})};(function(a){var b;if(!a.getElementById("facebook-jssdk"))b=a.createElement("script"),b.id="facebook-jssdk",b.async=!0,b.src="//connect.facebook.net/en_US/all.js",a.getElementsByTagName("head")[0].appendChild(b)})(document);var ticks=[],clocks=[],user_is_login=!1,url_base_href;
$(function(){if(!/fbc_channel/.test(window.location))url_base_href=$("base").attr("href"),$("button.bidbtn").click(function(){placebid(this)}),$("button.buybid").click(function(){buybid(this)}),$("button.buynow").click(function(){buynow(this)}),$(".u1[name=u]").focus(function(){$(this).val("")}),$(".u1[name=p1]").focus(function(){$(this).hide();$(this).parent().find(".u1[name=p2]").show().focus()}),$("#signup").click(function(){document.location=url_base_href+"index.php?a=signup";return!1}),$("#signup2").click(function(){document.location=
url_base_href+"index.php?a=signup";return!1}),$("#learnmore").click(function(){document.location=url_base_href+"how-it-works/"}),$("#flogin").submit(function(){login("flogin");return!1}),$("#flogin2").submit(function(){login("flogin2");return!1}),$("#fautobid").live("submit",function(){autobid("fautobid");return!1}),$("#logout").click(function(){document.location=url_base_href+"index.php?a=logout";return!1}),$("#buybids").click(msgbox),$("#buybids2").click(msgbox),$("#stopautobid").live("click",stop_autobid),
$(window).scroll(function(){450<$(window).scrollTop()?$("#buynow-sticker, #buynow-popup").hide():$("#buynow-sticker").show()}),$("#buynow-sticker").hover(function(){$("#buynow-popup").show()},function(){$("#buynow-popup").hide()}),$.fn.yellowFade=function(){return this.css({backgroundColor:"#f60"}).stop().animate({backgroundColor:"transparent"},2E3)},$.fn.uc=function(){this.val(this.val().toUpperCase())},$("a[title],img[title]").each(function(a){if(""!=$(this).attr("title")){$("body").append("<div class='tooltip' style='display:none' id='tt_"+
a+"'>"+$(this).attr("title")+"&nbsp;<div class=tooltip-tip></div></div>");var b=$("#tt_"+a);$(this).removeAttr("title").mouseover(function(){b.css({opacity:0.8,display:"none"}).fadeIn(200)}).mousemove(function(a){a.stopPropagation();b.css({left:a.pageX,top:a.pageY})}).mouseout(function(){b.fadeOut(200)})}}),$(".simg").click(function(){$(".bimg").attr("src",$(this).attr("src"));$(".bimg").attr("src",$(this).attr("src").replace(/w=40&h=30/,"w=365&h=290"))}),$("#curtain").click(function(){msgbox(!1)}),
$("#msgbox_close").click(function(){msgbox(!1)}),$("#chgpsw").click(function(){$("#tchgpsw").show();$("#newp1").addClass("required");$("#newp2").addClass("required");$(this).parent().parent().remove()}),clocks=$(".tick"),0<clocks.length&&($(".tick").each(function(){void 0!=$(this).attr("rel")&&ticks.push($(this).attr("rel"))}),window.setInterval("update()",5E3),window.setInterval("tick()",1E3),window.setInterval("blink()",1E3)),$("#winner_fade").innerfade({containerheight:210,speed:"slow",timeout:4E3}),
0<$("#jackpot-box-float").length&&$(window).scroll(function(){450<$(window).scrollTop()?$("#jackpot-box-float").addClass("float"):$("#jackpot-box-float").removeClass("float")})});function z(a){a=Math.abs(a);return 10>a?"0"+a:a}var blinks=0;function blink(){blinks=(blinks+1)%2;0==blinks?$(".blink").removeClass("blink1").addClass("blink0"):$(".blink").removeClass("blink0").addClass("blink1")}var zeros=[];
function tick(){clocks.each(function(){update_tick(this)});0<zeros.length&&($.post(url_base_href+"index.php",{a:"data",all:1,lastid:lastid,id:zeros,last10:$("#bidderinfo").attr("rel")},function(a){_ajax=!1;update_callb(a)},"json"),zeros=[])}function update_tick(a){if(void 0!=a){var b=$(a).attr("alt");b--;if(0==b){var c=$(a).attr("rel");$("#bid_"+c).attr("disabled",!0);zeros.push(c)}updateclock(a,b)}}
function updateclock(a,b){var c=z(Math.floor(b/60%60))+":"+z(b%60);3600<b&&(c=Math.floor(b/3600)+":"+c);var d="";0>=b?(d="class=t0",c="00:00"):15>=b?d="class=t15":30>=b&&(d="class=t30");$(a).attr("alt",0<=b?b:-1);"jackpot_time"==a.id?update_big_clock(c):$(a).html("<span "+d+">"+c+"</span>")}function update_big_clock(a){var a="000:00:00".substr(0,9-a.length)+a,b=a.split("");$("#jackpot_time").children().each(function(a){0<a&&$(this).text(b[a])})}var lastid=0,_ajax=!1,update_all=1;
function update(){_ajax||(_ajax=$.post(url_base_href+"index.php",{a:"data",all:update_all,lastid:lastid,id:ticks,last10:$("#bidderinfo").attr("rel")},function(a){_ajax=!1;update_all=0;update_callb(a)},"json"))}
function placebid(a){if(user_is_login){var b=$(a).hasClass("booster")?1:0;b||$(a).text("Checking").attr("disabled",!0).attr("class","o");$.post(url_base_href+"index.php",{a:"bid",all:1,lastid:lastid,id:$(a).attr("rel"),boost:b},function(b){$(a).attr("disabled",!1);b.buy?msgbox(!0):update_callb(b)},"json");_gaq.push(["_trackEvent","Auction","Bid Item",$(a).attr("rel")])}else msgbox()}
function buybid(a){user_is_login?($("<iframe width=1 height=1>").appendTo(document.body).attr("src",url_base_href+"index.php?a=buybid&n="+$(a).attr("alt")),_gaq.push(["_trackEvent","Buy Bids","Buy Bids",$(a).attr("alt")])):alert("Please login")}function msgbox(a){!1==a?(curtain(!1),$("#msgbox").hide()):(curtain(),$("#msgbox").show());return!1}
function update_callb(a){if(void 0!=a.lastid)lastid=a.lastid;void 0!=a.u&&$.each(a.u,function(a,b){if(""==b.u)b.u="-no bid-";$("#winner_"+a).text(b.u);void 0!=b.boost&&1==b.boost?$("#booster_"+a).css("display",""):$("#booster_"+a).css("display","none");void 0!=b.arb&&($("#arb").text(number_format(b.arb,0)),void 0!=$("#arb").get(0)&&0>=b.arb&&stop_autobid());0>=b.c?("Closed"==b.t?$("#bid_"+a).attr("class","g"):$("#bid_"+a).attr("class","s"),b.c=0):0==b.open||"Coming Soon"==b.t||"Back Soon"==b.t?($("#bid_"+
a).attr("class","g"),0==b.open&&$("#bid_"+a).attr("disabled",!0)):b.lead?$("#bid_"+a).attr("class","l"):$("#bid_"+a).attr("class","y");void 0!=b.c&&updateclock("#tick_"+a,b.c);void 0!=b.st&&$("#tick_"+a).hasClass("ts")&&($("#tl_"+a).text("Time left"),$("#tick_"+a).removeClass("ts").addClass("t"));$("#bid_"+a).text(b.t);0<b.c&&1==b.open&&$("#bid_"+a).attr("disabled",!1);void 0!=b.p&&$("#price_"+a).text()!=b.p&&($("#price_"+a).text(number_format(b.p)).yellowFade(),$("#winner_"+a).text(b.u).yellowFade());
void 0!=b.buynow&&(0>=b.rem?($(".buynow_table").show(),$(".buynow_msg").hide(),$(".buynow_mybids").text(b.my),$(".buynow_mydiscount").text(number_format(1.5*b.my)),$(".buynow_myprice").text(number_format($(".buynow_myprice").attr("data-rp")-1.5*b.my))):$(".buynow_rem").text(b.rem))});void 0!=a.b&&$("#bids_left").text(number_format(a.b,0));void 0!=a.last10&&$("#bidderinfo").html(a.last10);void 0!=a.jt&&(0>a.jt?($("#jackpot_time").remove(),$("#jackpot_price").show()):$("#jackpot_time").attr("alt",a.jt));
if(void 0!=a.jb){var b=parseFloat(a.jb).toFixed(2);$("#jackpot_price").attr("rel")!=b&&($("#jackpot_price").attr("rel",b),void 0==a.win?$("#jackpot_user").text("Leading by "+a.jn):$("#jackpot_user").text("Won by "+a.jn+"!"),void 0!=a.jnotify&&$("#jackpot_price").addClass("blink"),a.leaderboard&&$("#jackpot_leader").html(a.leaderboard),animate_jackpot_price())}}var jp_now=0,jp_clk=!1;
function animate_jackpot_price(){var a=$("#jackpot_price").attr("rel");if(!(jp_now>=a)){var b=(parseFloat(a)-jp_now)/2;0.01>b&&(b=0.01);jp_now+=b;if(jp_now>a||0.01>=Math.abs(jp_now-a))jp_now=parseFloat(a);var a=""+jp_now.toFixed(2),a="00000.00".substr(0,8-a.length)+a,c=a.split("");$("#jackpot_price").children().each(function(a){$(this).text(c[a])});!1!=jp_clk&&clearTimeout(jp_clk);jp_clk=setTimeout("animate_jackpot_price()",100)}}
function number_format(a,b,c,d){var g=isNaN(b=Math.abs(b))?2:b,b=void 0==c?".":c,d=void 0==d?",":d,c=0>a?"-":"",f=parseInt(a=Math.abs(+a||0).toFixed(g))+"",e=3<(e=f.length)?e%3:0;return c+(e?f.substr(0,e)+d:"")+f.substr(e).replace(/(\d{3})(?=\d)/g,"$1"+d)+(g?b+Math.abs(a-f).toFixed(g).slice(2):"")}function curtain(a){!1==a?$("#curtain").hide():($("#curtain").css("height",$(document).height()),$("#curtain").css("opacity",0.5).show())}
function login(a){a="#"+a;$(a).find(".error").text("Logging in...");$.post(url_base_href+"index.php",$(a).serialize(),function(b){"OK"==b?window.location.reload():$(a).find(".error").text(b)})}function stop_autobid(){user_is_login?$("#autobidbox").load(url_base_href+"index.php",{a:"autobid_stop",id:$("#stopautobid").attr("rel")}):msgbox()}
function autobid(a){user_is_login?(a="#"+a,$("#btnautobid").text("Checking").attr("disabled",!0).attr("class","o"),$("#autobidbox").load(url_base_href+"index.php",$(a).serialize())):msgbox()}function valid_email(a){return/^[a-z0-9_.\-]+@[a-z0-9\-]+\.[a-z0-9\-]+(\.[a-z0-9\-]+)*$/.test(a)}
function checke(a){valid_email($(a).val())?($("#checke").attr("class","").html("&nbsp;"),$.post(url_base_href+"index.php",{a:"fcheck",f:"e",v:$(a).val()},function(a){"OK"==a?$("#checke").attr("class","status-ok"):$("#checke").attr("class","status-alert").html(a)})):$("#checke").attr("class","status-alert").html("Invalid email format")}
function checku(a){$(a).val($(a).val().replace(/[^a-z0-9_\-.]/ig,""));6>$(a).val().length?$("#checku").attr("class","status-alert").html("at least 6 characters"):($("#checku").attr("class","").html("&nbsp;"),$.post(url_base_href+"index.php",{a:"fcheck",f:"u",v:$(a).val()},function(a){"OK"==a?$("#checku").attr("class","status-ok"):$("#checku").attr("class","status-alert").html(a)}))}
function checkic(a){$(a).val($(a).val().replace(/[^0-9]/g,"").toUpperCase());$("#checkic").attr("class","").html("&nbsp;");$.post(url_base_href+"index.php",{a:"fcheck",f:"ic",v:$(a).val()},function(a){"OK"==a?$("#checkic").attr("class","status-ok"):$("#checkic").attr("class","status-alert").html(a)})}
function checkpstr(a){var b=RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*W).*$","g"),c=RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$","g"),d=RegExp("(?=.{6,}).*","g");0==a.value.length?$("#checkp").attr("class","status-alert").html("Type Password"):!1==d.test(a.value)?$("#checkp").attr("class","status-alert").html("More Characters"):b.test(a.value)?$("#checkp").attr("class","status-ok").html("Good!"):c.test(a.value)?$("#checkp").attr("class",
"status-ok").html("OK"):$("#checkp").attr("class","status-alert").html('<span style="color:red">Weak!</span>')}function checkp(a){return a.elements["m[p1]"].value!=a.elements["m[p2]"].value?(alert("Password does not match"),a.elements["m[p2]"].value="",a.elements["m[p2]"].focus(),!1):!0}
function checkrequired(a){var b=!0;$(a).find(".required").each(function(){$(this).removeClass("error");if(""==$(this).val()){var a=$(this).parent().prev().text();""==a&&(a="Field");alert(a+" is required");$(this).addClass("error").focus();return b=!1}});return b}
function checkregex(a){var b=!0;$(a).find("input[rel]").each(function(){var a=RegExp("^"+$(this).attr("rel")+"$");$(this).removeClass("error");if(!a.test($(this).val()))return a=$(this).parent().prev().text(),""==a&&(a="Field"),alert(a+" is invalid"),$(this).addClass("error").select().focus(),b=!1});return b}
function checksignup(a){if(!checkrequired(a))return!1;if(""==Recaptcha.get_response())return alert("Please enter the CAPTCHA Code"),Recaptcha.focus_response_field(),!1;if(!checkregex(a))return!1;if(!checkp(a))return!1;return!a.elements["m[agree]"].checked?(alert("Please tick the I agree box."),!1):!0}
function checkresetpsw(a){if(!/^[a-z0-9_.\-]+@[a-z0-9\-]+\.[a-z0-9\-]+(\.[a-z0-9\-]+)*$/.test($(a.e).val()))return alert("Invalid email"),$(a.e).addClass("error").select().focus(),!1;if(!checkrequired(a))return!1;return""==Recaptcha.get_response()?(alert("Please enter the CAPTCHA Code"),Recaptcha.focus_response_field(),!1):!0}function checkprofile(a){return!checkrequired(a)?!1:!checkregex(a)?!1:!checkp(a)?!1:!0}
function bow_vote(a){user_is_login?$("#vote").load(url_base_href+"index.php",{a:"bow_vote",n:a}):msgbox()}function closed_goto_page(a){document.location=url_base_href+"index.php?a=closed&pg="+a}function winners_goto_page(a){document.location=url_base_href+"all-winners/?pg="+a}function buynow(a){if(!confirm("You will not able to participate in this auction anymore if you choose to Buy Now. Do you agree?"))return!1;document.location=url_base_href+"index.php?a=buynow&item="+$(a).attr("item")}
function user_share(a){$.post(url_base_href+"index.php?a=addthis&s="+a.data.service)}function check_like_and_reload(){$.post(url_base_href+"index.php",{a:"fbcheck_like"},function(a){/^OK;/.test(a)&&(a=a.split(/;/),alert("Thank you for liking us! You have been given "+a[1]+" free bids."),$("#bids_left").text(number_format(a[2],0)))})};

