$().ready( function() {
	$(".nav a").mouseover( function() {
		mouseovercheck($(this))
	} );
	$(".nav").each( function() {
		mouseovercheck($(this).find("a:first"));
	} );
	function mouseovercheck(obj) {
		if ( !obj.hasClass("current") ) {
			obj.parent().parent().find("a").filter( function(index) {
				return $(this).hasClass("current");
			} ).removeClass("current");
			obj.addClass("current");
			LoadContactList(obj);
		}
	}
	
	function LoadContactList(obj) {
		var box = obj.parent().parent().parent().next();
		box.html("数据载入中...");
		$.ajax( {
			type: "get",
			url: "ajax/ContactList.asp",
			cache: false,
			data: "C_id=" + obj.attr("rel"),
			dataType: ($.browser.msie) ? "text" : "xml",
			error: function() { alert("Error loading XML document"); },
			success: function(result) {
				if ( typeof result == "string" ) {
					var xml = new ActiveXObject("Microsoft.XMLDOM");
					xml.async = false;
					xml.loadXML(result);
				}
				else {
					var xml = result;
				}
				if ( xml.getElementsByTagName("root")[0].getAttribute("error") == "PaWrong" ) {
					alert("对不起，参数错误！");
				}
				else {
					var contact = xml.getElementsByTagName("root")[0].getElementsByTagName("contacts")[0] , xmldate = "";
					if ( contact.getAttribute("C_Addr") != "" ) {
						xmldate += "<p>地址：" + contact.getAttribute("C_Addr") + "</p>\n";
					}
					if ( contact.getAttribute("C_Tel") != "" ) {
						xmldate += "<p>电话：" + contact.getAttribute("C_Tel") + "</p>\n";
					}
					if ( contact.getAttribute("C_Fax") != "" ) {
						xmldate += "<p>传真：" + contact.getAttribute("C_Fax") + "</p>\n";
					}
					if ( contact.getAttribute("C_24Tel") != "" ) {
						xmldate += "<p>24小时热线电话：" + contact.getAttribute("C_24Tel") + "</p>\n";
					}
					if ( contact.getAttribute("C_Manager") != "" ) {
						xmldate += "<p>经理：" + contact.getAttribute("C_Manager") + "</p>\n";
					}
					if ( contact.getAttribute("C_Mobile") != "" ) {
						xmldate += "<p>手机：" + contact.getAttribute("C_Mobile") + "</p>\n";
					}
					if ( contact.getAttribute("C_FreeTel") != "" ) {
						xmldate += "<p>免费电话：" + contact.getAttribute("C_FreeTel") + "</p>\n";
					}
					box.html(xmldate);
				}
			}
		} );
	}
} );