tboks.webtboks.all_info={};

/**
 * 当用户选择domain时候获得所选择的domain id用于显示相应的category
 * 
 * @param {int} domainid
 */
 tboks.webtboks.all_info.getCategoryByDomainID=function(domainid)
{	
	if(domainid == 0)
	return;
	if (tboks.webtboks.all_info.cllfqzxxdiv()) {
		jAlert("Veuillez préciser si vous voulez demander un service ou, si vous recherchez un job.","Tboks");
		return;
	}
	if(domainid == 38)
	{
		$('#ProTravelDiv').show();
		$('#ProButtonDiv').show();
		$('#NoProDiv').hide();
		$('#NoProButtonDiv').hide();
	}else{
		$('#NoProDiv').show();
		$('#NoProButtonDiv').show();
		$('#ProTravelDiv').hide();
		$('#ProButtonDiv').hide();
	}
	
	tboks.webtboks.all_info.noneAllCategory();
	tboks.webtboks.all_info.noneAllSubCategory();
	
	$("#FakeCategoryDiv").hide();
	$("#CateDiv"+domainid).show();
	//checkAndDoSimSelect("CateDiv"+domainid);
	
	
	//unsetAll(); // 重置所有数值
	 tboks.webtboks.all_info.setHiddenValue('HDomain',domainid);
	
}



/**
 * 当用户选择domain时候获得所选择的domain id用于显示相应的category
 * 
 * @param {int} domainid
 */
 tboks.webtboks.all_info.getCategoryByDomainIDNoVerif=function(domainid)
{	
	if(domainid == 0)
	return;
	if(domainid == 38)
	{
		$('#ProTravelDiv').show();
		$('#ProButtonDiv').show();
		$('#NoProDiv').hide();
		$('#NoProButtonDiv').hide();
	}else{
		$('#NoProDiv').show();
		$('#NoProButtonDiv').show();
		$('#ProTravelDiv').hide();
		$('#ProButtonDiv').hide();
	}
	
	tboks.webtboks.all_info.noneAllCategory();
	tboks.webtboks.all_info.noneAllSubCategory();
	
	$("#FakeCategoryDiv").hide();
	$("#CateDiv"+domainid).show();
	//checkAndDoSimSelect("CateDiv"+domainid);
	
	
	//unsetAll(); // 重置所有数值
	 tboks.webtboks.all_info.setHiddenValue('HDomain',domainid);
	
}


/**
 * 隐藏所有选择category的div。用于准备显示属于选择的domain的那组categories
 */
 tboks.webtboks.all_info.noneAllCategory=function()
{
	$(".CategoryClass").each(function(){
		$(this).hide();
	});
	$("#FakeCategoryDiv").show();
}

