function setElementClassById(elem, value) {
	if(document.getElementById) {
		var obj = document.getElementById(elem);
		if(obj) {
			obj.className = value;
		}
	}
}
function find_search() {
	kwd = document.search.q.value;
	if ( kwd == "" ) {
		alert( "検索キーワードを入力してください。" );
		return false;
	}
	value = getSearchCookie('keyword');
	if ( !value ) {
		ofset = -1;
		value = '';
	} else {
                ofset = value.indexOf(kwd);
	}
	if ( ofset == -1 ) {
		
		if ( value ) {
			arry = value.split(',');
			if ( arry.length > 20 ) {
				value = '';
				for ( i = 1; i < arry.length - 1; i++ ) value += arry[ i ] + ',';
			}
		}
		
		setSearchCookie( value + document.search.q.value + ',' );
	}
	return true;
}
function kwdboxForcus() {
	document.search.q.style.background = "url(/img/s.gif)";
	document.search.q.style.backgroundColor = "#fff";
}
function kwdboxBlur() {
	if ( document.search.q.value == "" ) document.search.q.style.background = "url(/img/spotlight_bg.gif) no-repeat left top";
	else document.search.q.style.background = "url(/img/s.gif)";
	document.search.q.style.backgroundColor = "#fff";
}


function setSearchCookie( str ) {
	clear_date = new Date();
	clear_date.setTime(clear_date.getTime() + (365 * 1000 * 60 * 60 * 24));
	clear_date = clear_date.toGMTString();
	document.cookie = "keyword=" + escape(str) + ";expires=" + clear_date;
}

function getSearchCookie( name ) {
	name = name + "=";
	value = null;
	str = document.cookie + ";" ;
	ofst = str.indexOf(name);
	if ( ofst != -1 ) {
		start = ofst + name.length;
		end   = str.indexOf(";" , start);
		value = unescape(str.substring(start,end));
	}
}
