/* <!--  */

try { //如果变量已定义,则做较准确的测试; 否则从此JS载入时开始计时(可能其它CSS等文件已载入!);
if (starTimeS) { 
 starTimeS=starTimeS;	
}
}
catch(ex){
 //alert(ex);		
 var vNowTime =new Date();
 starTimeS=vNowTime.getTime(); 
}

 //alert(sLoadStatus);
 var sLoadStatus="打开";
  
 window.onload = function(){
    
   //window.setInterval("setnav()", 100);
   window.setInterval("heartBeatr()",50);  
   //window.setInterval("heartBeatT()",1);    
 
   //-------- 自动适应屏宽 ----------
   //alert(window.screen.availWidth + ", " +window.screen.width); 1024,1024
   if (window.screen.width<1024) {
   	 document.getElementById("autob").style.width="1002px";
   }
   else if(window.screen.width<1364){
   	 document.getElementById("autob").style.width=window.screen.width-22+"px";
   }
   else {
   	 document.getElementById("autob").style.width="1364px";
   }

  //-------- 调整助手显示效果 -------
  if (window.sidebar)  //firefox
  {  
  	 //alert(document.getElementById("helperFrm").height+"");
      document.getElementById("helperFrm").height="318";  
  }  
  else if(document.all)  
  {  
      document.getElementById("helperFrm").height="352";  
   }  
  else  
  {  
      //return true;  
   } 

//------------判断是否页面刷新并显示装载时间----------------

   //测试时,如果其他页面调用此JS,不会出错; 比如页面尾部没有加入 id="laodTime"
 	 
   var vNowTime =new Date();
   endTimeS=vNowTime.getTime();
   var loadTime=endTimeS-starTimeS; 
   
try {         
   var lastTime=GetCookie("lastTime");
   //alert(lastTime);
/* lastTime.setFullYear(getCookie("yyyy"));
   lastTime.setMonth(getCookie("mmo"));
   lastTime.setDate(getCookie("dd"));
   lastTime.setHours(getCookie("hh"));
   lastTime.setMinutes(getCookie("mmi"));
   lastTime.setSeconds(getCookie("ss"));
   lastTime.setMilliseconds(getCookie("ms")); */   
   //alert("lastTime:"+lastTime+"?==document.location.href: "+(lastUrl==document.location.href));
   var TimeDiff=endTimeS-Date.parse(lastTime);	
   //alert("TimeDiff:"+TimeDiff+"?<86400000*7: "+(TimeDiff<86400000*7));
   var lastUrl=GetCookie("lastUrl");

   
   //document.write ((endTimeS-starTimeS)+"ms"); //这会造成页面被全新写一遍;
   //if (document.referrer==document.url) { //页面刷新操作, 约172300字节 , 这不能得出结果   
   if (document.location.href!="http://www.lvpu.net/loadtime.asp") { //非测试页面,只显示装载时间,不显示带宽
   	setElementTextById("loadTime","页面装载时间: "+loadTime+"ms");
  }
   else {
    if (lastUrl==document.location.href && TimeDiff<86400000*7) { //在7天之内重载,说明缓存没有清过;7天以上,认为网站已更新,但第一次测试值不算!
       var bandwith=175889/(loadTime-531);
       var fmtbd=new Number(bandwith);	
   	   setElementTextById("loadTime","页面装载时间: "+loadTime+"ms"+" 带宽: "+fmtbd.toFixed(3)+"KB/s");
   	   //alert("刷新");
     }
    else {
   	  var bandwith=1470884/(loadTime-960);
   	  var fmtbd=new Number(bandwith);
      setElementTextById("loadTime","页面装载时间: "+loadTime+"ms"+" 带宽: "+fmtbd.toFixed(3)+"KB/s");
   }   
  }
  
  // --------- 设置 Cookie 并退出 ----------
  SetCookie("lastUrl",document.location.href);
  var lastTime=new Date();
/*SetCookie("yyyy",lastTime.getFullYear());
  SetCookie("mmo",lastTime.getMonth());
  SetCookie("dd",lastTime.getDate());
  SetCookie("hh",lastTime.getHours());
  SetCookie("mmi",lastTime.getMinutes());
  SetCookie("ss",lastTime.getSeconds());
  SetCookie("ms",lastTime.getMilliseconds()); */
  SetCookie("lastTime",lastTime.toUTCString());
    
 } // try 带宽测试;
catch(ex) {//将异常对象引用给变量ex
 //alert(ex);//处理异常
 //alert(document.referrer);
 //alert(document.location.href); // url只在VBS中定义;
}

 //alert(sLoadStatus);
 //alert(document.cookie);
 
 try{  
 	 //alert(sFlashName=="");
   if (sFlashName) { //只有在需要加载Flash时:已定义,而且不为空,才实现它的动态加载! 
   	 try {
   	 	 if (maxLoadTime>45000) maxLoadTime=45000; //限制最大的下载时间为45秒!
   	 	 else if (maxLoadTime<10) maxLoadTime=10;  //规定最小下载时间为10ms;
   	 	}
   	 	catch(bx) {
   	 		maxLoadTime=25000; //设置默认最大下载时间为25秒;
   	 	}  	 
     if (loadTime<maxLoadTime) { //只在网速较快,25秒以下装载时间(25000)时才装载Flash!
 	      loadJS("http://www.lvpu.net/2009code/swfobject.js");
			  loadFlash(500,sFlashName,0)			  
      }
    }
  }
 catch(ex) {
 	//alert(ex);  
 } 
}
// -------------- onload End ------------------------
			var flashvars = {};
			var params = {};
			params.play = "true";
			params.loop = "true";
			params.quality = "best";
			var attributes = {};
			attributes.align = "middle"; 	
 function loadFlash(maxTryCount,sFlashName,TryCount) {
 	//ReferenceError: swfobject is not defined
 	try{
 	    //if (TryCount<500) {
 	      swfobject.embedSWF(sFlashName, "myAlternativeContent", "1000", "210", "9.0.0", "/imgs/expressInstall.swf", flashvars, params, attributes); 	
 	    //window.setTimeout("loadFlash("+maxTryCount+",'"+sFlashName+"',"+(++TryCount)+")", 10);
 	    //}
 	    //else alert("Try Times:" + TryCount + " !");
 	    //alert(document.getElementById("http://www.lvpu.net/2009code/swfobject.js").text);
 	    //看出,FF中,动态创建的HTML元素实际上有问题! 不论等多少时间,动态创建的那个js文件其实根本没有运行到结束!因为我在测试的JS最后放了一个alert
  }
  catch(ex) {
  	//if (ex=="ReferenceError: swfobject is not defined" && TryCount<maxTryCount) {
  		window.setTimeout("loadFlash("+maxTryCount+",'"+sFlashName+"',"+(++TryCount)+")", 30);
  	//}
  	//else alert(ex + " Try Times:" + TryCount + " !");
  }
  
}

 function loadJS(langfullpath){
  try{  
   var sId = langfullpath; 
   if(!document.getElementById(sId)){  //以文件路径作为id，考虑以后要求动态卸载 
      var oHead = document.getElementsByTagName('HEAD').item(0); 
      var oScript = document.createElement("script"); 
      oScript.language = "javascript"; 
      oScript.type = "text/javascript"; 
      oScript.id = sId; 
      oScript.defer = true; 
    //oScript.text = source;
      oScript.src = langfullpath;
      oHead.appendChild(oScript); 
   }
   else{ //id已存在
   	  oScript=document.getElementById(sId);
      //oScript.language = "javascript"; 
      //oScript.type = "text/javascript";   	
   	  //oScript.defer = true;
   	  oScript.src = langfullpath;
   	  //alert("已存在!");
  }
 }
 catch(ldex){
 	alert(ldex);
 }
}


 window.onunload = function(){
   //if(sLoadStatus=="刷新")
   //alert(sLoadStatus);
   //else
   //alert("这是关闭页面"); 	
}
  
 window.onbeforeunload = function(){
 	sLoadStatus="刷新";
}
  
  function setnav() {
  var navtop=getScrollTop();    
  if (navtop>214) {
 	  document.getElementById("navbox").style.top =(navtop-214)*xishu+"px";
  }
  else {
  	document.getElementById("navbox").style.top = "0px";
  }
 }

