function addBookmark(){

	var title="wakazaka.jp - カテゴリ情報検索エンジン";
    var url="http://www.wakazaka.jp";

    if (window.sidebar) window.sidebar.addPanel(title, url,"");

    else if( window.opera && window.print ){
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',title);
		mbm.click();
    }

    else if( document.all ) window.external.AddFavorite( url, title);
}

function is_ie_mac(){
	return ((navigator.appVersion.indexOf("Mac") > -1) && (navigator.appVersion.indexOf("MSIE") > -1));
}

function over_region(id_region){
	if ( !is_ie_mac()  ){
		document.images['img_over'].src='/images/map_'+ id_region +'.gif';
		document.getElementById(''+id_region).style.color = "#22ad16";
		document.getElementById(''+id_region).style.textDecoration = "underline";
	}
	return true;
}

function clear_region(id_region){
	if ( !is_ie_mac() )	{
		document.images['img_over'].src='/images/empty.gif';
		document.getElementById(''+id_region).style.color = "#348de5";
		document.getElementById(''+id_region).style.textDecoration = "none";
	}
	return true;
}


function write_style(){
	if ( navigator.appVersion.indexOf("MSIE 7.") > -1 )	{
		document.write('<style type="text/css">');
		document.write('.img_over {height: 490px;width: 490px; position: relative; margin-bottom: -490px; margin-bottom: -490px;top: -490px; top: -490px;}');
		document.write('</style>');
	} else {
		document.write('<style type="text/css">');
		document.write('.img_over {height: 490px;width: 490px;position: relative;margin-bottom: -490px; margin-bottom: -490px; top: -490px; top: -490px;}');
		document.write('</style>');
	}
}


function eraseCookie(){
		document.cookie = "tla=";
	}

function deleteOneCookie(no){
	var co = document.cookie.split("%7C%7C%7C");
	var newCookie = "";
	for(var i=0; i<co.length; i++){
		if(i != Number(no)){
			newCookie += co[i];
			if(i < co.length-1) newCookie += "|||";
		}
	}
	var dat = new Date();
	var expi = new Date (dat.getTime() + 2592000);
	document.cookie = newCookie+";expires="+expi;
}

function changeDisplay(itemNo, itemName){
	var item2change = "subList"+itemNo;
	var sign2change = "subSign"+itemNo;
	if(document.getElementById(item2change).style.display == "none"){
		document.getElementById(item2change).style.display = "";
		document.getElementById(sign2change).innerHTML = "- "+itemName;
	} else {
		document.getElementById(item2change).style.display = "none";
		document.getElementById(sign2change).innerHTML = "+ "+itemName;
	}
}

function displayRecent(){
	if(document.getElementById("5more").style.display == "none"){
		document.getElementById("5more").style.display = "";
		document.getElementById("a5more").style.display = "none";
		document.getElementById("a5less").style.display = "";

	} else {
		document.getElementById("5more").style.display = "none";
		document.getElementById("a5more").style.display = "";
		document.getElementById("a5less").style.display = "none";
	}


}

function regionChange(totalNo){
	for(var i=0; i<(totalNo+1); i++){
		document.getElementById("subReg"+i).style.display = "none";
	}
	newList = document.rightOptionsForm.selregsubreg.selectedIndex;
	document.getElementById("subReg"+newList).style.display = "";
}

function setCat(cat2show, val){
	document.rightOptionsForm.cat.value = val;
	document.rightOptionsForm.cat2show.value = cat2show;
	document.rightOptionsForm.submit();
}

function changePage(pageNo){
	document.rightOptionsForm.pg.value = pageNo;
	document.rightOptionsForm.submit();
}

//function setSortBy(formid){
//	document.rightOptionsForm.sorttype.value = formid;
//	document.rightOptionsForm.submit();
//}


function submitHome(sel, regNo){
	document.rightOptionsForm.reg.value = regNo;
	document.rightOptionsForm.submit();
}

function checkContactForm(){
	if(document.contForm.nameBox.value != "" && document.contForm.emailBox.value != "" && document.contForm.emailBox.value.indexOf('@') > -1 && document.contForm.emailBox.value.indexOf('.') > -1 && document.contForm.topicBox.value != "" && document.contForm.textArea.value != ""){
		document.contForm.submit();
	} else {
		alert("すべての欄に記入");
		return false;
	}
}

function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURIComponentNew(s) {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}

function escape(s)
{
	if (s == "") return s;
	var encodedField = "";

	if (typeof encodeURIComponent == "function")
		encodedField = encodeURIComponent(s);
	else
		encodedField = encodeURIComponentNew(s);

	return encodedField;
}


