	function vChange(sId){
		elText=document.getElementById(sId);
		sValue=elText.value;

		var elems = document.getElementsByTagName("input");
		for(var i = 0; i < elems.length; i++){
			if(elems[i].type=='text')
				elems[i].value = sValue;
		}

	}

	function bSearch(sId,sUrl){
		var sType=0;
		var sTarget='_self';
		var sWord=document.getElementById(sId).value;

		if(sUrl.indexOf('{euc}')!=-1)
			sType=1;
		else if(sUrl.indexOf('{sjis}')!=-1)
			sType=2;
		window.open("http://www.doko2.com/redirect/?u="+sEncodeURL(sUrl)+"&p="+sEncodeURL(sWord)+"&t="+sType,sTarget);
		return false;
	}



function bKeyDown(objEv,sId){
	if(objEv.keyCode!=13)
		return true;

	objEv.returnValue=false;
	document.getElementById("b"+sId).click();
	return false;
}

function bSubmit(sId,sUrl){
	event.returnValue=false;
	vSearch(sId,sUrl);
	return false;
}



function sEncodeURL(sStr){
    var s0, i, s, u;
    s0 = "";                // encoded str
    if(typeof(sStr)!='string')return '';
    for (i = 0; i < sStr.length; i++){   // scan the source
        s = sStr.charAt(i);
        u = sStr.charCodeAt(i);          // get unicode of the char
        if (s == " "){s0 += "+";}       // SP should be converted to "+"
        else {
            if ( u == 0x2a || u == 0x2d || u == 0x2e || u == 0x5f || ((u >= 0x30) && (u <= 0x39)) || ((u >= 0x41) && (u <= 0x5a)) || ((u >= 0x61) && (u <= 0x7a))){       // check for escape
                s0 = s0 + s;            // don't escape
            }
            else {                  // escape
                if ((u >= 0x0) && (u <= 0x7f)){     // single byte format
                    s = "0"+u.toString(16);
                    s0 += "%"+ s.substr(s.length-2);
                }
                else if (u > 0x1fffff){     // quaternary byte format (extended)
                    s0 += "%" + (oxf0 + ((u & 0x1c0000) >> 18)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0x3f000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
                else if (u > 0x7ff){        // triple byte format
                    s0 += "%" + (0xe0 + ((u & 0xf000) >> 12)).toString(16);
                    s0 += "%" + (0x80 + ((u & 0xfc0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
                else {                      // double byte format
                    s0 += "%" + (0xc0 + ((u & 0x7c0) >> 6)).toString(16);
                    s0 += "%" + (0x80 + (u & 0x3f)).toString(16);
                }
            }
        }
    }
    return s0;
}