﻿var imgUrl  = new Array();
var imgLink = new Array();
var imgTxt  = new Array();

var adNum=0;
var dlen=4;

initData();

function initData(){
$.ajax({ url:'/xmlfiles/topv.xml?t='+Math.random(),type: 'GET', dataType: 'xml',timeout: 2012,error: function(xml){ return false; },
success: function(xml){

var id = $($(xml).find("topv")[2]).children("id").text();
var photo = $($(xml).find("topv")[2]).children("photo").text();
var title = $($(xml).find("topv")[2]).children("title").text();

document.images.entImg.src=photo;
document.images.entImg.alt=title;
$("span#entObj").html(title);

var i,j; i=0;j=1;

$(xml).find("topv").each(function(){
if(i>=2){
imgUrl[j] = $(this).children("photo").text();
imgLink[j] = "/video-"+$(this).children("id").text()+".aspx";
imgTxt[j] = $(this).children("title").text();
j++;
}
i++;
});
}
});

nextAd();
}

function playTran(){
		if (document.all)
		{
		    $("#entImg").css({"filter":"progid:DXImageTransform.Microsoft.RevealTrans(enabled=ture,transition="+Math.round(Math.random() * 23) +");"});
			document.images.entImg.filters[0].Apply();
			document.images.entImg.filters[0].Play(duration=1);
		}		
	}
	
var theTimer;
function nextAd(){

		if(adNum < dlen) adNum++ ;
		else adNum=1;
		playTran();	
		document.images.entImg.src=imgUrl[adNum];
		document.images.entImg.alt=imgTxt[adNum];

		$("span#entObj").html(imgTxt[adNum]);
		theTimer = setTimeout("nextAd()", 5000);
	}
	
function goUrl(){
		jumpUrl=imgLink[adNum];
		jumpTarget='_blank';
		if (jumpUrl != ''){
			if (jumpTarget != '') 
			window.open(jumpUrl,jumpTarget);
			else
				location.href=jumpUrl;
	}
	}


   
  
