var isconfig=false;function Money(num)
{var string=""+num;if(string.indexOf('.')==-1)return string+'.00';var seperation=string.length-string.indexOf('.');if(seperation>3)return string.substring(0,string.length-seperation+3);else if(seperation==2)return string+'0';return string;}
function AddOne(store_id)
{eval('max_order = document.store'+store_id+'.max_order.value');if(max_order=='?')
{alert('Не выбран параметр!');return;}
eval('step_order = document.store'+store_id+'.step_order.value*1');eval('price = document.store'+store_id+'.price.value*1');eval('how = document.store'+store_id+'.how_much.value*1');how=how+step_order;how=(how-(how%step_order));if(how>max_order)how=max_order*1;eval('document.store'+store_id+'.how_much.value = how');Count(store_id);}
function DecOne(store_id)
{eval('max_order = document.store'+store_id+'.max_order.value');if(max_order=='?')
{alert('Не выбран параметр!');return;}
eval('step_order = document.store'+store_id+'.step_order.value*1');eval('min_order = document.store'+store_id+'.min_order.value*1');eval('price = document.store'+store_id+'.price.value*1');eval('how = document.store'+store_id+'.how_much.value*1');how=how-step_order;how=(how-(how%step_order));if(how<min_order)
{how=min_order;}
eval('document.store'+store_id+'.how_much.value = how');Count(store_id);}
function Count(store_id)
{eval('max_order = document.store'+store_id+'.max_order.value');eval('how = document.store'+store_id+'.how_much.value*1');eval('step_order = document.store'+store_id+'.step_order.value*1');eval('min_order = document.store'+store_id+'.min_order.value*1');eval('price = document.store'+store_id+'.price.value*1');if(max_order=='?')max_order=how;if(how==0)how=min_order;if(how>max_order)how=max_order;if(max_order!=how)
{how=(how-(how%step_order));if(how<step_order)how=step_order;if(how<min_order)how=min_order;}
how=Math.ceil(how*1);eval('document.store'+store_id+'.suma.value = Money(price*how + 0.00001)');eval('document.store'+store_id+'.how_much.value = how');if(isconfig)
{eval('goods_list = document.config.goods_list.value');var goods=goods_list.split(",");var all_suma=0;for(var i=0;i<goods.length;i++)
{eval('obj = document.store'+goods[i]+'.how_much');if(!obj)continue;eval('goods_suma = document.store'+goods[i]+'.suma.value');all_suma=all_suma+goods_suma*1;}
eval('document.config.all_suma.value = Money(all_suma + 0.00001)');}}
function BasketAddOne(id)
{eval('max_order = document.basket.max_order'+id+'.value*1');eval('step_order = document.basket.step_order'+id+'.value*1');eval('how = document.basket.how'+id+'.value*1');how=how+step_order;how=(how-(how%step_order));if(how>max_order)
{how=max_order*1;alert("К сожалению, количество товара ограниченно до "+how);}
eval('document.basket.how'+id+'.value = how');}
function BasketDecOne(id)
{eval('min_order = document.basket.min_order'+id+'.value*1');eval('step_order = document.basket.step_order'+id+'.value*1');eval('how = document.basket.how'+id+'.value*1');how=how-step_order;how=(how-(how%step_order));if(how<0)how=0;if(how<min_order&&how>0)
{how=min_order;}
eval('document.basket.how'+id+'.value = how');}
function BuyGoods(store_id)
{eval('how = document.store'+store_id+'.how_much.value');eval('max_order = document.store'+store_id+'.max_order.value');how=Math.ceil(how*1);if(how<1||isNaN(how))
{how=1;}
var param_line='';eval('obj = document.store'+store_id+'.param_code');if(obj)
{eval('code = document.store'+store_id+'.param_code.value');var base_param_exists=false;var params=code.split("I");for(var i=0;i<params.length-1;i++)
{eval('group_id = document.store'+store_id+'.param'+params[i]+'_group.value');if(group_id==0)
{base_param_exists=true;}
else
{eval('param_check = document.store'+store_id+'.param'+params[i]+'.checked');if(param_check)
{eval('modify_value_id = document.store'+store_id+'.param'+params[i]+'_value_id.value');if(param_line=='')
{param_line='&modify_code='+modify_value_id;}
else
{param_line+='I'+modify_value_id;}}}}
if(base_param_exists)
{eval('do_param_id = document.store'+store_id+'.do_param.value');if(do_param_id>0)
{eval('param_value_id = document.store'+store_id+'.param'+do_param_id+'_value_id.value');if(param_value_id>0)
{param_line+='&param_value_id='+param_value_id;}
else
{if(isconfig)
{eval('goods_name = document.store'+store_id+'.goods_name.value');alert('Не выбрано значение базового параметра для товара "'+goods_name+'"');}
else
{alert('Не выбрано значение базового параметра!');}
return false;}}
else
{if(isconfig)
{eval('goods_name = document.store'+store_id+'.goods_name.value');alert('Не выбран базовый параметр для товара "'+goods_name+'"');}
else
{alert('Не выбран базовый параметр!');}
return false;}}}
if(isconfig)
{return'store_id='+store_id+'&how='+how+param_line;}
var line='buy.php?store_id='+store_id+'&how='+how+param_line+'&'+phpsessid;hs.htmlExpand(null,{src:line,width:700,height:450,objectType:'iframe',outlineType:'rounded-white',wrapperClassName:'draggable-header',headingText:decodeURI('')});}
function SimpleBuy(store_id)
{var line='buy.php?store_id='+store_id+'&'+phpsessid;hs.htmlExpand(null,{src:line,width:700,height:450,objectType:'iframe',outlineType:'rounded-white',wrapperClassName:'draggable-header',headingText:decodeURI('')});}
function ToGoods(store_id)
{document.location='goods.php?id='+store_id+'&'+phpsessid;}
function SetParam(param_id,store_id)
{eval('obj = document.store'+store_id+'.how_much');if(!obj)return;eval('default_how = document.store'+store_id+'.max_order_default.value');eval('default_price = document.store'+store_id+'.price_default.value');var result_how=default_how;var result_price=default_price;var modify_suma=0;eval('param_state = document.store'+store_id+'.param'+param_id+'.checked');eval('param_group_id = document.store'+store_id+'.param'+param_id+'_group.value');eval('code = document.store'+store_id+'.param_code.value');var params=code.split("I");for(var i=0;i<params.length-1;i++)
{eval('group_id = document.store'+store_id+'.param'+params[i]+'_group.value');if(param_group_id==group_id)
{eval('document.store'+store_id+'.param'+params[i]+'.checked = false');}}
eval('document.store'+store_id+'.param'+param_id+'.checked = param_state');for(var i=0;i<params.length-1;i++)
{eval('param_state = document.store'+store_id+'.param'+params[i]+'.checked');if(!param_state)continue;eval('group_id = document.store'+store_id+'.param'+params[i]+'_group.value');if(group_id>0)continue;eval('document.store'+store_id+'.do_param.value = '+params[i]);eval('param_type = document.store'+store_id+'.param'+params[i]+'_type.value');eval('param_value_id = document.store'+store_id+'.param'+params[i]+'_value_id.value');if(param_value_id>0)
{if(param_type=='list')
{eval('result_how = document.store'+store_id+'.param'+params[i]+'_value'+param_value_id+'_how.value');eval('result_price = document.store'+store_id+'.param'+params[i]+'_value'+param_value_id+'_price.value');}
else
{eval('result_how = document.store'+store_id+'.param'+params[i]+'_value_how.value');eval('result_price = document.store'+store_id+'.param'+params[i]+'_value_price.value');}}}
for(var i=0;i<params.length-1;i++)
{eval('param_state = document.store'+store_id+'.param'+params[i]+'.checked');if(!param_state)continue;eval('group_id = document.store'+store_id+'.param'+params[i]+'_group.value');if(group_id==0)continue;eval('param_value_id = document.store'+store_id+'.param'+params[i]+'_value_id.value');eval('param_type = document.store'+store_id+'.param'+params[i]+'_type.value');if(param_value_id>0)
{if(param_type=='list')
{eval('modify_price = document.store'+store_id+'.param'+params[i]+'_value'+param_value_id+'_price.value');}
else
{eval('modify_price = document.store'+store_id+'.param'+params[i]+'_value_price.value');}
modify_suma+=modify_price*1-default_price*1;}}
result_price=result_price*1+modify_suma;eval('document.store'+store_id+'.max_order.value = "'+result_how+'"');eval('document.store'+store_id+'.price.value = "'+result_price+'"');Count(store_id);}
function GetParam(param_id,store_id,xpos,ypos,w,h)
{var line='param.php?param_id='+param_id+'&store_id='+store_id+'&'+phpsessid;hs.htmlExpand(null,{src:line,width:w,height:h,objectType:'iframe',outlineType:'rounded-white',wrapperClassName:'draggable-header',headingText:decodeURI('')});}
function SelectValues(id)
{eval('code = document.select_goods.value_code_'+id+'.value');var values=code.split("I");var set_values='';for(var n=0;n<values.length-1;n++)
{eval('document.select_goods.value_'+values[n]+'.checked=true');}}
function DeSelectValues(id)
{eval('code = document.select_goods.value_code_'+id+'.value');var values=code.split("I");var set_values='';for(var n=0;n<values.length-1;n++)
{eval('document.select_goods.value_'+values[n]+'.checked=false');}}
function DoSelect()
{var line_filter='and';var line_values='';eval('code = document.select_goods.filter_code.value');var filters=code.split("I");for(var i=0;i<filters.length-1;i++)
{eval('code = document.select_goods.value_code_'+filters[i]+'.value');if(code!='menu')
{var values=code.split("I");var set_values='';for(var n=0;n<values.length-1;n++)
{eval('val_sel = document.select_goods.value_'+values[n]+'.checked');if(val_sel)
{set_values+=values[n]+'or';if(line_filter.indexOf('and'+filters[i]+'and')==-1)
{line_filter+=filters[i]+'and';}}}
if(set_values.length>0)line_values+='filter'+filters[i]+'='+set_values.slice(0,-2)+'&';}
else
{eval('val_menu = document.select_goods.value_menu_'+filters[i]+'.value');if(val_menu.length>0)
{line_filter+=filters[i]+'and';line_values+='filter'+filters[i]+'='+val_menu+'&';}}}
line_filter=line_filter.slice(3,-3);eval('price_from = document.select_goods.price_from.value');eval('price_to = document.select_goods.price_to.value');eval('topic = document.select_goods.topic.value');var line='./dir.php?id='+topic+'&select=go&price_from='+escape(price_from)+'&price_to='+escape(price_to);if(line_values.length>0)line+='&'+line_values.slice(0,-1);if(line_filter.length>0)line+='&filter='+line_filter;document.location=line+'&'+phpsessid;}
function ShowApendix(id,xpos,ypos,w,h)
{window.open('./descr.php?id='+id+'&'+phpsessid,'','top='+ypos+',left='+xpos+',width='+w+',height='+h+',scrollbars=yes,location=no,toolbar=no,directories=no,status=yes,menubar=no,resizable=yes');}
function ShowCompare(id)
{hs.htmlExpand(null,{src:'./compare.php?id='+id+'&'+phpsessid,width:600,height:300,objectType:'iframe',outlineType:'rounded-white',wrapperClassName:'draggable-header'});}
function ShowCurrency()
{window.open('./currency.php?'+phpsessid,'','top=10, left=100, width=500, height=500,scrollbars=no,location=no,toolbar=no,directories=no,status=yes,menubar=no,resizable=yes');}
function ShowVoteDescr(id)
{window.open('./vote.php?action=descr&vote_list='+id+'&'+phpsessid,'','top=10, left=100, width=400, height=200,scrollbars=yes,location=no,toolbar=no,directories=no,status=yes,menubar=no,resizable=yes');}
function SaveVote(id)
{eval('code = document.voting'+id+'.code.value');var line='';if(code!='')
{var vote=code.split("I");for(var i=0;i<vote.length;i++)
{eval('state = document.voting'+id+'.vote'+vote[i]+'.checked');if(state)line+=vote[i]+'I';}}
eval('group = document.voting'+id+'.group.value');if(group!='')
{var vote=group.split("I");for(var i=0;i<vote.length;i++)
{eval('obj = document.voting'+id+'.vote'+vote[i]);if(obj.type!='radio')
{for(var n=0;n<=obj.length-1;n++)
{if(obj[n].checked)line+=obj[n].value+'I';}}
else
{line+=obj.value;}}}
line='./vote.php?action=save_vote&vote='+id+'&vote_list='+line+'&'+phpsessid;window.open(line,'','top=10,left=10,width=500,height=500,scrollbars=no,location=no,toolbar=no,directories=no,status=yes,menubar=no,resizable=yes');}
function ShowVoting(id)
{window.open('./vote.php?action=show_voting&vote='+id+'&'+phpsessid,'','top=10, left=10, width=550, height=500,scrollbars=yes,location=no,toolbar=no,directories=no,status=yes,menubar=no,resizable=yes');}
function MenuHide()
{}
function ShowBigFoto(theURL,w,h)
{if(theURL){hs.htmlExpand(null,{src:theURL,width:w,height:h,objectType:'iframe',outlineType:'rounded-white',wrapperClassName:'draggable-header',headingText:'Фотография товара'});}}
function SelectFilterValue(id)
{eval("document.select_goods.value_"+id+".checked=!document.select_goods.value_"+id+".checked");}
function ExpandSearch()
{window.open('./exp_search.php?' + phpsessid,'','top=10, left=10, width=550, height=300,scrollbars=yes,location=no,toolbar=no,directories=no,status=yes,menubar=no,resizable=yes');}
function InfoDescr(id)
{window.open('./info_descr.php?id='+id+'&'+phpsessid,'','top=100, left=100, width=350, height=300,scrollbars=yes,location=no,toolbar=no,directories=no,status=yes,menubar=no,resizable=yes');}
function TabHide(block_name)
{if(!tab_descr_exists)
{if(document.getElementById("bl_"+block_name+"_tab_descr")!=null)document.getElementById("bl_"+block_name+"_tab_descr").style.display='none';}
if(!tab_info_exists)
{if(document.getElementById("bl_"+block_name+"_tab_info")!=null)document.getElementById("bl_"+block_name+"_tab_info").style.display='none';}
if(!tab_comp_exists)
{if(document.getElementById("bl_"+block_name+"_tab_comp")!=null)document.getElementById("bl_"+block_name+"_tab_comp").style.display='none';}
if(!tab_disc_exists)
{if(document.getElementById("bl_"+block_name+"_tab_disc")!=null)document.getElementById("bl_"+block_name+"_tab_disc").style.display='none';}
if(!tab_family_exists)
{if(document.getElementById("bl_"+block_name+"_tab_family")!=null)document.getElementById("bl_"+block_name+"_tab_family").style.display='none';}
if(!tab_comment_exists)
{if(document.getElementById("bl_"+block_name+"_tab_comment")!=null)document.getElementById("bl_"+block_name+"_tab_comment").style.display='none';}
if(!tab_section_exists)
{if(document.getElementById("bl_"+block_name+"_tab_section")!=null)document.getElementById("bl_"+block_name+"_tab_section").style.display='none';}
if('block_'+block_name in this)document.getElementById("block_"+block_name).style.display='none';}
function TabShow(block_name)
{if(tab_descr_exists){document.getElementById("block_descr").style.display='none';}
if(tab_info_exists){document.getElementById("block_info").style.display='none';}
if(tab_comp_exists){document.getElementById("block_comp").style.display='none';}
if(tab_disc_exists){document.getElementById("block_disc").style.display='none';}
if(tab_family_exists){document.getElementById("block_family").style.display='none';}
if(tab_comment_exists){document.getElementById("block_comment").style.display='none';}
if(tab_section_exists){document.getElementById("block_section").style.display='none';}
document.getElementById("block_"+block_name).style.display='block';}
function TabFirst(tab_name)
{var start_tab='';if(tab_section_exists)start_tab='section';if(tab_comment_exists)start_tab='comment';if(tab_family_exists)start_tab='family';if(tab_disc_exists)start_tab='disc';if(tab_comp_exists)start_tab='comp';if(tab_info_exists)start_tab='info';if(tab_descr_exists)start_tab='descr';if(tab_name=='#info')start_tab='info';if(tab_name=='#comp')start_tab='comp';if(tab_name=='#disc')start_tab='disc';if(tab_name=='#family')start_tab='family';if(tab_name=='#comment')start_tab='comment';if(start_tab!='')TabShow(start_tab);}
function number_format(number,decimals,dec_point,thousands_sep)
{var i,j,kw,kd,km,minus="";if(number<0){minus="-";number=number*-1;}
if(isNaN(decimals=Math.abs(decimals))){decimals=2;}
if(dec_point==undefined){dec_point=",";}
if(thousands_sep==undefined){thousands_sep=".";}
i=parseInt(number=(+number||0).toFixed(decimals))+"";if((j=i.length)>3){j=j%3;}else{j=0;}
km=(j?i.substr(0,j)+thousands_sep:"");kw=i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+thousands_sep);kd=(decimals?dec_point+Math.abs(number-i).toFixed(decimals).replace(/-/,0).slice(2):"");return km+kw+kd;}
function print_price(price,curr,ot)
{price=price.split("'").join("");price=price.split(",").join(".");price_usd=price*curr;if(ot==0)
{price_usd=number_format(price_usd,2,',','\'');document.write(price_usd);}
else
{price_usd=number_format(price_usd,2,',','');if(price_usd.substr(price_usd.length-3)==',00')price_usd=price_usd.substr(0,price_usd.length-3);document.write(price_usd);}}
function fast_buy(code)
{var line='fastorder.php?code='+code+'&'+phpsessid;hs.htmlExpand(null,{src:line,width:400,height:320,objectType:'iframe',outlineType:'rounded-white',wrapperClassName:'draggable-header',headingText:'Оформление быстрого заказа'});}
function select_value(id)
{eval('document.select_goods.value_'+id+'.checked = true');DoSelect();}
function unselect_value(id)
{eval('document.select_goods.value_'+id+'.checked = false');DoSelect();}
