﻿
$(function(){
	main_menu();//主导航鼠标悬浮效果
	common_tab();//通用TAB
	common_tab_vertical();//通用竖向tab，点击效果
	common_tab_has_scroll();//通用tab，鼠标悬浮效果
	pro_list_panel_bg();//自助服务产品列表表格样式
	selfservice_form_pop_panel();//客户信息管理-我的产品，弹出层
	customer_panel_effect();//用户选择号码相关函数
	common_tips.init();//通用提示
	common_select();//通用模拟下拉 
	quick_servive();//首页快捷服务菜单
	//judge_height();//自助服务框架下，判断左右高度是否相等，如果右侧小于左侧，则右侧等于左侧高亮
	about_q_and_a();//常见问题解答
	pop_mask_height();//调整弹出的遮罩层的高度，使得遮罩层覆盖整个页面
	about_common_menu();//主菜单相关
	
	
})


function main_menu(){
	$(".menu > ul > li.on").addClass("tmpon");
	$(".menu > ul > li").hover(
		function(){
			$(".menu > ul > li").removeClass("on");
			$(this).addClass("bg");
		},
		function(){
			$(this).removeClass("bg");
			$(".menu li.tmpon").addClass("on");
		}
	)
	$(".menu > ul > li").click(function(){
		$(".menu > ul > li").removeClass("on");	
		$(".menu > ul > li").removeClass("tmpon");
		$(this).addClass("on");
		$(this).addClass("tmpon");
	})
}


function common_tab(){//通用tab，点击效果
	$(".common-tab-panel .tab-nav ul li").click(function(){
		$(this).parent().find(".on").removeClass("on");
		$(this).addClass("on");
		var temp_id = $(this).parent().children("li").index($(this));
		$(this).parent().parent().next().children("div").removeClass("on");
		$(this).parent().parent().next().children("div").eq(temp_id).addClass("on");
		
	})
}

/*function tab_scroll_index(){//专为首页TAB滚动写的js，作用是点击tab时隐藏滚动层
	$(".show-area .tab-caption ul>li").click(function(){
		var temp_id = $(this).parent().children().index($(this));
		if(temp_id!=3){
			$("#ad-panel-scroll").hide();
		}
		else{
			$("#ad-panel-scroll").show();
		}
	})
}
*/
function common_tab_vertical(){//通用竖向tab，点击效果
	$(".common-tab-panel-vertical .tab-nav-vertical ul li").click(function(){
		$(this).parent().find(".on1").removeClass("on1");
		$(this).addClass("on1");
		var temp_id = $(this).parent().children().index($(this));
		$(this).parent().parent().next().children("div").removeClass("on1");
		$(this).parent().parent().next().children("div").eq(temp_id).addClass("on1");
		
	})
}

function common_tab_has_scroll(){//点击,内容滚动的TAB
	$(".common-tab-mouseover-hoverpanel .tab-nav ul li").click(function(){
		$(this).parent().find(".on").removeClass("on");
		$(this).addClass("on");
		var temp_id = $(this).parent().children().index($(this));
		var top_y= temp_id*(-269);
		$(this).parent().parent().next().children(".div-container").animate({marginTop:top_y},500);
		
	})
}


function hide_tab(ary){//指定哪个TAB为隐藏并将其删除，需要延时执行。不可以直接执行
		$(".common-tab-panel #"+ary).hide();
		$(".common-tab-panel #"+ary+"content").hide();
}
function flag_common_tab(id){//此函数与后台发生交互，通过后台返回的变量，判断哪个TAB高亮
	var temp_id=$("#"+id).parent().children("li").index($("#"+id));
	
	$(".flag_common_tab .tab-nav ul>li").removeClass("on");
	$(".flag_common_tab .tab-content>.box").removeClass("on");

	$(".flag_common_tab .tab-nav ul>li").eq(temp_id).addClass("on");
	$(".flag_common_tab .tab-content>.box").eq(temp_id).addClass("on");
}


function pro_list_panel_bg(){
	$(".pro-list-panel table tr input[type='radio']").click(function(){
		$(".pro-list-panel table tr").removeClass("on");													 
		$(this).parent().parent().addClass("on");
	 })
}

