function checkAndDisplayToBuy(D,A){url=base_url+"index.php/limitbuy/hassellorder/"+D;var B="index.php/item/index/"+D;var C={success:function(F){reply=F.responseText;if(reply=="no"){displayPlaceBuyOrder(D)}else{if(A){document.getElementById("item-detail-title").innerHTML="Open Sell Orders";hideAllDecorationDownArrow();resetSelectItem();var E=document.getElementById("tab_for_sale");E.className="tab-on";E.getElementsByTagName("a")[0].style.textDecoration="none";document.getElementById("special-market-arrow-down").style.display="block"}if(reply=="yes"){showDefaultForSale(D)}else{location.href=base_url+"index.php/buy/buywizard/index/"+reply}}},failure:function(E){}};YAHOO.util.Connect.asyncRequest("GET",url,C)}function gotoPlaceBuyOrderWithItem(A){idobj=document.getElementById("id_used_place_buyorder_id");if(idobj!=null&&idobj.value!=""){cancelPopup();buyAnItemPlaceBuy(idobj.value)}else{cancelPopup()}}function buyAnItemPlaceBuy(B){var A=document.getElementById("item_id_"+B).value;displayPlaceBuyOrder_item(A)}function gotoBuyItem(A){sellorderidobj=document.getElementById("sell_order_id_id");if(sellorderidobj!=null&&sellorderidobj.value!=""){disableButton(A.id);newurl=base_url+"index.php/buy/buywizard/index/"+sellorderid;location.href=newurl}else{cancelPopup()}}function buyAnItem(C){var A=document.getElementById("item_id_"+C);if(A!=null){A=A.value}var B={success:function(D){reply=D.responseText;if(reply=="no"){idobj=document.getElementById("id_used_place_buyorder_id");if(idobj!=null){idobj.value=C}launchPopUp("make_offer_place_buyorder",false)}else{if(reply.indexOf("ok:")==0){sellorderid=reply.substr(3);sellorderidobj=document.getElementById("sell_order_id_id");if(sellorderidobj!=null){sellorderidobj.value=sellorderid}launchPopUp("forward_buy_item",false)}}},failure:function(D){}};url=base_url+"index.php/item/hasItemActiveSellorder/"+A;YAHOO.util.Connect.asyncRequest("GET",url,B)}function inputBuyOrderInstanceAttributes(A){var H=document.getElementById("numreqattr").value;for(var F=0;F<H;F++){var B=document.getElementById("instance_attid_"+F).value;var C=document.getElementById("owner_instance_att_id_"+A+"_"+B);if(C!=null&&C.value!="N/A"){var I=document.getElementById("instance_atttype_"+F).value;var J=C.value;if(I==1){document.getElementById("instance_att_id_"+B).value=J}else{if(I==3){var K=J.split(" | ");var G=document.getElementsByName("instance_att_"+B+"_"+I+"[]");for(var E=0;E<G.length;E++){for(var D=0;D<K.length;D++){if(K[D]==G[E].value){G[E].checked=true}}}}else{document.getElementById("instance_att_id_"+B).value=J}}}}}function resetBuyOrder(){document.getElementById("buy_order_item_id").value="";document.getElementById("buy_price").value=document.getElementById("market").value;var E=document.getElementById("numreqattr").value;for(var C=0;C<E;C++){var B=document.getElementById("instance_attid_"+C).value;var D=document.getElementById("instance_atttype_"+C).value;if(D==1){document.getElementById("instance_att_id_"+B).value=""}else{if(D==3){var F=document.getElementsByName("instance_att_"+B+"_"+D+"[]");for(var A=0;A<F.length;A++){F[A].checked=false}}else{if(document.getElementById("instance_att_id_"+B)!=null){document.getElementById("instance_att_id_"+B).value=""}}}}}function checkLimitBuyForm(A){form=document.getElementById("limitbuyform");isvalid=false;isvalid=validateFieldNumber(form,"quantity","Please input a quantity.","integer");isvalid=validateFieldNumber(form,"buy_price","Please input a price.","float")&&isvalid;theitemprice=form["the_item_price"].value;theitemid=form["buy_order_item_id"].value;if(theitemprice!=""&&theitemid!=""){myprice=form["buy_price"].value;bppobj=document.getElementById("buy_price_p");mypricefloat=parseFloat(myprice);theitempricefloat=parseFloat(theitemprice);if(mypricefloat<theitempricefloat){if(bppobj!=null){bppobj.innerHTML='The price you input should be greater than or equal to the "Make me Sell" price the owner has set for this item, $'+theitemprice+".";bppobj.style.display="";form["buy_price"].focus()}isvalid=false}else{bppobj.innerHTML="";bppobj.style.display="none"}}YAHOO.util.Connect.setForm("limitbuyform");url=form.action;var B={success:function(C){reply=C.responseText;if(parseInt(reply)>0){window.location.href=base_url+"item/"+A}},failure:function(C){}};if(isvalid){inputlink=document.getElementById("submitlimitbuylink");if(inputlink!=null){inputlink.removeAttribute("href")}YAHOO.util.Connect.asyncRequest("POST",url,B)}}function displayPlaceBuyOrder(A){disableSellBuyButton();forSaleObj=document.getElementById("for_sale");document.getElementById("left-image-sell-grey").style.display="block";document.getElementById("left-image-sell").style.display="none";document.getElementById("left-image-buy-grey").style.display="block";document.getElementById("left-image-buy").style.display="none";window.location.href=base_url+"index.php/itemplaceorder/show/"+A}function displayPlaceBuyOrder_item(A){window.location.href=base_url+"index.php/itemplaceorder/show/"+A+"/1"}function disableSellBuyButton(){buybuttondiv=document.getElementById("buy-button-div");sellbuttondiv=document.getElementById("sell-button-div");buybuttonlink=document.getElementById("buy-button-link");sellbuttonlink=document.getElementById("sell-button-link");if(buybuttondiv!=null&&buybuttonlink!=null){buybuttondiv.className="buy-button-grey";buybuttonlink.disabled=true}if(sellbuttondiv!=null&&sellbuttonlink!=null){sellbuttondiv.className="sell-button-grey";sellbuttonlink.disabled=true}}function enableSellBuyButton(){buybuttondiv=document.getElementById("buy-button-div");sellbuttondiv=document.getElementById("sell-button-div");buybuttonlink=document.getElementById("buy-button-link");sellbuttonlink=document.getElementById("sell-button-link");if(buybuttondiv!=null&&buybuttonlink!=null){buybuttondiv.className="buy-button";buybuttonlink.disabled=false}if(sellbuttondiv!=null&&sellbuttonlink!=null){sellbuttondiv.className="sell-button";sellbuttonlink.disabled=false}}function closePlaceBuyOrder(){document.getElementById("left-image-sell-grey").style.display="none";document.getElementById("left-image-sell").style.display="block";document.getElementById("left-image-buy-grey").style.display="none";document.getElementById("left-image-buy").style.display="block";enableSellBuyButton()}function showEditBuyOrder(A){var B={success:function(C){reply=C.responseText;ebodiv=document.getElementById("edit_buy_order_div");if(ebodiv!=null){ebodiv.innerHTML=reply;launchPopUp(ebodiv.id,false);edit_buy_init()}},failure:function(C){}};url=base_url+"index.php/limitbuy/showBuyOrderEditDiv/"+A;YAHOO.util.Connect.asyncRequest("GET",url,B)}function saveEditBuyOrder(){form=document.getElementById("editbuyform");isvalid=false;isvalid=validateFieldNumber(form,"quantity","Please input a number for quantity.");isvalid=validateFieldNumber(form,"buy_price","Please input the price.");duration=form["duration"].value;if(duration==DURATION_SPECIFY_A_DATE){isvalid=validateFieldNull(form,"duration_datetime","Please input the cancel date.")&&isvalid}document.getElementById("reload_orginal_uri").value=document.getElementById("reload_uri").value;if(isvalid){form.submit()}}
