
var timer=new Array();var current_p;var qb_pos=0;var qb=false;var qb_image_loading=false;var prinfo;var groups=new Array();var current_cat_id;var current_group_id;function getCat(group_id){if(groups[group_id]){getCatCB(groups[group_id]);}else{gps=findObj('qb_cats');gps.options.length=0;gps.options[0]=new Option('Loading...',"");rpc.methodName="getCatsinGroups_qb";rpc(new Array(group_id.toString()),getCatCB);current_group_id=group_id;}}
function getProductsinCats(){current_cat_id=findObj('qb_cats').value;if(cats[current_cat_id]){getPinCCB(cats[current_cat_id],null);}else{qb_loading();rpc.methodName="getProductsinCat";rpc(new Array(current_cat_id.toString()),getPinCCB);}}
function getPinCCB(a,b){if(b){alert(b);}else{product_ids=a;qb_display_products();cats[current_cat_id]=a;}}
function getCatCB(a,b)
{if(b){alert(b);}else{gps=findObj('qb_cats');gps.options.length=0;groups[a[0].group_id]=a;gps.options[gps.options.length]=new Option("Select Category","");for(i=0;i<a.length;i++){gps.options[gps.options.length]=new Option(a[i].cat_new_name,a[i].cat_id);}}}
function scrollStrip(amount){if(timer.length!=0||(qb_pos+amount)>=product_ids.length||(qb_pos+amount)<0)
return;img=findObj('img_'+qb_pos).style;img.borderColor='#B9CBCB';img.cursor='pointer';qb_pos+=amount;strip=findObj('film_strip');style=strip.style;myMove(amount);if(qb_pos==0)
{sw_tb_but_off('up');sw_tb_but_off('qb_prev');}
else
{sw_tb_but('up');sw_tb_but('qb_prev');}
if((qb_pos+1)==product_ids.length)
{sw_tb_but_off('dn2');sw_tb_but_off('qb_next');}
else
{sw_tb_but('dn2');sw_tb_but('qb_next');}}
function clearTimer(){for(k=0;k<timer.length;k++)
clearInterval(timer[k]);timer=new Array();}
function myMove(incs){this.step=4;var isize=89;if(typeof this.target!="number")
this.target=89*incs;strip=findObj('film_strip');style=strip.style;this.topY=parseInt(style.top);this.topY=this.topY-(89*incs);style.top=this.topY+'px';style.clip="rect("+(this.topY*-1)+"px 87px "+(446+(this.topY*-1))+"px 0px)";img=findObj('img_'+qb_pos);img.style.borderColor='#FEEDE5';img.style.cursor='auto';qb_loadProduct(img.product_id);}
var qb_pos=0;function qb_loading(){findObj('qb_prod_desc').className='qb_dim';findObj('qb_prod_price').className='qb_dim';findObj('qbcart').style.visibility='hidden';qb_showPicture();sw_tb_but_off('qb_sb_1');sw_tb_but_off('qb_sb_2');sw_tb_but_off('qb_sb_3');findObj('qb_image').style.backgroundImage="url(images/loading.gif)";findObj('qb_image').style.backgroundPosition="center center";findObj('also_design').style.display='none';}
qb_image=new Image();qb_image.onload=displayImage;function displayImage(theImage){if(qb_progress){qb_image_loading=false;return;}
else{qb_image_loading=false;findObj('qb_image').style.backgroundImage="url("+this.src+")";findObj('qb_image').style.backgroundPosition="center -20px";}}
function qb_loadProduct(product_id){qb_loading();qb_progress=true;current_p=product_id;qb_image.src='http://www.montred.com/images/products/'+product_id+'_q.jpg';findObj('product_id').value=product_id;if(qb_results[product_id]){qb_loadProductCB(qb_results[product_id],null);return;}
id=product_id.toString();rpc.methodName="getProductCachedDetails_qb";rpc(new Array(id),qb_loadProductCB);}
var t="";function qb_loadProductCB(a,b){if(b){alert(b);}else{prinfo=a.prinfo;if(current_p!=prinfo.product_id)
return;qb_results[prinfo.product_id]=a;rp=a.rp;also=a.also;acc=a.ac;plink='pid-'+a.prinfo.id+'-'+a.prinfo.pmt.toLowerCase()+'-'+a.prinfo.pt.toLowerCase()+'.html';findObj('qb_title').innerHTML=a.prinfo.nm;findObj('qb_title').href=plink;findObj('goto_product_quickbrowse').href=plink;findObj('linkTheProductImage').href=plink;findObj('qb_desc_txt').innerHTML=a.prinfo.dsc;findObj('qb_price').innerHTML="<b>Price: &nbsp; $"+prinfo.sp.replace(".00","")+"</b>";findObj('qbcart').style.visibility='visible';shippingInfoText="";findObj('qb_shipping_info_days').innerHTML=prinfo.tts;if(prinfo.pt=="Ring"){var ringSizeRange=prinfo.rs;var ringSizeRangeTemp=new Array();ringSizeRangeTemp=ringSizeRange.split('-');rss=findObj('ring_size');rss.options.length=0;rss.options[rss.options.length]=new Option("Select","");for(i=parseInt(ringSizeRangeTemp[0]);i<=parseInt(ringSizeRangeTemp[1]);i=i+.5){rss.options[rss.options.length]=new Option(i,i);}
findObj('ring_sizer').style.display='';}else{findObj('ring_sizer').style.display='none';}
t=qb_details_tr("Product Info");t+=qb_details(prinfo,"product_id",'',"Product #");t+=qb_details(prinfo,"pm",'',"Metal");t+=qb_details(prinfo,"ps",'',"Stone");t+=qb_details(prinfo,"cm",'',"Chain Metal");t+=qb_details(prinfo,"cl",'inches',"Chain Length");t+=qb_details(prinfo,"pl",'mm',"Length");t+=qb_details(prinfo,"pw",'mm',"Width");t+=qb_details(prinfo,"d",'mm',"Diameter");t+=qb_details(prinfo,"h",'mm',"height");t+=qb_details(prinfo,"w",'gm',"Approximate weight");t+=qb_details(prinfo,"cm",'',"Clasp Metal");t+=qb_details(prinfo,"ct",'',"Clasp Type");t+=qb_details(prinfo,"f",'',"finish");if(stoneinfo=a.stoneinfo)
{if(ds=stoneinfo.d)
{for(i=0;i<ds.length;i++){d=ds[i];t+=qb_details_tr("Diamond Info");t+=qb_details(d,"dn2",'',"Number of Diamonds");t+=qb_details(d,"ds",'',"Shape");t+=qb_details(d,"dc",'',"Total Carat Weight");t+=qb_details(d,"dc2",'',"Cut");t+=qb_details(d,"dc3",'',"Color");t+=qb_details(d,"dc4",'',"Clarity");t+=qb_details(d,"dst",'',"Setting Type");}}
if(gs=stoneinfo.g)
{for(i=0;i<gs.length;i++){g=gs[i];t+=qb_details_tr("Gemstone Info");t+=qb_details(g,"n",'',"Number of Gemstones");t+=qb_details(g,"gt",'',"Type");t+=qb_details(g,"gs",'',"Shape");t+=qb_details(g,"gc",'',"Color");t+=qb_details(g,"gc1",'',"Clarity");t+=qb_details(g,"gst",'',"Setting Type");t+=qb_details(g,"gd",'mm',"Dimension");}}
if(ps=stoneinfo.p)
{for(i=0;i<ps.length;i++)
{p=ps[i];t+=qb_details_tr("Pearl Info");t+=qb_details(p,"n",'',"Number of Pearls");t+=qb_details(p,"ps",'',"Shape");t+=qb_details(p,"pc",'',"Color");t+=qb_details(p,"pt",'',"Type");t+=qb_details(p,"pl",'',"Luster");t+=qb_details(p,"pu",'',"Uniformity");t+=qb_details(p,"psm",'',"Surface Markings");t+=qb_details(p,"pst",'',"Setting Type");t+=qb_details(p,"pgs",'',"Graduated Size");t+=qb_details(p,"pms",'',"Mimimum Size");}}}
findObj('qb_info_table').innerHTML='<table cellpadding=1 cellspacing=0 width=278 border=0>'+t+'</table>';if(rp){txt='';for(i=0;i<rp.length;i++){txt+='<img src="http://www.montred.com/images/products/'+rp[i].id+'_t.jpg" style="cursor:pointer" onclick="qb_loadProduct('+rp[i].id+'); return false;" align=left><font style="cursor:pointer" onclick="qb_loadProduct('+rp[i].id+'); return false;">'+rp[i].name+'</font><br /><b>$'+rp[i].sp.replace(".00","")+'</b><br /><a href="#" onclick="qb_loadProduct('+rp[i].id+'); return false;">View product</a><br clear="all" /><br clear="all" /><br clear="all" />';}
findObj('rel_prods_desc').innerHTML=txt;sw_tb_but('qb_sb_2');}
if(acc.metal=="found"){also_text='';for(i=0;i<also.length;i++){if(also[i].relation=='metal')
also_text+='<a href="#" class="'+also[i].m.toLowerCase().replace(" ","-")+'" onclick="qb_loadProduct('+also[i].id+'); return false;" style="text-decoration:none"><img src="images/'+also[i].m.toLowerCase()+'.gif" border=0 style="padding-right: 3px;"> <u>'+also[i].m+'</u></a><br clear=all />';}
findObj('also_table').style.display='';findObj('also_td').innerHTML=also_text;}else{findObj('also_table').style.display='none';findObj('also_td').innerHTML='';}
if(acc.stone=="found"){also_text='<strong>Also see the design in</strong><br /><table width="100" border="0" cellspacing="0" cellpadding="0" style="margin:0 auto;" id="also_table_2"><tr>';for(i=0;i<also.length;i++){if(also[i].relation=='gemstone'){also_text+='<td><a href="#" onclick="qb_loadProduct('+also[i].id+'); return false;">'+also[i].g+'</a><br>$'+also[i].sp.replace(".00","")+'</td>';}
if(also[i].relation=='diamond'){also_text+='<td><a href="#" onclick="qb_loadProduct('+also[i].id+'); return false;">'+also[i].c+'_ct._tw.</a><br>$'+also[i].sp.replace(".00","")+'</td>';}}
also_text+='</tr></table>';findObj('also_design').style.display='';findObj('also_table_2_tr').innerHTML=also_text;findObj('qb_image').style.marginTop="0px";}else{findObj('qb_image').style.marginTop="35px";findObj('also_design').style.display='none';findObj('also_table_2_tr').innerHTML='';}
sw_tb_but_off('qb_sb_1');sw_tb_but('qb_sb_3');sw_tb_but('goto_qb');findObj('qb_desc2').style.display='';findObj('qb_prod_desc').className='qb_high';findObj('qb_prod_price').className='qb_high';qb_progress=false;if(!qb_image_loading){findObj('qb_image').style.backgroundImage='url(http://www.montred.com/images/products/'+prinfo.product_id+'_q.jpg)';findObj('qb_image').style.backgroundPosition="center -20px";}}}
function submitQBCart(){if(qb_results[current_p].prinfo.pt=="Ring"&&findObj('ring_size').options.selectedIndex==0)
{alert('Please select a ring size');return false;}
findObj('qbcart').submit();}
function qb_showPicture(){qb_hideAll();findObj('qb_image').style.display='';sw_tb_but_off('qb_sb_1');if(qb_results[product_ids[qb_pos]])
if(qb_results[product_ids[qb_pos]].ac.stone)
findObj('also_design').style.display='';}
function qb_showRP(){qb_hideAll();findObj('qb_rel_prods').style.display='';sw_tb_but_off('qb_sb_2');}
function qb_showShp(){qb_hideAll();sw_tb_but_off('qb_sb_3');findObj('qb_shipping_info').style.display='';}
function qb_showInfo(){qb_hideAll();findObj('qb_info_table').style.display='';}
function qb_hideAll(){findObj('qb_info_table').style.display='none';findObj('qb_image').style.display='none';findObj('qb_rel_prods').style.display='none';findObj('also_design').style.display='none';findObj('qb_shipping_info').style.display='none';sw_tb_but('qb_sb_1');sw_tb_but('qb_sb_2');sw_tb_but('qb_sb_3');}
function sw_tb_but(id){img=findObj(id);with(img){src='images/'+id+'_on.gif';style.cursor='pointer';}}
function sw_tb_but_off(id){img=findObj(id);with(img){src='images/'+id+'_off.gif';style.cursor='default';}}
function qb_details_tr(head){return'<tr><td class="head" colspan=2>'+head+'</tr>';}
function qb_details(obj,prop,units,txt)
{if(typeof this.html=="undefined")
this.html='';if(m=eval('obj.'+prop))
{return"<tr><td>"+txt+":</td><td>"+m+" "+units+"</td></tr>";}
return this.html;}
function qb_display_products(){qb_pos=0;sw_tb_but_off('up');sw_tb_but_off('qb_prev');sw_tb_but('dn2');sw_tb_but('qb_next');strip=findObj('film_strip');strip.innerHTML="";style=strip.style;style.clip="rect(0px 87px 446px 0px)";style.top="0px";var div=document.createElement("div");div.className='empty';div.innerHTML='&nbsp;';strip.appendChild(div);for(i=0;i<product_ids.length;i++)
{image=new Image();image.src='http://www.montred.com/images/products/'+product_ids[i]+'_t.jpg';image.height=85;image.width=85;image.id='img_'+i;image.pos=i;image.product_id=product_ids[i];if(i==0){image.style.borderColor='#FEEDE5';image.style.cursor='auto';}
strip.appendChild(image);}
var div=document.createElement("div");div.className='empty';div.innerHTML='&nbsp;';strip.appendChild(div);var div=document.createElement("div");div.className='empty';div.innerHTML='&nbsp;';strip.appendChild(div);var div=document.createElement("div");div.className='empty';div.innerHTML='&nbsp;';strip.appendChild(div);Behaviour.apply();scrollStrip(1);}
var myrules={'#film_strip img':function(el){el.onmousedown=function(){if((this.pos-qb_pos)!=0)
scrollStrip(this.pos-qb_pos);}}};Behaviour.register(myrules);