
//加入购物车时触发的form提交
function addCate(currentObj)
{
	var tr=currentObj.parentNode.parentNode;
	document.getElementById('Product_Reserve_ID').value=FxIeGetText(tr.cells[0]);
	document.getElementById('LeaveDate').value=FxIeGetText(tr.cells[1]);
	document.getElementById('BackDate').value=FxIeGetText(tr.cells[2]);
	document.getElementById('Price').value=FxIeGetText(tr.cells[3]);
	document.getElementById('Name').value=FxIeGetText(tr.cells[4]);
	document.getElementById('Quantity').value=tr.cells[9].getElementsByTagName('input')[0].value;
	document.getElementById('AttributeSetInstance').value=FxIeGetText(tr.cells[8]);
	document.getElementById('SalesRep_ID').value=FxIeGetText(tr.cells[10]);
	
	/*alert("Product_Reserve_ID"+"-"+document.getElementById('Product_Reserve_ID').value);
	alert("LeaveDate"+"-"+document.getElementById('LeaveDate').value);
	alert("Price"+"-"+document.getElementById('Price').value);
	alert("Name"+"-"+document.getElementById('Name').value);
	alert("Quantity"+"-"+document.getElementById('Quantity').value);
	alert("AttributeSetInstance"+"-"+document.getElementById('AttributeSetInstance').value);
	alert(document.getElementById('MProductID').value);
	alert(document.getElementById('SalesRep_ID').value);
	*/
	document.getElementById('mproducts').submit();
}
//点击每一天，把当天城市显示在google中
var currentDay=1;
function showGoogle(day)
{
	currentDay=day;
	document.getElementById('googleIfr').src="http://erp.becit.cn:9180/daymapInIframe.jsp?pid="+M_Product_ID+"&day="+day;
	
}
function goGoogle()
{
	var url="http://erp.becit.cn:9180/daymap.jsp?pid="+M_Product_ID+"&day="+currentDay;
	window.open(url,'_blank');
}

