﻿window.onerror = function () { return true; }

function dialog() {
	var temp_box = new String;
	temp_box += "<div id=\"dialogBg\" style=\"height:" + $(document).height() + "px;\"></div>";
	temp_box += "<div id=\"dialog\">";
	temp_box += "<div id=\"dialog_title\"><h4></h4><small onclick=\"new dialog().close()\">关闭</small></div>";
	temp_box += "<div id=\"dialog_content\"></div>";
	temp_box += "</div>";
	this.init = function (_title, _w, _h) {
		if (!$("#dialog").length) $("body").append(temp_box);
		$("#dialogBg").show();
		$("#dialog").show().css({ width: _w, left: $(document).width() / 2 - parseInt(_w) / 2, top: $(document).scrollTop() + document.documentElement.clientHeight / 2 - parseInt(_h) / 2 - 50 });
		if (_title.length) $("#dialog_title h4").html(_title);
		$("#dialog_content").css({ height: _h });
	}
	this.close = function () {
		$("#dialogBg").hide();
		$("#dialog").hide();
	}
	this.open = function (_url) {
		$("#dialog_content").html("<iframe src=\"" + _url + "\" width=\"100%\" height=\"100%\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
	}
	this.alert = function (_url) {
		$.get(_url, function (data) {
			$("#dialog_content").html(data);
		});
	}

}
function openWindow(_url, _title, _w, _h) {
	var obj = new dialog();
	obj.init(_title, _w, _h);
	obj.open(_url);
}

//商务通脚本-----------------------------------------------------------------------------------------------------------------
//主动邀请标题重写
var LiveAutoInvite0 = '美联臣 - 成功人士首选医疗美容机构';
//移动
function Move_swtInvitation() {
	var newPlace = document.documentElement.scrollTop + document.documentElement.clientHeight - document.getElementById("swtInvitation").offsetHeight;
	var oldPlace = parseInt(document.getElementById('swtInvitation').style.top);
	document.getElementById('swtInvitation').style.top = oldPlace + (newPlace - oldPlace) / 3 + 'px';
	document.getElementById('swtInvitation').style.left = (document.documentElement.scrollLeft + document.documentElement.clientWidth - document.getElementById("swtInvitation").offsetWidth) + "px";
}

//显示脚本
function showReception(seconds) {
	if (document.getElementById("swtInvitation") == null) {
		document.write('<div id="swtInvitation" style="top:0px; left:2000px; position:absolute;display:none;">');
		document.write('	<embed src="/style/shangwutong.swf" wmode="transparent" menu="false" bgcolor="#F0F0F0" quality="high" width="325" height="176" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('	<div class="btn">');
		document.write('		<a href="/LiveReception.htm" target="_blank" title="接受对话"><img src="/style/accept.gif" alt="接受对话" /></a>');
		document.write('		<a href="javascript:hideSwtInvitation();" title="暂不对话"><img src="/style/nexttime.gif" alt="暂不对话" /></a>');
		document.write('	</div>');
		document.write('</div>');
	}

	//弹出等待时间
	if (!seconds)
		seconds = 10;
	//判断当前时间,造成八点至晚上24点开放。
	var now = new Date();
	if (now.getHours() >= 8 && now.getHours() <= 23)
		setTimeout("document.getElementById('swtInvitation').style.display='block';setInterval('Move_swtInvitation()', 15);", seconds * 1000);
}

//隐藏
function hideSwtInvitation() {
	document.getElementById('swtInvitation').style.display = 'none';
	//隐藏后90秒重新出现
	showReception(90);
}
//-----------------------------------------------------------------------------------------------------------------------------------

$(function () {
	$("#nav .nav").hover(
	function () {
		$(this).addClass("current");
		$(this).children(".float").show();
	},
	function () {
		$(this).removeClass("current");
		$(this).children(".float").hide()
	}
);
});

$(function () {
	$("#nav_1").hover(
	function () {
		for (var i = 1; i < 3; i++) {
			$(".stitle" + i).hide();
		}
	},
	function () {
		for (var i = 1; i < 3; i++) {
			$(".stitle" + i).show();
		}
	}
);
});

$(function () {
	$("#nav_2").hover(
	function () {
		for (var i = 1; i < 3; i++) {
			$(".stitle" + i).hide();
		}
	},
	function () {
		for (var i = 1; i < 3; i++) {
			$(".stitle" + i).show();
		}
	}
);
});

function trim(str) {
	if (str == null) {
		return "";
	}
	return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1');
}

function checkphone(tel) {
	var str = tel;
	//在JavaScript中，正则表达式只能使用"/"开头和结束，不能使用双引号
	var Expression = /(\d{3}-)(\d{8})$|(\d{4}-)(\d{7})$|0{0,1}\d{11}$/; //匹配字符串中的指定位数，(\d{8})$表明以8个数字结尾
	var objExp = new RegExp(Expression);
	if (objExp.test(str) == true) {
		return true;
	}
	else {
		return false;
	}
}

function yzEmail(email) {
	email = trim(email);
	if (email != "") {
		var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
		if (!reg.test(email)) {
			return false;
		}
		return true;
	}
	return false;
}

function IsURL(str) {
	var Expression = /([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
	var objExp = new RegExp(Expression);
	if (objExp.test(str) == true) {
		return true;
	}
	else {
		return false;
	}
}

//google统计代码
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-10471799-2']);
_gaq.push(['_setDomainName', '.meilianchen.com']);
_gaq.push(['_trackPageview']);

(function () {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
