document.write('<div id="slide" class="pics" style="position:absolute;"></div>');
document.write('<div id="loading" style="position:absolute;"><img src="js/loading.gif" /></div>');
$(function(){
	var rand = Math.floor(Math.random()*1000000);
	var today = new Date();
	var sYear   = today.getFullYear(); 
	var sMonth  = today.getMonth() + 1;
	var sDate   = today.getDate();
	var sHour   = today.getHours();
	var sMinute = today.getMinutes();
	var sSecond = "00";
	if (sMonth < 10) sMonth = "0" + sMonth;
	if (sDate < 10) sDate = "0" + sDate;
	if (sHour < 10) sHour = "0" + sHour;
	if (sMinute < 10) sMinute = "0" + sMinute;
//	if (sSecond < 10) sSecond = "0" + sSecond;
	var date_now = sYear + sMonth + sDate + sHour + sMinute + sSecond;

	$.ajax({
		url:'js/xmlslidesdata.php',
		dataType: 'xml',
		cache :false,
		success : function(data){
			$("image",data).each(function(){

				date_from = $("start_time",this).text();
				date_to   = $("limit_time",this).text();

				if(date_now - date_from > 0 && date_to - date_now > 0){
					if($("msg",this).text() == "none" || $("msg",this).text() == null || $("msg",this).text() == ""){
						$("#slide").append("<a href='" + $("url",this).text() + "' target='" + $("target",this).text() +"'><img src='"+ $("src",this).text() +"' /></a>");
					}else{
						$("#slide").append("<a href='" + $("url",this).text() + "' target='" + $("target",this).text() +"'><img src='"+ $("src",this).text() +"' /><div id='slidemsg' class='clsslidemsg'>" + $("msg",this).text() + "</div></a>");
					}
				}
			})
			$('#loading').fadeOut(1000);
			$('#slide').cycle({
				fx:'scrollDown',
				speed:    1000, 
				timeout:  6000, 
				random:0,
				before:onBefore, 
				after:onAfter 
			});
			function onBefore() { 
			    $('#slidemsg').css("display","none"); 
			}                        
			function onAfter() { 
			    $('#slidemsg').css("display",""); 
			} 
		}
	})
})

