$(function(){ var xpos = 300; var ypos = 200; var step = 1; var delay = 30; var height = 0; var hoffset = 0; var woffset = 0; var yon = 0; var xon = 0; var pause = true; var interval; if($("#fl_img").html() == ""){ $("#img1").hide(); } $("#img1").css("visibility","visible"); // img1.visibility = "visible"; interval = setinterval(function(){ //$("#img1").css("top",ypos); width=$(window).width(); height=$(window).height(); hoffset=$("#img1").height(); woffset=$("#img1").width(); //alert(""+$(window).scrollleft()+""); $("#img1").css("left",xpos + $(window).scrollleft()); //alert(""+xpos+""); $("#img1").css("top",ypos + $(window).scrolltop()); if (yon) {ypos = ypos + step;} else {ypos = ypos - step;} if (ypos < 0) {yon = 1;ypos = 0;} if (ypos >= (height - hoffset)) {yon = 0;ypos = (height - hoffset);} if (xon) {xpos = xpos + step;} else {xpos = xpos - step;} if (xpos < 0) {xon = 1;xpos = 0;} if (xpos >= (width - woffset)) {xon = 0;xpos = (width - woffset); } }, delay); // alert(""+hoffset+""); $("#img1").hover(function(){ cleartimeout(interval); },function(){ interval=setinterval(function(){ //$("#img1").css("top",ypos); width=$(window).width(); height=$(window).height(); hoffset=$("#img1").height(); woffset=$("#img1").width(); //alert(""+$(window).scrollleft()+""); $("#img1").css("left",xpos + $(window).scrollleft()); //alert(""+xpos+""); $("#img1").css("top",ypos + $(window).scrolltop()); if (yon) {ypos = ypos + step;} else {ypos = ypos - step;} if (ypos < 0) {yon = 1;ypos = 0;} if (ypos >= (height - hoffset)) {yon = 0;ypos = (height - hoffset);} if (xon) {xpos = xpos + step;} else {xpos = xpos - step;} if (xpos < 0) {xon = 1;xpos = 0;} if (xpos >= (width - woffset)) {xon = 0;xpos = (width - woffset); } }, delay); }); $("#closefloat").click(function(){ $("#img1").empty(); $("#img1").hide(); }) });