﻿/*
	账户中心-首页
*/

$(document).ready(function(){


	/********************************* 搜索栏 *********************************/

	//输入框
	$("#txtSearchBox").keypress(function(e){
		if(e.keyCode == '13'){
			search_page($("#select_search").val(),$("#txtSearchBox").val().trim());
		}
	});
	
	//点击按钮-查询
	$("#butSearch").click( function () {
		search_page($("#select_search").val(),$("#txtSearchBox").val().trim());
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//点击链接-查询
	$(".butLinkSearch").click( function () {
		search_page($("#select_search").val(),$(this).text().trim());
	})
		
	/********************************* 用户登陆 *********************************/
	//提示框图标
	$("#alertMessage .blockIcon").attr("src","images/tehuiqu/kuangjia/icon_zhengque.jpg");
	
	//登陆
	$("#LoginButton").click( function () {
		login_submit();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	// 显示登陆框
	$.get("/index.aspx?u=/Portal/home_login", function(data){
		$("#login_div").html(data);
	});


	/********************************* 特惠区 *********************************/

	//免费试用
	$("#but_free_trial").click( function () {
		$("#but_free_trial_div").removeClass().addClass("titleright2");
		$("#but_coupon_div").removeClass().addClass("titleright");
		$("#but_promotions_div").removeClass().addClass("titleright");
		$("#but_merchant_div").removeClass().addClass("titleright");
		$("#div_free_trial").show();
		$("#div_coupon").hide();
		$("#div_promotions").hide();
		$("#div_merchant").hide();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//优惠券
	$("#but_coupon").click( function () {
		$("#but_free_trial_div").removeClass().addClass("titleright");
		$("#but_coupon_div").removeClass().addClass("titleright2");
		$("#but_promotions_div").removeClass().addClass("titleright");
		$("#but_merchant_div").removeClass().addClass("titleright");
		$("#div_free_trial").hide();
		$("#div_coupon").show();
		$("#div_promotions").hide();
		$("#div_merchant").hide();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//促销活动
	$("#but_promotions").click( function () {
		$("#but_free_trial_div").removeClass().addClass("titleright");
		$("#but_coupon_div").removeClass().addClass("titleright");
		$("#but_promotions_div").removeClass().addClass("titleright2");
		$("#but_merchant_div").removeClass().addClass("titleright");
		$("#div_free_trial").hide();
		$("#div_coupon").hide();
		$("#div_promotions").show();
		$("#div_merchant").hide();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//商家大全
	$("#but_merchant").click( function () {
		$("#but_free_trial_div").removeClass().addClass("titleright");
		$("#but_coupon_div").removeClass().addClass("titleright");
		$("#but_promotions_div").removeClass().addClass("titleright");
		$("#but_merchant_div").removeClass().addClass("titleright2");
		$("#div_free_trial").hide();
		$("#div_coupon").hide();
		$("#div_promotions").hide();
		$("#div_merchant").show();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	
	/********************************* 信用卡 *********************************/
	
	//新闻资讯
	$("#but_creditcard_info_a").click( function () {
		$("#but_creditcard_info_a_div").removeClass().addClass("titleright2");
		$("#but_creditcard_info_b_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_c_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_d_div").removeClass().addClass("titleright");
		$("#div_creditcard_info_a").show();
		$("#div_creditcard_info_b").hide();
		$("#div_creditcard_info_c").hide();
		$("#div_creditcard_info_d").hide();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//申请有好礼
	$("#but_creditcard_info_b").click( function () {
		$("#but_creditcard_info_a_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_b_div").removeClass().addClass("titleright2");
		$("#but_creditcard_info_c_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_d_div").removeClass().addClass("titleright");
		$("#div_creditcard_info_a").hide();
		$("#div_creditcard_info_b").show();
		$("#div_creditcard_info_c").hide();
		$("#div_creditcard_info_d").hide();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//刷卡有优惠
	$("#but_creditcard_info_c").click( function () {
		$("#but_creditcard_info_a_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_b_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_c_div").removeClass().addClass("titleright2");
		$("#but_creditcard_info_d_div").removeClass().addClass("titleright");
		$("#div_creditcard_info_a").hide();
		$("#div_creditcard_info_b").hide();
		$("#div_creditcard_info_c").show();
		$("#div_creditcard_info_d").hide();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//知识库
	$("#but_creditcard_info_d").click( function () {
		$("#but_creditcard_info_a_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_b_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_c_div").removeClass().addClass("titleright");
		$("#but_creditcard_info_d_div").removeClass().addClass("titleright2");
		$("#div_creditcard_info_a").hide();
		$("#div_creditcard_info_b").hide();
		$("#div_creditcard_info_c").hide();
		$("#div_creditcard_info_d").show();
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	/********************************* 信用卡 *********************************/
	//默认显示 女人世界
	fill_home_ci(5);
	
	//女人世界
	$("#but_ci_a").click( function () {
		$("#but_ci_a_div").removeClass().addClass("titleright2");
		$("#but_ci_b_div").removeClass().addClass("titleright");
		$("#but_ci_c_div").removeClass().addClass("titleright");
		$("#but_ci_d_div").removeClass().addClass("titleright");
		$("#but_ci_e_div").removeClass().addClass("titleright");
		$("#but_ci_f_div").removeClass().addClass("titleright");
		$("#but_ci_g_div").removeClass().addClass("titleright");
		$("#but_ci_h_div").removeClass().addClass("titleright");
		fill_home_ci(5);
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//男人天下
	$("#but_ci_b").click( function () {
		$("#but_ci_a_div").removeClass().addClass("titleright");
		$("#but_ci_b_div").removeClass().addClass("titleright2");
		$("#but_ci_c_div").removeClass().addClass("titleright");
		$("#but_ci_d_div").removeClass().addClass("titleright");
		$("#but_ci_e_div").removeClass().addClass("titleright");
		$("#but_ci_f_div").removeClass().addClass("titleright");
		$("#but_ci_g_div").removeClass().addClass("titleright");
		$("#but_ci_h_div").removeClass().addClass("titleright");
		fill_home_ci(6);
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//旅行机票
	$("#but_ci_c").click( function () {
		$("#but_ci_a_div").removeClass().addClass("titleright");
		$("#but_ci_b_div").removeClass().addClass("titleright");
		$("#but_ci_c_div").removeClass().addClass("titleright2");
		$("#but_ci_d_div").removeClass().addClass("titleright");
		$("#but_ci_e_div").removeClass().addClass("titleright");
		$("#but_ci_f_div").removeClass().addClass("titleright");
		$("#but_ci_g_div").removeClass().addClass("titleright");
		$("#but_ci_h_div").removeClass().addClass("titleright");
		fill_home_ci(7);
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//餐饮娱乐
	$("#but_ci_d").click( function () {
		$("#but_ci_a_div").removeClass().addClass("titleright");
		$("#but_ci_b_div").removeClass().addClass("titleright");
		$("#but_ci_c_div").removeClass().addClass("titleright");
		$("#but_ci_d_div").removeClass().addClass("titleright2");
		$("#but_ci_e_div").removeClass().addClass("titleright");
		$("#but_ci_f_div").removeClass().addClass("titleright");
		$("#but_ci_g_div").removeClass().addClass("titleright");
		$("#but_ci_h_div").removeClass().addClass("titleright");
		fill_home_ci(8);
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//我爱我家
	$("#but_ci_e").click( function () {
		$("#but_ci_a_div").removeClass().addClass("titleright");
		$("#but_ci_b_div").removeClass().addClass("titleright");
		$("#but_ci_c_div").removeClass().addClass("titleright");
		$("#but_ci_d_div").removeClass().addClass("titleright");
		$("#but_ci_e_div").removeClass().addClass("titleright2");
		$("#but_ci_f_div").removeClass().addClass("titleright");
		$("#but_ci_g_div").removeClass().addClass("titleright");
		$("#but_ci_h_div").removeClass().addClass("titleright");
		fill_home_ci(9);
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//网络游戏
	$("#but_ci_f").click( function () {
		$("#but_ci_a_div").removeClass().addClass("titleright");
		$("#but_ci_b_div").removeClass().addClass("titleright");
		$("#but_ci_c_div").removeClass().addClass("titleright");
		$("#but_ci_d_div").removeClass().addClass("titleright");
		$("#but_ci_e_div").removeClass().addClass("titleright");
		$("#but_ci_f_div").removeClass().addClass("titleright2");
		$("#but_ci_g_div").removeClass().addClass("titleright");
		$("#but_ci_h_div").removeClass().addClass("titleright");
		fill_home_ci(10);
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//理财财经
	$("#but_ci_g").click( function () {
		$("#but_ci_a_div").removeClass().addClass("titleright");
		$("#but_ci_b_div").removeClass().addClass("titleright");
		$("#but_ci_c_div").removeClass().addClass("titleright");
		$("#but_ci_d_div").removeClass().addClass("titleright");
		$("#but_ci_e_div").removeClass().addClass("titleright");
		$("#but_ci_f_div").removeClass().addClass("titleright");
		$("#but_ci_g_div").removeClass().addClass("titleright2");
		$("#but_ci_h_div").removeClass().addClass("titleright");
		fill_home_ci(11);
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	//人在职场
	$("#but_ci_h").click( function () {
		$("#but_ci_a_div").removeClass().addClass("titleright");
		$("#but_ci_b_div").removeClass().addClass("titleright");
		$("#but_ci_c_div").removeClass().addClass("titleright");
		$("#but_ci_d_div").removeClass().addClass("titleright");
		$("#but_ci_e_div").removeClass().addClass("titleright");
		$("#but_ci_f_div").removeClass().addClass("titleright");
		$("#but_ci_g_div").removeClass().addClass("titleright");
		$("#but_ci_h_div").removeClass().addClass("titleright2");
		fill_home_ci(12);
	}).mousemove(function(){
		$(this).css("cursor","hand");
	});
	
	
});

//查询 00 信用卡卡库 01 信用卡频道 02 消费资讯 03 免费试用 04 优惠券 05 促销活动
function search_page(type,txtValue)
{
	//信用卡卡库
	if(type=="00"){
		location.href = _view+"?u="+encodeURIComponent("/Creditcard_list/sub_channel/3/88//"+_depth+"/1/"+txtValue+"/");
	}
	//信用卡频道
	if(type=="01"){
		location.href = _view+"?u="+encodeURIComponent("/Creditcard_info/sub_channel/3/85//1/1/"+txtValue+"/");
	}
	//消费资讯
	if(type=="02"){
		location.href = _view + "?u=" + encodeURIComponent("/Consumption_info/query/"+_fid+"/"+_cid+"/"+_depth+"/1/"+txtValue+"/");
	}
	//免费试用
	if(type=="03"){
		location.href = _view+"?u="+encodeURIComponent("/Free_trial/sub_channel/2/65/"+_depth+"/1/"+txtValue+"//");
	}
	//优惠券
	if(type=="04"){
		location.href = _view+"?u="+encodeURIComponent("/Coupon/sub_channel/2/66/"+_depth+"/1/"+txtValue+"//");
	}
	//促销活动
	if(type=="05"){
		location.href = _view+"?u="+encodeURIComponent("/Promotions/sub_channel/2/67/"+_depth+"/1/"+txtValue+"//");
	}
}

//填充消费资讯信息
function fill_home_ci(ci_id)
{
	$.get(_view, { "u": encodeURIComponent("/Portal/home_ci/"+ci_id) },
	function(data){
		$("#div_ci").html(data);
	});
}



//登陆-提交
function login_submit()
{
	//准备数据
	var UserName = $("#UserName").val();
	var UserPassword = $("#UserPassword").val();
	
	//必须输入项目
	if((UserName=="")||(UserPassword=="")){
		alert("注：账号，密码为必输项");
		return;
	}
	
	//密码必须6位
	if(UserPassword.length < 6){
		alert("密码必须大于等于6位");
		$("#UserPassword").focus();
		return;
	}
	
	//登陆提交
	$("#alertMessage .blockTitle").html("正在验证用户身份...");
	$.blockUI({
		message: $('#alertMessage'),
		css: {
				top:  ($(window).height() - $('#alertMessage').height()) /2 + 'px', 
				left: ($(window).width() - $('#alertMessage').width()) /2 + 'px',
				width: '520px'
				},
		onBlock: function() {
				//提交数据
				$.getJSON(
					_view,
					{
						"u": encodeURIComponent("/Reg_user/reguser_login/"+UserName+"/"+UserPassword)
					},
					function(json){
						if(json.ret){
							//$.unblockUI();
							setTimeout(login_home, 1000);
						}
						else{
							$.unblockUI();
							alert(json.err);
						}
					});
            }
  	}); 
}
//跳转等待验证页面
function login_home(){
	location.href = _view+"/Reg_user/home";
}













