function cleanMenu(bt){
	if(bt)
	$$(bt).each(function(bt){bt.className='btna_b';$(bt.id+'_div').style.display = "none";});
}

function nav_pwd() {
	var pwd = window.location.href;
	var r1  = /http\:\/\/shoes.mop.com\/{0,1}$/;
	var r2  = /http\:\/\/shoes.mop.com\/shoes/;
	var r3  = /ishoes\/topic/;
	var r5  = /ishoes\/website/;
	var r6  = /ishoes\/magazine/;
	if (pwd.match(r1)) {
		$('nav_1').removeClassName('btn_b').addClassName('btn_a');
		return false;
	};
	if (pwd.match(r2)) {
		$('nav_2').removeClassName('btn_b').addClassName('btn_a');
		return false;
	};
	if (pwd.match(r3)) {
		$('nav_3').removeClassName('btn_b').addClassName('btn_a');
		return false;
	};
	if (pwd.match(r6)) {
		$('nav_6').removeClassName('btn_b').addClassName('btn_a');
		return false;
	};
	if (pwd.match(r5)) {
		$('nav_5').removeClassName('btn_b').addClassName('btn_a');
		return false;
	};
}

////// SDGlobal.js

// JScript File

var g_numSeed = 1;
var g_strSeed = "topic";

function SD_GetRandomStr()
{
    var name = g_strSeed;
    name += g_numSeed;

    g_numSeed++;
    return name;
}

function SDImageScroll(hostT, width, height, list)
{
    this.speed = 200;
    this.width = width;
    this.height = height;
    this.szDiv0 = SD_GetRandomStr();
    this.szDiv1 = SD_GetRandomStr();
    this.szDiv2 = SD_GetRandomStr();
    var pNode = $(hostT);
		var divT = $('topic1');
    var div_tpl = new Template('<div><div class="blank8"></div><p><a href="#{url}" target="_blank"><img src="#{img}" border="0"></a></p><div class="jz textleft" style="padding: 3px 3px 3px 10px;background: rgb(0, 0, 0) none repeat scroll 0%;width: 227px;"><img src="/images/in_22.gif" align="absmiddle"> <a href="#{url}" target="_blank" class="cgreen fb">#{title}</a></div><p><img src="/images/in_21.gif"></p></div>');

    var div1 = document.createElement("div");
    div1.id = this.szDiv1;

    for(p=0; p<list.length; p++)
    {
      var div_p = div_tpl.evaluate(list[p]);
      div1.innerHTML += div_p; 
    }   

    var div2 = document.createElement("div");
    div2.id = this.szDiv2;   
    divT.appendChild( div1 );
    divT.appendChild( div2 );
    div2.innerHTML = div1.innerHTML;
    divT.scrollTop = divT.scrollHeight;
};


SDImageScroll.prototype.start = function( speed )
{
    this.speed = speed;
    var div = $( this.szDiv0 );
    var div1 = $( this.szDiv1 );   
    var div2 = $( this.szDiv2 ); 

    var me = this;

    this.MarqueeT = function(){
        var div = $( me.szDiv0 );
        var div1 = $( me.szDiv1 );   
        var div2 = $( me.szDiv2 );   

        if(div1.offsetTop - div.scrollTop >= 0)
            div.scrollTop += div2.offsetHeight;
        else
            div.scrollTop--;
    }

    div.onmouseover = function() {
        clearInterval(me.MyMar);
    }
    div.onmouseout = function() {
        me.MyMar = setInterval(me.MarqueeT,me.speed);
    }

    this.MyMar = setInterval( this.MarqueeT, this.speed);    
}

function autoScroll() {
  var imgscr = new SDImageScroll("topics_list", "280px", "600px", topics_list);   
  imgscr.start(100);
}

window.onload = function() {
	nav_pwd();
	if ($("topics_list" && typeof(topics_list) != "undefined")) {
		autoScroll();
	}
}

var FastInit = {
	onload : function() {
		if (FastInit.done) { return; }
		FastInit.done = true;
		for(var x = 0, al = FastInit.f.length; x < al; x++) {
			FastInit.f[x]();
		}
	},
	addOnLoad : function() {
		var a = arguments;
		for(var x = 0, al = a.length; x < al; x++) {
			if(typeof a[x] === 'function') {
				if (FastInit.done ) {
					a[x]();
				} else {
					FastInit.f.push(a[x]);
				}
			}
		}
	},
	listen : function() {
		if (/WebKit|khtml/i.test(navigator.userAgent)) {
			FastInit.timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					clearInterval(FastInit.timer);
					delete FastInit.timer;
					FastInit.onload();
				}}, 10);
		} else if (document.addEventListener) {
			document.addEventListener('DOMContentLoaded', FastInit.onload, false);
		} else if(!FastInit.iew32) {
			if(window.addEventListener) {
				window.addEventListener('load', FastInit.onload, false);
			} else if (window.attachEvent) {
				return window.attachEvent('onload', FastInit.onload);
			}
		}
	},
	f:[],done:false,timer:null,iew32:false
};
/*@cc_on @*/
/*@if (@_win32)
FastInit.iew32 = true;
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
$('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
/*@end @*/
FastInit.listen();
function setCookie(cookieName,cookieValue,nDays) {
	 var today = new Date();
	 var expire = new Date();
	 if (nDays==null || nDays==0) nDays=1;
	 expire.setTime(today.getTime() + 3600000*24*nDays);
	 document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();
}
function readCookie(cookieName) {
	 var theCookie=""+document.cookie;
	 var ind=theCookie.indexOf(cookieName);
	 if (ind==-1 || cookieName=="") return ""; 
	 var ind1=theCookie.indexOf(';',ind);
	 if (ind1==-1) ind1=theCookie.length; 
	 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

(function(){
	var _init = function() {
		// var text = document.createTextNode("Page loaded!");
		// var message = $("bottom");
		// message.appendChild(text);
		if (readCookie('poped') == 1)
return;
		var nowDate = new Date();
		var nowTime =nowDate.getHours()*3600 + nowDate.getMinutes()*60 + nowDate.getSeconds();
		var DAY = 24*3600;
		var leaveTime = DAY - nowTime;
		setCookie('poped',1,0.1);
		var popuped = false;
		var popAd = function() {
		   if (popuped) return;
		   popuped = true;
		   var purl='http://m.mop.com/';
		   var w=1020;
		   var h=500;
		   var adPopup = window.open('about:blank', '_blank','toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes,width='+w+',height='+h+', ...');
		   adPopup.blur();
		   adPopup.opener.focus();
		   adPopup.location = purl;
		   // $E.removeListener(document.body, 'click', arguments.callee);
					 Event.stopObserving(document.body, 'click', arguments.callee);
		   return adPopup;
		}
		try {
		    popAd();
		} catch (e) {
		    popuped = false;
    Event.observe(document.body, 'click', function() {
				  popAd();
			});
		}
	}
	// Event.observe(window, 'load', function() {
	//   _init();
	// });
	FastInit.addOnLoad(_init);
})();
