//<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
var domain="be-webdesigner.com";
var url="http://www.be-webdesigner.com/";
var lc=location.href;
var dlength=domain.length;



// 手空きに作る
function observeLine(t){
	return;
	

	var lange = 5;
	
	var n = t.value.match(/\n/g);
	var len = n ? n.length + 2 : 9;
	
	if(len > 20) len = 20;

	
	if((len & lange) ==0){
		t.style.height = len * 18;
	}
}



function acclog(){
	
	if(isTest()){
		return;
	}
	
	if(lc.indexOf(domain)){
		var tmp=lc.indexOf(domain,0)+dlength;
		tmp=lc.substring(tmp);
		
		if(tmp.substring(tmp.length-1)=="/"){
			//tmp+="index.htm";
		}
	}
	document.write("<img src=\"http://www.be-webdesigner.com/cgi-bin/report/log.cgi?"+tmp+","+ lc +"," + document.referrer +"\" width=\"1\" height=\"1\">");
}


function isTest(){
	if(lc.indexOf('//local.') >= 0 || lc.indexOf('192.168.1.') >= 0 || lc.toLowerCase().indexOf('rserver') >= 0){
		return true;	
	}else{
		return false;
	}
}

function writeMail(t1,t3,t2,linkT){
	if(linkT==""||linkT==undefined){
		var linkT='メール';
	}

	var tmp='mailto:'+t1;
	var tmp2=t2;
	var tmp3=t3;

	document.write('<A href="' + tmp + tmp2 + tmp3 +'">'+linkT+'</A>');
}


function getId(){

	var tmp=Math.ceil(Math.random() * b_h4.length);
	if(tmp==b_h4.length){
		tmp=0;
	}
	return(tmp);
}




function getRandom(e){
	var tmp=Math.ceil(Math.random() * e);
	//alert(tmp);
	return(tmp);
}


function printSearchBox(){
	document.open();
	document.write('<form action="http://search.yahoo.co.jp/search" method="get">');
	document.write('<p><a href="http://search.yahoo.co.jp" target="_blank">Powered by Yahoo!検索</a><br>');
	document.write('<input type="text" name="p" value="サイト内検索" onfocus="if(this.value==\'サイト内検索\'){this.value=\'\';this.style.color=\'#000000\';}" onblur="if(this.value==\'\'){this.value=\'サイト内検索\';this.style.color=\'#999\';}" style="vertical-align:top;margin-right:5px;width:175px;color:#999">');
	document.write('<input type="image" src="/img/search.gif">');
	document.write('<input type="hidden" name="fr" value="yssw">');
	document.write('<input type="hidden" name="ei" value="UTF-8">');
	document.write('<input name="vs" type="hidden" value="www.be-webdesigner.com">');
	document.write('</p>');
	document.write('</form>');
	document.close();
}


function printSearchBoxPlain(){
	document.open();
	document.write('<form action="http://search.yahoo.co.jp/search" method="get">');
	document.write('<input type="text" name="p" value="サイト内検索" onfocus="if(this.value==\'サイト内検索\'){this.value=\'\';this.style.color=\'#000000\';}" onblur="if(this.value==\'\'){this.value=\'サイト内検索\';this.style.color=\'#999\';}" style="vertical-align:top;margin-right:5px;width:175px;color:#999">');
	document.write('<input type="image" src="/img/search.gif">');
	document.write('<input type="hidden" name="fr" value="yssw">');
	document.write('<input type="hidden" name="ei" value="UTF-8">');
	document.write('<input name="vs" type="hidden" value="www.be-webdesigner.com">');
	document.write('</p>');
	document.write('</form>');
	document.close();
}