function selfservice_form_pop_panel(){
	$(".selfservice-form .show-selfservice-form-pop-panel").click(function(){
		$(".on .selfservice-form-pop-panel").fadeIn(300);	
	})
	$(".selfservice-form-pop-panel .hide-selfservice-form-pop-panel").click(function(){
		$(".on .selfservice-form-pop-panel").fadeOut(300);
	})
}

function category_show(){
		if($(".mcdropdown").length>0){
			$(".mcdropdown").show();
		}
}
function category_hide(){
		if($(".mcdropdown").length>0){
			$(".mcdropdown").hide();	
		}									  
}
function customer_panel_effect(){//用户选择号码，切换当前号码
	$(".customer-panel .tab-user").click(function(){
		$(".customer-panel .pop").slideDown("fast");
		category_hide();
	})
	$(".customer-panel .close-btn").click(function(){
		$(".customer-panel .pop").slideUp("fast");
		category_show()
	})
	$(document).mouseover(function(){
		$(".customer-panel .pop").slideUp("middle");
		category_show()
	})
	$(".customer-panel").mouseover(function(e){
		e=e||window.event;
		e.stopPropagation?e.stopPropagation():e.cancelBubble=true;	
	})
	$(".customer-panel tr").click(function(){
		$(".customer-panel .pop").slideUp("fast");
		$(this).children().children("input:radio").attr("checked","checked");
		var temp_number=$(this).children().children("span").eq(0).html();
		$(".customer-panel .current-number").html(temp_number);
		category_show()
	})
}


var common_tips=function(){
    function init(){
	  $(".common-tips").each(function(){
			var til=$(this).find(".tips-title");
			var ct=$(this).find(".tips-content");
			til.hover(
			function(){
			  ct.show();
			  $(this).mousemove(function(e){ct.css({"left":e.pageX+10,"top":e.pageY+5,"display":"block"})})
			  //alert(ct.height());
			  var h=ct.height();
			  ct.height(h);
			  ct.css("visibility","visible");
			},
			function(){
			  var animate_timer=setTimeout(function(){ct.hide()},1);
			  ct.hover(
				function(){
				  clearTimeout(animate_timer);
				},
				function(){
				  ct.hide("fast")
				}
			  )
			}
			)
	  })
	  
	}
	return {
	  init:init
	}
}()


/*function about_fee_order(){//费用定制提醒
	$(".email-order").css("display","none");
	$(".about-fee-order input:radio").click(function(){
		if($(this).attr("class")=="btn-email-order"){
			$(".email-order").fadeIn("fast");
		}
		else{
			$(".email-order").hide();
		}
	})
}*/


function common_select(){//通用模拟下拉select
	$(".common-select .input").click(function(e){
		e.stopPropagation?e.stopPropagation():e.cancelBubble=true;			
		if($(this).next().find("ul li").length>7){
			$(this).next(".option").css("height",150+"px");
		}
		$(this).next().slideToggle(100);
	})
	$(".common-select .option li").click(function(){
		var temp_value=$(this).children().html();
		$(this).parent().parent().parent().find(".text").html(temp_value);
		$(this).parent().parent().hide();
	})
	$(document).click(function(){
		$(".option").hide();
	})
}

function quick_servive(){//首页快捷服务菜单
	$(".quick-servive li").hover(function(){
		$(this).addClass("on");	
	},function(){
		$(this).removeClass("on");	
	})
}



function about_q_and_a(){//常见问题解答
	$(".q-a .question").click(function(){
		$(this).next().toggle(500);
	})
}

//遮罩层相关start
function show_pop_result(){
	$(".pop-result").fadeIn(500,function(){$(".pop-mask").show();});
}
function hide_pop_result(){
	$(".pop-result").fadeOut();
	$(".pop-mask").hide();
}
function pop_mask_height(){
	var temp_height=$(document).height();
	$(".pop-mask").height(temp_height);
}
//遮罩层相关end

function about_common_menu(){//主菜单相关
	$(".common-menu ul>li span").click(function(){
		$(this).toggleClass("down");
		$(this).next().next().toggle();
	})
}


