
var contextPath = "";
var url_literature_favorite = "/literature/favorite.php"

function gfnSwitch(strObj) {
	var obj = document.getElementById(strObj);
	if(obj.style.display =="block") {
		obj.style.display ="none";
	}else {
		obj.style.display ="block";
	}
} 

function toggle(divid) {
	if($(divid)) {
		Element.toggle($(divid));
	}
}
/** 
 *  分页页面换页用
 *  参 数: toPage  -- 要去的页的页数
 *  参 数: strAction  -- form提交向的action
 *  返回值: 无
 */
function goPage(toPage,strAction,objForm) {
	if(strAction.indexOf("?")>0){
		strAction=strAction+"&page="+toPage
	}else{
		strAction=strAction+"?page="+toPage
	}
	var runMsg = document.getElementById("runMsg");
	if(runMsg) {
		runMsg.style.display = "block";
	}
	var page = document.getElementById("page");
	if(page) {
		page.value = toPage;
	}
	var form = objForm;
	if(!form) {
		form = document.forms["form1"];
	}
	form.action = strAction;
	form.method = "POST";
	form.target = "_self";
	form.submit();
}

function gotoPage(gotoPageObjID,strAction,objForm) {
	var toPage = document.getElementById(gotoPageObjID).value;
	goPage(toPage,strAction,objForm);
}
function openKYP2PWin(kyp2pUrl) {
	var newwin = window.open(kyp2pUrl,'KYP2PWin','toolbar=0,location=0,height=150,width=380,left=0,top=0');
	var closeNewwin = function(){newwin.close()};
	newwin.focus();
	setTimeout(closeNewwin,'2500');
}

function emtInstalled() {
	return true;
}
// IE用，判断医脉通有没有安装
function emtInstalledBak() {
	try {
		var obj = new ActiveXObject("Msxml2.XMLHTTP");

		if (obj) {
			try {
				var emt = new ActiveXObject("EmtQuery.EMTQuery");

				if (emt) {
					var isEMTInstalled = emt.IsEMTInstalled(0)
					if (isEMTInstalled && isEMTInstalled == 1) {
						// alert("检测成功");
						return true;
					} else {
						// 理论上没有这样的情况
						alert("您的医脉通安装有问题，请重新安装");
						return false;
					}
				}
			} catch (e2) {
				// 医脉通没有安装
				alert("您还没有安装医脉通或您安装的版本太低，请下载并安装最新版医脉通");
				window.location.href = "http://www.medlive.cn" + contextPath + "/download/emt.exe";
				return false;
			}
		} else {
			// 理论上没有这样的情况
			alert("您的医脉通安装有问题，请重新安装");
			return false;
		}
	} catch (e) {
		// ActiveX对象不允许运行
		alert("您的安全设置太高，请修改安全设置。");
		return false;
	}
}

/** 
 *  评论部分前端分页页面换页用
 *  参 数: toPage  -- 要去的页的页数
 *  参 数: typeid  -- 数据库的表id
 *  参 数: objid  -- 数据库的主键id
 *  返回值: 无
 */
function goMyPage(toPage,typeid,objid) {
	var  pars  =  'page=' + toPage+'&typeid='+typeid+'&objid='+objid;
	if($('commentDiv')) {
		var url = contextPath + '/comment/comment_list.do';
//		$('commentDiv').focus();
		var myAjax = new Ajax.Updater({success:'commentDiv'},url,{
			method: 'get',
			parameters: pars,
			evalScripts: true,
			on503: function(){$('commentDiv').innerHTML = ''}
		});
//		new Effect.ScrollTo('commentDiv', {offset: 2});
	}
}

function getImage() {
	$('captcha').src='captchaAction.do?cd='+Math.random();
}

function hideDefault(input){
  if(typeof(input.defaultValue)=="undefined") {
    input.defaultValue = input.value;
  }
  if(input.value == input.defaultValue) {
    input.value = "";
	input.style.color = '#000000'; 
  }
  return true;
}
function showDefault(input){
  if(input.value == "" && typeof(input.defaultValue)!="undefined"){
    input.value = input.defaultValue;
  }
  return true;
}

function bg_even(o,a,b,c,d){
	var t=document.getElementById(o).getElementsByTagName("tr");
	for(var i=0;i<t.length;i++){
		t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
				t[i].onmouseover=function(){
			if(this.x!="1")this.style.backgroundColor=c;
		}
		t[i].onmouseout=function(){
			if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;//移走时恢复常态
		}
	}
}

 function goTop(){
  	var locat = document.location.href;
	locat = locat.replace('#top','')+'#top';
	location.href = locat;
}