function print_comment(page, mode){
	
	var buf = new String();
	var h4 = new String();
	var title = new String();
	var array = new Array();
	
	//タイトルが長ければ省略
	array = document.title.split('-');
	
	
	if(array[0] > 64){
		title = array[0](0, 64)+"…";
	}else{
		title = array[0];
	}
	
	if(mode == 'ARTICLE'){
		h4 = '「'+title+'」<br>の記事についてコメントする！';
		p = 'この記事について質問など、お気軽にコメントをお送りください。</a>';		
	}/*else if(mode == 'INDEX'){
		h4 = 'こんな記事を書いてほしい！<br>このカテゴリに記事をリクエストする！！';
		p = 'このカテゴリに関連しそうな記事をリクエストできます。必ずご希望に添えるわけではありませんが、今後のページ制作に役立たせていただきます。';		
	}else if(mode == 'TOP'){
		h4 = 'こんな記事を書いてほしい！<br>記事をリクエストする！！';
		p = '管理人に書いて欲しい記事をリクエストできます。必ずご希望に添えるわけではありませんが、今後のページ制作に役立たせていただきます。';		
	}*/else{
		return;
	}
	
	if(getRandom(2) == 1){
		var faceType = 'face';
	}else{
		var faceType = 'face2';
	}
	
	
	
	
	buf += '<a name="comment"></a><div id="comment">';
	buf += '<form method="POST" id="commentForm" name="commentForm" action="/contact/comment/" target="new" onSubmit="window.open(\'\',\'new\',\'width=730, height=650,scrollbars=yes, resizable=1\');">';
	buf += '<table border="0" cellpadding="0" cellspacing="0" id="commentTitle">';
	buf += '<tr>';
	buf += '<td style="font-size:0;" rowspan="3" class="commentTf"><img src="/img/comment/'+faceType+'.gif" alt="" width="40" height="60"></td>';
	buf += '<td style="font-size:0;" class="commentTnw"><img src="/img/comment/table_nw.gif" alt="" width="13" height="12"></td>';
	buf += '<td style="font-size:0;" class="commentTn"><img src="/img/comment/table_n.gif" alt="" width="13" height="12"></td>';
	buf += '<td style="font-size:0;" class="commentTne"><img src="/img/comment/table_ne.gif" alt="" width="13" height="12"></td>';
	buf += '</tr>';
	
	buf += '<tr>';
	buf += '<td class="commentTw"><img src="/img/comment/table_w2.gif"></td>';
	buf += '<td>'+h4+'</td>';
	buf += '<td class="commentTe"><img src="/img/comment/table_e.gif"></td>';
	buf += '</tr>';
	
	buf += '<tr>';
	buf += '<td style="vertical-align:top;"><img src="/img/comment/table_sw.gif" alt="" width="13" height="12"></td>';
	buf += '<td style="vertical-align:top;" class="commentTs"><img src="/img/comment/table_s.gif" alt="" width="13" height="12"></td>';
	buf += '<td style="vertical-align:top;"><img src="/img/comment/table_se.gif" alt="" width="13" height="12"></td>';
	buf += '</tr>';
	buf += '</table>';
	
	//buf += '<p style="margin:0;">'+p+'<a href="JavaScript:window.open(\'/contact/comment/help.htm\',\'win\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=886,height=650,screenX=0,screenY=0\');void(0);" class="thickbox"><img src="/img/hatena.gif" style="vertical-align:middle;"></a></p>';
	//buf += '<p style="margin:0;">'+p+'<a href="/contact/comment/help.htm?TB_iframe=true&width=720&height=760" class="thickbox"><img src="/img/hatena.gif" style="vertical-align:middle;"></a></p>';
	buf += '<p style="margin:0;">'+p+'</p>';
	buf += '<input type="hidden" name="page" value="'+page+'" class="form-input">';
	buf += '<input type="hidden" name="title" value="'+document.title+'">';
	buf += '<dl style="width:100%;margin-top:10px;">';
	buf += '<dt>お名前:<img src="/img/form/require.gif"></dt><dd style="margin:0 0 10px 0;"><input type="text" class="input" name="name" value="" style="width:170px;" /></dd>';
	buf += '<dt>メールアドレス:<img src="/img/form/un_require.gif"></dt><dd style="margin:0 0 10px 0;"><input type="text" class="input" name="email" value="" style="width:170px;" /> （メールアドレスは公開されませんのでご安心ください。）</dd>';
	buf += '<dt>本文:<img src="/img/form/require.gif"></dt><dd style="margin:0 0 7px 0;"><textarea cols="60" rows="15" name="comment"></textarea></dd><dd style="text-align:right;"><div style="margin:8px 0 0 0;"><input type="submit" value="入力内容を確認する"></div><div style="font-size:10px;padding:3px 0 0 0;">（※新規ウィンドウまたはタブで開きます）</div></dd>';
	buf += '</dl>';
	buf += '</form>';
	//document.write('<p>※質問コーナーからの投稿メールが増えすぎてしまったため、いったんこのコーナーを停止させていただきます。（すいません）</p>');
	buf += ('</div>');
	document.open();
	document.write(buf);
	document.close();
}

