/**
 * 利用日初期値設定function
 */
$( function(){
	var obj;
	var now_year;
	var now_month;
	var now_day;
	nowDate_defo = new Date();
	nowDate = new Date( nowDate_defo.getFullYear(), parseInt(nowDate_defo.getMonth(),10), parseInt(nowDate_defo.getDate(),10) + 2 );
	if (parseInt(nowDate.getMonth(),10) != 11) {
		nowDate = new Date( nowDate.getFullYear(), parseInt(nowDate.getMonth(),10) + 1, parseInt(nowDate.getDate(),10) );
		now_year = nowDate.getFullYear();
		now_month = nowDate.getMonth();
		now_day = nowDate.getDate();
	} else {
		nowDate = new Date( nowDate.getFullYear(), 11, parseInt(nowDate.getDate(),10) );
		now_year = nowDate.getFullYear();
		now_month = 12;
		now_day = nowDate.getDate();
	}
	
	obj = document.check_form;
	if ( obj == 'undefined' || obj == null || obj == '' ) obj = document.map_form;
	if ( obj == 'undefined' || obj == null || obj == '' ) obj = document.needs_form;
	
	if ( obj != 'undefined' && obj != null && obj != '' ){
		for ( i = 0; i < obj.year_loans.length; i++ ) {
			if ( now_year == obj.year_loans.options[i].value ) obj.year_loans.options.selectedIndex = i;
		}
		for ( i = 0; i < obj.month_loans.length; i++ ) {
			if ( now_month == obj.month_loans.options[i].value ) obj.month_loans.options.selectedIndex = i;
		}
		for ( i = 0; i < obj.day_loans.length; i++ ) {
			if ( now_day == obj.day_loans.options[i].value ) obj.day_loans.options.selectedIndex = i;
		}
//		for ( i = 0; i < obj.hour_loans.length; i++ ) {
//			if ( 10 == obj.hour_loans.options[i].value ) obj.hour_loans.options.selectedIndex = i;
//		}
		if ( obj.name == 'check_form' ) {
			for ( i = 0; i < obj.year_return.length; i++ ) {
				if ( now_year == obj.year_return.options[i].value ) obj.year_return.options.selectedIndex = i;
			}
			for ( i = 0; i < obj.month_return.length; i++ ) {
				if ( now_month == obj.month_return.options[i].value ) obj.month_return.options.selectedIndex = i;
			}
			for ( i = 0; i < obj.day_return.length; i++ ) {
				if ( now_day == obj.day_return.options[i].value ) obj.day_return.options.selectedIndex = i;
			}
//			for ( i = 0; i < obj.hour_return.length; i++ ) {
//				if ( 17 == obj.hour_return.options[i].value ) obj.hour_return.options.selectedIndex = i;
//			}
		}
	}
});

/**
 * トップページで使用するファンクション

function JUMP(){
var url = "http://www.rental-car.jp/jnet/cars/index/00/00/";
//var formobj = document.check_form;

var obj = document.check_form.prefecture; // 県
url += setSeparate( obj.options[obj.selectedIndex].value, "/-/" );

obj  = document.check_form.year_loans;    // 出発年
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.month_loans;   // 出発月
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.day_loans;     // 出発日
url += setSeparate( obj.options[obj.selectedIndex].value, "/" );

obj  = document.check_form.year_return;   // 返却年
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.month_return;  // 返却月
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.day_return;    // 返却日
url += setSeparate( obj.options[obj.selectedIndex].value, "/" );

obj  = document.check_form.hour_loans;    // 出発時
url += setSeparate( obj.options[obj.selectedIndex].value, "-00/" );

obj  = document.check_form.hour_return;   // 返却時
url += setSeparate( obj.options[obj.selectedIndex].value, "-00/,/,/" );

url += setSeparate( "556", "/" );
//ブランド、グループ
url += "2/89/";
url += "#view_point"; //アンカーリンク
window.open(url);
} 
*/
function JUMP(){
var url = "http://www.rental-car.jp/jnet/cars/index/00/00/";
//var formobj = document.check_form;

var obj = document.check_form.prefecture; // 県
url += setSeparate( obj.options[obj.selectedIndex].value, "/-/" );
obj  = document.check_form.year_loans;    // 出発年
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.month_loans;   // 出発月
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.day_loans;     // 出発日
url += setSeparate( obj.options[obj.selectedIndex].value, "/" );

obj  = document.check_form.year_return;   // 返却年
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.month_return;  // 返却月
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.day_return;    // 返却日
url += setSeparate( obj.options[obj.selectedIndex].value, "/" );
url += "-/-/,/,/";
obj  = document.check_form.area;          // エリア

	//営業所
	if ( obj.options[obj.selectedIndex].value == 'undefined' || obj.options[obj.selectedIndex].value == null || obj.options[obj.selectedIndex].value == '' ) {
		url += setSeparate( '-', "/" );
	} else {
		url += setSeparate( obj.options[obj.selectedIndex].value, "/" );
	}
	
	//ブランド、グループ
	url += "2/11/";

	//url += "#view_point"; アンカーリンク
	window.open(url);
}

