VehicleImageControl.prototype.selectedView=null;var hideVehicleImageOnLoad=false;VehicleImageControl.prototype.addImageSet=function(name){this.imageSet[name]=
{viewNames:[],
images:[],
largeImages:[],
viewNameToIndex:{},
imageCount:0,
selectedViewNames:[],
imageType:[]
};}
function VehicleImageControl(width,height,vehicleClass,enlargerImage){this.imageSet=new Array();this.image=newDocObj(null,0,0,273,169,"");this.enlarger=newDocObj(null,0,0,0,10,"");this.selector=newDocObj(null,0,0,0,30,"");if(vehicleClass){this.image.setClass(vehicleClass);this.enlarger.setClass(vehicleClass);this.selector.setClass(vehicleClass);}
this.width=width;this.height=height;this.useEnlargeFlash=false;this.enlarger.docObj.style.width='100';this.enlargerImage=enlargerImage;internal_VIC=this;}
VehicleImageControl.prototype.addImage=function(imageSetName,viewName,selectedViewName,imageURL,largeImageURL,imageType){var index=this.imageSet[imageSetName].imageCount++;this.imageSet[imageSetName].viewNames[index]=viewName;this.imageSet[imageSetName].selectedViewNames[index]=selectedViewName;this.imageSet[imageSetName].images[index]=imageURL;this.imageSet[imageSetName].largeImages[index]=largeImageURL;this.imageSet[imageSetName].viewNameToIndex[viewName]=index;this.imageSet[imageSetName].imageType[index]=imageType;}
VehicleImageControl.prototype.selectView=function(viewName,imageSetName){this._selectView(viewName,imageSetName);this.update(imageSetName);if(this.imageSet[imageSetName].imageType[this.selectedIndex]=="yappa"){_hbLink("Exterior3d");}
}
VehicleImageControl.prototype._selectView=function(viewName,imageSetName){var position=this.imageSet[imageSetName].viewNameToIndex[viewName];this.setCookie(viewName);if(typeof position=='undefined')return;this.selectedIndex=position;this.selectedView=this.imageSet[imageSetName].viewNames[position];}
VehicleImageControl.prototype.updateExteriorImage=function(imageSetName,imageURL,largeImageURL,selectedViewIndex){this.imageSet[imageSetName].images[selectedViewIndex]=imageURL;this.imageSet[imageSetName].largeImages[selectedViewIndex]=largeImageURL;this.selectedIndex=selectedViewIndex;this.selectedView=this.imageSet[imageSetName].viewNames[selectedViewIndex];this.update(imageSetName);}
VehicleImageControl.prototype.update=function(imageSetName){this.selector.setInnerHTML("");this.image.setInnerHTML("");this.enlarger.setInnerHTML("");if(this.imageSet[imageSetName].imageCount==0){this.selectedView=null;this.selectedIndex=-1;this.enlarger.hide();this.image.hide();this.selector.hide();}else{var pos=-1;if(this.selectedView==null||
(typeof this.imageSet[imageSetName].viewNameToIndex[this.selectedView]=='undefined')){var selImgView=this.getCookie('selectedImageView');if(selImgView==null||(selImgView=='undefined')){selImgView=this.imageSet[imageSetName].viewNames[0];}
var isPresent=false;for(var i=0;i<this.imageSet[imageSetName].viewNames.length;i++){if(isNaN(this.imageSet[imageSetName].viewNames[i])&&isNaN(selImgView)){if((this.imageSet[imageSetName].viewNames[i]).match(selImgView)!=null){isPresent=true;pos=i;}
}else if((!isNaN(this.imageSet[imageSetName].viewNames[i]))&&(!isNaN(selImgView))){if(this.imageSet[imageSetName].viewNames[i]==selImgView){isPresent=true;pos=i;}
}
}
if(isPresent){this._selectView(selImgView,imageSetName);}
else if(this.imageSet[imageSetName].viewNames[0]!='undefined'||this.imageSet[imageSetName].viewNames[0]!=null){this._selectView(this.imageSet[imageSetName].viewNames[0],imageSetName);pos=0;}
}else{pos=this.imageSet[imageSetName].viewNameToIndex[this.selectedView];this._selectView(this.imageSet[imageSetName].viewNames[pos],imageSetName);}
var s="<nobr>",x;for(x in this.imageSet[imageSetName].viewNames){if(pos==x){s+="<img src='"+this.imageSet[imageSetName].selectedViewNames[x]+"'>";}else{s+="<a href=\"javascript:internal_VIC.selectView('"+this.imageSet[imageSetName].viewNames[x]+"', '"+imageSetName+"')\"><img src='"+this.imageSet[imageSetName].viewNames[x]+"'></a>";}
}
s+="</nobr>";this.selector.setInnerHTML(s);var selectedViewIsFlash=false;var selectedViewIsYappa=false;if(this.imageSet[imageSetName].imageType[this.selectedIndex]=="flash"){this.image.setInnerHTML(this.getFlashHTML(this.imageSet[imageSetName].images[this.selectedIndex]));selectedViewIsFlash=true;}else if(this.imageSet[imageSetName].imageType[this.selectedIndex]=="yappa"){var yappaObj=this.imageSet[imageSetName].images[this.selectedIndex].yappa;this.setYappaHTML(yappaObj,this.selectedIndex);selectedViewIsYappa=true;}else{this.image.setInnerHTML("<table><tr><td height=169 width=273 valign='middle'><img src='"+this.imageSet[imageSetName].images[this.selectedIndex]+"'></td></tr></table>");}
var enlargeURL;if(selectedViewIsFlash){enlargeURL="javascript:internal_VIC.enlargeFlash('"+imageSetName+"')";}else if(selectedViewIsYappa){enlargeURL="javascript:internal_VIC.enlargeYappa('"+imageSetName+"')";}else{enlargeURL="javascript:internal_VIC.enlarge('"+imageSetName+"')";}
if(this.enlargerImage!=null){this.enlarger.setInnerHTML("<a href=\""+enlargeURL+"\"><img src=\""+this.enlargerImage+"\"/></a> ");}else{this.enlarger.setInnerHTML("<a href=\""+enlargeURL+"\">enlarge image +</a> ");}
this.enlarger.show();this.selector.show();this.image.show();}
}
VehicleImageControl.prototype.setCookie=function(viewName){setCookieValue('selectedImageView',viewName);}
VehicleImageControl.prototype.getCookie=function(name){return getCookieValue(name);}
VehicleImageControl.prototype.enlarge=function(imageSetName){var path=this.imageSet[imageSetName].largeImages[this.selectedIndex];openAndResizeEnlargerWindow(path);}
VehicleImageControl.prototype.enlargeFlash=function(imageSetName){var path=this.imageSet[imageSetName].largeImages[this.selectedIndex];openFlashEnlargerWindow(path);}
VehicleImageControl.prototype.enlargeYappa=function(imageSetName){var parameter=this.imageSet[imageSetName].largeImages[this.selectedIndex];openYappaEnlargerWindow(parameter);}
var currentImageCookie;VehicleImageControl.prototype.hideFlashImage=function(imageSetName){currentImageCookie=this.getCookie('selectedImageView');if(this.imageSet[imageSetName]!=null&&this.imageSet[imageSetName].viewNames.length>0){this.setCookie(this.imageSet[imageSetName].viewNames[0]);this.update(imageSetName);}
}
VehicleImageControl.prototype.revertToPreviousImage=function(){if(currentImageCookie!=null){this.setCookie(currentImageCookie);}
}
VehicleImageControl.prototype.setEnlargeFlash=function(value){this.useEnlargeFlash=value;}
VehicleImageControl.prototype.getFlashHTML=function(images){var flashMovie="";if(this.useEnlargeFlash){flashMovie="360ViewLarge.swf";}else{flashMovie="360View.swf";}
var currentLocation=new String(window.location);var protocol=currentLocation.substr(0,currentLocation.indexOf("://"));var region=getRegion();var codebase=protocol+"://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0";return'<div style="margin-top: 13px;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
+' codebase="'+codebase+'"'
+' width="'+this.width+'"'
+' height="'+this.height+'">'
+'<param name="movie" value="'+region+'/flash/'+flashMovie+'">'
+'<param name="loop" value="false">'
+'<param name="menu" value="false">'
+'<param name="quality" value="high">'
+'<param name="bgcolor" value="'+vehicleBackgroundColor+'">'
+'<param name="FlashVars" value="images='+images+'">'
+'<embed src="'+region+'/flash/'+flashMovie+'"'
+' loop="false"'
+' menu="false"'
+' quality="high"'
+' bgcolor="'+vehicleBackgroundColor+'"'
+' width="'+this.width+'"'
+' height="'+this.height+'"'
+' type="application/x-shockwave-flash"'
+' pluginspage="http://www.macromedia.com/go/getflashplayer"'
+' FlashVars="images='+images+'">'
+'<\/embed>'
+'<\/object><\/div>';}
VehicleImageControl.prototype.setYappaHTML=function(yappaObj,idx){var divID="yappaDiv"+idx;this.image.setInnerHTML("<div id='"+divID+"' style='margin-top:13px;'></div>");setYappa(this.image,divID,yappaObj);}
VehicleImageControl.prototype.hideAll=function(){this.enlarger.hide();this.image.hide();this.selector.hide();}
VehicleImageControl.prototype.showAll=function(){this.enlarger.show();this.image.show();this.selector.show();}
VehicleImageControl.prototype.moveEnlargerTo=function(x,y){if(navOffset){y+=navOffset;}
this.enlarger.moveTo(x,y);}
VehicleImageControl.prototype.moveSelectorTo=function(x,y){if(navOffset){y+=navOffset;}
this.selector.moveTo(x,y);}
VehicleImageControl.prototype.moveImageTo=function(x,y){if(navOffset){y+=navOffset;}
this.image.moveTo(x,y);}
function setYappa(rootEle,divID,yappaObj){var appletObj=document.createElement('applet');if(rootEle){getDocObjFromElement(rootEle,divID).docObj.appendChild(appletObj);}else{getDocObj(divID).docObj.appendChild(appletObj);}
for(var attr in yappaObj.attribute){for(var key in yappaObj.attribute[attr]){appletObj.setAttribute(key,yappaObj.attribute[attr][key]);}
}
for(var paramAttr in yappaObj.param){for(var paramKey in yappaObj.param[paramAttr]){var paramEle=document.createElement('param');paramEle.setAttribute("name",paramKey);paramEle.setAttribute("value",yappaObj.param[paramAttr][paramKey]);appletObj.appendChild(paramEle);}
}
}