//----------------------------------------------------------------
 var lastScrollYr=0;
 var lastScrollYT=0;
function getScrollTop() {
var Y;
if (document.documentElement && document.documentElement.scrollTop)
    Y = document.documentElement.scrollTop;
else if (document.body && document.body.scrollTop)
    Y = document.body.scrollTop;
else
    {/*Netscape stuff*/
    Y=0;	//设置为零，不进行任何处理
   }
return Y;    	
}

function heartBeatr(){ 

  var diffY=getScrollTop();  
//alert(diffY);
	if (diffY>180) diffY=diffY-180;
  percent=.1*(diffY-lastScrollYr); 
  if(percent>0)percent=Math.ceil(percent); 
  else percent=Math.floor(percent); 
  //document.getElementById("leftnav").style.top=parseInt(document.getElementById("leftnav").style.top)+percent+"px";  
  helperTop=parseInt(document.getElementById("helper").style.top)+percent;
  document.getElementById("helper").style.top=helperTop+"px";
  if (helperTop>388) {
  	document.getElementById("leftnav").style.top=(helperTop-210)+"px";
  }
  else{
  	document.getElementById("leftnav").style.top="178px";
  }
  //document.getElementById("test").style.top=document.getElementById("leftnav").style.top;
  lastScrollYr=lastScrollYr+percent; 
  //alert(lastScrollYr);
}

