
Array.prototype.indexOf=function(n){for(var i=0;i<this.length;i++){if(this[i]===n){return i;}}return-1;}
var isOpera=navigator.userAgent.indexOf('Opera')>-1;image=new Image();image.onload=displayImage
var qi_progress=false;var qi_image_loading=false;function qi_loadProduct(product_id){qi_image_loading=true;image.src='http://www.montred.com/images/products/'+product_id+'_q.jpg';if(qi_results[product_id])
displayQi(qi_results[product_id]);else{loading();id=""+product_id+"";jsonrpc.methodName="qi_get_product_info";qi_progress=true;jsonrpc(new Array(id),qi_loadProductCB);}}
function qi_loadProductCB(a,b)
{if(b)
alert("Sorry, request failed. Please try again later.");else{qi_progress=false;qi_results[a.id]=a;displayQi(a);}}
function qi_next(){if(qi_progress)
return;if(qi_pos<(product_ids.length-1))
{qi_pos++;loadProduct(qi_pos);}}
function qi_previous(){if(qi_progress)
return;if(qi_pos>0)
{qi_pos--;loadProduct(qi_pos);}}
function qi_highlight(img,status){findObj(img).className='qi_'+status;findObj(img).src='images/'+img+'_'+status+'.gif';}
function qiPID(product_id){if(isOpera)
findObj('ifram').style.display='none';pos=findpos(findObj('p_'+product_id));height=pos.y+101;findObj('qi_layer').style.top=height+'px';findObj('qi_layer').style.left='220px';qi_pos=product_ids.indexOf(product_id);if(qi_results[product_id])
displayQi(qi_results[product_id])
else
loadProduct(qi_pos);}
function loadProduct(index){qi_pos=index;if(qi_results[product_ids[qi_pos]])
displayQi(qi_results[product_ids[qi_pos]])
else
qi_loadProduct(product_ids[qi_pos]);}
function loading(){Drag.init(findObj('imgholder'),findObj('qi_layer'));Drag.init(findObj('qi_drag'),findObj('qi_layer'));qi_highlight('qi_previous_img','off');qi_highlight('qi_next_img','off');findObj('qi_image').style.backgroundImage="url(images/loading.gif)";findObj('qi_image').style.backgroundPosition="center center";findObj('go_to_link').href="#";findObj('image_link').href="#";findObj('image_link').className='qi_off';findObj('go_to_link').className='qi_off';findObj('tool_bar').innerHTML='';qi_highlight('goto_img','off');findObj('qi_info').className='qi_info_off';findObj('more_link').style.display='none';}
function displayQi(res){if(qi_progress)
return;plink='pid-'+res.id+'-'+res.mt.toLowerCase()+'-'+res.pt.toLowerCase()+'.html';if(affid)
plink+='?affid='+affid;qi_text='<div style="height:190px;" class="qi_info" id="qi_i"><img src="images/qi.gif" alt="Quick Info" width="85" height="21" /><h1><a href="'+plink+'">'+res.title+'</a></h1><h1>Price : $'+res.price+'</h1><div id="qi_desc">'+res.descr+'<img src="images/spacer.gif" id="sp_pos" align="baseline"></div></div>';findObj('qi_info').innerHTML=qi_text;findObj('qi_info').className='qi_info';if(!qi_image_loading){findObj('qi_image').style.backgroundImage='url(http://www.montred.com/images/products/'+res.id+'_q.jpg)';findObj('qi_image').style.backgroundPosition="-10px -10px";}
findObj('go_to_link').href=plink;findObj('image_link').href=plink;findObj('image_link').className='qi_on';findObj('go_to_link').className='qi_on';qi_highlight('goto_img','on');findObj('qi_img').src='images/spacer.gif';if(qi_pos==(product_ids.length-1))
qi_highlight('qi_next_img','off');else
qi_highlight('qi_next_img','on');if(qi_pos==0)
qi_highlight('qi_previous_img','off');else
qi_highlight('qi_previous_img','on');p=findObj('sp_pos');pp=findpos(p);or=findpos(findObj('qi_layer'));h=pp.y-or.y;findObj('more_link').href=plink;if(h>210)
findObj('more_link').style.display='block';else
findObj('more_link').style.display='none';urchinTracker("/QI-pid-"+res.id+".html");if(res.also.length>0)
{qi_tool_text="Also available in: ";for(i=0;i<res.also.length;i++)
{qi_tool_text+="<span class='qi_on' onclick='qi_loadProduct(\""+res.also[i].id+"\")'><img src='images/"+res.also[i].m.toLowerCase()+".gif' style='padding-right: 3px;'><font style='text-decoration:underline;'>"+res.also[i].m+"</font></span>&nbsp;&nbsp;";}
findObj('tool_bar').innerHTML=qi_tool_text;}}
function displayImage(theImage){if(qi_progress){qi_image_loading=false;return;}
else{qi_image_loading=false;findObj('qi_image').style.backgroundImage="url("+this.src+")";findObj('qi_image').style.backgroundPosition="-10px -10px";}}
function qi_on(id)
{img=id+'_img';img=findObj(img);img.src='images/qi_on.gif';img.style.height='27px';img.style.width='27px';img.style.margin='0 5px 0 26px';pos=findpos(findObj(id+'_img'));height=pos.y+8;width=pos.x-50;findObj('QI_Action_show').style.top=height+'px';findObj('QI_Action_show').style.left=width+'px';findObj('QI_Action_show').style.display="block";}
function qi_off(id)
{img=id+'_img';img=findObj(img);img.src='images/qi_off.gif';img.style.height='23px';img.style.width='23px';img.style.margin='0 5px 0 30px';findObj('QI_Action_show').style.display="none";}
var Drag={obj:null,init:function(o,oRoot,minX,maxX,minY,maxY,bSwapHorzRef,bSwapVertRef,fXMapper,fYMapper)
{o.onmousedown=Drag.start;o.hmode=bSwapHorzRef?false:true;o.vmode=bSwapVertRef?false:true;o.root=oRoot&&oRoot!=null?oRoot:o;if(o.hmode&&isNaN(parseInt(o.root.style.left)))o.root.style.left="0px";if(o.vmode&&isNaN(parseInt(o.root.style.top)))o.root.style.top="0px";if(!o.hmode&&isNaN(parseInt(o.root.style.right)))o.root.style.right="0px";if(!o.vmode&&isNaN(parseInt(o.root.style.bottom)))o.root.style.bottom="0px";o.minX=typeof minX!='undefined'?minX:null;o.minY=typeof minY!='undefined'?minY:null;o.maxX=typeof maxX!='undefined'?maxX:null;o.maxY=typeof maxY!='undefined'?maxY:null;o.xMapper=fXMapper?fXMapper:null;o.yMapper=fYMapper?fYMapper:null;o.root.onDragStart=new Function();o.root.onDragEnd=new Function();o.root.onDrag=new Function();},start:function(e)
{var o=Drag.obj=this;e=Drag.fixE(e);var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);o.root.onDragStart(x,y);o.lastMouseX=e.clientX;o.lastMouseY=e.clientY;if(o.hmode){if(o.minX!=null)o.minMouseX=e.clientX-x+o.minX;if(o.maxX!=null)o.maxMouseX=o.minMouseX+o.maxX-o.minX;}else{if(o.minX!=null)o.maxMouseX=-o.minX+e.clientX+x;if(o.maxX!=null)o.minMouseX=-o.maxX+e.clientX+x;}
if(o.vmode){if(o.minY!=null)o.minMouseY=e.clientY-y+o.minY;if(o.maxY!=null)o.maxMouseY=o.minMouseY+o.maxY-o.minY;}else{if(o.minY!=null)o.maxMouseY=-o.minY+e.clientY+y;if(o.maxY!=null)o.minMouseY=-o.maxY+e.clientY+y;}
document.onmousemove=Drag.drag;document.onmouseup=Drag.end;return false;},drag:function(e)
{e=Drag.fixE(e);var o=Drag.obj;var ey=e.clientY;var ex=e.clientX;var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);var nx,ny;if(o.minX!=null)ex=o.hmode?Math.max(ex,o.minMouseX):Math.min(ex,o.maxMouseX);if(o.maxX!=null)ex=o.hmode?Math.min(ex,o.maxMouseX):Math.max(ex,o.minMouseX);if(o.minY!=null)ey=o.vmode?Math.max(ey,o.minMouseY):Math.min(ey,o.maxMouseY);if(o.maxY!=null)ey=o.vmode?Math.min(ey,o.maxMouseY):Math.max(ey,o.minMouseY);nx=x+((ex-o.lastMouseX)*(o.hmode?1:-1));ny=y+((ey-o.lastMouseY)*(o.vmode?1:-1));if(o.xMapper)nx=o.xMapper(y)
else if(o.yMapper)ny=o.yMapper(x)
Drag.obj.root.style[o.hmode?"left":"right"]=nx+"px";Drag.obj.root.style[o.vmode?"top":"bottom"]=ny+"px";Drag.obj.lastMouseX=ex;Drag.obj.lastMouseY=ey;Drag.obj.root.onDrag(nx,ny);return false;},end:function()
{document.onmousemove=null;document.onmouseup=null;Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode?"left":"right"]),parseInt(Drag.obj.root.style[Drag.obj.vmode?"top":"bottom"]));Drag.obj=null;},fixE:function(e)
{if(typeof e=='undefined')e=window.event;if(typeof e.layerX=='undefined')e.layerX=e.offsetX;if(typeof e.layerY=='undefined')e.layerY=e.offsetY;return e;}};