// JavaScript Document
function addAd(ads){  
            function bindActive(obj){  
                var ad = document.createElement('DIV');  
                var content = document.createElement('IMG');  
//                var close = document.createElement('IMG');  
                ad.style.position = "absolute";  
                ad.style.top = obj['顶部距离'];  
                obj['左右'] == '左' ? ad.style.left = obj['边距'] || '15px' : ad.style.right = obj['边距'] || '15px'  
                content.src = obj['图片地址'];  
//                close.style.marginLeft = '-15px';  
//                close.src = 'images/divColse.gif';  
                ad.appendChild(content);  
//                ad.appendChild(close);  
                document.body.appendChild(ad);  
                content.onclick = function(){  
                    window.open(obj['链接地址'])  
                }  
//                close.onclick = function(){  
//                    document.body.removeChild(ad);  
//                }  
                var lastScrollY = 0;  
                var diffY, percent;  
                window.setInterval(function(){  
                    if (document.documentElement && document.documentElement.scrollTop) {  
                        diffY = document.documentElement.scrollTop;  
                    }  
                    else {  
                        diffY = document.body.scrollTop;  
                    }  
                    percent = 0.1 * (diffY - lastScrollY);  
                    if (percent > 0) {  
                        percent = Math.ceil(percent);  
                    }  
                    else {  
                        percent = Math.floor(percent);  
                    }  
                    ad.style.top = parseInt(ad.style.top) + percent + "px";  
                    lastScrollY = lastScrollY + percent;  
                }, 10);  
            }  
            for (i in ads) {  
                bindActive(ads[i])  
            }  
  }  
  window.onload=function(){  
         addAd([{  
            '图片地址':'/wp-content/themes/lse/images/ad.jpg',  
            '链接地址':'http://www.wyhotel.com.cn/index.php/2010/04/02/5th/',  
            '顶部距离':'80px',  
            '左右':'左'  
           },{  
                '图片地址':'/wp-content/themes/lse/images/ad.jpg',  
                '链接地址':'http://www.wyhotel.com.cn/index.php/2010/04/02/5th/',  
                '顶部距离':'80px',  
                '左右':'右'  
           }])  
  }  