$(document).ready(function(){
	$("#submitbutton").click(function(){
		var name=$("#name").get(0).value;
		var description=$("#description").val();
		var verify=$("#verify").val();
		
		if(name == ''){
			alert("请填写名称！");
			return false;
		}
		if(description == ''){
			alert("请填写问题！");
			return false;
		}
		if(verify == ''){
			alert("请填写验证码！");
			return false;
		}
		
		
		$.post("/ProductFaqServlet.htm",{name:name,description:description,M_Product_ID:M_Product_ID,verify:verify}, 
			function(data){
				$("#verifyIMG").get(0).src="/img/main/dd01.gif";
				if(data==1){
					alert("验证码错误，请重新输入！");
					return false;
				}					
				else if(data==2){
					alert("问题录入成功！");
					$("#name").get(0).value="";
					$("#description").get(0).value="";
					return false;
				}
				else if(data==3){
					alert("问题录入失败！");
					return false;
				}
				$("#verifyIMG").get(0).src="/VerifyServlet.htm";
				$("#verify").get(0).value="";
				$("#verify").get(0).focus();
		});
		document.getElementById('productFaq').submit();
	});
	$("#changeVer").click(function(){
		var random=new Date();//javascript:void(0);=#
		$("#verifyIMG").get(0).src="/img/main/dd01.gif";
		$("#verifyIMG").get(0).src="/VerifyServlet?r="+random.getTime();
	});
	
	$("#changeVer1").click(function(){
		var random=new Date();//javascript:void(0);=#
		$("#verifyIMG1").get(0).src="/img/main/dd01.gif";
		$("#verifyIMG1").get(0).src="/VerifyServlet?r="+random.getTime();
	});
});

	
	$(document).ready(function(){
		/*行程展示的类标签，给其定义一个Click事件*/
		$(".fred").bind("click",function(){
				label_click(this);	
		});
		/*行程展示中的天数列表，给其定义Click事件*/
		$(".journey_day_list").bind("click",function(){
			journey_day_list_click(this);
		});
		/*地图中的天数列表，给其定义Click事件*/
		$(".google_map_list").bind("click",function(){
			google_map_click(this);
		});	

		showGoogleMap(1);
	});
	/*
	 	标签的Click事件 id='1_list' class='current_item fred'
	  	要显示的id="journey_1_show"
	 */
	function label_click(obj){
		/*obj.id = '1_list';parseInt(obj.)*/		
		var id = parseInt(obj.id);
		var show_list = "#journey_" + id + "_show";
		/*将所有的class='fred'中移除current_item的样式*/
		$(".fred").each(function(i){
			$(this).removeClass("current_item");
		});
		/*标签对应显示div添加hidden样式*/
		$(".hot-db").each(function(i){
			$(this).addClass("hidden");
		});
		/*给Click的这个对象添加current_item样式*/
		$("#"+obj.id).addClass("current_item");
		/*将它所对应的div移除hidden样式*/
		$(show_list).removeClass("hidden");
		
		auto_height();
		
		
	}
	/*class="nav2  journey_day_list" id="2_day_journey"*/
	function journey_day_list_click(obj){
		//2=2_day_journey
		var id = parseInt(obj.id);
		/*遍历所有的class="journey_day_list"的节点，移除current_day样式*/
		$(".journey_day_list").each(function(i){
			$(this).removeClass("current_day");

		});
		/*class="journey_day_show" id="journey_1_day_show"*/
		/*遍历所有的class="journey_day_show"的节点*/
		$(".journey_day_show").each(function(i){
			$(this).addClass("hidden");

		});
		/*给当前Click的节点添加current_day样式*/
		$("#"+obj.id).addClass("current_day");
		/*根据触发节点的id构造与之对应的节点*/
		var show_select_day = "#journey_"+id+"_day_show";
		/*给这个与之对应的节点移除hidden样式*/
		$(show_select_day).removeClass("hidden");		
	}
	/*class="nav2 google_map_list current_map" id="1_google_map_list"*/
	function google_map_click(obj){
		//1 = 1_google_map_list;
		var id = parseInt(obj.id);
		/*遍历所有class="google_map_list"移除current_map样式*/
		$(".google_map_list").each(function(i){			
			$(this).removeClass("current_map");			
		});
		/*遍历所有class='google_map_show'添加hidden样式*/
//		$(".google_map_show").each(function(i){
//			$(this).addClass("hidden");
//		});
		/*给触发这个事件的节点添加current_map这个样式*/
		$("#"+obj.id).addClass("current_map");
		/*构造与这个触发事件节点相对应的节点*/
//		var google_map_show = "#google_"+id+"_day_show";
		/*将其移除hidden样式*/
//		$(google_map_show).removeClass("hidden");
		showGoogleMap(id);	
	}

	function responseGoogle_list(obj){
		//获取点击时候的第i天
		var list_id = parseInt(obj.id);
		showGoogleMap(list_id);
		$(".google_map_list").each(function(i){
			this.className = "nav2 google_map_list";
		});
		obj.className = "nav2 google_map_list current_map";
	}

	var current_day = 1;
	function showGoogleMap(day){
		var day_src = "http://erp.becit.cn:9180/daymapInIframe.jsp?pid="+M_Product_ID+"&day="+day;
		$("#googlefr").attr("src",day_src);
	}
	
	
	
	
	$(document).ready(function(){
		

		$(".faq_list").click(function(){
			var id = $(this).attr("id");
			var content_id = "#faq_content_" + parseInt(id);
			
			$(".faq_content").each(function(i){
				$(this).addClass("hidden");
			});

			$(".faq_list").each(function(i){
				$(this).removeClass("current_faq");
			});
			$(this).addClass("current_faq");
			$(content_id).removeClass("hidden");
		});
		
		
		$(".faq_question").click(function(){
//			$(this).next().toggle();
//			var obj = $(this);
//			$(this).toggle(function(obj){
//				$(obj).children().get(0).text("▲");
//				alert($(obj).children().get(0).text());
//			},function(){
//				$(obj).children().get(0).text("▼");
//			});
			
//			$(".faq_answer").addClass("hidden");

//			var parent = $(this).parent().parent();
//			$(parent).children().children(".faq_answer").addClass("hidden");
//			$(this).next().removeClass("hidden");
			
		});
		
		
	});

	
