function window_onload(){PopulateModelos();}
function enumero(a){a=form1.preco.value;a=a.replace(" ","");a=a.replace(",",".");return a;}
function testatudo(forma,serie){var ab="";var z=99
for(var i=0;i<forma.elements.length;i++){if(serie.substring(i,i+1)=="1"&&forma.elements[i].value==""){ab=ab+forma.elements[i].name+", \n";if(i<z){z=i;}}}
if(ab==""){forma.Enviar.disabled=true;form1.sit6.disabled=false;return true;}else{alert("deve preenceher o(s) campo(s) de \n"+ab+"\n para colocar o seu carro à venda.");forma.elements[z].focus();return false;}}
function criaCookie(nome,valor,dias){if(dias){var date=new Date();date.setTime(date.getTime()+(dias*24*60*60*1000));var expira="; expira="+date.toGMTString();}else{var expira="";}
document.cookie=nome+"="+valor+expira+"; path=/";}
function leCookie(nome){var nome_igual=nome+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nome_igual)==0)return c.substring(nome_igual.length,c.length);}
return null;}
function apagaCookie() {
  for(var i=0; i<arguments.length; i++) {
	criaCookie(arguments[i],"",-1);
	}
}
function guardar(){var b=document.getElementById("form1");var a="marka|idmarca|"+b.idmarca.value+"||"
a+="marka_md|idmodelo|"+b.idmodelo.value+"||"
a+="marka_ai|ano_i|"+b.ano_i.value+"||"
a+="marka_af|ano_f|"+b.ano_f.value+"||"
a+="marka_ei|euro_ini|"+b.euro_ini.value+"||"
a+="marka_ef|euro_fin|"+b.euro_fin.value+"||"
a+="marka_cb|comb|"+b.comb.value+"||"
a+="marka_ct|categoria|"+b.categoria.value+"||"
try{a+="marka_iex|iex|"+b.iex.selectedIndex+"||";}catch(e){}
try{a+="marka_iexm|iexm|"+b.iexm.value+"||";}catch(e){}
try{a+="marka_km|km|"+b.km.value+"||";}catch(e){}
a+="marka_cvi|cv_i|"+b.cv_i.value+"||"
a+="marka_cvf|cv_f|"+b.cv_f.value;criaCookie("marka_gd",a,5,"/");}
function limpar(){var ca=[["idmarca","a",0],["idmodelo","a",0],["ano_i","a",1],["ano_f","a",0],["euro_ini","b",0],["euro_fin","b",500000],["comb","a",0],["categoria","a",0],["cv_i","b",0],["cv_f","b",999],["iex","a",0],["iexm","a",0],["km_in","b",0],["km","b",""],["concelho","b",""]];
apagaCookie("marka_idv", "marka_km", "marka_kmin", "marka", "marka_md", "marka_ai", "marka_af", "marka_ei", "marka_ef", "marka_cb", "marka_cvi", "marka_cvf", "marka_ct", "marka_iex");
try{multiselect_selectall('idversao',false);}catch(e){}
try{var b1=document.getElementById("form1").elements;for(var i=0;i<b1.length;i++){if(b1[i].name.substring(0,3)=="ex_"){b1[i].checked=false;}}}catch(e){}
for(var i=0;i<ca.length;i++){ca_ck=ca[i];b=document.getElementById(ca_ck[0]);switch(ca_ck[1]){case"a":try{if(ca_ck[2]==1){b.selectedIndex=(b.length-1);}else{b.selectedIndex=0;}}catch(e){}
break;case"b":try{b.value=ca_ck[2];b.style.backgroundColor="#fff";}catch(e){}
break;}}
Marca_onchange();try{restable("idv");}catch(e){}}
function restaurar1(){restaurar();Modelo_onchange("../",12);}
function restaurar(){b=leCookie("marka_gd");if(!b)return;ca=b.split('||');for(var i=0;i<ca.length;i++){ca_ck=ca[i].split('|');criaCookie(ca_ck[0],ca_ck[2],5);try{el=document.getElementById(ca_ck[1]);switch(ca_ck[1]){case"idmodelo":PopulateModelos(ca_ck[2]);break;case"iex":el.selectedIndex=ca_ck[2];break;default:el.value=ca_ck[2];break;}
switch(ca_ck[1]){case"cv_i":case"euro_ini":if(ca_ck[2]>0)el.style.backgroundColor="#ffa";break;case"cv_f":if(ca_ck[2]!="999")el.style.backgroundColor="#ffa";break;case"euro_fin":if(ca_ck[2]!="500000")el.style.backgroundColor="#ffa";break;}}catch(e){}}}
function vrfy(a,b){if(a.value==b){a.style.backgroundColor="#fff";}else{a.style.backgroundColor="#ffa";}}
function Marca_onchange(){PopulateModelos();try{document.getElementById("txtHint").style.height="5px";document.getElementById("lver").style.visibility="hidden";document.getElementById("_blok").style.visibility="hidden";}catch(e){}}
function restor_marca(idmarca){}
function Modelo_onchange(c,d){if(arguments.length==0){var c="";var d=0;}
d=d+5;try{restable("idv");}catch(e){}
var imar=document.getElementById("idmarca");var imod=document.getElementById("idmodelo");a="&mk="+imar.options[imar.selectedIndex].text+"&md="+imod.options[imod.selectedIndex].text;if(imod.value>0&&typeof document.getElementById("_blok")=='object'){
		try {	v_get ("idmarca=" + imar.value + "&idmodelo="+imod.value + a, c, d);
		document.getElementById("txtHint").style.height="120px";
		document.getElementById("scond").style.visibility="hidden";
		document.getElementById("lver").style.visibility="visible";
		 } catch (e) {}		
try{b=document.getElementById("filtra");b.focus();b.select();}catch(e){}}}
function Modelo1_onchange(){try{restable("idv");}catch(e){}
a="&mk="+document.form1.idmarca.options[document.form1.idmarca.selectedIndex].text+"&md="+document.form1.idmodelo.options[document.form1.idmodelo.selectedIndex].text;if(document.form1.idmodelo.value>0){v_get("idmarca="+document.form1.idmarca.value+"&idmodelo="+document.form1.idmodelo.value+a,"../",17);document.getElementById("scond").style.visibility="hidden";document.getElementById("lver").style.visibility="visible";document.form1.filtra.focus();document.form1.filtra.select();}}
function PopulateModelos(idmodel_o,nao){
var b1=document.getElementById("idmarca");var index=b1.selectedIndex;var marca=b1.options[index].value;var b2=document.getElementById("idmodelo").options;b2.length=1;b2[0]=new Option("Modelo","0");b2[0].style.backgroundColor="#ffffff";var indice=0;var aModelos=sModelos.split("||");var n=1;for(var i=0;i<aModelos.length;i++){var a=aModelos[i].split("|");if(a[0]==marca){b2[n]=new Option(a[2],a[1]);if(a[1]==idmodel_o){indice=n;}
n=n+1;}}
document.getElementById("idmodelo").selectedIndex=indice;if(n>=1 && (!nao || 0 === nao.length)){Modelo_onchange();}}
var xmlHttp
var sVersao=""
function v_get(str,niv,altura){xmlHttp=GetXmlHttpObject()
if(xmlHttp==null){alert("Neste browser não funciona")
return}
var url=niv+"conteudo/get_versao1.php";url=url+"?"+str
url=url+"&altura="+altura;url=url+"&sid="+Math.random();xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)}
function stateChanged(){if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){try{restable("idv");}catch(e){}
var meutexto=xmlHttp.responseText;var root=meutexto.split("||");var n=1;for(var i=0;i<root.length-1;i++){var celu=root[i].split("|");addrow("idv",celu);}}
filtra_idv_coki();}
function restable(tablename){var tbl=document.getElementById(tablename);if(tbl==null) return;
var lastRow=tbl.rows.length;for(i=lastRow-1;i>=0;i--){tbl.deleteRow(i);}}
function addrow(tablename,arr){ var tbl=document.getElementById(tablename);if(tbl==null) return;
 var lastRow=tbl.rows.length;var row=tbl.insertRow(lastRow);try{row.name=arr[0];row.style.cursor="pointer";row.style.backgroundColor="#88bbff";row.onmouseover=function(){this.style.backgroundColor="#cccccc";}
row.onmouseout=function(){ab=document.getElementById('idv_ch_'+row.rowIndex);if(ab.checked){this.style.backgroundColor="#ffa";}else{this.style.backgroundColor="#ffffff";}}
row.onclick=function(event){ab=document.getElementById('idv_ch_'+row.rowIndex);ab.checked=!ab.checked;this.style.backgroundColor="#ffa";}}catch(e){}
var cell=row.insertCell(0);cell.innerHTML="<input type=checkbox name='idversao[]' id='idv_ch_"+row.rowIndex+"' VALUE='"+arr[0]+"' checked onclick=\"this.checked=!this.checked;\" class='chkbx'></input>";cell.className="idv_bb";var cell=row.insertCell(1);cell.innerHTML=arr[1];cell.className="idv_bb";var cell=row.insertCell(2);cell.innerHTML=arr[2];cell.className="idv_bb";}
function multiselect_selectall(name,val){var els=document.getElementsByTagName('input');var cor_bk=val?"#ffa":"#ffffff";var j=0;for(var i=0;i<els.length;i++)if((els[i].name==name+'[]'||els[i].name==name)){els[i].checked=val;document.getElementById('idv').tBodies[0].rows[j].style.backgroundColor=cor_bk;j++;}}
function filtra_este(valor){if(valor.value==""){multiselect_selectall('idversao',false);return;}
v_txt=valor.value.toUpperCase();var bob=document.getElementById('idv');for(var x=0;x<bob.tBodies[0].rows.length;x++){var tex=bob.tBodies[0].rows[x].cells[1].innerHTML.toUpperCase();bob.tBodies[0].rows[x].style.backgroundColor="#ffffff"
var ab=document.getElementById('idv_ch_'+x);if(tex.indexOf(v_txt)!=-1){bob.tBodies[0].rows[x].style.backgroundColor="#ffa";ab.checked=true;}else{ab.checked=false;}}}
function filtra_idv_coki(){multiselect_selectall('idversao',false);var bob=document.getElementById('idv');if (bob==null) return;for(var x=0;x<bob.tBodies[0].rows.length;x++){var ab=document.getElementById('idv_ch_'+x);for(i in marka_idv_){if(ab.value==marka_idv_[i]){ab.checked=true;bob.tBodies[0].rows[x].style.backgroundColor="#ffa";}}}}
function GetXmlHttpObject(){var objXMLHttp=null
if(window.XMLHttpRequest){objXMLHttp=new XMLHttpRequest()
if(objXMLHttp.overrideMimeType){objXMLHttp.overrideMimeType('text/xml');}}else if(window.ActiveXObject){objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
try{objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}
return objXMLHttp}


if(typeof com=="undefined"){var com=new Object();}
if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();this.useExpressInstall=_7;if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";this.addParam("quality",q);var _d=(_9)?_9:window.location;this.setAttribute("xiRedirectUrl",_d);this.setAttribute("redirectUrl","");if(_a){this.setAttribute("redirectUrl",_a);}};com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},createParamTag:function(n,v){var p=document.createElement("param");p.setAttribute("name",n);p.setAttribute("value",v);return p;},getVariablePairs:function(){var _19=new Array();var key;var _1b=this.getVariables();for(key in _1b){_19.push(key+"="+_1b[key]);}
return _19;},getFlashHTML:function(){var _1c="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_1c="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";_1c+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1d=this.getParams();for(var key in _1d){_1c+=[key]+"=\""+_1d[key]+"\" ";}
var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_1c+="flashvars=\""+_1f+"\"";}
_1c+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_1c="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";_1c+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _20=this.getParams();for(var key in _20){_1c+="<param name=\""+key+"\" value=\""+_20[key]+"\" />";}
var _22=this.getVariablePairs().join("&");if(_22.length>0){_1c+="<param name=\"flashvars\" value=\""+_22+"\" />";}_1c+="</object>";}
return _1c;},write:function(_23){if(this.useExpressInstall){var _24=new com.deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}else{this.setAttribute("doExpressInstall",false);}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _23=="string")?document.getElementById(_23):_23;n.innerHTML=this.getFlashHTML();}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){var _28=new com.deconcept.PlayerVersion(0,0,0);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_28=new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");for(var i=3;axo!=null;i++){axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);_28=new com.deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_26&&_28.major>_26.major){return _28;}
if(!_26||((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major)||_28.major!=6||_27){try{_28=new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}catch(e){}}}
return _28;};com.deconcept.PlayerVersion=function(_2c){this.major=parseInt(_2c[0])||0;this.minor=parseInt(_2c[1])||0;this.rev=parseInt(_2c[2])||0;};com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;};com.deconcept.util={getRequestParameter:function(_2e){var q=document.location.search||document.location.href.hash;if(q){var _30=q.indexOf(_2e+"=");var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;if(q.length>1&&_30>-1){return q.substring(q.indexOf("=",_30)+1,_31);}}return"";},removeChildren:function(n){while(n.hasChildNodes()){n.removeChild(n.firstChild);}}};if(Array.prototype.push==null){Array.prototype.push=function(_33){this[this.length]=_33;return this.length;};}
var getQueryParamValue=com.deconcept.util.getRequestParameter;var FlashObject=com.deconcept.FlashObject;
