function addPaypayinSkutrading(form){isvalid=true;if(form.skutrading_paypal_account.value==""||form.skutrading_paypal_account.value.indexOf("@")==-1){document.getElementById("add_paypal_in_skutrading_error").style.display="";isvalid=false}else{document.getElementById("add_paypal_in_skutrading_error").style.display="none";disableButton("submitaddpaypal_skutrading");tobeinvoked=form.callback.value;mycallback={success:function(o){},failure:function(o){cancelPopup()},upload:function(o){reply=o.responseText;if(reply=="ok"){cancelPopup();eval(tobeinvoked)}else{cancelPopup();alert("failed to add paypal!")}}};YAHOO.util.Connect.setForm("skutrading_addpaypal_form",true);YAHOO.util.Connect.asyncRequest("POST",base_url+"index.php/skutrading/addPaypal",mycallback)}}function addPaypal(A){paypalobj=document.getElementById("sku_trading_add_paypal");if(paypalobj!=null){var B={success:function(C){reply=C.responseText;paypalobj.innerHTML=reply;formobj=document.getElementById("skutrading_addpaypal_form");if(formobj!=null){formobj["callback"].value=A}launchPopUp(paypalobj.id)},failure:function(C){}};YAHOO.util.Connect.asyncRequest("GET",base_url+"/index.php/skutrading/displayAddpaypal",B)}}function checkPaypal(A){url=base_url+"/index.php/item/precheckBeforeSell";var B={success:function(C){if(C.responseText=="yes"){launchPopUp("add_payment_account",false)}else{addPaypal(A)}},failure:function(C){}};YAHOO.util.Connect.asyncRequest("GET",url,B)}function listPrice1(A){listPrice1Callback(A)}function listPrice1Callback(A){callback={success:function(B){ret=B.responseText;listpriceobj=document.getElementById("list-price-container");if(listpriceobj!=null){listpriceobj.innerHTML=ret;launchPopUp(listpriceobj.id);list_price_cal_init()}},failure:function(B){}};YAHOO.util.Connect.asyncRequest("GET",base_url+"index.php/skutrading/displayListPrice1/"+A,callback)}function checkListPriceForm1(A){isvalid=true;listpriceobj=document.getElementById("list_price_for_sku_price_id");theform=document.getElementById("listpriceforskuform1_id");price="";duration="";canceldate="";payment_method="";paypal_account="";if(theform!=null){paymentarray=theform["payment_methods[]"];for(temp=0;temp<paymentarray.length;temp++){if(paymentarray[temp].checked){if(payment_method.length>0){payment_method=","+paymentarray[temp].value}else{payment_method=paymentarray[temp].value}}}pmpobj=document.getElementById("payment_method_id_p");if(pmpobj!=null){pmpobj.style.display="none"}if(payment_method.length==0){isvalid=false;if(pmpobj!=null){pmpobj.style.display=""}}else{if(payment_method.indexOf("1")!=-1){payppal_account_obj=document.getElementById("paypalaccount_id");if(payppal_account_obj!=null){papobj=document.getElementById("paypal_account_id_p");if(!checkEmailValid(payppal_account_obj.value)){isvalid=false;if(papobj!=null){papobj.style.display=""}}else{paypal_account=payppal_account_obj.value;if(papobj!=null){papobj.style.display="none"}}}}else{if(payment_method.indexOf("3")!=-1){gcheckout_account_obj=document.getElementById("gcheckoutaccount_id");if(gcheckout_account_obj!=null){papobj=document.getElementById("gcheckout_account_id_p");pattern=/^([1-9])([0-9])+$/;if(!pattern.test(gcheckout_account_obj.value)){isvalid=false;if(papobj!=null){papobj.style.display=""}}else{gcheckout_account=gcheckout_account_obj.value;if(papobj!=null){papobj.style.display="none"}}}}}}}if(listpriceobj!=null){listprice=listpriceobj.value;pobj=document.getElementById(listpriceobj.id+"_p");if(listprice==""||parseFloat(listprice)==0){isvalid=false;if(pobj!=null){pobj.style.display=""}}else{if(pobj!=null){pobj.style.display="none"}price=listprice}}durationobj=document.getElementById("list_price_for_sku_duration_id");if(durationobj!=null){duration=durationobj.value;if(duration==DURATION_SPECIFY_A_DATE){canceldateobj=document.getElementById("list_price_dur_datetime");pobj1=document.getElementById(canceldateobj.id+"_p1");pobj2=document.getElementById(canceldateobj.id+"_p2");if(canceldateobj!=null){canceldate=canceldateobj.value;if(canceldate==""){isvalid=false;if(pobj1!=null){pobj1.style.display=""}if(pobj2!=null){pobj2.style.display="none"}}else{if(!isDateLaterThanToday(canceldate)){isvalid=false;if(pobj1!=null){pobj1.style.display="none"}if(pobj2!=null){pobj2.style.display=""}}else{if(pobj1!=null){pobj1.style.display="none"}if(pobj2!=null){pobj2.style.display="none"}}}}}}if(isvalid){sbutton=document.getElementById("listpricesubmitbutton1");if(sbutton!=null){disableButton(sbutton.id)}mycallback={success:function(B){reply=B.responseText;listpriceobj1=document.getElementById("list-price-commit-to-sell");if(listpriceobj1!=null){cancelPopup();listpriceobj1.innerHTML=reply;launchPopUp(listpriceobj1.id)}},failure:function(B){cancelPopup()},upload:function(B){cancelPopup()}};YAHOO.util.Connect.setForm("listpriceforskuform1_id",false);YAHOO.util.Connect.asyncRequest("POST",base_url+"index.php/skutrading/displayListPrice2/"+A,mycallback)}}function checkEmailValid(A){pattern=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\-])+\.)+([a-zA-Z0-9]{2,4})+$/;return pattern.test(A)}function isDateLaterThanToday(A){isvalid=true;datearray=A.split("/");theDate=new Date(parseInt(datearray[2]),parseInt(datearray[0])-1,parseInt(datearray[1]));toDay=new Date();if((Date.parse(theDate.toString())-Date.parse(toDay.toString()))<=0){isvalid=false}return isvalid}function listPrice2(F,C,D,A,E,B){callback={success:function(G){ret=G.responseText;listpriceobj1=document.getElementById("list-price-commit-to-sell");cancelPopup();if(listpriceobj1!=null){listpriceobj1.innerHTML=ret;launchPopUp(listpriceobj1.id)}},failure:function(G){cancelPopup()}};if(A.indexOf("/")!=-1){datearray=A.split("/");A=datearray[0]+"-"+datearray[1]+"-"+datearray[2]}YAHOO.util.Connect.asyncRequest("GET",base_url+"index.php/skutrading/displayListPrice2/"+F+"/"+C+"/"+D+"/"+E+"/"+A+"/"+B,callback)}function checkWhetherToCliskCommon(B,A){subbuttonobj=document.getElementById(A);if(B.checked){if(subbuttonobj!=null){subbuttonobj.disabled=false;subbuttonobj.className="popup-button"}}else{if(subbuttonobj!=null){subbuttonobj.disabled=true;subbuttonobj.className="popup-button-grey"}}}function checkWhetherToClick(A){subbuttonobj=document.getElementById("list_price_submit_button_id");if(A.checked){if(subbuttonobj!=null){subbuttonobj.disabled=false;subbuttonobj.className="popup-button"}}else{if(subbuttonobj!=null){subbuttonobj.disabled=true;subbuttonobj.className="popup-button-grey"}}}function checkWhetherToClickBid(A){subbuttonobj=document.getElementById("bid_price_submit_button_id");if(A.checked){if(subbuttonobj!=null){subbuttonobj.disabled=false;subbuttonobj.className="popup-button"}}else{if(subbuttonobj!=null){subbuttonobj.disabled=true;subbuttonobj.className="popup-button-grey"}}}function checkListPriceCommitToSell(A){isvalid=true;acheck=A["listskupriceagreecheckbox"];if(acheck!=null&&acheck.checked){}else{isvalid=false}if(isvalid){sbutton=document.getElementById("list_price_submit_button_id");if(sbutton!=null){disableButton(sbutton.id)}}return isvalid}function editListPrice(B,A){callback={success:function(C){ret=C.responseText;listpriceobj=document.getElementById("edit-list-price-container");if(listpriceobj!=null){listpriceobj.innerHTML=ret;launchPopUp(listpriceobj.id);list_price_cal_init()}},failure:function(C){}};YAHOO.util.Connect.asyncRequest("GET",base_url+"index.php/skutrading/displayEditListPrice/"+B+"/"+A,callback)}function checkEditForm(){form=document.getElementById("edit_list_price_form_id");isvalid=validateFieldNull(form,"edit_list_price_for_sku_price",'Please input "Ask Price".');if(form["list_price_for_sku_duration"].value==DURATION_SPECIFY_A_DATE){pobj1=document.getElementById("edit_list_price_dur_datetime_p1");pobj2=document.getElementById("edit_list_price_dur_datetime_p2");if(form["cancel-date"].value==""){isvalid=false;pobj1.style.display="";pobj2.style.display="none"}else{if(!isDateLaterThanToday(form["cancel-date"].value)){isvalid=false;pobj1.style.display="none";pobj2.style.display=""}else{pobj1.style.display="none";pobj2.style.dispaly="none"}}}paymentobj=form["payment_methods[]"];paymentinput="";if(paymentobj!=null){pmipobj=document.getElementById("payment_method_id_p");if(paymentobj.length==null){if(paymentobj.checked){paymentinput=paymentobj.value}}else{for(tempcount=0;tempcount<paymentobj.length;tempcount++){if(paymentobj[tempcount].checked){if(paymentinput.length==0){paymentinput=paymentinput+paymentobj[tempcount].value}else{paymentinput=paymentinput+";"+paymentobj[tempcount].value}}}}if(paymentinput.length==0||paymentinput==""){isvalid=false;if(pmipobj!=null){pmipobj.style.display=""}}else{if(pmipobj!=null){pmipobj.style.display="none"}}}if(paymentinput.indexOf("1")!=-1){payppal_account_obj=document.getElementById("paypalaccount_id");if(payppal_account_obj!=null){papobj=document.getElementById("paypal_account_id_p");if(!checkEmailValid(payppal_account_obj.value)){isvalid=false;if(papobj!=null){papobj.style.display=""}}else{paypal_account=payppal_account_obj.value;if(papobj!=null){papobj.style.display="none"}}}}if(isvalid){disableButton("editlistpricesubmitbutton1");form.submit()}return isvalid}function bidSku1(A){callback={success:function(B){ret=B.responseText;bidpriceobj1=document.getElementById("bidding-price-container");if(bidpriceobj1!=null){bidpriceobj1.innerHTML=ret;launchPopUp(bidpriceobj1.id);list_price_cal_init()}},failure:function(B){}};YAHOO.util.Connect.asyncRequest("GET",base_url+"index.php/skutrading/displayBidSku1/"+A,callback)}function checkBidPriceForm1(A){isvalid=true;theform=document.getElementById("bidpriceforskuform1_id");bidpriceobj=document.getElementById("bid_price_for_sku_price_id");price="";duration="";canceldate="";paymentinput="";if(theform!=null){for(temp=0;temp<theform["payment_methods[]"].length;temp++){if(theform["payment_methods[]"][temp].checked){if(paymentinput.length==0){paymentinput=theform["payment_methods[]"][temp].value}else{paymentinput=";"+theform["payment_methods[]"][temp].value}}}}pmipobj=document.getElementById("payment_method_id_p");if(paymentinput.length==0||paymentinput==""){isvalid=false;if(pmipobj!=null){pmipobj.style.display=""}}else{if(pmipobj!=null){pmipobj.style.display="none"}}if(bidpriceobj!=null){bidprice=bidpriceobj.value;pobj=document.getElementById(bidpriceobj.id+"_p");if(bidprice==""||parseFloat(bidprice)==0){isvalid=false;if(pobj!=null){pobj.style.display=""}}else{if(pobj!=null){pobj.style.display="none"}price=bidprice}}durationobj=document.getElementById("bid_price_for_sku_duration_id");if(durationobj!=null){duration=durationobj.value;if(duration==DURATION_SPECIFY_A_DATE){canceldateobj=document.getElementById("list_price_dur_datetime");pobj1=document.getElementById(canceldateobj.id+"_p1");pobj2=document.getElementById(canceldateobj.id+"_p2");if(canceldateobj!=null){canceldate=canceldateobj.value;if(canceldate==""){isvalid=false;if(pobj1!=null){pobj1.style.display=""}if(pobj2!=null){pobj2.style.display="none"}}else{if(!isDateLaterThanToday(canceldate)){isvalid=false;if(pobj1!=null){pobj1.style.display="none"}if(pobj2!=null){pobj2.style.display=""}}else{if(pobj1!=null){pobj1.style.display="none"}if(pobj2!=null){pobj2.style.display="none"}}}}}}if(isvalid){sbutton=document.getElementById("bidpricesubmitbutton1");if(sbutton!=null){disableButton(sbutton.id)}bidSku2(A,price,duration,canceldate,paymentinput)}}function bidSku2(E,C,D,B,A){callback={success:function(F){alert("succ")},failure:function(F){cancelPopup()},upload:function(F){ret=F.responseText;if(ret.indexOf("isbuydirectly_inner")!=-1){containerobj=document.getElementById("buy_directly_container_frombid");containerobjinner=document.getElementById("buy_directly_container_frombid_inner");cancelPopup();if(containerobj!=null){containerobjinner.innerHTML=ret;launchPopUp(containerobj.id)}}else{listpriceobj1=document.getElementById("bid-price-commit-to-bid");innerobj=document.getElementById("bid-price-commit-to-bid-inner");cancelPopup();if(listpriceobj1!=null){innerobj.innerHTML=ret;launchPopUp(listpriceobj1.id)}}}};if(B.indexOf("/")!=-1){datearray=B.split("/");B=datearray[0]+"-"+datearray[1]+"-"+datearray[2]}YAHOO.util.Connect.setForm("bidpriceforskuform1_id",true);YAHOO.util.Connect.asyncRequest("POST",base_url+"index.php/skutrading/displayBidSku2/"+E,callback)}function checkBidCommitToBid(A){isvalid=true;acheck=A["bidskupriceagreecheckbox"];if(acheck!=null&&acheck.checked){}else{isvalid=false}if(isvalid){sbutton=document.getElementById("bid_price_submit_button_id");if(sbutton!=null){disableButton(sbutton.id)}}return isvalid}function checkEditBidForm(A){form=document.getElementById("edit_bid_price_form_id");isvalid=validateFieldNull(form,"edit_bid_price_for_sku_price",'Please input "Bidding Price".');if(form["bid_price_for_sku_duration"].value==DURATION_SPECIFY_A_DATE){pobj1=document.getElementById("edit_bid_price_dur_datetime_p1");pobj2=document.getElementById("edit_bid_price_dur_datetime_p2");if(form["cancel-date"].value==""){isvalid=false;pobj1.style.display="";pobj2.style.display="none"}else{if(!isDateLaterThanToday(form["cancel-date"].value)){isvalid=false;pobj1.style.display="none";pobj2.style.display=""}else{pobj1.style.display="none";pobj2.style.dispaly="none"}}}paymentobj=form["payment_methods[]"];paymentinput="";if(paymentobj!=null){pmipobj=document.getElementById("payment_method_id_p");if(paymentobj.length==null){if(paymentobj.checked){paymentinput=paymentobj.value}}else{for(tempcount=0;tempcount<paymentobj.length;tempcount++){if(paymentobj[tempcount].checked){if(paymentinput.length==0){paymentinput=paymentinput+paymentobj[tempcount].value}else{paymentinput=paymentinput+";"+paymentobj[tempcount].value}}}}if(paymentinput.length==0||paymentinput==""){isvalid=false;if(pmipobj!=null){pmipobj.style.display=""}}else{if(pmipobj!=null){pmipobj.style.display="none"}}}if(isvalid){disableButton("editbidpricesubmitbutton1");mycallback={success:function(B){},failure:function(B){cancelPopup()},upload:function(B){reply=B.responseText;if(reply=="ok"){url=base_url+"index.php/item/index/"+A;location.href=url}else{if(reply=="cannot change"){url=base_url+"index.php/item/index/"+A;location.href=url}else{if(reply.indexOf("frombid:")==0){sellorderid=reply.substring(8);buyDirectly(sellorderid,"Y")}}}}};YAHOO.util.Connect.setForm("edit_bid_price_form_id",true);YAHOO.util.Connect.asyncRequest("POST",base_url+"index.php/skutrading/saveeditbid",mycallback)}return isvalid}function showBiddinglist(B,A){bidlist=document.getElementById("bidding-list-div-id");if(bidlist!=null){if(A==""||A==null){A=0}callback={success:function(C){ret=C.responseText;if(bidlist!=null){bidlist.innerHTML="";bidlist.innerHTML=ret}},failure:function(C){}};YAHOO.util.Connect.asyncRequest("GET",base_url+"index.php/skutrading/displayBiddingList/"+B+"/"+A,callback)}}function sellDirectlyCallback(A){callback={success:function(B){ret=B.responseText;sellobj=document.getElementById("sell_directly_container");if(sellobj!=null){sellobj.innerHTML=ret;launchPopUp(sellobj.id)}},failure:function(B){}};YAHOO.util.Connect.asyncRequest("GET",base_url+"index.php/skutrading/displaySellDirectly/"+A,callback)}function sellDirectly(A){sellDirectlyCallback(A)}function checkSellDirectlyForm(A){isvalid=true;if(!A["selldirectlycheckbox"].checked){isvalid=false}pmobj=A["payment_methods"];selectpayment=false;pm=false;if(pmobj.length==null){if(pmobj.checked){selectpayment=true;pm=pmobj.value}}else{for(temp=0;temp<pmobj.length;temp++){if(pmobj[temp].checked){selectpayment=true;pm=pmobj[temp].value}}}pmipobj=document.getElementById("payment_method_id_p");if(!selectpayment){isvalid=false;if(pmipobj!=null){pmipobj.style.display=""}}else{if(pmipobj!=null){pmipobj.style.display="none"}if(pm==1){if(A["paypal_account"]!=null&&checkEmailValid(A["paypal_account"].value)==false){isvalid=false;document.getElementById("paypal_account_p").style.display=""}}else{if(pm==3){var B=/^([1-9])([0-9])+$/;if(A["gcheckout_account"]!=null&&B.test(A["gcheckout_account"].value)==false){isvalid=false;document.getElementById("gcheckout_account_p").style.display=""}}}}if(isvalid){buyorderid=A["buyorderid"].value;disableButton("sell_directly_submit_button_id");callback={success:function(C){},failure:function(C){},upload:function(H){ret=H.responseText;if(ret.indexOf("ok:")!=0){sellobj=document.getElementById("sell_directly_errors_container");if(sellobj!=null){sellobj.innerHTML=ret;cancelPopup();launchPopUp(sellobj.id)}}else{obj=document.getElementById("ordermanagement");if(obj!=null){var F=document.getElementById("reload_uri");if(F!=null){location.href=base_url+"/index.php"+F.value}else{closePopup();var E=document.getElementById("view_tab").value;var D=document.getElementById("table_name").value;var G=document.getElementById("offset").value;var C=document.getElementById("user_id").value;showOrders(C,E,D,G)}}else{transid=ret.substring(3);url=base_url+"index.php/trading/commit/"+transid+"/0";location.reload()}}}};YAHOO.util.Connect.setForm("sell_directly_form_id",true);YAHOO.util.Connect.asyncRequest("POST",base_url+"index.php/skutrading/sellDirectly/"+buyorderid,callback)}return isvalid}function buyDirectly(B,A){if(A=="false"){A="N"}callback={success:function(C){ret=C.responseText;if(A=="Y"){containerobj=document.getElementById("buy_directly_container_frombid");containerobjinner=document.getElementById("buy_directly_container_frombid_inner");cancelPopup();if(containerobj!=null){containerobjinner.innerHTML=ret;launchPopUp(containerobj.id)}}else{buyobj=document.getElementById("buy_directly_container");if(buyobj!=null){buyobj.innerHTML=ret;cancelPopup();launchPopUp(buyobj.id)}}},failure:function(C){}};url=base_url+"index.php/skutrading/displayBuyDirectly/"+B+"/"+A;YAHOO.util.Connect.asyncRequest("GET",url,callback)}function checkBuyDirectlyForm(A){isvalid=true;if(!A["buydirectlycheckbox"].checked){isvalid=false}paymentinput="";payments=A["payment_methods"];if(payments!=null){if(payments.length==null){if(payments.checked){paymentinput=payments.value}}else{for(temp=0;temp<payments.length;temp++){if(payments[temp].checked){if(paymentinput.length==0){paymentinput+=payments[temp].value}else{paymentinput+=";"+payments[temp].value}}}}}pmipobj=document.getElementById("payment_methods_id_p");if(paymentinput.length==0){isvalid=false;if(pmipobj!=null){pmipobj.style.display=""}}else{if(pmipobj!=null){pmipobj.style.display="none"}}if(isvalid){sellorderid=A["sellorerid"].value;disableButton("buy_directly_submit_button_id");callback={success:function(B){},failure:function(B){},upload:function(B){ret=B.responseText;if(ret.indexOf("ok:")!=0){sellobj=document.getElementById("sell_directly_errors_container");if(sellobj!=null){sellobj.innerHTML=ret;cancelPopup();launchPopUp(sellobj.id)}}else{obj=document.getElementById("ordermanagement");if(obj!=null){cancelPopup()}else{transid=ret.substring(3,ret.lastIndexOf(":"));transtype=ret.substring(ret.lastIndexOf(":")+1);iswigixowned=A["iswigix"].value;if(iswigixowned=="true"||paymentinput=="2"){url=base_url+"index.php/paypalgateway/thankyou/1/"+transid+"/"+transtype;cancelPopup();location.href=url}else{url=base_url+"index.php/trading/commit/"+transid+"/0";cancelPopup();location.href=url}}}}};YAHOO.util.Connect.setForm("buy_directly_form_id",true);YAHOO.util.Connect.asyncRequest("POST",base_url+"index.php/skutrading/buyDirectly/"+sellorderid,callback)}return isvalid}function succeedInBuyingSkuFromWigix(A){callback={success:function(B){ret=B.responseText;buyobj=document.getElementById("buy_directly_wigix_success");if(buyobj!=null){buyobj.innerHTML=ret;cancelPopup();launchPopUp(buyobj.id)}},failure:function(B){}};YAHOO.util.Connect.asyncRequest("GET",base_url+"index.php/skutrading/displayBuyDirectlyWigixSuccess/"+A,callback)}function showWhatItIsTooltip(){var A=new YAHOO.widget.Tooltip("myTooltip",{context:"whatitis",text:'SKU Trading allows Wigix users to buy and sell the ownership of a [<a href="'+base_url+"index.php/usage/help_center/15\">Wigix homestead</a>]. The owner of a homestead gets a share of the item's advertising and transaction revenue. Therefore you can make money, even without selling a thing.",showDelay:500});A.hideEvent.subscribe(preventHide)}function wigixToWigixTooltip(){var A=new YAHOO.widget.Tooltip("wigixtowigix",{context:"wigix-to-wigix",text:"Wigix - Wigix payment method enables money transfer directly from your account to another Wigix user's account and vice versa.",showDelay:500})}var skutrading_left;var skutrading_right;var skutrading_top;var skutrading_bottom;var tooltip;var interval;var preventHide=function(){tooltip=document.getElementById("myTooltip");if(tooltip.getElementsByTagName("a").length!=0){skutrading_left=YAHOO.util.Dom.getRegion(tooltip).left;skutrading_right=YAHOO.util.Dom.getRegion(tooltip).right;skutrading_top=YAHOO.util.Dom.getRegion(tooltip).top;skutrading_bottom=YAHOO.util.Dom.getRegion(tooltip).bottom;tooltip.style.visibility="visible";YAHOO.util.Event.addListener(document,"mousemove",tooltipMousemoveHandler)}else{return }};var tooltipMousemoveHandler=function(C){var B=YAHOO.util.Event.getPageX(C);var A=YAHOO.util.Event.getPageY(C);if(B<skutrading_left||B>skutrading_right||A<skutrading_top||A>skutrading_bottom){tooltip.style.visibility="hidden";YAHOO.util.Event.removeListener(document,"mousemove",tooltipMousemoveHandler)}};YAHOO.util.Event.onDOMReady(showWhatItIsTooltip);function displayPaypal(A){paypal_span_obj=document.getElementById("paypal_span_id");if(paypal_span_obj!=null){if(A){paypal_span_obj.style.display=""}else{paypal_span_obj.style.display="none"}}}function displayGCheckout(A){gcheckout_span_obj=document.getElementById("gcheckout_span_id");if(gcheckout_span_obj!=null){if(A){gcheckout_span_obj.style.display=""}else{gcheckout_span_obj.style.display="none"}}}