var ColorfulInput = {
   init: function() {
      this.addEvent(window, 'load', this.set());
   },
   set: function() {

		
		var self = this;
      return function() {
			//alert(document.forms.length);
			for (var i = 0; i < document.forms.length; i++) {
				for (var f = 0; f < document.forms[i].length; f++) {
					var elm = document.forms[i][f];
					
					if(!_checkSkip(elm)) continue;

					_setColor(elm, 'focus');
					_setColor(elm, 'blur');
				}       
			}
		}
		function _checkSkip(elm) {
			var skip  = ['submit', 'reset', 'button'];

			for(var i in skip) {
				if(elm.type == skip[i]) return false;
			}
			return true;
		}
	
		function _setColor(elm, type) { 
			var defineColor = { 'blur': '', 'focus': '#fff6d1' };
//			var defineColor = { 'blur': 'solid 1px #7f9db9', 'focus': 'solid 2px #0000ee' };
		
			var color = defineColor[type];
			var event = function() { elm.style.backgroundColor = color; };
//			var event = function() { elm.style.border = color; };
	
			if(elm.addEventListener) {
				elm.addEventListener(type, event, false); 
			} else if(elm.attachEvent) {
				elm.attachEvent('on'+type, event); 
			} else {
				elm['on'+type] = event;
			}
		}
	},
   addEvent: function(elm, type, event) {
      if(elm.addEventListener) {
         elm.addEventListener(type, event, false);
      } else if(elm.attachEvent) {
         elm.attachEvent('on'+type, event);
      } else {
         elm['on'+type] = event;
      }
   }	
}
ColorfulInput.init();








/**-----------------------------------------------------------------------------------
 * ブラウザを判別するオブジェクト
 * そんなに正確じゃありませんのでサイト構築後に都度チェックして下さい。
 * 
 *（コンストラクタ）
 */
var Browser = function() {
	
	//this.browser = this.getBrowser();
	//this.platform = this.getPlatform();
	
}
Browser.prototype = {
	getBrowser: function () {
		var an = navigator.appName.toLowerCase();
		var ua = navigator.userAgent.toLowerCase();
	
		if (document.all || document.getElementById || document.layers) {
			if (an == "microsoft internet explorer") {
	
				if (ua.indexOf("opera 6") >= 0) {
					return "opera6";
				} else if (ua.indexOf("opera 1") >= 0) {
					return "opera1";
				} else if (ua.indexOf("opera 2") >= 0) {
					return "opera2";
				} else if (ua.indexOf("opera 3") >= 0) {
					return "opera3";
				} else if (ua.indexOf("opera 4") >= 0) {
					return "opera4";
				} else if (ua.indexOf("opera 5") >= 0) {
					return "opera5";
				} else if (ua.indexOf("opera 6") >= 0) {
					return "opera6";
				} else if (ua.indexOf("opera 7") >= 0) {
					return "opera7";
				} else if (ua.indexOf("opera 8") >= 0) {
					return "opera8";
				} else if (ua.indexOf("opera 9") >= 0) {
					return "opera9";
				} else if (ua.indexOf("opera 10") >= 0) {
					return "opera10";
				} else if (ua.indexOf("opera 11") >= 0) {
					return "opera11";
				} else if (ua.indexOf("opera 12") >= 0) {
					return "opera12";
				} else if (ua.indexOf("msie 3") >= 0) {
					return "ie3";
				} else if (ua.indexOf("msie 4") >= 0) {
					return "ie4";
				} else if (ua.indexOf("msie 5") >= 0) {
					return "ie5";
				} else if (ua.indexOf("msie 6") >= 0) {
					return "ie6";
				} else if (ua.indexOf("msie 7") >= 0) {
					return "ie7";
				} else if (ua.indexOf("msie 8") >= 0) {
					return "ie8";
				} else if (ua.indexOf("msie 9") >= 0) {
					return "ie9";
				} else if (ua.indexOf("msie 10") >= 0) {
					return "ie10";
				}else{
					return "Other";
				}
			} else if (an == "netscape") {
				if (ua.indexOf("netscape6") >= 0) {
					return "netscape";
				} else if (ua.indexOf("netscape/7") >= 0) {
					return "netscape";
				} else if (ua.indexOf("netscape/8") >= 0) {
					return "netscape";
				} else if (ua.indexOf("netscape/9") >= 0) {
					return "netscape";
				} else if (ua.indexOf("firefox/1.5") >= 0) {
					return "firefox";
				} else if (ua.indexOf("firefox/2") >= 0) {
					return "firefox";
				} else if (ua.indexOf("firefox/3") >= 0) {
					return "firefox";
				} else if (ua.indexOf("safari") >= 0) {
					return "safari";
				} else if (ua.indexOf("chrome") >= 0) {//Chrome/2
					return "chrome";
				}
				
				else{
					return "other";
				}
			}else{
				return "other";
			}
		}else{
			if (an =="Netscape") {
				//return "netscapeOLD";
				return "other";
			} else if (an =="microsoft internet explorer") {
				//return "ieOLD";
				return "other";

			}else{
				//return "OLD";
				return "other";
			}
		}
	},
	getPlatform: function () {
		var tmp = navigator.platform.toUpperCase();
	
		if (tmp.indexOf("WIN") >= 0) {
			return "WIN";
		} else if (tmp.indexOf("MAC") >= 0) {
			return "MAC";
		} else if (tmp.indexOf("X11") >= 0) {
			return "UNIX";
		}else{
			return "other";
		}
	}
}