function auto_height(){
	
	$("#journey_6_show .top10-list").attr("id","question_list_id");
	$("#journey_6_show .top10-bd").attr("id","recom-top10-faq");
	
	$("#journey_1_show .top10-list").attr("id","journey_list_id");
	$("#journey_1_show .top10-bd").attr("id","recom-top10-journey");
	
	if(document.getElementById("recom-top10-faq").clientHeight < document.getElementById("question_list_id").clientHeight){
		document.getElementById("recom-top10-faq").style.height = document.getElementById("question_list_id").offsetHeight+"px";
		document.getElementById("journey_6_show").style.height = document.getElementById("question_list_id").offsetHeight+"px";
	}else{
		document.getElementById("question_list_id").style.height = document.getElementById("recom-top10-faq").offsetHeight+"px";
		document.getElementById("journey_6_show").style.height = document.getElementById("recom-top10-faq").offsetHeight+"px";

	}
	
	
	if(document.getElementById("recom-top10-journey").clientHeight < document.getElementById("journey_list_id").clientHeight){
		document.getElementById("recom-top10-journey").style.height = document.getElementById("journey_list_id").offsetHeight+"px";
		document.getElementById("journey_1_show").style.height = document.getElementById("journey_list_id").offsetHeight+"px";
	}else{
		document.getElementById("journey_list_id").style.height = document.getElementById("recom-top10-journey").offsetHeight+"px";
		document.getElementById("journey_1_show").style.height = document.getElementById("recom-top10-journey").offsetHeight+"px";
	}
	
	
}
	
	

