var toggle=0; last=""; function autoComplete() { $(function() { //autocomplete $(".search").autocomplete({ source: "searchfield.php?toggle="+toggle , minLength: 3, search: function( event, ui ) { if (this.value.indexOf("Search")<0) last=this.value; }, focus: function( event, ui ) { // $(this).autocomplete("search"); }, select: function(event, ui) { //assign value back to the form element if(ui.item){ if (ui.item.value.indexOf("Search only")>=0) { // alert(ui.item.value); toggle=1; newUrl="searchfield.php?toggle="+toggle ; $(this).autocomplete("option","source",newUrl); ui.item.value=last; // $(this).autocomplete("search"); } else if (ui.item.value.indexOf("Search all")>=0) { toggle=0; newUrl="searchfield.php?toggle="+toggle ; $(this).autocomplete("option","source",newUrl) ui.item.value=last; // $(this).autocomplete("search"); } else { $(event.target).val(ui.item.value); //submit the form $(event.target.form).submit(); } } } }); }); } function autoCompleteCheckJquery() { if (typeof jQuery != 'undefined' ) { autoComplete(); } else { window.setTimeout( autoCompleteCheckJquery, 500 ); } } // Put all your jQuery UI stuff in this function autoCompleteCheckJquery(); function searchSubmit($www) { $url="search.php?"; $search=document.getElementById("searchfield").value; if ($search!="") $url+="search="+escape($search); document.location=$url; return false; } function hideCallout($id) { var http = false; // new way if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari http=new XMLHttpRequest(); } else { // code for IE6, IE5 http=new ActiveXObject("Microsoft.XMLHTTP"); } var date=new Date(); // line below in case need to send sessionid http.open("POST", "includes/hideCallout.php?id="+$id+"&cache="+date.getTime()); http.onreadystatechange=function() { if(http.readyState == 4) { response=http.responseText; if (response!="") { document.getElementById($id).className="hide"; } } } http.send(null); return false; } function priceAlert($id) { if (isPhone()) { return true; /* So href on anchor works */ } else { url="price-alert.php?id="+$id; //$.colorbox({width:"800", height:"500", iframe:true, href: url}); /* Shoe reveal */ $.colorbox({width:"670", height:"500", iframe:true, href: url}); return false; } } function watchlist($el, $id) { $.ajax({ method: "POST", url: "includes/watchlist-ajax.php", data: { id : $id }, success:function(data) { if(data) $el.text('Remove from Watchlist'); else $el.text('Add to Watchlist'); } }); } $(document).ready(function(){ $(".iframe").colorbox({iframe:true, width: 570, height: 500}); });