function JUMPTOP(){
var url = "http://www.rental-car.jp/jnet/cars/index/00/00/";
//var formobj = document.check_form;

var obj = document.check_form.prefecture; // 県
url += setSeparate( obj.options[obj.selectedIndex].value, "/-/" );
obj  = document.check_form.year_loans;    // 出発年
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.month_loans;   // 出発月
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.day_loans;     // 出発日
url += setSeparate( obj.options[obj.selectedIndex].value, "/" );

obj  = document.check_form.year_return;   // 返却年
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.month_return;  // 返却月
url += setSeparate( obj.options[obj.selectedIndex].value, "-" );
obj  = document.check_form.day_return;    // 返却日
url += setSeparate( obj.options[obj.selectedIndex].value, "/" );
url += "-/-/";

obj  = document.check_form.car_type;
for ( i = 0, j= 0; i < obj.length; i++ ) {
if ( obj[i].checked ) {
if ( j != 0 ) url += setSeparate( "", "," );
url += setSeparate( obj[i].value, "" );
if ( j == 0 ) j++;
}
}
url += ",/,/";

	obj  = document.check_form.area;          // エリア
	
	//営業所
	if ( obj.options[obj.selectedIndex].value == 'undefined' || obj.options[obj.selectedIndex].value == null || obj.options[obj.selectedIndex].value == '' ) {
		url += setSeparate( '-', "/" );
	} else {
		url += setSeparate( obj.options[obj.selectedIndex].value, "/" );
	}
	
	//ブランド、グループ
	url += "2/11/";

	//url += "#view_point"; アンカーリンク
	window.open(url);
}


/**
 * 文字列追加ファンクション
 * param  string param    パラメータ
 * param  string separate パラメータを区切る文字
 *                        例：'3/47' や '2010-1'
 * return string url      param + separate
 *                        例：param = '9', separate = '-' なら '9-'
 */
function setSeparate( param, separate ){
var url  = param;
    url += separate; // 区切り文字追加
return url;
}


var $area_list = new Array();
$area_list["0"] = new Array();
$area_list["0"]["0"] = new Array();$area_list["0"]["0"].push("店舗を選択");

$area_list["46"] = new Array();
$area_list["46"]["0"] = new Array();$area_list["46"]["0"].push("店舗を選択");
$area_list["46"]["1"] = new Array();$area_list["46"]["1"].push("");
$area_list["46"]["1"].push("5");$area_list["46"]["0"].push("屋久島店");
$area_list["46"]["1"].push("552");$area_list["46"]["0"].push("屋久島安房港店");

var view_area = {
"1":$area_list[1],"2":$area_list[2],"3":$area_list[3],"4":$area_list[4],
"5":$area_list[5],"6":$area_list[6],"7":$area_list[7],"8":$area_list[8],
"9":$area_list[9],"10":$area_list[10],"11":$area_list[11],"12":$area_list[12],
"13":$area_list[13],"14":$area_list[14],"15":$area_list[15],"16":$area_list[16],
"17":$area_list[17],"18":$area_list[18],"19":$area_list[19],"20":$area_list[20],
"21":$area_list[21],"22":$area_list[22],"23":$area_list[23],"24":$area_list[24],
"25":$area_list[25],"26":$area_list[26],"27":$area_list[27],"28":$area_list[28],
"29":$area_list[29],"30":$area_list[30],"31":$area_list[31],"32":$area_list[32],
"33":$area_list[33],"34":$area_list[34],"35":$area_list[35],"36":$area_list[36],
"37":$area_list[37],"38":$area_list[38],"39":$area_list[39],"40":$area_list[40],
"41":$area_list[41],"42":$area_list[42],"43":$area_list[43],"44":$area_list[44],
"45":$area_list[45],"46":$area_list[46],"47":$area_list[47]
};

/**
 * エリアプルダウン作成
 * param  string select_SpotId
 * param  string make_AreaName
 * param  string area_id
 * return string 空文字
 */
function make_AreaPulldown( select_SpotId, make_AreaName, area_id ){
	var $pulldown_area = $( '#' + make_AreaName );
	$pulldown_area.empty();
	$option_entries = new Array();
	
	$.each( view_area[ select_SpotId ]["0"], function(j){
		var select_r = '';
		if ( area_id != '' ){
			if ( area_id == parseInt( $area_list[select_SpotId]["1"][j] )){
				select_r = 'selected';
			}
		}
		$option_entries.push( '<option value="'+ $area_list[ select_SpotId ]["1"][j] +'" '+ select_r +'>'+ this +'</option>' );
	});
	$pulldown_area.append( $option_entries.join() );
	return '';
};