//
//var Consultation = function(){};
//Consultation.prototype.name = "";
//Consultation.prototype.phone = "";
//Consultation.prototype.email = "";
//Consultation.prototype.message = "";
//Consultation.prototype.productId = "";
//Consultation.prototype.result = "";
////Consultation.prototype.check = "";
//
//Consultation.prototype.init = function(){
//	
//	
//	
//	Consultation.prototype.name = $("#name_consultation").val();
//	Consultation.prototype.phone = $("#phone_consultation").val();
//	Consultation.prototype.email = $("#email_consultation").val();
//	Consultation.prototype.message = $("#message_consultation").val();
//	Consultation.prototype.productId = $("#product_id").val();
//	
//	
//	
//	
//	
//}
//
//Consultation.prototype.check_name = function(){
//	var name = Consultation.prototype.name;
//	var reg = /^[\u4E00-\u9FA5]+$/; /*中文的正则表达式*/
//	var bool = reg.test(name);
//	$("#name_consultation_error").html("");
//	
//	if(name == ""){
//		$("#name_consultation_error").html("请填写用户姓名！");
//		$("#name_consultation_error").addClass("submit_message_show_red");
//		return false;
//	}
//	
//	if(bool == false){
//		$("#name_consultation_error").html("用户姓名只能填写汉字！");
//		$("#name_consultation_error").addClass("submit_message_show_red");
//		return false;
//	}
//	return true;
//}
//
//Consultation.prototype.check_email = function(){
//	var email = Consultation.prototype.email;
//	var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; /*电子邮箱的正则表达式*/
//	var bool = reg.test(email);
//	$("#email_consultation_error").html("");
//	
////	if(email == ""){
////		return true;
////	}
//	
//	if(bool == false && email != ""){
//		$("#email_consultation_error").html("邮箱格式错误，请重新填写！");
//		$("#email_consultation_error").addClass("submit_message_show_red");
//		return false;
//	}
//	return true;
//}
//
//Consultation.prototype.check_message = function(){
//	var message = Consultation.prototype.message;
//	$("#message_consultation_error").html("");
//
//	if(message == ""){
//		$("#message_consultation_error").html("请填写留言内容！");
//		$("#message_consultation_error").addClass("submit_message_show_red");
//		return false;
//	}
//	return true;
//}
//
//Consultation.prototype.check_phone = function(){
//	var phone = Consultation.prototype.phone;
//	var reg = /^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/; /*电话号码的正则表达式*/
//	var phone_reg = /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
//	var mobile_reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
//	var bool = mobile_reg.test(phone);
////	var bool = phone_reg.test(phone) || mobile_reg.test(phone);
//	$("#phone_consultation_error").html("");
//
//	
//	
////	if(phone == ""){
////		return true;
////	}
//	
//	if(bool == false && phone != ""){
//		$("#phone_consultation_error").html("联系手机格式错误，请重新填写！");
//		$("#phone_consultation_error").addClass("submit_message_show_red");
//		return false;
//	}
//	return true;
//}
//
//
//Consultation.prototype.submit = function(){
//	
//	var phone = Consultation.prototype.phone;
//	var email = Consultation.prototype.email;
//	var message = Consultation.prototype.message;
//	var name = Consultation.prototype.name;
//	var productId = Consultation.prototype.productId;
//	$.ajax({
//		type:"POST",
//		dataType:"text",
//		url:encodeURI("/sendOnLineQuizServlet?productId="+productId+"&name="+name+"&phone="+phone+"&email="+email+"&message="+message),
//		success:function(data){	
//		Consultation.prototype.result = data;
//		Consultation.prototype.processor();
//		}
//	
//	});
//	
//	
//}
//
//Consultation.prototype.processor = function(){
//	var result = Consultation.prototype.result;
//	if(result == "SUCCESS"){
//		alert("提交问题成功，请等候我们旅行顾问的回复！");
//		
//		$("#name_consultation").val("");
//		$("#phone_consultation").val("");
//		$("#email_consultation").val("");
//		$("#message_consultation").val("");
//		
//	}else
//	if(result == "FAIL"){
//		alert("对不起，您提交问题失败，请重试！");
//	}else{
//		alert("系统繁忙，请稍候重试...");
//	}
//	
//	
//}
//
//
//Consultation.prototype.on_submit = function(){
//	
//	var phone_val = Consultation.prototype.phone;
//	var email_val = Consultation.prototype.email;
//	var message_val = Consultation.prototype.message;
//	var name_val = Consultation.prototype.name;
//	var name = Consultation.prototype.check_name();
//	var message = Consultation.prototype.check_message();
//	
//	
//	if(phone_val == "" && email_val == ""){
////		$("#phone_consultation_error").html("此项与电子邮箱二者必填一项！").addClass("submit_message_show_red");
//		$("#email_consultation_error").html("联系电话与电子邮箱二者必填一项！").addClass("submit_message_show_red");
//		return false;
//	}else{
//		Consultation.prototype.check_email();
//		Consultation.prototype.check_phone(); 
//	}
//	
//	if(phone_val == "" && email_val == "" && name_val == ""){
////		$("#phone_consultation_error").html("此项与电子邮箱二者必填一项！").addClass("submit_message_show_red");
//		$("#email_consultation_error").html("联系电话与电子邮箱二者必填一项！").addClass("submit_message_show_red");
//		$("#name_consultation_error").html("请填写用户姓名！").addClass("submit_message_show_red");
//		return false;
//		
//	}
//	
//	
//	if(phone_val == "" && email_val == "" && message_val == ""){
////		$("#phone_consultation_error").html("此项与电子邮箱二者必填一项！").addClass("submit_message_show_red");
//		$("#email_consultation_error").html("联系电话与电子邮箱二者必填一项！").addClass("submit_message_show_red");
//		$("#message_consultation_error").html("请填写留言内容！").addClass("submit_message_show_red");
//		return false;
//		
//	}
//	
//	
//	
//	var phone = Consultation.prototype.check_phone(); 
//	var email = Consultation.prototype.check_email();
//
//	
//	var bool = message && name && email && phone;
//	if(bool){
//		Consultation.prototype.submit();
//	} else{
////		alert("请将信息填写完整！");
//		
//	}
//	return false;
//	
//}




var Consultation = function(){};
Consultation.prototype.name = "";
Consultation.prototype.phone = "";
Consultation.prototype.email = "";
Consultation.prototype.message = "";
Consultation.prototype.productId = "";
Consultation.prototype.result = "";

Consultation.prototype.init = function(){
	Consultation.prototype.name = $("#name_consultation").val();
	Consultation.prototype.phone = $("#phone_consultation").val();
	Consultation.prototype.email = $("#email_consultation").val();
	Consultation.prototype.message = $("#message_consultation").val();
	Consultation.prototype.productId = $("#product_id").val();
}

Consultation.prototype.check_name = function(){
	var name = Consultation.prototype.name;
	var reg = /^[\u4E00-\u9FA5]+$/; /*中文的正则表达式*/
	var bool = reg.test(name);
	$("#name_consultation_error").html("");
	
	if(name == ""){
		return true;
	}
	
	if(bool == false){
		$("#name_consultation_error").html("用户姓名只能填写汉字！");
		$("#name_consultation_error").addClass("submit_message_show_red");
		return false;
	}
	return true;
}

