var ctrlcode=0;
var IE5=((navigator.appVersion.indexOf("MSIE")!=-1)&&(navigator.appVersion.substr(22,1)>=5))?1:0;
var NS=(navigator.appName == 'Netscape')?1:0;


function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function fp(){
this.hp.style.behavior='url(#default#homepage)';
this.hp.setHomePage('http://www.ahnw.gov.cn/');
}
function printIt(){
	
	if ((IE5) || (NS))
	{	

		window.print();
	}
	else
	{	
		alert("  您用的不是IE5.0以上版本，不支持直接打印。请用\n\nCtrl+p或单击鼠标右键,选菜单中的[打印]！");
		//WebBrowser1.ExecWB(6,2);
	}
}

function shutwin(){
window.close();
return;
}
function openwin(zjname)
     {

	window.open(zjname,"","top=0,left=0,height=450,width=710,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
	}
function openwin1(zjname)
     {

	window.open(zjname,"","top=,left=40,height=450,width=710,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
	}
function openlm(zjname)
     {

	window.open(zjname,"","top=0,left=0,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,menubar=yes,location=yes");
	}
function openmin(zjname)
     {

	window.open(zjname,"","top=0,left=0,height=450,width=400,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
	}

function openad(zjname,width,height)
     {

	window.open(zjname,"","top=0,left=0,height="+height+",width="+width+",resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
	}
function opendd(open1,open2){
openlm(open1);
openwin(open2);
}

function isBlank(s){
 var len=s.length;
 var i;
for (i=0;i<len;++i)
{
 if(s.charAt(i)!=" ") return false;
}
 return true;

}


function checkKey(ob)
{
  if((IE5) || (NS)){
	if (window.event.ctrlKey)  // checks whether the ctrl key  // is pressed
	   	JM_cc(ob);
  }	
}

function JM_cc(ob){
  if ((IE5) || (NS))
{
   
	  ob.select();
	  js=ob.createTextRange();
	  js.execCommand("Copy");

   /*
	  ob.readOnly=false;
	  ob.focus();
	  ob.readOnly=true;
	  ob.blur();
  */
  }

else{
   if ((event.button == 2)||(event.button==3)){
     alert("欢迎您访问安徽农网(http://www.ahagri.com)");
     return false;
       }									
    }
}

function unselect()
{
   document.selection.empty();
   
}
function opencontent(id){
	window.open("count.asp?id="+id,"","top=0,left=0,height=450,width=710,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
	}


//////////////////////////////
function OpenLink(thisform){
  if (thisform.options[thisform.selectedIndex].value.length>0)
  	window.open(thisform.options[thisform.selectedIndex].value);

};


function TabKey(){
  if (event.keyCode==13)
   event.keyCode=9;
}
function EnterSubmit(obj){
  if (event.keyCode==13)
  obj.submit();

}

function GetCookie (name) 
{
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
  }
 function getCookieVal (offset)
  {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
  }


  function SetCookie (name, value)
  {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  var expdate = (new Date()).getTime()

  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
  }

function Set30DayCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}


function textCounter(field, countfield, maxlimit) {
var length=word=0;
var a1,a2;
a1 = field.value.toString();
for (i=0;i<field.value.length;i++){
	a2=escape(a1.charAt(i));
	 length += 1;
	if(length<maxlimit) word++;
}
if (length > maxlimit){
	field.value = field.value.substring(0,word);
	return false;}
else {
	countfield.value = maxlimit-length;
	return true;
	}
}
function encode(datastr, bassnum) {
	var tempstr;
	var tchar;
	var newdata = "";

	for (var i = 0; i < datastr.length; i++)
	{
		tchar = 65535 + bassnum - datastr.charCodeAt(i);
		tchar = tchar.toString();

		while(tchar.length < 5)
		{
			tchar = "0" + tchar;
		}

		newdata = newdata + tchar;
	}

	return newdata;
}
function openbigmov(zjname)
     {
	window.open("/nwkx/more.asp?sort=音频视频&SortName=音频视频");
	window.open("/movie/movisdn.asp?name="+zjname,"","top=0,left=0,height=450,width=600,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
	}
function opensmallmov(zjname)
     {
window.open("/nwkx/more.asp?sort=音频视频&SortName=音频视频");
window.open("/movie/mov56.asp?name="+zjname,"","top=0,left=0,height=256,width=340,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
	}
function openflash(num){
 window.open("/swtd/jpzs/?id="+num,"allflash","");
  }	


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function OpenShow(id)
{
 popUpWindow("show.asp?id="+id,0,0,540,500)
}

function OpenHelp(id)
{
 popUpWindow("showHelp.asp?id="+id,0,0,540,500)
}


function playMp3(stype){

      //mp3frame.location.href="mp3.asp?id="+m_id
	//  location.href=mp3frame.src
      if (stype==1)
      {
	     mp3frame.document.getElementById("player").controls.play();
		 document.getElementById("mp3img").src="/images/voice_start.gif"
       }else if(stype==2){
	     mp3frame.document.getElementById("player").controls.pause();
		 document.getElementById("mp3img").src="/images/voice_pause.gif"	   
	   }else if (stype==3){
	     mp3frame.document.getElementById("player").controls.stop();
		 document.getElementById("mp3img").src="/images/voice_stop.gif"	 	   
	   }

}
function ShowPannel(nType){
  url=window.location.href;
  str=url.substr(url.lastIndexOf('/'));
  id=unescape(str.substr(1,str.indexOf(".")-1))
  str=url.substr(1,url.lastIndexOf('/')-1);
  datepath=str.substr(str.lastIndexOf('/')+1);

  if (datepath>='20070501')
  {
     str=""
     str="<div align=center><img src=\"/Images/voice_stop.gif\" id=\"mp3img\" border=\"0\" usemap=\"#Map3\" width=\"181\" height=\"29\">"
     str=str+"<iframe id=\"mp3frame\" name=\"mp3frame\" src=\"/mp3.asp?classname="+nType+"&id="+id+"&sDate="+datepath+"\" width=0 height=0><\/iframe></div>"
	 str=str+"<map name=\"Map3\"><area shape=\"rect\" coords=\"100,4,118,24\" style=\"cursor:pointer\" onClick=\"playMp3(1)\"><area shape=\"rect\" coords=\"124,4,139,23\" style=\"cursor:pointer\" onclick=\"playMp3(2)\"><area shape=\"rect\" coords=\"142,5,161,23\" style=\"cursor:pointer\"  onClick=\"playMp3(3)\"></map>"
    
	 document.getElementById("content_show").insertAdjacentHTML("beforeBegin",str)
  }
 
}