/**-----------------------------------------------------------------------------------
 * 
 * コンストラクタ
 *
 */
var Css = function() {

	// CSSのTOPディレクトリ
	this.cssDir = '/css/';
	
	// ブラウザごとに読み込ませるCSSのディレクトリ
	this.browserDir = this.cssDir + 'browser/';
	
	//this.setStyle();
}
Css.prototype = {
	importByBrowser: function () {
		var browser = new Browser();
		var b = browser.getBrowser();
		var p = browser.getPlatform();
		
		document.open();
	
		// 読み込むCSSをコメントアウトで調整して下さい。
		if (p=="WIN") {
			if (b=="ie6") {
				//document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_ie6.css\" type=\"text/css\">");
			} else if (b=="ie7") {
				//document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_ie7.css\" type=\"text/css\">");
			} else if (b=="ie8") {
				//document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_ie8.css\" type=\"text/css\">");
			} else if (b=="firefox") {
				//alert("test");
				//alert("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_firefox.css\" type=\"text/css\">");
			} else if (b=="ie5") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_ie6.css\" type=\"text/css\">");
			} else if (b=="ie4") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_ie6.css\" type=\"text/css\">");
			} else if (b=="safari") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_safari.css\" type=\"text/css\">");
			} else if (b=="netscape7") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_netscape7.css\" type=\"text/css\">");
			} else if (b=="netscape6") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_netscape6.css\" type=\"text/css\">");
			} else if (b=="netscape4") {
				//isOK();
			} else if (b=="opera6") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_opera6.css\" type=\"text/css\">");
			} else if (b=="opera7") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "win_opera7.css\" type=\"text/css\">");
			} else if ((b=="ieOLD") || (b=="netscapeOLD") || (b=="OLD")) {
				// document.write("");
			}else{
				// document.write("");
			}
		} else if (p=="MAC") {
	
			if (b=="ie5") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "mac_ie5.css\" type=\"text/css\">");
			} else if (b=="ie4") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "mac_ie.css\" type=\"text/css\">");
			} else if (b=="firefox") {
				document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "mac_firefox.css\" type=\"text/css\">");
			} else if (b=="safari") {
				document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "mac_safari.css\" type=\"text/css\">");
			} else if (b=="opera6") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "mac_op.css\" type=\"text/css\">");
			} else if (b=="opera7") {
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "mac_op.css\" type=\"text/css\">");
			}else{
				// document.write("<link rel=\"stylesheet\" href=\"" + this.browserDir + "mac.css\" type=\"text/css\">");
			}
		}
		document.close();
	},
	// importByBrowserの別名
	importByUa: function () {
		this.importByBrowser();
	},
	setCssDir: function($dir) {
		this.cssDir = $dir;
	},
	setBrowserDir: function($dir) {
		this.browserDir = $dir;
	}
}






var css = new Css();
// ブラウザごとに違うCSSをセット
css.setBrowserDir('/css/browser/');
css.importByBrowser();











/*


var DisableSubmit = {
   init: function() {
      this.addEvent(window, 'load', this.set());
   },

   set: function() {
      var self = this;
      return function() {
         for (var i = 0; i < document.forms.length; ++i) {
            if(document.forms[i].onsubmit) continue;
            document.forms[i].onsubmit = function() {
               self.setDisable(this.getElementsByTagName('input'));
            };
         }
      }
   },

   setDisable: function(elms) {
      for (var i = 0, elm; elm = elms[i]; i++) {
         if ((elm.type == 'submit' || elm.type == 'image') && !elm.disabled) {
            Set(elm);
            unSet(elm);
         }
      }

      function Set(button) {
         window.setTimeout(function() { button.disabled = true; }, 1);
      }
      function unSet(button) {
         window.setTimeout(function() { button.disabled = false; }, 1000);
      }
   },

   addEvent: function(elm, type, event) {
      if(elm.addEventListener) {
         elm.addEventListener(type, event, false);
      } else if(elm.attachEvent) {
         elm.attachEvent('on'+type, event);
      } else {
         elm['on'+type] = event;
      }
   }
}

DisableSubmit.init();

*/