Consultation.prototype.check_email = function(){
	var email = Consultation.prototype.email;
	var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; /*电子邮箱的正则表达式*/
	var bool = reg.test(email);
	$("#email_consultation_error").html("");
	
	if(bool == false && email != ""){
		$("#email_consultation_error").html("邮箱格式错误，请重新填写！");
		$("#email_consultation_error").addClass("submit_message_show_red");
		return false;
	}
	return true;
}

Consultation.prototype.check_message = function(){
	var message = Consultation.prototype.message;
	$("#message_consultation_error").html("");
	if(message == ""){
		return true;
	}
	return true;
}

Consultation.prototype.check_phone = function(){
	var phone = Consultation.prototype.phone;
	var reg = /^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/; /*电话号码的正则表达式*/
	var phone_reg = /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
	var mobile_reg = /^1[3|4|5|8][0-9]\d{4,8}$/;
	var bool = mobile_reg.test(phone);
	$("#phone_consultation_error").html("");
	
	if(phone == ""){
		$("#phone_consultation_error").html("请填写联系手机！");
		$("#phone_consultation_error").addClass("submit_message_show_red");
		return false;
	}
	
	
	if(bool == false && phone != ""){
		$("#phone_consultation_error").html("联系手机格式错误，请重新填写！");
		$("#phone_consultation_error").addClass("submit_message_show_red");
		return false;
	}
	return true;
}


Consultation.prototype.submit = function(){
	
	var phone = Consultation.prototype.phone;
	var email = Consultation.prototype.email;
	var message = Consultation.prototype.message;
	var name = Consultation.prototype.name;
	var productId = Consultation.prototype.productId;
	$.ajax({
		type:"POST",
		dataType:"text",
		url:encodeURI("/sendOnLineQuizServlet?productId="+productId+"&name="+name+"&phone="+phone+"&email="+email+"&message="+message),
		success:function(data){	
		Consultation.prototype.result = data;
		Consultation.prototype.processor();
		}
	
	});
	
	
}

Consultation.prototype.processor = function(){
	var result = Consultation.prototype.result;
	if(result == "SUCCESS"){
		alert("提交问题成功，请等候我们旅行顾问的回复！");
		$("#name_consultation").val("");
		$("#phone_consultation").val("");
		$("#email_consultation").val("");
		$("#message_consultation").val("");
	}else
	if(result == "FAIL"){
		alert("对不起，您提交问题失败，请重试！");
	}else{
		alert("系统繁忙，请稍候重试...");
	}
	
	
}


Consultation.prototype.on_submit = function(){
	
	var phone_val = Consultation.prototype.phone;
	var email_val = Consultation.prototype.email;
	var message_val = Consultation.prototype.message;
	var name_val = Consultation.prototype.name;
	
	var name = Consultation.prototype.check_name();
	var message = Consultation.prototype.check_message();
	var phone = Consultation.prototype.check_phone(); 
	var email = Consultation.prototype.check_email();

	
	var bool = message && name && email && phone;
	
	if(bool){
		Consultation.prototype.submit();
	} else{
	}
	return false;
	
}






$(document).ready(function(){
	

	
	$(".online_submit").click(function(){
		var con = new Consultation();
		con.init();
		con.on_submit();
		
	});
	
	
	
});	
	
	
	
var download = function(){};

download.prototype.url = "";
download.prototype.result = "";

download.prototype.download = function(url){
	$.ajax({
		type:"POST",
		dataType:"text",
		url:encodeURI(url),
		success:function(){	
		download.prototype.processor();
		
	}
		
	});
	
	
	
};

download.prototype.init = function(){
	
};

download.prototype.processor = function(){
	alert("success");
	
};
	
	
	
$(document).ready(function(){
	
	
//	$("#doc_download").bind("click",function(){
//		var doc_url = $("#url_doc_value").val();
//		var doc_download = new download();
//		doc_download.url = doc_url;
//		doc_download.download(doc_url);
//	});
//	
//	$("#pdf_download").bind("click",function(){
//		var pdf_url = $("#url_pdf_value").val();
//		var pdf_download = new download();
//		pdf_download.url = pdf_url;
//		pdf_download.download(pdf_url);
//	});
	
});	
	
	
	
	
	


