/*
Plugin Name: Cruftless Search
Plugin URI: http://isaacschlueter.com/plugins/i-made/cruft-free-search-plugin/
Description: Provided that your search terms fields are named "s", this will make all WordPress searches use clean URLs like "/search/search+terms". Note: It uses JavaScript, and attaches a window.onload handler. So, if you use window.onload for something else, then you'll have to tweak it to play nice.
Author: Isaac Z. Schlueter
Version: 0.1
Author URI: http://isaacschlueter.com
Generating script for http://www.homepage-tipp.de */
function __cs_form_submit(e) {
var s=document.getElementsByName('s')[0];
if(!s)return true;
if(!s.value&&s.value!='')return true;
s=s.value+'';
if(s!='')window.location.href='http://www.homepage-tipp.de/search/' + escape(s);
else window.location.href='http://www.homepage-tipp.de';
if(!e&&window.event)e=window.event;
e.returnValue=false;
if(e.preventDefault)e.preventDefault();
return false;
}
function __cs_synch_s(e) {
if(!e&&window.event)e=window.event;
var lnk;
if(e.srcElement)lnk=e.srcElement;
if(e.target)lnk=e.target;
if(!lnk)return true;
var s=document.getElementsByName('s');
for(var i=s.length-1;i>-1;i--)
{
if(s[i]==lnk)continue;
s[i].value=lnk.value;
}
return true;
}
if(typeof(getParent)!=='function'){
function getParent(el, pTagName, goUpAnyways){if(el==null)return null;else if(el.nodeType==1 && el.tagName.toLowerCase()==pTagName.toLowerCase()){if(goUpAnyways>0)return getParent(el.parentNode,pTagName,1.0*goUpAnyways-1.0);else return el;}else return getParent(el.parentNode, pTagName, goUpAnyways);};
}
function cs_setup_clean_search() {
if(!document.getElementsByName)return;
var s=document.getElementsByName('s');
for(var i=s.length-1;i>-1;i--)
{
var f=getParent(s[i],'form');
if(f)f.onsubmit=__cs_form_submit;
s[i].onkeyup=__cs_synch_s;
s[i].value=unescape(s[i].value);
}
}
window.onload=function(){cs_setup_clean_search();}