var ImageGallery={};ImageGallery.images={};ImageGallery.primary_image="";ImageGallery.photogallery="";ImageGallery.curr_thumb_index=0;ImageGallery.curr_thumb_page=0;ImageGallery.THUMBS_TO_SHOW=4;ImageGallery.createActionMap=function(){ImageGallery.action_map={fetch_images:{remote:{url:"/index.php/ImageGallery",method:"post",parameters:{},onSuccess:ImageGallery.fetchImagesSuccess,onFailure:ImageGallery.fetchImagesFailure}}}};ImageGallery.init=function(c,d,a,b){ImageGallery.createActionMap();ImageGallery.primary_image=Com.$(c);ImageGallery.photogallery=Com.$(d);ImageGallery.images.default_image=a;ImageGallery.images.default_thumb=b};ImageGallery.fetchImagesLocal=function(a){ImageGallery.images.image_list=a;if(ImageGallery.photogallery!==undefined){ImageGallery.populatePhotoGallery()}};ImageGallery.fetchImagesRemote=function(f,a,b,e,d){var c=ImageGallery.action_map.fetch_images.remote;c.parameters.year=f;c.parameters.make_name=a;c.parameters.model_name=b;if(e!==undefined){c.parameters.bodystyle=e}if(d!==undefined){c.parameters.style=d}ImageGallery.ajaxRequest(c)};ImageGallery.ajaxRequest=function(b){var a=new Com.Ajax();a.ok=ImageGallery.ajaxResponder(b.onSuccess);a.er=function(){b.onFailure(b)};a.ex({url:b.url,method:b.method,query:ImageGallery.paramsToQueryString(b.parameters)})};ImageGallery.ajaxResponder=function(a){return function(d){try{var c=Com.evalJSON(d.responseText);a(c)}catch(b){}}};ImageGallery.paramsToQueryString=function(b){var c="",a="";for(a in b){if(b.hasOwnProperty(a)){c+=a+"="+escape(b[a]);c+="&"}}c=c.substr(0,(c.length-1));return c};ImageGallery.fetchImagesSuccess=function(a){ImageGallery.images=a;if(ImageGallery.photogallery!==undefined){ImageGallery.populatePhotoGallery()}};ImageGallery.fetchImagesFailure=function(){ImageGallery.images={}};ImageGallery.populatePhotoGallery=function(){var a=0,c=0,b='<table border="0" cellspacing="0" cellpadding="0">  <tr>    <td>      <a style="color:#AAAAAA; font-weight:bold; font-size:8.8pt;           font-family:verdana,arial,helvetica,sans-serif; letter-spacing:0px;           text-decoration: underline; cursor: pointer;"           onmouseover="style.color=\'#DDDDDD\';"           onmouseout="style.color=\'#AAAAAA\';"           onclick="ImageGallery.scrollPhotoGalleryPrevPage()">        <div style="width:30px;"><img src="/images/make_model/gallery_arrow_left.png"/></div>      </a>    </td>    <td>      <div style="padding:0px; margin:0px; width:396px;height:62px">        <table cellspacing=0 border=0><tr>';while(true){b+="<td width=100 height=60 align=center>";if(ImageGallery.curr_thumb_page===0&&a===0){b+='   <div style="border:#cccccc solid 1px; padding-top:5px; width:85px; height:55px; vertical-align:bottom">    <img style="width: 80px; height: 50px; cursor:pointer;"        onclick="ImageGallery.viewImage(\''+ImageGallery.images.default_image+'\')"        src="'+ImageGallery.images.default_thumb+'"/>   </div>'}else{if(ImageGallery.curr_thumb_index<ImageGallery.images.image_list.length){c=ImageGallery.curr_thumb_index;b+='   <div style="border:#cccccc solid 1px; padding-top:5px; width:85px; height:55px; vertical-align:bottom">    <img style="cursor:pointer;"         onclick="ImageGallery.viewImage(            \'http://images.newcars.com/images/car-pictures/large/'+ImageGallery.images.image_list[c]+'.png\')"         src="http://images.newcars.com/images/car-pictures/thumbnail/'+ImageGallery.images.image_list[c]+'.png"/>   </div>';ImageGallery.curr_thumb_index+=1}}b+="</td>";a+=1;if(a===ImageGallery.THUMBS_TO_SHOW){break}}b+='        </tr></table>      </div>    </td>    <td>      <a style="color:#AAAAAA; font-weight:bold; font-size:8.8pt;           font-family:verdana,arial,helvetica,sans-serif; letter-spacing:0px;           text-decoration: underline; cursor: pointer;"           onmouseover="style.color=\'#DDDDDD\';"           onmouseout="style.color=\'#AAAAAA\';"           onclick="ImageGallery.scrollPhotoGalleryNextPage()">        <div style="width:30px;"><img src="/images/make_model/gallery_arrow_right.png"/></div>      </a>    </td>    <td>  </tr></table>';ImageGallery.photogallery.innerHTML=b};ImageGallery.viewImage=function(a){ImageGallery.primary_image.src=a};ImageGallery.scrollPhotoGalleryNextPage=function(){if(ImageGallery.curr_thumb_index>=ImageGallery.images.image_list.length){return}ImageGallery.curr_thumb_page+=1;ImageGallery.populatePhotoGallery()};ImageGallery.scrollPhotoGalleryPrevPage=function(){if(ImageGallery.curr_thumb_page===0){return}ImageGallery.curr_thumb_page-=1;ImageGallery.curr_thumb_index=ImageGallery.curr_thumb_page*ImageGallery.THUMBS_TO_SHOW;ImageGallery.populatePhotoGallery()};