/*@cc_on _d=document;eval('var document=_d')@*/

/**
 * 教えて！モリサワさんフォームで質問内容が空欄の場合、遷移を制限する
 * 
 * @package	FORM
 * @since	2009/11/11
 */
function restrictAgentForm(div_id, div_class)
{
	var text_field	= document.agent_form.search_word;
	var div_obj		= document.getElementById(div_id);
	
	
	// trim
	trim_str	= text_field.value.replace(/^[ 　]+/,"").replace(/[ 　]+$/,"");
	
	if(trim_str == '' || trim_str == '(例)パスポートってどんな製品？')
	{
		div_obj.className	= div_class + '-er';
		text_field.focus();
		
		
		return false;
	}
}

/**
 * 教えて！モリサワさんフォームで質問内容が空欄の場合、遷移を制限する(ご利用ガイドページ)
 * 
 * @package	FORM
 * @since	2009/12/17
 */
function restrictAgentFormGuide(obj)
{
	var text_field	= document.agent_form.search_word;
	
	
	// trim
	trim_str	= text_field.value.replace(/^[ 　]+/,"").replace(/[ 　]+$/,"");
	
	if(trim_str == '' || trim_str == '(例)パスポートってどんな製品？')
	{
		obj.style.backgroundImage	= 'url(/common/imgs/agent-hdl-er.gif)';
		text_field.focus();
		
		
		return false;
	}
}

/**
 * button押下時にhiddenタグ追加(戻るボタンで使用)
 * 
 * 戻るボタンもtype="submit"にすると、
 * IE6では全submitボタンの情報が送られてしまう為、戻るを押した時だけname="back"の情報が渡せるように
 * 
 * @package	FORM
 * @since	2009/11/04
 */
function submitBack(obj)
{
	var tag		= document.createElement('input');
	tag.name	= "back";
	tag.value	= "1";
	tag.type	= "hidden";
	obj.form.appendChild(tag);
	
	obj.form.submit();
}

/**
 * サイト内検索フォームで内容が空欄の場合、遷移を制限する
 * 
 * @package	FORM
 * @since	2010/01/19
 */
function restrictSiteSearchForm(obj)
{
	var text_field	= obj.q;
	
	// &nbsp;を置換
	var nbsp	= String.fromCharCode(160);
	var value	= text_field.value.replace(nbsp, "");
	
	// trim
	trim_str	= value.replace(/^[ 　]+/,"").replace(/[ 　]+$/,"");
	
	if(trim_str == '' || trim_str == 'このサイト内を検索')
	{
		text_field.focus();
		
		
		return false;
	}
}

/**
 * 教えて！モリサワさんフォームで質問内容が空欄の場合、遷移を制限する(サイト内検索ページで使用)
 * 
 * @package	FORM
 * @since	2010/01/19
 */
function restrictAgentFormForSiteSearch(div_id, div_class)
{
	var text_field	= document.agent_form.search_word;
	var div_obj		= document.getElementById(div_id);
	
	
	// trim
	trim_str	= text_field.value.replace(/^[ 　]+/,"").replace(/[ 　]+$/,"");
	
	if(trim_str == '' || trim_str == '(例)パスポートってどんな製品？')
	{
		div_obj.className	= div_class + '-er';
		text_field.focus();
		
		
		return false;
	}
	
	
	var tag		= document.createElement('input');
	tag.name	= "referer_page";
	tag.value	= document.location.href;
	tag.type	= "hidden";
	document.agent_form.appendChild(tag);
	
	document.agent_form.submit();
}
