﻿ 
 //漂浮图片开始
	var xstep = 1;  //x移动速度
	var ystep = 1;  //y移动速度
	var xport = 0; //记录x坐标
	var yport = 0; //记录y坐标
	var pftime;      //停止开始时间
	var scrollPos; //有滚动条是需要
	var RsecSrc = "";
	var secSrc = "";
	var firstUrl = "";
	var secUrl = "";
	var _width = 0;//图片宽
	var _height = 0; //图片高
	//触法的动作
	function yd(){
	    var obj = document.getElementById("rewin_piaofu");  //图片对象
	    width = parseInt(document.body.clientWidth)-parseInt(obj.width);  //可见区域宽
		height = 600;//可见区域高
		if (typeof window.pageYOffset != 'undefined') { 
			scrollPos = window.pageYOffset; 
		} 
		else if (typeof document.compatMode != 'undefined' && 
			 document.compatMode != 'BackCompat') { 
		   scrollPos = document.documentElement.scrollTop; 
		} 
		else if (typeof document.body != 'undefined') { 
		   scrollPos = document.body.scrollTop; 
		}else{
		   scrollPos = document.body.scrollTop; 
		}//获取高度
		xport =xport+ xstep;  //设置x轴坐标
		if(xport>width){
			xstep = -(Math.abs(xstep));
			xport = width;
		}else if(xport<0){
			xstep = Math.abs(xstep);
			xport = 0;
		}
		obj.style.left =  xport+"px"; //图片的x坐标
		yport = yport+ ystep;  //设置y轴坐标
		if(yport>height){
			ystep = -(Math.abs(ystep));
			yport = height;
		}else if(yport<0){
			ystep = Math.abs(ystep);
			yport = 0;
		}
		obj.style.top = yport + scrollPos+"px";//图片y轴坐标

	}
	function stop(){   //停止图片移动
		clearInterval(pftime);
	}
	function qieh(){   //两个图片切换
		var obj = document.getElementById("rewin_piaofu");
		if(obj!=undefined){
			if(obj.src.indexOf(RsecSrc)>=0){
				obj.src=secSrc;
				obj.onclick = function(){
					window.open(secUrl);
				}
				
			}else{
				obj.src=RsecSrc;
				obj.onclick = function(){
					window.open(firstUrl);
				}
			}
		}else{
			return;
		}
		window.setTimeout("qieh()",2000);
	}
	rewinjson.client.StyleTextPF = function (repText,divID){
		repText = repText.trim();
		if(repText != null && repText != undefined && repText != NaN && repText.length > 0){
			var rewinJSON_Text = eval("("+repText+")");
			if(rewinJSON_Text.result == "" || rewinJSON_Text.result == "error"){
				return;
			}else{
				if(document.getElementById("rewin_piaofu") != null && document.getElementById("rewin_piaofu") != undefined){
					var _len = parseInt(rewinJSON_Text.len);
					RsecSrc = rewinJSON_Text.result[0].src;
					firstUrl = rewinJSON_Text.result[0].href;
					_width = rewinJSON_Text.result[0].width;
					_height = rewinJSON_Text.result[0].height;
					if(_len==2){
						secSrc = rewinJSON_Text.result[1].src;
						secUrl = rewinJSON_Text.result[1].src;
						_width = rewinJSON_Text.result[1].width;
						_height = rewinJSON_Text.result[1].height;
					}
					var obj = document.getElementById("rewin_piaofu");
						obj.src=RsecSrc;
						obj.width = _width;
						obj.height = _height;
						obj.onclick = function(){
						window.open(firstUrl);
					}
					obj.onmousemove = function(){
						stop();
					}
					obj.onmouseout = function(){
						pftime=  setInterval('yd()',40);
					}
					pftime =  setInterval('yd()',40); //启动图片移动
					obj.style.display='';
					if(_len==2){
						qieh();
					}
			   }
			
			}
		}
	}
	new rewinjson.rewinAjax("/jxjj/index/ad.jsp",
		new rewinjson.tool.parameter('style','type=101','',''),
		rewinjson.client.StyleTextPF,
		"GET",
		"rewinjson_ad_pf"
		);
	//漂浮图片结束 
