var slide_obj_num = 1;
var slide_obj_nums;

$(document).ready(function(){
	slide_obj_nums = $('#slidingText p').length;
	if (slide_obj_nums > 1) {
		sliding_notice();
	}
});

function sliding_notice() {
	var obj = $("#slidingText p:nth-child(" + slide_obj_num + ")");
	setTimeout("slide_hide()", 5000);
	return false;
}

function slide_hide() {
	
	$("#slidingText p:nth-child(" + slide_obj_num + ")").hide("slide", { direction: "left" }, 3000, function() { slide_show(); });
	
	if (slide_obj_num == slide_obj_nums) {
		slide_obj_num = 1;
	}
	
	else {
		slide_obj_num++;
	}
	
	return false;
}

function slide_show() {
	$("#slidingText p:nth-child(" + slide_obj_num + ")").show("slide", { direction: "right" }, 3000, function() { sliding_notice(); });
	return false;
	
}

/* -----------------------------------------------------------
 * pagerのselectでlocation.href
----------------------------------------------------------- */
function sel_location(obj) 
{
	location.href = obj.options[obj.selectedIndex].value;
}

/* -----------------------------------------------------------
 * detail  image change
----------------------------------------------------------- */
function set_img(obj, target) 
{
	var photo_main = document.getElementById(target);
	photo_main.setAttribute("src", obj.getAttribute("src"));
}

function OnSubmit(frm, act, type, para)
{
	frm.target = "_top";
	frm.action += "?act=" + act + "&type=" + type;
	if (para) 
	{
		frm.action += "&para=" + para;
	}
	frm.submit();
}

function OnConfSubmit(frm, act, type, para, confmsg)
{
	frm.target = "_top";
	frm.action += "?act=" + act + "&type=" + type;
	if (para) 
	{
		frm.action += "&para=" + para;
	}
	
	if (confirm(confmsg))
	{
		//frm.submit();
		//OKのときSubmit
		try 
		{
			frm.submit();
		}
		catch(e) 
		{
			// input type=file でファイルが存在しないとJavaScriptエラーが発生するので、try-catchで回避する
			if (e.number == -2147024891) 
			{
				alert(e.message + "添付ファイルが存在するか、確認ください。");	//「アクセスが拒否されました。」
			}
		}
	}
}


/* -----------------------------------------------------------
 * searchTruck  text hint
----------------------------------------------------------- */
$(function(){
  $('#text').blur(function(){
		var $$=$(this);
		if($$.val()=='' || $$.val()==$$.attr('title')){
			$$.css('color', '#999')
			.val($$.attr('title'));
		}
	})
	.focus(function(){
		var $$=$(this);
		if($$.val()==$$.attr('title')){
			$(this).css('color', '#000').val('');
		}
	})
	.parents('form:first').submit(function(){
		var $$=$('#text');
		if($$.val()==$$.attr('title')){
			$$.triggerHandler('focus');
		}
	}).end()
	.blur();
});

/* -----------------------------------------------------------
 * searchTruck zno 6桁制御
----------------------------------------------------------- */
function setZno(obj)
{
	if (obj.value)
	{
		if (parseInt(obj.value, 10))
		{
			var numtext = "000000" + obj.value;
			obj.value = numtext.substr(obj.value.length, 6);
		}
	}
}

/* -----------------------------------------------------------
 * searchTruck 検索条件クリア
----------------------------------------------------------- */
function clr(frm)
{
	frm.mkr.value = "";
	frm.agf.value = "";
	frm.agt.value = "";
	frm.sz .value = "";
	frm.mdl.value = "";
	frm.kj .value = "";
	frm.zno.value = "";
	frm.kwd.value = "";
}
