var requestAccepted; var status; var isResults; var isAFD = false; function google_callback(google_requestAccepted, google_status) { requestAccepted = google_requestAccepted; status = google_status; isResults = parkingData.pageType == 2; isAFD = google_status.feed != "afs"; if (!requestAccepted) { failover(); return; } if ((!isAFD) && (isResults)) { //$("
").insertAfter("#ads"); $("").insertAfter("#webResults"); } } function failover() { var location = window.location.href; if (location.indexOf('?') == -1) { location += '?ai=' + (parseInt(parkingData.apiIteration) + parseInt(1)); } else { var split = location.split('?'); location = split[0]; var query = split[1]; var params = query.split('&'); var itemsWritten = 0; for (i = 0; i < params.length; i++) { if (params[i].indexOf('ai=') == -1) { if (itemsWritten == 0) location += '?' + params[i]; else location += '&' + params[i]; itemsWritten++; } } if (itemsWritten == 0) location += '?ai=' + (parseInt(parkingData.apiIteration) + parseInt(1)); else location += '&ai=' + (parseInt(parkingData.apiIteration) + parseInt(1)); itemsWritten++; } if (location != window.location.href) window.location = location; } function exists(x) { if (typeof (x) == 'undefined') return false; if (x == null) return false; if (x === '') return false; return true; } function set_cookie(name, value) { var argumentCount; var argumentValues; var domain; var expires; var path; var secure; argumentValues = setCookie.arguments; argumentCount = setCookie.arguments.length; expires = (argumentCount > 2) ? argumentValues[2] : null; path = (argumentCount > 3) ? argumentValues[3] : null; domain = (argumentCount > 4) ? argumentValues[4] : null; secure = (argumentCount > 5) ? argumentValues[5] : false; document.cookie = name + '=' + escape(value) + ((expires == null) ? '' : ('; expires=' + expires.toGMTString())) + ((path == null) ? '' : ('; path=' + path)) + ((domain == null) ? '' : ('; domain=' + domain)) + ((secure == true) ? '; secure' : ''); } function get_cookie(name) { var argument; var argumentLength; var cookieLength; var endString; var i; var j; argument = name + '='; argumentLength = argument.length; cookieLength = document.cookie.length; i = 0; while (i < cookieLength) { j = i + argumentLength; if (document.cookie.substring(i, j) == argument) { endString = document.cookie.indexOf(';', j); if (endString == -1) endString = document.cookie.length; return unescape(document.cookie.substring(j, endString)); } i = document.cookie.indexOf(' ', i) + 1; if (i == 0) break; } return (null); } function delete_cookie(name) { var cookieValue; var expirationDate; expirationDate = new Date(); expirationDate.setTime(expirationDate.getTime() - 1); cookieValue = getCookie(name); if (cookieValue != null) setCookie(name, '', expirationDate, '/'); } function strip_html(input) { var output = ''; var inTag = false; for (var i = 0; i < input.length; i++) { if (input.charAt(i) == '<') inTag = true; if (input.charAt(i) == '>') { if (input.charAt(i + 1) == '<') { } else { inTag = false; i++; } } if (!inTag) output += input.charAt(i); } return output; } function build_logging_url(rank, sponsoredCount, resultLinkType, visibleUrl) { var url = '/clickLog?ck=' + encodeURIComponent(parkingData.cacheKey) + '&d=' + encodeURIComponent(parkingData.domainName) + '&aid=' + encodeURIComponent(parkingData.adNetworkID) + '&r=' + encodeURIComponent(rank) + '&rc=' + encodeURIComponent(sponsoredCount) + '&rlt=' + encodeURIComponent(resultLinkType) + '&du=' + encodeURIComponent(strip_html(visibleUrl)) + '&afd=' + isAFD; return url; } function create_request() { try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { } try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { } try { return new XMLHttpRequest(); } catch (e) { } return null; } function fetch_web_results() { var request = "/interface/6/?mode=wr&outputType=json" + "&dn=" + encodeURIComponent(parkingData.domainName) + "&st=" + encodeURIComponent(parkingData.searchText) + "&num=" + encodeURIComponent("10") + "&ia=" + encodeURIComponent(parkingData.adultTag) + "&hl=" + encodeURIComponent(parkingData.hl) + "&cip=" + encodeURIComponent(parkingData.cip) + "&ref=" + encodeURIComponent(document.referrer) + "&ua=" + encodeURIComponent(navigator.userAgent); var http = create_request(); if (http != null) { http.open('GET', request, true); http.setRequestHeader('Connection', 'close'); http.onreadystatechange = function () { if (http.readyState == 4) { var webResults = eval("(" + http.responseText + ")"); render_web_results(webResults); } } http.send(null); } } function render_web_results(webResults) { //have web results? if ((webResults) && (webResults.webResults) && (webResults.webResults.length > 0)) { //find output div var div = document.getElementById("webResults"); if (div) { //daughter window? var dw = " target='_blank'"; //write header var html = "

Web Results

"; //open list html += ""; div.innerHTML = html; } } }