function processVatID()
{IDContainer=$("#bdi_vatIDContainer");if($("#order_person_company").val().length>0)
{IDContainer.show();}
else
{IDContainer.hide();}}
function setProductVariation(jdata,formIter,selIds,selItems)
{$.each(jdata,function(indexItem,item){elements=['price','priceNonSpecial','priceMsrp','notice','productNo','issues','shipping_costs'];jdataIdent=['price','priceNonSpecial','msrp','price_notice','product_no','issues','shipping_costs'];for(var i in elements)
{element=$('#'+elements[i]+'_'+formIter);if(element.text().length>0)
{element.text(item[jdataIdent[i]]);}}
shipping_costs_text=$('#shipping_costs_text_'+formIter);if(parseFloat(item.shipping_costs.replace(',','.'))>0)
{shipping_costs_text.show();}
else
{shipping_costs_text.hide();}
i=0;$.each(item.variations,function(varKey,varArr){select=$('#'+selIds[i]);select.children('option').remove();$.each(varArr,function(key,option){select.append('<option value="'+key+'">'+option+'</option>');});select.children('option[value='+selItems[i]+']').attr("selected","selected");i++;});});}
function getProductVariation(formIter,client)
{if(typeof client=='undefined')
{client='home';}
form=$('#order_'+formIter+'_vv_1').parents('form:first');qstr='/'+client+'/xml/json/product/';productId=form.find('input[name="product[product_id]"]').val();qstr+='?product_id='+productId;selects=form.find('select[name="product[variations]['+productId+'][]"]');selIds=new Array(selects.length);selItems=new Array(selects.length);selects.each(function(index){selIds[index]=$(this).attr('id');selItems[index]=$(this).children('option:selected').val();var_index=index+1;qstr+='&variation_'+var_index+'='+selItems[index];});$.getJSON(qstr,function(jdata){setProductVariation(jdata,formIter,selIds,selItems);});}
function getBookmarkLink(link,bookmarkTitle)
{var url=window.location.href;var bookmarkUrl=url.substring(0,url.length-1);if(window.sidebar){window.sidebar.addPanel(bookmarkTitle,bookmarkUrl,'');}else if(window.external||document.all){window.external.AddFavorite(bookmarkUrl,bookmarkTitle);}else if(window.opera){link.attr('href',bookmarkUrl);link.attr('title',bookmarkTitle);link.attr('rel','sidebar');link.click();}
return false;}
