function checkbrowser(){var a="unknown";if(navigator.userAgent.indexOf("Netscape")>0){a="NS"}else{if(navigator.userAgent.indexOf("Firefox")>0){a="FF"}else{if(navigator.userAgent.indexOf("MSIE")>0&&navigator.userAgent.indexOf("Opera")<0){a="IE"}else{if(navigator.userAgent.indexOf("Opera")>0){a="OP"}}}}return a}function openhelp(a){helpwindow=window.open(a,"helpwindow","width=792,height=600,left=0,top=190,scrollbars=yes,resizable=yes ");helpwindow.focus()}function resizeboxes(c,b,f){if(f==null){f=0}var a=$("contentbox"+c);var h=$("contentbox"+b);if(a!=null&&typeof a!="undefined"&&h!=null&&typeof h!="undefined"){var e=checkbrowser();if(e=="IE"||e=="NS"){a.style.height="1%";h.style.height="1%";varCorrection=0;f=0}else{a.style.height="";h.style.height="";varCorrection=0;f=0}var g=a.clientHeight;var d=h.clientHeight;if(g<d){a.style.height=d+varCorrection+f+"px"}else{if(d<g){h.style.height=g+varCorrection+f+"px"}}}}function preloadImages(){var f=document;if(f.images){if(!f.p){f.p=new Array()}var e,c=f.p.length,b=preloadImages.arguments;for(e=0;e<b.length;e++){if(b[e].indexOf("#")!=0){f.p[c]=new Image;f.p[c++].src=b[e]}}}}function findObj(f,e){var c,b,a;if(!e){e=document}if((c=f.indexOf("?"))>0&&parent.frames.length){e=parent.frames[f.substring(c+1)].document;f=f.substring(0,c)}if(!(a=e[f])&&e.all){a=e.all[f]}for(b=0;!a&&b<e.forms.length;b++){a=e.forms[b][f]}for(b=0;!a&&e.layers&&b<e.layers.length;b++){a=findObj(f,e.layers[b].document)}if(!a&&document.getElementById){a=document.getElementById(f)}return a}function swapImage(){var e,d=0,b,c=swapImage.arguments;document.sr=new Array;for(e=0;e<(c.length-2);e+=3){if((b=findObj(c[e]))!=null){document.sr[d++]=b;if(!b.oSrc){b.oSrc=b.src}b.src=c[e+2]}}}function swapImgRestore(){var d,b,c=document.sr;for(d=0;c&&d<c.length&&(b=c[d])&&b.oSrc;d++){b.src=b.oSrc}}function hideselect(a){for(var b=a;b<=9;b++){$("select_0"+b).style.visibility="hidden";$("select_0"+b).style.position="absolute"}}function shownextselect(c){var b="dealerType"+c;b=$(b);var a="dealerFor"+c;a=$(a);if((b.selectedIndex!=0)&&(a.selectedIndex!=0)){$(c).style.visibility="visible";$(c).style.position="relative";$(c).style.height="100%"}}var checkflag="false";function check(c,b,a){if(checkflag=="false"){for(i=0;i<c.length;i++){c[i].checked=true}checkflag="true";return b}else{for(i=0;i<c.length;i++){c[i].checked=false}checkflag="false";return a}}function toggleCountySelection(){if($("country")){if($("countySelect")){hideFormField("countySelect")}var b=$("country");var a=b.getElementsByTagName("select")[0];if(a.value=="GB"){showFormField("countySelect")}a.onchange=function(){if(a.value=="GB"){showFormField("countySelect")}else{hideFormField("countySelect");$("countyValue").value=""}}}}function showFormField(a){$(a).style.display="inline"}function hideFormField(a){$(a).style.display="none"}function addEvent(d,c,a){if(d.addEventListener){d.addEventListener(c,a,false);return true}else{if(d.attachEvent){var b=d.attachEvent("on"+c,a);return b}else{return false}}}addEvent(window,"load",toggleCountySelection);function toggleDisplay(c,a){var b=$(a);if(b!=null&&typeof b!="undefined"){if(c.checked){b.style.display="block"}else{b.style.display="none"}}}function toggleEnabled(c,a){var b=$(a);if(b!=null&&typeof b!="undefined"){if(!c.checked){b.value="";b.style.backgroundColor="#DDD"}else{b.style.backgroundColor="#FFF"}b.readOnly=!c.checked}}function showVehicleDescription(){var b=$("standardVehicleDescription");var d=$("customTemplateDescription");var c=$("standardDescriptionTab");var a=$("htmlDescriptionTab");b.style.display="block";d.style.display="none";c.setAttribute("class","active");c.setAttribute("className","active");a.setAttribute("class","");a.setAttribute("className","")}function showHtmlDescription(){var b=$("customTemplateDescription");var d=$("standardVehicleDescription");var c=$("standardDescriptionTab");var a=$("htmlDescriptionTab");b.style.display="block";d.style.display="none";a.setAttribute("class","active");a.setAttribute("className","active");c.setAttribute("class","");c.setAttribute("className","")}function getXMLHttpObject(){var a=false;if(typeof XMLHttpRequest!="undefined"){a=new XMLHttpRequest()}if(!a){try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(b){a=null}}}return a}function ajaxPost(formId,target,displayDivId,serializeFields,executeOnSuccess,executeOnFailure){var form=$(formId);var displayDiv=$(displayDivId);var parameters=form.serialize();if(serializeFields!=null){parameters=serializeFields.toQueryString()}new Ajax.Request(target,{method:"post",parameters:parameters,onCreate:function(){},onSuccess:function(transport){var response=transport.responseText||"no response text";if(displayDiv){displayDiv.innerHTML=response}if(executeOnSuccess){eval(executeOnSuccess)}},onFailure:function(){if(executeOnFailure){eval(executeOnFailure)}}})}var DRAFT_SAVE_DEFAULT_ID="draftSaveDefault";var DRAFT_SAVE_PROGRESS_ID="draftSaveProgress";var DRAFT_SAVE_SUCCESS_ID="draftSaved";function showDraftSaveFeedback(a){$(DRAFT_SAVE_PROGRESS_ID).style.display="none";$(a).style.display="block";if(a==DRAFT_SAVE_SUCCESS_ID){updateLastSavedDraftWithCurrentTime()}window.setTimeout("showDraftSaveDefault('"+a+"')",2000)}function showDraftSaveDefault(a){$(a).style.display="none";$(DRAFT_SAVE_DEFAULT_ID).style.display="block"}function updateLastSavedDraftWithCurrentTime(){updateLastSavedDraft(Date.parse(new Date()))}function updateLastSavedDraft(c){try{if(typeof(c)!="number"&&typeof(lastSavedDraft)=="number"){c=lastSavedDraft}if(typeof(c)=="number"){var a=new Date(c);var h=a.getHours();var f=a.getMinutes();var b;if(0<=h&&h<12){b="AM";if(h==0){h=12}}else{b="PM";h=h-12;if(h==0){h=12}}if(h<10){h="0"+h}if(f<10){f="0"+f}var d=h+":"+f+" "+b;$("draftLastSaved").innerHTML="Last Saved: "+d}}catch(g){}}function saveDraft(){$(DRAFT_SAVE_DEFAULT_ID).style.display="none";$(DRAFT_SAVE_PROGRESS_ID).style.display="block";var a="saveDraft.html";if(typeof(draftTarget)!="undefined"){a=draftTarget}ajaxPost("descForm",a,null,null,'showDraftSaveFeedback("draftSaved")','showDraftSaveFeedback("draftSaveFailed")')}function autoSaveDraft(b){try{var b="saveDraft.html";if(typeof(draftTarget)!="undefined"){b=draftTarget}ajaxPost("descForm",b,null,null,"updateLastSavedDraftWithCurrentTime()",null)}catch(a){}}function displayOverlay(d,a){if($(d)&&$("mainbox")){var e=$$(".overlay");for(var c=0;c<e.length;c++){closeOverlay(e[c].id)}if(Element.firstDescendant($(document.body))!=$(d)){var b=$(d).remove();$(document.body).insert({top:b})}$("mainbox").className="transpa";$(d).style.display="block";if(!a){$(d).style.top=(scrollTopF()+20)+"px"}}}function closeOverlay(a){if($(a)&&$("mainbox")){$(a).style.display="none";$("mainbox").className=""}}function reloadOverlayFrame(a){if($(a)){$(a).src=$(a).src}}function adjustOverlayFrameHeight(b,a){if($(b)){$(b).style.height=a}}function scrollTopF(){var a=null;var b=0;if(document.all&&!window.opera){a=(window.document.compatMode=="CSS1Compat")?window.document.documentElement:window.document.body||null}else{a=document.documentElement}if(window.pageYOffset){b=window.pageYOffset}else{if(typeof a.scrollTop=="number"){b=a.scrollTop}}return b}function offsetF(a){var b=offsetTopF(a);var c=scrollTopF();return b-c}function offsetTopF(a){var b=a.offsetTop;a=a.offsetParent;while(a){b+=a.offsetTop;a=a.offsetParent}return b}function offsetLeftF(a){var b=a.offsetLeft;a=a.offsetParent;while(a){b+=a.offsetLeft;a=a.offsetParent}return b}function toggleHelpBubble(b,f){var e=document.getElementById("empHlpBub");var h=document.getElementById("boBubbleText");var j=document.getElementById("jsBubbleText");if(e.style.visibility=="hidden"){if("boBubbleText"==f){h.style.display="block"}else{j.style.display="block"}var c=offsetTopF(b);var g=offsetF(b);if(e.offsetHeight<g){if(e.className!="ovrly"){e.className="hlpBubTopRgt"}e.style.top=(c-e.offsetHeight-2+(e.className=="ovrly"?10:0))+"px"}else{if(e.className!="ovrly"){e.className="hlpBubBtmRgt"}e.style.top=(c+b.offsetHeight+2+(e.className=="ovrly"?10:0))+"px"}if(e.className=="ovrly"){var a=$$("#empHlpBub .cntnr");var k=$$("#empHlpBub .rght_sd_shdw");k[0].style.height=(a[0].getDimensions().height-34)+"px"}var d=offsetLeftF(b);if(d>250){d-=200}else{d+=15}e.style.left=d+"px";e.style.visibility="visible"}else{e.style.visibility="hidden";h.style.display="none";j.style.display="none"}return true}var toggleMandatoryFieldsConfig=$H({triggers:$H({"command.ad.vehicle.type":["MOTORCROSS","QUAD_ATV"],"command.ad.vehicle.condition":["NEW"]}),elems:["command.ad.vehicle.mileage","command.firstRegistrationDate"]});function toggleMandatoryFields(){var b=toggleMandatoryFieldsConfig.get("triggers");var c=false;b.each(function(e){var d=$(e.key);if(null!=d){e.value.each(function(f){c=c||d.options[d.selectedIndex].value==f})}});var a=toggleMandatoryFieldsConfig.get("elems");a.each(function(d){$("requiredIcon"+d).style.display=(c?"none":"block")})}sfHover=function(){if(document.getElementById("mainnavi")!=null&&typeof document.getElementById("mainnavi")!="undefined"){var b=document.getElementById("mainnavi").getElementsByTagName("LI");for(var a=0;a<b.length;a++){b[a].onmouseover=function(){this.className+=" sfhover"};b[a].onmouseout=function(){this.className=this.className.replace(new RegExp(" sfhover\\b"),"")}}}};if(window.attachEvent){window.attachEvent("onload",sfHover)}function openHelpWindows(){if(!document.getElementsByTagName){return false}var a=document.getElementsByTagName("a");for(var b=0;b<a.length;b++){if(a[b].className.match(".*openHelp.*")){a[b].onclick=function(){helpwindow=window.open(this.href,"helpwindow","width=955,height=600,left=0,top=190,scrollbars=yes,resizable=yes ");helpwindow.focus();return false}}}}addEvent(window,"load",openHelpWindows);var MIN_FLASH_VERSION_NEXT_GEN=parseFloat("10.0");var MIN_FLASH_REVISION_NEXT_GEN=0;var FLASH_NAME="Shockwave Flash";var PIC_UPLOADER_TYPE_COOKIE="picUploaderType";var PIC_UPLOADS=["standardUpload","advancedUploadNextGen"];function detectFlash(){var g=new Array();try{var b=false;if(window.ActiveXObject){var f=null;f=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(f){b=true;var d=f.GetVariable("$version").substring(4);d=d.split(",");var j=parseFloat(d[0]+"."+d[1]);var k=d[2]}}else{for(i=0;i<navigator.plugins.length;i++){if(navigator.plugins[i].name==FLASH_NAME){b=true;var l=navigator.plugins[i].description;var d=l.substring(FLASH_NAME.length+1);var j=parseFloat(d.substring(0,d.indexOf(" ")));var k=d.substring(d.indexOf(" r")+2)}}}var c=j>MIN_FLASH_VERSION_NEXT_GEN||j==MIN_FLASH_VERSION_NEXT_GEN&&k>=MIN_FLASH_REVISION_NEXT_GEN;var a=readCookie("picUploader")}catch(h){}g=new Array(b,c,j,k,a==PIC_UPLOADS[0],d,navigator.platform);if(location.search.indexOf("flashdebug")>0){alert("flash installed: "+g[0]+"\nflash version compatible next gen: "+g[1]+"\nflash whole version: "+g[5]+"\nflash major version: "+g[2]+"\nflash minor version: "+g[3]+"\nnon-flash cookie detected: "+g[4]+"\nplatform: "+g[6])}return g}function changePictureUploadTab(a){createCookie(PIC_UPLOADER_TYPE_COOKIE,a,365);document.location.href=document.location.href}function displayFlashInstruction(){var b=detectFlash();var a=null;var c=null;if(!b[0]){a=$("msgNoFlash");c=$("msgNoFlashNextGen")}else{if(!b[1]){c=$("msgWrongFlashVersionNextGen")}}if(a){a.style.display="block"}if(c){c.style.display="block"}}function readCookie(b){var e=b+"=";var a=document.cookie.split(";");for(var d=0;d<a.length;d++){var f=a[d];while(f.charAt(0)==" "){f=f.substring(1,f.length)}if(f.indexOf(e)==0){return f.substring(e.length,f.length)}}return null}function createCookie(c,d,e){if(e){var b=new Date();b.setTime(b.getTime()+(e*24*60*60*1000));var a="; expires="+b.toGMTString()}else{var a=""}document.cookie=c+"="+d+a+"; path=/"}var btnClss={def:"iDefault",hover:"iHover",clk:"iClick"};function initButtons(){var b=$$(".btnSpn");for(var a=0;a<b.length;a++){b[a].onmouseover=function(){this.className=this.className.replace(/(iClick|iDefault)/,btnClss.hover)};b[a].onmouseout=function(){this.className=this.className.replace(/(iClick|iHover)/,btnClss.def)};b[a].onmousedown=function(){this.className=this.className.replace(/(iDefault|iHover)/,btnClss.clk)};b[a].onmouseup=function(){this.className=this.className.replace(/(iClick|iDefault)/,btnClss.hover)}}}addEvent(window,"load",initButtons);function updateNewSRP(a){if(a.options[a.selectedIndex].value=="VIDEO"){$("newSRPImageURL").style.display="none";$("newSRPVideoURL").style.display="table-row"}else{if(a.options[a.selectedIndex].value=="IMAGE"){$("newSRPImageURL").style.display="table-row";$("newSRPVideoURL").style.display="none"}else{$("newSRPImageURL").style.display="none";$("newSRPVideoURL").style.display="none"}}}function showWaitScreen(){$("mainbox").className="transpa";$("pleaseWaitMessage").style.top=(scrollTopF()+200)+"px";$("pleaseWaitMessage").style.display="block"}function showFreetextFildForChoice(a,c){var b="freetext"+a;if(c!=null&&c){$(b).style.display="block"}else{$(b).style.display="none"}};
