// JavaScript Document
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) {
    if (obj.style) {obj=obj.style;}
	v=args[i+2];
	if(v){v=(v=='show')?'visible':(v=='hide')?'hidden':v;}
	else {v=obj.visibility; v=(v=='hidden')?'visible':(v=='visible')?'hidden':v;}
    obj.visibility=v; }
}

function doselectAll(theBox){
  	xState=theBox.checked;
  	elm=theBox.form.elements;
  	for(i=0;i<elm.length;i++) {
   		if(elm[i].type=="checkbox") {
			elm[i].checked=xState;
		}
	}    
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' 必须是一个EMAIL地址.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' 必须包含一个数字.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' 必须在数字 '+min+' 和 '+max+'之间.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' 是必填的.\n'; }
  } if (errors) alert('有以下错误发生:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + value + expire;
}

// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function switchTab(tabid,flag)
{
 	//if(flag!=true) clearTimeout(jingpin);
    var obj;
    var obj2;
	for(i=1; i <=6; i++)
	{
		obj=document.getElementById("navtab_"+i);
		obj2=document.getElementById("tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhover";
		     if (obj2!=null){
				// if(document.getElementById("tabcontent"+i).innerHTML=='' || document.getElementById("tabcontent"+i).innerHTML=='<div style=\"padding:20px; text-align:center\">数据加载中...</div>'){
			 		 //document.getElementById("tabcontent"+switch_jingpin_now).style.filter = "alpha(opacity=50)";
					 document.getElementById("tabcontent"+i).innerHTML='<div style=\"padding:20px; text-align:center\">数据加载中...</div>';
					 //ajax_get('index_area.php?mod=jp&typeid='+i,'tabcontent'+i);	
					 ajax_get('index_area_new.php?mod=jp&typeid='+i,'tabcontent'+i);
					 ajax_get('index_area_link.php?id='+i,'index_area_link');
				 //}
				//document.getElementById("tabcontent"+switch_jingpin_now).style.filter = "";
				obj2.style.display='block';
			 }
		   }
		   else
		   {
   		     obj.className="normal";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
	//switch_jingpin_now = tabid;
}

function daodu_switchTab(tabid,flag)
{
	//if(flag!=true) clearTimeout(daodu);
    var obj;
    var obj2;
	for(i=1; i <=10; i++)
	{
		obj=document.getElementById("nav_daodu_tab_"+i);
		obj2=document.getElementById("daodu_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhover";
		     if (obj2!=null){
		       	//if(document.getElementById("daodu_tabcontent"+i).innerHTML=='' ||document.getElementById("daodu_tabcontent"+i).innerHTML=='<div style=\"padding:20px; text-align:center\">数据加载中...</div>'){
					document.getElementById("daodu_tabcontent"+i).innerHTML='<div style=\"padding:20px; text-align:center\">数据加载中...</div>';
					ajax_get('index_area.php?mod=dd&typeid='+i,'daodu_tabcontent'+i);	 
				//}
			    obj2.style.display='block';
			 }
		   }
		   else
		   {
   		     obj.className="normal";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}

function zuixin_switchTab(tabid,flag)
{
	if(flag!=true) clearTimeout(zuixin);
    var obj;
    var obj2;
	for(i=1; i <=5; i++)
	{
		obj=document.getElementById("nav_zuixin_tab_"+i);
		obj2=document.getElementById("zuixin_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhoverright";
		     if (obj2!=null){
				if(document.getElementById("zuixin_tabcontent"+i).innerHTML=='' || document.getElementById("zuixin_tabcontent"+i).innerHTML=='<div style=\"padding:20px; text-align:center\">数据加载中...</div>'){
					document.getElementById("zuixin_tabcontent"+i).innerHTML='<div style=\"padding:20px; text-align:center\">数据加载中...</div>';
					ajax_get('index_area.php?mod=zx&typeid='+i,'zuixin_tabcontent'+i);	 
				} 
		        obj2.style.display='block';
			 }
		   }
		   else
		   {
   		     obj.className="normalright";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}


function rexiao_switchTab(tabid,flag)
{
	//if(flag!=true) clearTimeout(rexiao);
    var obj;
    var obj2;
	for(i=1; i <=5; i++)
	{
		obj=document.getElementById("nav_rexiao_tab_"+i);
		obj2=document.getElementById("rexiao_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="onhoverright";
		     if (obj2!=null){
		        //if(document.getElementById("rexiao_tabcontent"+i).innerHTML==''||document.getElementById("rexiao_tabcontent"+i).innerHTML=='<div style=\"padding:20px; text-align:center\">数据加载中...</div>'){
					document.getElementById("rexiao_tabcontent"+i).innerHTML='<div style=\"padding:20px; text-align:center\">数据加载中...</div>';
					//ajax_get('index_area.php?mod=rx&typeid='+i,'rexiao_tabcontent'+i);	 
					ajax_get('index_area_rx.php?typeid='+i,'rexiao_tabcontent'+i);	 
				//} 
				obj2.style.display='block';
			 }
		   }
		   else
		   {
   		     obj.className="normalright";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}

function tuijian_switchTab(tabid)
{
    var obj;
    var obj2;
	for(i=1; i <=4; i++)
	{
		obj=document.getElementById("nav_tuijian_tab_"+i);
		obj2=document.getElementById("tuijian_tabcontent"+i);
		if (obj!=null)
		{
   		   if (i==tabid)
		   {
		     obj.className="tuijian_nav_on";
		     if (obj2!=null)
		        obj2.style.display='block';
		   }
		   else
		   {
   		     obj.className="tuijian_nav";
		     if (obj2!=null)
		        obj2.style.display='none';
		   }
		}
    } 
}

function confirm_redirect(url,text)
{
	if (confirm(text)) {
			window.location = url;
	}
}
function   myAddPanel(title,url,desc)   {   
  if   ((typeof   window.sidebar   ==   'object')   &&   (typeof   window.sidebar.addPanel   ==   'function'))//Gecko   
  {   
  window.sidebar.addPanel(title,url,desc);   
  }   
  else//IE   
  {   
  window.external.AddFavorite(url,title);   
  }   
}   

function show_layer(){
	var eSrc=(document.all)?window.event.srcElement:arguments[1];
	var shield = document.createElement("DIV");
	shield.id = "shield";
	shield.style.position = "absolute";
	shield.style.left = "0px";
	shield.style.top = "0px";
	shield.style.width = "100%";
	shield.style.height = ((document.documentElement.clientHeight>document.documentElement.scrollHeight)?document.documentElement.clientHeight:document.documentElement.scrollHeight)+"px";
	shield.style.background = "#333";
	shield.style.textAlign = "center";
	shield.style.zIndex = "10000";
	shield.style.filter = "alpha(opacity=0)";
	shield.style.opacity = 0;

	document.body.appendChild(shield);
	document.getElementById("download_layer").style.display='block';
	this.setOpacity = function(obj,opacity){
		if(opacity>=1)opacity=opacity/100;
		try{ obj.style.opacity=opacity; }catch(e){}
		try{ 
			if(obj.filters.length>0&&obj.filters("alpha")){
				obj.filters("alpha").opacity=opacity*100;
			}else{
				obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
			}
		}catch(e){}
	}
	var c = 0;
	this.doAlpha = function(){
		if (++c > 20){clearInterval(ad);return 0;}
		setOpacity(shield,c);
	}
	var ad = setInterval("doAlpha()",1);
	this.doOk = function(){
		//alertFram.style.display = "none";
		//shield.style.display = "none";
		//document.body.removeChild(alertFram);
		document.getElementById("download_layer").style.display='none';
		document.body.removeChild(shield);
		//eSrc.focus();
		document.body.onselectstart = function(){return true;}
		document.body.oncontextmenu = function(){return true;}
	}
	//document.getElementById("do_OK").focus();
	//eSrc.blur();
	document.body.onselectstart = function(){return false;}
	document.body.oncontextmenu = function(){return false;}
}

function  openWindows(url)   {  
  //window.location.href=url;
  window.open(url);
  //bschitchat=window.open(url,'bschitchat','fullscreen=yes,toolbar=no,Status=no,scrollbars=yes,resizable=yes');
  return;
} 

function pep_download(pid,uid)
{
	var DooX;
	show_float_layer("float_down_layer","close");
	//alert("downloading...");
	try
	{
		DooX = document.createElement("OBJECT");
		DooX.classid = "CLSID:C6D3941B-8B86-4B91-8067-42813A9B90EC";
		//show_float_layer("float_down_layer","close");
	}
	catch(e)
	{
		document.getElementById('down_msg').innerHtml = '您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。<BR>请在软件下载页面下载安装客户端。';
		//show_float_layer("float_down_layer","close");
		alert("您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。\n请在软件下载页面下载安装客户端。");
		document.getElementById('down_soft').style.display='block';
		return;
	}

	try
	{
		DooX.Init();
		DooX.StartDownLoad('<i c="down" p="'+pid+'" t="mag" u="'+uid+'" />');
	}
	catch(e)
	{
		 document.getElementById('down_msg').innerHtml = '您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。<BR>请在软件下载页面下载安装客户端。';
		//show_float_layer("float_down_layer","close");
		 alert("您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。\n请在软件下载页面下载安装客户端。");
		document.getElementById('down_soft').style.display='block';
		 return;
	}
}
function pep_download_bookshelf(pid,uid)
{
	var DooX;
	//show_float_layer("float_down_layer","close");
	//alert("downloading...");
	try
	{
		DooX = document.createElement("OBJECT");
		DooX.classid = "CLSID:C6D3941B-8B86-4B91-8067-42813A9B90EC";
		//show_float_layer("float_down_layer","close");
	}
	catch(e)
	{
		//document.getElementById('down_msg').innerHtml = '用户可能没装客户端，或者浏览器不支持。';
		//show_float_layer("float_down_layer","close");
		alert("您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。\n请在软件下载页面下载安装客户端。");
		window.location("http://www.dooland.com/magazine/download.php");
		//document.getElementById('down_soft').style.display='block';
		return;
	}

	try
	{
		DooX.Init();
		DooX.StartDownLoad('<i c="down" p="'+pid+'" t="mag" u="'+uid+'" />');
	}
	catch(e)
	{
		// document.getElementById('down_msg').innerHtml = '用户可能没装客户端，或者浏览器不支持。bb';
		//show_float_layer("float_down_layer","close");
		 alert("您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。\n请在软件下载页面下载安装客户端。");
		 window.location("http://www.dooland.com/magazine/download.php");
		//document.getElementById('down_soft').style.display='block';
		 return;
	}
}
function pep_refush(uid)
{
	var PEPCom;
	try
	{
		PEPCom = document.createElement("object");
		PEPCom.classid = "CLSID:C6D3941B-8B86-4B91-8067-42813A9B90EC";
		PEPCom.Init();
		PEPCom.StartDownLoad('<i c="rf" t="mag" u="'+uid+'"/>');
	}
	catch(e)
	{
		 return;
	}
}

function pep_read(param,title)
{
	var DooX;
	try
	{
		DooX = document.createElement("OBJECT");
		DooX.classid = "CLSID:C6D3941B-8B86-4B91-8067-42813A9B90EC";
	}
	catch(e)
	{
		alert("您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。\n请在软件下载页面下载安装客户端。");
		window.location("http://www.dooland.com/magazine/download.php");
		return;
	}

	try
	{
		DooX.Init();
		DooX.StartDownLoad('<i c="open" u="?'+param+'" t="paper" uid="" d="'+title+'"/>');
	}
	catch(e)
	{
		 alert("您可能尚未安装客户端，或者您所使用的浏览器不支持客户端。\n请在软件下载页面下载安装客户端。");
		 window.location("http://www.dooland.com/magazine/download.php");
		 return;
	}
	//window.close();
}
