// JavaScript Document
//
//	v.1.0 sagba	11.06.2009
//
function newSearch(){
	var str=(location.search);

if(str=="") {
// No Search Supplied
	document.write("<div class=\"advImg\">");
	// Link
	document.write("<a href=\"http://www.cardiff.ac.uk/search/index.html\">");
	
	document.write("<img src=\"http://www.cardiff.ac.uk/search/images/search-deep.jpg\" alt=\"Click here to try our new Search\"/>");
	// End
	document.write("</a></div>");
		} else {
			if(str.match("qt=")){
				var splitStart=(str.indexOf('qt=')+3);				// Start of keywords (+2 to exclude the 'q=' from the string)
				} else {
					// Split the query out of the Google Search string
		  		var splitStart=(str.indexOf('q=')+2);				// Start of keywords (+2 to exclude the 'q=' from the string)
				}
		  var splitEnd=(str.indexOf('&'));				// End of the keywords when submit button used
		  	if(splitEnd=='-1'){
				var searchStr=(str.slice(splitStart));	// Slice the keywords string from the location - IE8 keeps the keywords as the last items in the string
			} else {
		  		var searchStr=(str.slice(splitStart,splitEnd));	// Slice the keywords string from the location
			}
		  // Extract keywords for use in links
			// Replace all instances of "+" in the string
			var keywords=(searchStr.replace(/\+/gi," "));

			document.write("<div class=\"advImg\">");
			// link
			document.write("<a href=\"http://www.cardiff.ac.uk/search/index.html?cx=004497668956212682542%3Altvwfafuryg&cof=FORID%3A9&ie=ISO-8859-1&q="+searchStr+"&submit=Submit#1161\">");
			// image
			document.write("<img src=\"http://www.cardiff.ac.uk/search/images/search-deep.jpg\" alt=\"Click here to try our new Search\" Title=\"Search Preview - Click here to try our new Search\"/>");
			// End
			document.write("</a></div>");
		}
	}