/**
 * 获得选择的Category的ID
 * @param {int} categoryid
 */
 tboks.webtboks.all_info.getSubCategoryByCategoryID=function(categoryid)
{
	tboks.webtboks.all_info.noneAllSubCategory();
	
	//Travel 重置
	if( tboks.webtboks.all_info.inArrayCheck(categoryid,Array(229,230,231,232,233,234))&&$("#HCategory").attr("value")!=categoryid)
	{
		//unsetTravel();
	}
	
	 tboks.webtboks.all_info.setHiddenValue('HCategory',categoryid);
	
	switch (categoryid)
	{
		case "234":
			 tboks.webtboks.all_info.setHiddenValue("HRequestType",11);//Activity
			break;
		case "233":
			 tboks.webtboks.all_info.setHiddenValue("HRequestType",12);//Hotel
			break;
		case "231":
			 tboks.webtboks.all_info.setHiddenValue("HRequestType",13);//Location voiture
			break;
		case "232":
			 tboks.webtboks.all_info.setHiddenValue("HRequestType",14);//Sejour
			$("#dateLabelFrom").text("Aller");
			$("#dateLabelTo").text("Retour");
			break;
		case "229":
			 tboks.webtboks.all_info.setHiddenValue("HRequestType",15);//Vol + Hotel
			$("#dateLabelFrom").text("Aller");
			$("#dateLabelTo").text("Retour");
			break;
		case "230":
			 tboks.webtboks.all_info.setHiddenValue("HRequestType",16);//Vol
			$("#dateLabelFrom").text("Aller");
			$("#dateLabelTo").text("Retour");
			break;
		default:
			 tboks.webtboks.all_info.setHiddenValue("HRequestType",1);
	}
	
	//是否计算人数
	if(categoryid == 231)
	{
		$("#divPeopleNumber").hide();
	}else{
		$("#divPeopleNumber").show();
	}
	//时间Label显示
	if( tboks.webtboks.all_info.inArrayCheck(categoryid,Array(229,230,232,234)))
	{
		$("#dateLabelFrom").text("Aller");
		$("#dateLabelTo").text("Retour");
	}
	if(categoryid == 231)
	{
		$("#dateLabelFrom").text("Date d'enlèvement");
		$("#dateLabelTo").text("Date de retour");
	}
	if(categoryid == 233)
	{
		$("#dateLabelFrom").text("Date d'arrivée");
		$("#dateLabelTo").text("Date de retour");
	}
	
	if( tboks.webtboks.all_info.inArrayCheck(categoryid,Array(234,233,231)))
	{
		$("#locationDivTwo").show();
		$("#locationDivOne").hide();
		return
	}
	if( tboks.webtboks.all_info.inArrayCheck(categoryid,Array(232,229,230)))
	{
		$("#locationDivOne").show();
		$("#locationDivTwo").hide();
		return
	}
	
	//------ 分界线 ------
	
	//显示相应SubCategory
	//if ($("#MutiSelectClassDiv" + categoryid).children("div").children().length) {
	if ($("#MutiSelectClassDiv" + categoryid).length) {
		$("#MutiSelectClassDiv" + categoryid).show();
	}
	$("#FakeSubCategoryDiv").hide();
}

/**
 * 隐藏所有subcategory的div。
 */
 tboks.webtboks.all_info.noneAllSubCategory=function()
{
	$(".SubCategorySelectDiv").each(function(){
		$(this).hide();
	});
	$("#FakeSubCategoryDiv").show();
}





/**
 * 当用户填写Description时自动消除默认字符
 */
 tboks.webtboks.all_info.writeDescriptionOne=function(e)
{
	
	var id = e.data.id;
	if($("#"+id).css("fontStyle") == "italic")
	{
		$("#"+id).val("");
		$("#"+id).css("fontStyle","normal");
	}
}
/**
 * Description 长度检测
 * @param {Object} dNode
 */
  tboks.webtboks.all_info.descriptionLen=function(e)
{
	var id = e.data.id;
	var maxLen = 999;
	var len = $("#"+id).val().length;
 	if(len > maxLen)
	{
		$("#"+id).val($("#"+id).val().substring(0,maxLen));
 	}
}

/**
 * 判断输入数字是否属于数组。用于找出Pro的Category
 * 
 * @param {int} num
 * @param {array} arr
 * 
 * @return boolean
 */
 tboks.webtboks.all_info.inArrayCheck=function(num, arr)
{
	for (var i = 0; i < arr.length; i++) {
		if(arr[i]==num)
		return true;   
	}
	return false;
}
/**
 * 转换日期格式
 * @param {string} date
 */
 tboks.webtboks.all_info.dataFormatConversion=function(date)
{
	return date.substr(6,4) + date.substr(3,2) + date.substr(0,2);
}
/**
 * 检测数字
 * @param {Object} num
 */
 tboks.webtboks.all_info.checkNumber=function(num)
{
	var format = /^[0-9]{1,3}$/;
	if (format.exec(num)) {
		return true;
	}else{
		return false;
	}
}




