var weather, exchange_rate, CHL, text_ad, slider;
jQuery(document).ready(function() {
	var gotoTop = WaiWai.addGotoTopButton();
	if (jQuery('#nv_portal').hasClass('pg_index')) {
		jQuery('#text_ad_block').find('script').remove();
		jQuery('#slider_block').find('script').remove();
		jQuery('a').not('#headline .go_button a').not('.QQWorldSlider .pager-container li a').not('#gototop').not('#tools a').not('#toptb a').not('.ptm a').attr('target', '_blank');
		var calendar = new WaiWai.calendar;

		//首页272x90广告缩放效果
		/*function ww_getCookie(sName) {
			var aCookie = document.cookie.split("; ");
			for (var i=0; i < aCookie.length; i++) {
				var aCrumb = aCookie[i].split("=");
				if (sName == aCrumb[0]) return unescape(aCrumb[1]);
			}
			return null;
		}
		function ww_setCookie(sName, sValue, time) {
			date = new Date();
			date.setTime(date.getTime() + time);
			document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
		}
		function ww_ad_272x90_zoomOut() {
			jQuery('.ad_960x400').animate({
				width: '272px',
				height: '90px',
				padding: '0'
			}, 'normal').fadeOut('fast');
		}
		function ww_ad_272x90_zoomIn() {
			jQuery('.ad_960x400').fadeIn('fast').animate({
				width: '960px',
				height: '400px',
				padding: '20px'
			}, 'normal');
		}
		var ww_myDate = new Date();
		var ww_today = ww_myDate.getDate();
		if (ww_getCookie('ww_date') == null ||  ww_getCookie('ww_date') != ww_today) {
			ww_ad_272x90_zoomIn();
			setTimeout(ww_ad_272x90_zoomOut, 11500);
			ww_setCookie('ww_date', ww_today, ww_myDate.getTime() + 1000*60*60*24);
		}
		jQuery('.ad_272x90').mouseover(function() {
			if (jQuery('.ad_960x400').is(':hidden')) {
				ww_ad_272x90_zoomIn();
				setTimeout(ww_ad_272x90_zoomOut, 10750);
			}
		});*/
	}
	//读取天气的列表
	jQuery.getScript("w/js/data/waiwai.today.weather.js", function(){
		var html = "";
		for (var w=0; w<WaiWai.Today.WeatherInfo.length; w++) {
			var todayWeather = WaiWai.Today.WeatherInfo[w]
			html += '<li><div id="weather_icon" style="background: url(w/images/weather/'+ todayWeather.condition+'.png);"></div><strong>'+ todayWeather.id+'</strong> ' + todayWeather.low + '/' + todayWeather.high + '°C</li>';
		}
		jQuery('#weather .list ol').html(html);
		//天气幻灯
		weather = new WaiWai.fadeSlider;
		weather.objList = jQuery('#weather ol li');
		weather.objButton = {
			next: jQuery('#weather .arrow_up'),
			prev: jQuery('#weather .arrow_down')
		}
		weather.init();
	}); 
	//读取汇率的列表
	jQuery.getScript("w/js/data/waiwai.today.forex.js", function(){
		var html = "";
		for (var w=0; w<WaiWai.Today.ForexInfo.length; w++) {
			var todayForex = WaiWai.Today.ForexInfo[w]
			html += '<li><strong>'+ todayForex.id+'</strong> '+ todayForex.rate+'</span></li>';
		}
		jQuery('#exchange_rate .list ol').html(html);
		//汇率幻灯
		exchange_rate = new WaiWai.fadeSlider;
		exchange_rate.objList = jQuery('#exchange_rate ol li');
		exchange_rate.objButton = {
			next: jQuery('#exchange_rate .arrow_up'),
			prev: jQuery('#exchange_rate .arrow_down')
		}
		exchange_rate.init();
	});
	if (jQuery('#nv_portal').hasClass('pg_index')) {
		//头版幻灯
		CHL = jQuery('#headline_list').QQWorldSlider({
			speed: 500,
			num: 3,
			pager: false,
			controls: true,
			containerID: 'headline',
			easing: 'easeInOutExpo',
			autoStart: false
		});
		//文字头条幻灯
		/*text_ad = jQuery('#text_ad').QQWorldSlider({
			mode: 'vertical',
			easing: 'easeInOutExpo',
			speed: 1500,
			pager: false,
			controls: false
		});*/
		//幻灯片幻灯
		slider = jQuery('#slider').QQWorldSlider({
			easing: 'easeInOutExpo',
			speed: 500,
			pager: true,
			controls: false,
			mouseEvent: 'mouseover'
		});
	}
	//为上述5个幻灯计时运行
	new WaiWai.timer;
})
