var TOP_TOPICS_DISPLAY_PATH='/cgi-bin/contents/topTopics/display.cgi';
var HOT_NEWS_DISPLAY_PATH='/cgi-bin/contents/hotNews/display.cgi';
var MAKER_COLLECTION_DISPLAY_PATH='/cgi-bin/contents/makerCollection/display.cgi';
var SPECIAL_BANNER_DISPLAY_PATH='/cgi-bin/contents/specialBanner/display.cgi';

var BOTTOM_BANNER_DISPLAY_PATH='/cgi-bin/contents/bottomBanner/display.cgi';

var CAMPAIGN_REST_DISPLAY_PATH ='/cgi-bin/contents/campaignRest/display.cgi';
//----------------------------------


var pageContName;
function displayPage(page_name,path) {
	var param = 'page='+page_name;
	var page_name2=page_name;
	var str1= page_name2.substr(0,1);
	var str2= page_name2.substr(1,page_name2.length);
	page_name2 =str1.toUpperCase()+str2;
	
	pageContName= 'page'+page_name2+'Cont';
	
	sendXRequest(pageCont, param, '/cgi-bin/contents/page/'+page_name+'/index.cgi','POST');
}

function displayPage2(page_name,path) {
	var param = 'page='+page_name;
	var page_name2=page_name;
	var str1= page_name2.substr(0,1);
	var str2= page_name2.substr(1,page_name2.length);
	page_name2 =str1.toUpperCase()+str2;
	
	pageContName= 'page'+page_name2+'Cont-'+path;
	sendXRequest(pageCont, param, '/cgi-bin/contents/page/'+page_name+'/'+path+'/index.cgi','POST');
}


function pageCont(obj) {

	var res= obj.responseText;

	document.getElementById(pageContName).innerHTML = res;
	frameInit();
}
//----------------------------------


function displayInfiniteTest(file) {
	var param = 'file='+file;
	sendXRequest(infiniteTestCont, param, '/cgi-bin/contents/service/display/index.cgi','POST');
}

function infiniteTestCont(obj) {
	var res= obj.responseText;
	document.getElementById('infiniteTestCont').innerHTML = res;
	frameInit();
}


function displayTopTopics() {
	var step='show';
	var param = 'function=execute&step='+step;

	sendXRequest(topTopicsCont, param, TOP_TOPICS_DISPLAY_PATH,'POST');
}
function topTopicsCont(obj) {
	var res= obj.responseText;
	document.getElementById('topTopicsCont').innerHTML = res;
	frameInit();
}

function displayHotNews() {
	var step='show';
	var param = 'function=execute&step='+step;
		
	sendXRequest(hotNewsCont, param, HOT_NEWS_DISPLAY_PATH,'POST');
}
function hotNewsCont(obj) {
	var res= obj.responseText;
	document.getElementById('hotNewsCont').innerHTML = res;
	frameInit();
}


function displayMakerCollection() {
	var step='show';
	var param = 'function=execute&step='+step;
		
	sendXRequest(makerCollectionCont, param, MAKER_COLLECTION_DISPLAY_PATH,'POST');
}
function makerCollectionCont(obj) {
	var res= obj.responseText;
	document.getElementById('makerCollectionCont').innerHTML = res;
	frameInit();
}

function displaySpecialBanner() {
	var step='show';
	var param = 'function=execute&step='+step;
		
	sendXRequest(specialBannerCont, param, SPECIAL_BANNER_DISPLAY_PATH,'POST');
}
function specialBannerCont(obj) {
	var res= obj.responseText;
	document.getElementById('specialBannerCont').innerHTML = res;
	frameInit();
}






function displayBottomBanner() {
	var step='show';
	var param = 'function=execute&step='+step;
	sendXRequest(bottomBannerCont, param, BOTTOM_BANNER_DISPLAY_PATH,'POST');
}










function bottomBannerCont(obj) {
	var res= obj.responseText;
	document.getElementById('bottomBannerCont').innerHTML = res;
	frameInit();
}
function campaignRest(id) {
	var param = 'CAMPAIGN_ID='+id;
	sendXRequest(CAMPAIGN_REST_CONT, param, CAMPAIGN_REST_DISPLAY_PATH,'POST');
}
function CAMPAIGN_REST_CONT(obj) {
	var res= obj.responseText;
	document.getElementById('CAMPAIGN_REST_CONT').innerHTML = res;
	frameInit();
}


var INFINITE_PHOTO_LIST_PATH ='/cgi-bin/contents/infinitePhoto/list.cgi';
var INFINITE_PHOTO_MENU_PATH ='/cgi-bin/contents/infinitePhoto/menu.cgi';