/**
 * 显示相应国家的城市列表
 * @param {string} countrydata
 */
 tboks.webtboks.all_info.getCitiesByCountry=function(countrydata)
{
	tboks.webtboks.all_info.noneAllCities();
	$("#cityTableToCountry"+countrydata).show();
	//document.getElementById('cityTableToCountry'+countrydata).style.display = "block";
	//$('DIVCITYSELECTION').style.height = "200px";
}
/**
 * 隐藏所有城市表格
 */
 tboks.webtboks.all_info.noneAllCities=function()
{
	var nodes = document.getElementById('DIVCITYSELECTION').childNodes;
	var nodesLength = document.getElementById('DIVCITYSELECTION').childNodes.length;
	for(var i = 0; i < nodesLength; i++)
	{
		if(nodes[i].nodeType == 1)
		nodes[i].style.display = "none";
	}
}


/**
 * 判断下拉菜单是否经过模拟装饰
 * 如果没有模拟过则模拟
 */
 tboks.webtboks.all_info.checkAndDoSimSelect=function(divID)
{
	if($("#"+divID).children().length == 1) $("#"+divID).sSelect();
}


/**
 * 重置所有与request相关的存储数据 SessionID 不清空
 */
 tboks.webtboks.all_info.unsetAll=function()
{
	
	document.getElementById("HDomain").value = "";
	document.getElementById("HCategory").value = "";
	document.getElementById("HSubCategory").value = "";
	document.getElementById("HNoProDescription").value = "";
	
	document.getElementById("HFromDate").value = "";
	document.getElementById("HToDate").value = "";
	document.getElementById("HFromCountry").value = "";
	document.getElementById("HFromCity").value = "";
	document.getElementById("HToCountry").value = "";
	document.getElementById("HToCity").value = "";
	document.getElementById("HSingleCountry").value = "";
	document.getElementById("HSingleCity").value = "";
	document.getElementById("HAdult").value = "";
	document.getElementById("HChild").value = "";
	document.getElementById("HBaby").value = "";
	document.getElementById("HTravelDescription").value = "";
	
	document.getElementById("HRequestType").value = "";
}
/**
 * Travel相关数据重置
 */
 tboks.webtboks.all_info.unsetTravel=function()
{
	document.getElementById("HFromDate").value = "";
	document.getElementById("HToDate").value = "";
	document.getElementById("HFromCountry").value = "";
	document.getElementById("HFromCity").value = "";
	document.getElementById("HToCountry").value = "";
	document.getElementById("HToCity").value = "";
	document.getElementById("HSingleCountry").value = "";
	document.getElementById("HSingleCity").value = "";
	document.getElementById("HAdult").value = "1";
	document.getElementById("HChild").value = "0";
	document.getElementById("HBaby").value = "0";
	document.getElementById("HTravelDescription").value = "";
	
	document.getElementById("locationFrom").value = "";
	document.getElementById("locationTo").value = "";
	document.getElementById("locationSingle").value = "";
	document.getElementById("dateFrom").value = "";
	document.getElementById("dateTo").value = "";
	document.getElementById("adultNumber").value = "1";
	document.getElementById("childNumber").value = "0";
	document.getElementById("babyNumber").value = "0";
	
	//document.getElementById('travelDescription').value = "Décrivez ici votre besoin le plus précisément possible.";//Description 初始文字
	//document.getElementById('travelDescription').style.fontStyle = "italic";//cription 字体
}

/**
 * 完成发送request后页面转向
 */
 tboks.webtboks.all_info.reload=function()
{
	//parent.parent.document.location.reload();
	document.location.href="request.html?f="+$("#HOrigin").attr("value");
}

/**
 * 单个添加hidden数值
 * @param {string} hiddenID
 * @param {string} hiddenValue
 */
 tboks.webtboks.all_info.setHiddenValue=function(hiddenID,hiddenValue)
{
	document.getElementById(hiddenID).value = hiddenValue;
}

 tboks.webtboks.all_info.cllfqzxxdiv=function(){
	if($("#cllfqzxxdiv").css("display")=="none"){
		return false;
	}else{
		return true;
	}
}

 tboks.webtboks.all_info.selectClick=function(clickObj)
{
	//clickObj.children(".TitleOption").remove();
}
      