function heartBeatT(){ 
  var diffY=getScrollTop(); 
  //alert(diffY);
	if (diffY>210) diffY=diffY-210;
  percent=.1*(diffY-lastScrollYT); 
  if(percent>0)percent=Math.ceil(percent); 
  else percent=Math.floor(percent); 

  document.getElementById("navbox").style.top=parseInt(document.getElementById("navbox").style.top)+percent+"px";  
  //document.getElementById("helper").style.top=parseInt(document.getElementById("helper").style.top)+percent+"px";

  lastScrollYT=lastScrollYT+percent; 
  //alert(lastScrollY);
}

//----------------------------------------------------------------     
  function toshl(){
  var send1="abuse@isc.org.cn"; 
  if(document.all) {
  	var tt="宿根花卉订单咨询";
  }
  else{
  	var tt="about Perennial Flowers";
  }
  send1=send1.substr(5,1);
  send1="mai"+"lto"+":be"+"ijing"+send1+"lvp"+"u.n"+"et?subject="+tt;
  //alert(send1);
  window.location.href=send1;
  }

  function tooffice(){
  send2="abuse@isc.org.cn"; 
  send2=send2.substr(5,1);
  send2="mai"+"lto"+":of"+"fice"+send2+"lv"+"pu.ne"+"t";
  window.location.href=send2;
 }
  
  function prtdate() {
  	todayDate = new Date();
  	date = todayDate.getDate();
  	month= todayDate.getMonth() +1;
  	year= todayDate.getYear();
  	document.write("今天是");
  	document.write("<br>");
  	if(navigator.appName == "Netscape")
  	{
  		document.write(1900+year);
  		document.write("年");
  		document.write(month);
  		document.write("月");
  		document.write(date);
  		document.write("日");
  		document.write("<br>");
  	}
  	if(year<200) year=year+1900; /* for opera browser */
  	if(navigator.appVersion.indexOf("MSIE") != -1)
  	{
  	document.write(year);
  	document.write("年");
  	document.write(month);
  	document.write("月");
  	document.write(date);
  	document.write("日");
  	document.write("<br>");
  	}
  	if (todayDate.getDay() == 5) document.write("星期五");
  	if (todayDate.getDay() == 6) document.write("星期六");
  	if (todayDate.getDay() == 0) document.write("星期日");
  	if (todayDate.getDay() == 1) document.write("星期一");
  	if (todayDate.getDay() == 2) document.write("星期二");
  	if (todayDate.getDay() == 3) document.write("星期三");
  	if (todayDate.getDay() == 4) document.write("星期四");
  }
  
  function addmsite() {
    addBookmark("北京绿普花卉科技有限公司-供应宿根花卉,地被植物,园林花卉,景观花卉","http://www.lvpu.net/");
  }  

  function addBookmark(title,myurl) {  
  	  //alert(title);
  	  //alert(myurl);
      if (window.sidebar)  
      {  
          window.sidebar.addPanel(title, myurl, "");  
      }  
      else if(document.all)  
      {  
          window.external.AddFavorite(myurl, title);  
      }  
      else  
      {  
          return true;  
      }  
  }  

  //onclick="this.style.behavior='url(#default#homepage)';&#10;this.sethomepage('http://www.lvpu.net/');"
  function sethomepg(curobj) {
  	//alert(curobj.name);
    curobj.style.behavior="url(#default#homepage)";
    curobj.sethomepage("http://www.lvpu.net/");
  }
  
  
  function getTxtinHtmlObj(obj) {
    if(document.all){
       return obj.innerText;
     } 
    else{
      return obj.textContent;
    }   	
  }
  
  function setElementTextById(Id,sText) {
  	var e=document.getElementById(Id);
    if(document.all){
       e.innerText=sText;
     } 
    else{
      e.textContent=sText;
    }   	
  }
  

  function logoout(ig) {
    imgout(ig);     
  }   
  
  function testx() {
 
  		if (document.all) {
  			//alert("testx,sethomepage");
  			//sethomepg(document.getElementById("logonavto"));
  		}
  		else {
  		alert("本功能只对IE有效。\n您使用的不是IE浏览器，\n请您自己在浏览器中把我们的网址:'http://www.lvpu.net/'设置为主页");	
  		}
  	// return true;  	
  }

  function hideme() {
  	document.getElementById("bvista").style.zIndex=0;
  }
  
  function tovista(a) {
  	a="http://www.lvpu.net"+a;
  	document.getElementById("vista").src=a;
  	document.getElementById("bvista").style.zIndex=3;
  	//document.getElementById("mask").style.zIndex=0;
  } 
  function vistaw(w) {
  	document.getElementById("vista").style.width=w+"px";
  }
  function vistawh(w,h) {
  	s=document.getElementById("vista").style;
  	s.width=w+"px";
  	s.height=h+"px";
  }
  
  function sethelper(s){
   var helperStyle=document.getElementById("helper").style;	
   var diffY;
   var innerH;
   var diffY=getScrollTop(); 
   if (window.innerHeight) innerH=window.innerHeight; //ff;可显示部分的高度; 对于ff,document.documentElement.offsetHeight实际是文档的总长(3000px 或其他!)
   else if (document.documentElement && document.documentElement.offsetHeight) {
     innerH=document.documentElement.offsetHeight; //IE6,可显示部份的高度
     //alert(window.innerHeight);    
    }
   else if (document.body && document.body.offsetHeight) {
     innerH=document.body.offsetHeight; //没有测试过,不知道哪一种情况适合;
    }    
   else
    {/*Netscape stuff*/
    	innerH=600; //本人规定为600; Netscape 还没有测试过!
   	}   
   //alert(innerH + "");
   
   switch (s) { 
      case "l": 
         if (helperStyle.right=="") helperStyle.right="160px";
         else if (parseInt(helperStyle.right)<=parseInt(document.getElementById("autob").style.width)-320) helperStyle.right=parseInt(helperStyle.right)+160+"px"; 
         break; 
      case "r": 
         if (helperStyle.right=="") {}
         else if (parseInt(helperStyle.right)>=160) helperStyle.right=parseInt(helperStyle.right)-160+"px"; 
         break; 
      case "u":
         helperStyle.top=diffY+32+"px"; //parseInt(helperStyle.top)-160+"px"; 
         break; 
      case "d": 
         helperStyle.top=diffY-document.getElementById("helperFrm").height+innerH-16+"px"; //parseInt(helperStyle.top)+160+"px"; 
         break;
      case "o": 
         if (helperStyle.display=="none") helperStyle.display="block"; 
         else helperStyle.display="none";
         //return false;
         break; 
      case "c":
         helperStyle.display="none"; 
         break;
      }
                        	
  }

// --------------- cookie --------------------
function GetCookieVal(offset)
  //获得Cookie解码后的值
  {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

  
function SetCookie(name, value)
  //设定Cookie值
  {
  var expdate = new Date();
  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;
  if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
  document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
  +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
  +((secure == true) ? "; secure" : "");
}

function DelCookie(name)
  //删除Cookie
  {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}

  
function GetCookie(name)
  //获得Cookie的原始值
  {
  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;
}  
/*  -->  */