function infinitePhotoList(page_num){
	if(!page_num){
		page_num=1;
	}
	var param = 'PAGE_NUM='+page_num;
	sendXRequest(INFINITE_PHOTO_LIST_CONT, param, INFINITE_PHOTO_LIST_PATH,'POST');
}
function INFINITE_PHOTO_LIST_CONT(obj) {
	var res= obj.responseText;
	document.getElementById('INFINITE_PHOTO_LIST_CONT').innerHTML = res;
	frameInit();
}

var PHOTO_LIST_PATH ='/cgi-bin/contents/photoList/list.cgi';

function photoList(page_num, display_num,car_coating_en, car_maker_en){
	if(!page_num){
		page_num=1;
	}
	if(!display_num){
		display_num =50;
	}
	if(! car_coating_en){
		car_coating_en ='';
	}
	if(! car_maker_en){
		car_maker_en ='';
	}
	//コレクションごとにクッキー
	var param = 'PAGE_NUM='+page_num+'&DISPLAY_NUM='+display_num+
		'&CAR_COATING_EN='+car_coating_en+
		'&CAR_MAKER_EN='+car_maker_en+
		'&cache='+(new Date()).getTime();
		
	sendXRequest(PHOTO_LIST_CONT, param, PHOTO_LIST_PATH,'POST');
}
function photoListCarMakerSelect(page_num, display_num, car_coating_en){
	if(!page_num){
		page_num=1;
	}
	if(!display_num){
		display_num =50;
	}
	if(! car_coating_en){
		car_coating_en ='';
	}
	
	var car_maker_en = getElementValue('photoForm','CAR_MAKER_EN');
	//コレクションごとにクッキー
	var param = 'PAGE_NUM='+page_num+'&DISPLAY_NUM='+display_num+'&CAR_COATING_EN='+car_coating_en+'&CAR_MAKER_EN='+car_maker_en;
	sendXRequest(PHOTO_LIST_CONT, param, PHOTO_LIST_PATH,'POST');
}

function PHOTO_LIST_CONT(obj) {
	var res= obj.responseText;
	document.getElementById('PHOTO_LIST_CONT').innerHTML = res;
	frameInit();
}


function displaySubMenu(){
	var param = ''+
		'&cache='+(new Date()).getTime();
	sendXRequest(subMenuCont, param, '/cgi-bin/contents/subMenuCont/index.cgi','POST');
}
function subMenuCont(obj) {
	var res= obj.responseText;
	document.getElementById('subMenuCont').innerHTML = res;
	frameInit();
}


var sideBarCommon;
var sideBarCommon2;
function displaySideBar(){
	sideBarCommon='sidebarCont';
	sideBarCommon2='sidebarCont2';
	var param = ''+
		'&cache='+(new Date()).getTime();
		
	sendXRequest(sidebarCont, param, '/cgi-bin/contents/sidebarCont/index.cgi','POST');
	sendXRequest(sidebarCont2, param, '/cgi-bin/contents/sidebarCont2/index.cgi','POST');
}
function displaySideBarReserve(){
	sideBarCommon='sidebarReserveCont';
	sideBarCommon2='sidebarReserveCont2';
	var param = ''+
		'&cache='+(new Date()).getTime();
		
	sendXRequest(sidebarCont, param, '/cgi-bin/contents/sidebarCont/reserve.cgi','POST');
	sendXRequest(sidebarCont2, param, '/cgi-bin/contents/sidebarCont2/reserve.cgi','POST');
}
function displaySideBarShopping(){
	sideBarCommon='sidebarShoppingCont';
	sideBarCommon2='sidebarShoppingCont2';
	var param = ''+
		'&cache='+(new Date()).getTime();
		
	sendXRequest(sidebarCont, param, '/cgi-bin/contents/sidebarCont/shopping.cgi','POST');
	sendXRequest(sidebarCont2, param, '/cgi-bin/contents/sidebarCont2/shopping.cgi','POST');
}
function sidebarCont(obj) {
	var res= obj.responseText;
	document.getElementById(sideBarCommon).innerHTML = res;
	flashObjInit();
	frameInit();
}
function sidebarCont2(obj) {
	var res= obj.responseText;
	document.getElementById(sideBarCommon2).innerHTML = res;
	flashObjInit();
	frameInit();
}

function displayHighslideCont(){
	var param = '';
		
	sendXRequest(HIGH_SLIDE_CONT, param, '/cgi-bin/contents/highslideCont/display/index.cgi','POST');
}
function HIGH_SLIDE_CONT(obj) {

	var res= obj.responseText;
	document.getElementById('highslideCont').innerHTML = res;
}


