/**
 * search.js -> http://actoral.org/
 * JavaScript search module setup and interaction
 * (cc) creative commons by 3.0
 */




var _src_placeholder = 'archives';


/**
 * Setup the search input field.
 */
function search_setup() {
	
	var elem = document.getElementById( 'searchword' );
	
	// set Apple appareance
	if ( navigator.userAgent.match(/AppleWebKit/i) && navigator.appVersion.indexOf('Macintosh')!=-1 ) {
		elem.style.width = '150px';
		elem.setAttribute( 'results', 0 );
		elem.setAttribute( 'placeholder', _src_placeholder );
		elem.type = "search";
		elem.onblur = function() {
			if ( this.value=='' ) this.setAttribute( 'placeholder', _src_placeholder );
		}
	}
	// for other navigator, simulate the apple style
	else {
		document.getElementById('search').className = 'searchbox';
		elem.value	= _src_placeholder;
		elem.onblur = function() {
			if ( this.value=='' ) this.value = _src_placeholder;
		}
	}
}


/**
 * Clear the current search field content if match the placeholder value.
 */
function search_clear() {
	var elem = document.getElementById('searchword');
	if ( elem.value==_src_placeholder ) elem.value='';
}