function getXMLHTTP() { var xml = null; try { xml = new ActiveXObject( "Msxml2.XMLHTTP" ) } catch( e1 ) { try { xml = new ActiveXObject( "Microsoft.XMLHTTP" ) } catch( e2 ) { xml = null; } } if( !xml && typeof XMLHttpRequest != "undefined" ) { xml = new XMLHttpRequest(); } return xml; } var cookie_search = 'poraba_search'; function changeType( brand_id, id, cookie, selected_id ) { if ( brand_id != -1 ) { var xmlHttp = null; try { if( xmlHttp.readyState != 0 ) { xmlHttp.abort(); } } catch( e ) {} var link = "http://www.poraba.com/js/get_type.php?id="+brand_id; xmlHttp = getXMLHTTP(); xmlHttp.open( "GET", link, true, null, null); xmlHttp.onreadystatechange = function() { if( xmlHttp.readyState == 4 && xmlHttp.responseText ) { if( xmlHttp.responseText.charAt(0) == "<" ) { return false; } else { var podatki = new String(xmlHttp.responseText); var dataArray = podatki.split('#!'); //za splitat podatke var obj = document.getElementById( id ); //dobis objekt, ki ga bos nafilal var ctr = 1; obj.options[0] = new Option('izberi...',-1); for (var i = 0; i < dataArray.length-1; i++) { obj.options[ctr] = new Option(dataArray[i+1],dataArray[i]); if ( selected_id == dataArray[i]) var tmp = ctr; //da ga izbere nakonc i++; ctr++; } obj.length = ctr; obj.selectedIndex = tmp; //ga izbere //nastavi piskot ce je teba shrant if ( cookie ) { setCookie(cookie_search, brand_id); } } } } xmlHttp.send( null ); } else { var obj = document.getElementById( id ); //dobis objekt, ki ga bos nafilal obj.options[0] = new Option('izberi...',-1); obj.length = 1; obj.selectedIndex = 0; } return; } function changeSearch(w) { var topM = document.getElementById('top_model'); var topB = document.getElementById('top_brand'); var topS = document.getElementById('top_search'); if ( w == 'brand' ) { topS.name = 'searchb'; topS.value = topB.value; } else if ( w == 'type' ) { topS.name = 'searcht'; topS.value = topM.value; } } function changeSearchAdv(w) { var topM = document.getElementById('search_model'); var topB = document.getElementById('search_brand'); var topS = document.getElementById('adv_search'); if ( w == 'brand' ) { topS.name = 'searchb'; topS.value = topB.value; } else if ( w == 'type' ) { topS.name = 'searcht'; topS.value = topM.value; } }