var DEF_VAL = "Search"; // Default Value
var isSafari = (navigator.userAgent.indexOf("AppleWebKit") !=-1);
// Detecting not only Safari but WebKit-based browsers
run();
function run()
{
var oldOnload = window.onload; // window.onload will be overwritten, so save the old value
if (typeof(window.onload) != "function") {
window.onload = init;
} else {
window.onload = function() {
oldOnload();
init();
}
}
}
function init() {
if (!document.getElementById) return;
var theSearchField = document.getElementById('search');
if (isSafari) {
// Changing type to 'search' from 'text'
// and inserting 'autosave,' 'results,' 'placeholder' values for Safari and WebKit-based browsers
theSearchField.setAttribute('type', 'search');
theSearchField.setAttribute('autosave', 'saved.data');
theSearchField.setAttribute('results', '5');
theSearchField.setAttribute('placeholder', DEF_VAL);
} else {
// Doing the 'Live Search'-displaying-&-hiding-stuff for non-WebKit-based browsers
theSearchField.onfocus = focusSearch;
theSearchField.onblur = blurSearch;
if (theSearchField.value=='') theSearchField.value = DEF_VAL;
}
}
function focusSearch() {
if (this.value==DEF_VAL) {
this.value = '';
}
}
function blurSearch() {
if (this.value=='') {
this.value = DEF_VAL;
}
}

