function Utf8Encoder(str){
	result = encodeURI(str);
	return result;
}

function taggysubmit(){
	var baseURI = 'http://search-homewith.net/search/custom_homewithpet/';
	if(document.getElementById("taggytext") && document.getElementById("taggytext").value != '') {
		baseURI += '?key=' + document.getElementById("taggytext").value;
	}else{
	}
	window.open("","taggywindow","");
	document.getElementById("taggyform").target = "taggywindow";
	document.getElementById("taggyform").action = baseURI;
	document.getElementById("taggyform").submit();
}

/**
 * 押下されたキーコードを取得する
 * @param {Object} e
 */
function getKeyCode(e){
    if (document.all) {//IE
        return e.keyCode;
    } else if (document.getElementById) {//W3C DOMをサポートしているか
        return (e.keyCode) ? e.keyCode : e.charCode;
    } else if (document.layers) {//Netscape 4
        return e.which
    }
}

/**
 * Enterキーが押された時にfuncを実行する
 * @param {Object} e
 * @param {Object} func
 */
function controlEnter(e,func){
	if(getKeyCode(e) != 13 && getKeyCode(e) != 3){
		return true;
	}else{
		func();
		return false;
	}
}

function focusAction(id){
	document.getElementById(id).className = 'blackstyle';
}

function blurAction(id){
	if(document.getElementById(id).value == ''){
		document.getElementById(id).className = 'graystyle';
	}
}

function addLoadEventTaggy(func) {
    var oldonload = window.onload;
    if( typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function initTaggy(){
	if(document.getElementById("taggytext") && document.getElementById("taggytext").value != ''){
		document.getElementById("taggytext").className = 'blackstyle';
	}
	if(document.getElementById("taggytextTop") && document.getElementById("taggytextTop").value != ''){
		document.getElementById("taggytextTop").className = 'blackstyle';
	}
}

addLoadEventTaggy(initTaggy);