function menuText(id,text){
	document.getElementById(id).innerHTML = text;
}


//---------------------------------------------------------


function displaySlideBody(target_name,str){
	slideBodyName = target_name+'Body';

	var param= str+
		'&cache='+(new Date()).getTime();

	sendXRequest(receiveSlideBody, param, '/cgi-bin/contents/slideCont/'+target_name+'/index.cgi','POST');
	stopFlash();

}
function receiveSlideBody(obj) {
	var res= obj.responseText;
	document.getElementById(slideBodyName).innerHTML = res;
}

var slideCont;
function openSlideCommon(target_name,str){
	var param= str+
		'&cache='+(new Date()).getTime();
		
	slideCont = target_name+'Body';
	sendXRequest(slideCommonCont, param, '/cgi-bin/contents/slideCont/'+target_name+'/index.cgi','POST');
	stopFlash();

}
function slideCommonCont(obj) {
	var res= obj.responseText;
	document.getElementById(slideCont).innerHTML = res;
}



var slide_cont_name;
function displaySlideCont(target_name,str){
	var param= str+
		'&cache='+(new Date()).getTime();
		
	slide_cont_name = target_name+'Cont';
	sendXRequest(receiveSlideCont, param, '/cgi-bin/contents/slideCont/'+target_name+'/index.cgi','POST');
}

function receiveSlideCont(obj) {
	var res= obj.responseText;
	document.getElementById(slide_cont_name).innerHTML = res;
}

function questionList(){
	var param= '';
	sendXRequest(questionListCont, param, '/cgi-bin/contents/questionList/index.cgi','POST');
}

function questionListCont(obj) {
	var res= obj.responseText;
	document.getElementById('questionListCont').innerHTML = res;
}

function openSlideCollection(type,target_value){
	var param;
	if(type =='detail'){
		 param= 'COLLECTION_ID='+target_value+
		'&cache='+(new Date()).getTime();
	}else if (type=='maker'){
		 param= 'CAR_MAKER_EN='+target_value+
		'&cache='+(new Date()).getTime();
	}
	slideCont = 'slideCollectionBody';
	sendXRequest(slideCollectionCont, param, '/cgi-bin/contents/slideCont/slideCollection/index.cgi','POST');
	stopFlash();

}
function slideCollectionCont(obj) {
	var res= obj.responseText;
	document.getElementById('slideCollectionBody').innerHTML = res;
}

function selectGuide(type) {
	var guide_category;
	var guide_group;
	var guide_id;
	
	var param='step=select';
	
	if(type=='category'){
		guide_category =getElementValue('guideFrom','CATEGORY_NAME_EN');
		if(guide_category){
			param= param+'&CATEGORY_NAME_EN='+guide_category;

		}
	}else if(type=='group'){
		guide_category =getElementValue('guideFrom','CATEGORY_NAME_EN');
		guide_group=getElementValue('guideFrom','GROUP_NAME_EN');
		if(guide_group){
			param= param+'&CATEGORY_NAME_EN='+guide_category+'&GROUP_NAME_EN='+guide_group;
		}
	}else if(type=='article'){
	
		guide_id=getElementValue('guideFrom','GUIDE_ID');
		if(guide_id){
			param= param+'&GUIDE_ID='+guide_id;
		}
	}

	var param=param+'&cache='+(new Date()).getTime();
	//alert(param);
	slideCont = 'slideGuideBody';
	sendXRequest(slideCommonCont, param, '/cgi-bin/contents/slideCont/slideGuide/index.cgi','POST');
	stopFlash();
}

function selectQuestion(type) {
	var question_category;
	var question_group;
	var question_id;
	
	var param='step=select';
	
	if(type=='category'){
		question_category =getElementValue('questionFrom','CATEGORY_NAME_EN');
		if(question_category){
			param= param+'&CATEGORY_NAME_EN='+question_category;

		}
	}else if(type=='group'){
		question_category =getElementValue('questionFrom','CATEGORY_NAME_EN');
		question_group=getElementValue('questionFrom','GROUP_NAME_EN');
		if(question_group){
			param= param+'&CATEGORY_NAME_EN='+question_category+'&GROUP_NAME_EN='+question_group;
		}
	}else if(type=='article'){
	
		question_id=getElementValue('questionFrom','QUESTION_ID');
		if(question_id){
			param= param+'&QUESTION_ID='+question_id;
		}
	}
	var param=param+'&cache='+(new Date()).getTime();

	//alert(param);
	slideCont = 'slideQuestionBody';
	sendXRequest(slideCommonCont, param, '/cgi-bin/contents/slideCont/slideQuestion/index.cgi','POST');
	stopFlash();
}
