//////////////////////////友情链接
function dropList(){
	if($("#friendLink").length > 0){
		$("#select").click(function(){$("#linkList").toggle()});
		$("body").click(function(event){if(event.target.id != "select"){$("#linkList").hide()}});
	}
}
function equalHeight(){
	if($("#leftCol").length>0 && $("#midCol").length>0 && $("#rightCol").length>0){
		$("#leftCol").css("height","auto");
		$("#midCol").css("height","auto");
		$("#rightCol").css("height","auto");
		var _a = $("#leftCol").height();
		var _b = $("#midCol").height();
		var _c = $("#rightCol").height();
		var _d = (_a>_b?_a:_b)>_c?(_a>_b?_a:_b):_c;
		//alert(_a+"|"+_b+"|"+_c+"|"+_d);
		$("#leftCol").css("height",_d+"px");
		$("#midCol").css("height",_d+"px");
		$("#rightCol").css("height",(_d)+"px");
	}else if($("#leftCol").length>0 && $("#midCol2").length>0){
		if(($("#leftCol").height())<($("#midCol2").height()+30)){
			$("#leftCol").height($("#midCol2").height()+30);
		}else if(($("#leftCol").height()) > ($("#midCol2").height()+30)){
			$("#midCol2").height($("#leftCol").height()-30);
		}
	}
}
//////////////////////////PNG 半透明修复
function fixPng(classNames){
	if($.browser.msie && $.browser.version == 6.0){
	if($("img.png").length>0){
		$("img.png").each(function(){
			var imgSrc = $(this).attr("src");
			var _width = $(this).attr("width");
			var _height = $(this).attr("height");
			$(this).wrap("<span></span>");
			$(this).parent().css("display","block");
			$(this).parent().width(_width);
			$(this).parent().height(_height);
			$(this).parent().css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='crop', src='images/logo.png');");
			$(this).hide();
		});
	}
	}
}
//////////////////////////内容展开收缩
function switchCon(){
	if($(".switch").length > 0){
		$(".switch h3").append("<span class='switchBtn1'>点击展开</span>");
		$(".switch .con1").hide();
		$(".switch h3").eq(0).find("span").text("点击关闭");
		$(".switch h3").eq(0).find("span").attr("className","switchBtn2");
		$(".switch .con1").eq(0).show();
		//equalHeight();
		$(".switch h3").each(function(i){
			$(this).click(function(){
				$(this).next().toggle();
				if($(this).find("span").attr("className") == "switchBtn1"){
					$(this).find("span").attr("className","switchBtn2");
					$(this).find("span").text("点击关闭");
				}else if($(this).find("span").attr("className") == "switchBtn2"){
					$(this).find("span").attr("className","switchBtn1");
					$(this).find("span").text("点击展开");
				}
				equalHeight();
			});
		});
	}
}
//////////////////////////客户评价
function feedBack(){
	if($("#feedBack").length>0){
		$("body").append("<div id='overlay'></div>");
		$("a#feedbackBtn").click(function(){
			$("#overlay").width($(document).width());
			$("#overlay").height($(document).height());
			$("#overlay").fadeIn("fast");
			var _x = ($(window).width() - $("#postBox").width())/2;
			var _y = ($(window).height() - $("#postBox").height())/2;
			var pageScroll = getPageScroll();
			_x += pageScroll[0];
			_y += pageScroll[1];
			$("#postBox").css("left",_x);
			$("#postBox").css("top",_y);
			$("#postBox").fadeIn("slow");
		});
		$("#overlay").click(function(){
			$("#postBox").hide();
			$(this).fadeOut("fast");
		});
		$("span#close").click(function(){
			$("#postBox").hide();
			$("#overlay").fadeOut("fast");
		});
	}
}
//////////////////////////首页律师介绍
function lawyer(){
	if($("#team").length>0){
		$("body").append("<div id='overlay'></div>");
		$("#team li").each(function(i){
			$(this).click(function(){
			$("#overlay").width($(document).width());
			$("#overlay").height($(document).height());
			$("#overlay").fadeIn("fast");
			var _x = ($(window).width() - $(".team").eq(i).width())/2;
			var _y = ($(window).height() - $(".team").eq(i).height())/2;
			var pageScroll = getPageScroll();
			_x += pageScroll[0];
			_y += pageScroll[1];
			$(".team").eq(i).css("left",_x);
			$(".team").eq(i).css("top",_y);
			$(".team").eq(i).fadeIn("slow");
		});
		})
		$("#overlay").click(function(){
			$(".team").hide();
			$(this).fadeOut("fast");
		});
		$("span.close").click(function(){
			$(".team").hide();
			$("#overlay").fadeOut("fast");
		});
	}
}
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}
function searchForm(){
	if($("#searchKeyword").length>0){
		$("#searchKeyword").focus(function(){this.value=""});
	}
}
$(document).ready(dropList);
$(document).ready(fixPng);
$(document).ready(switchCon);
$(document).ready(feedBack);
$(document).ready(lawyer);
$(document).ready(equalHeight);
$(document).ready(searchForm);