var ObjArray = new Array();
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/CHGnkrhV8rpV.jpg";
Atitle		=	"";
Alink		=	"";
ObjArray[0]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/A66gO2Da6GVY.jpg";
Atitle		=	"";
Alink		=	"";
ObjArray[1]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/5wU7bgpNltFT.jpg";
Atitle		=	"";
Alink		=	"http://www.chalegraal.com.ua/ru/news/?article=132";
ObjArray[2]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/SjJjxmo6q8VN.jpg";
Atitle		=	"";
Alink		=	"http://www.chalegraal.com.ua/ru/news/?article=132";
ObjArray[3]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/vrB6FKQ9x60S.jpg";
Atitle		=	"";
Alink		=	"http://www.chalegraal.com.ua/ru/news/?article=132";
ObjArray[4]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/3d8kim4XdCNF.jpg";
Atitle		=	"";
Alink		=	"http://www.chalegraal.com.ua/ru/news/?article=132";
ObjArray[5]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/Sv02wyuIFNxG.jpg";
Atitle		=	"";
Alink		=	"/";
ObjArray[6]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/aqhoAjTwj0AX.jpg";
Atitle		=	"";
Alink		=	"/";
ObjArray[7]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/8eH1xju8Ut6W.jpg";
Atitle		=	"";
Alink		=	"";
ObjArray[8]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/oRaX58A8xux6.jpg";
Atitle		=	"";
Alink		=	"/";
ObjArray[9]		=	new Array(Aimg, Atitle, Alink);
Aimg		=	new Image(622,261);
Aimg.src	=	"/im/ads/HqTzDmMOBu2E.jpg";
Atitle		=	"";
Alink		=	"";
ObjArray[10]		=	new Array(Aimg, Atitle, Alink);
/* 
	
	js movie 
	single language version
	zmolo.com


*/

var ad			=0;
var adopacity	=0;
var ind			=1;
var frame_num	=0;
var imageID		='adImg';
var pagerID		='adpager';
var adstep		=10;
var adduration	=40;
var adstilltime	=3000;
var condition	='';
var stopMovie	=0;


function runAds(anchorID,pagerID){
	var aObj = 	document.getElementById(anchorID);
	aObj.innerHTML = "<img src='' id="+imageID+">";


	if (ObjArray.length == 1) {
		  transAd(anchorID, pagerID, ObjArray[0][0], ObjArray[0][1], ObjArray[0][2], 1);
	} else {
		var imgObj		=	document.getElementById(imageID);
		var pagerObj	=	document.getElementById(pagerID);
		pagerObj.innerHTML = buildPages(ObjArray.length);

		window.frameRunner= function() {runSlide(anchorID,pagerID,ObjArray,imgObj,aObj);}
		runSlide(anchorID,pagerID,ObjArray,imgObj,aObj);
	}
	
}


function transAd (aID, pID, Img, Txt, Lnk, direction){

	var aObj = 		document.getElementById(aID);
	var imgObj =	document.getElementById(imageID);
	window.addRunner= function() {changeOpacity(imgObj,direction);}
	if (!direction)
	{  
		imgObj.className = 'opaque';
		adopacity=100;
		if (eval(isdefined("downAd")))
		{
			clearTimeout(downAd);
		}
	} else {
		adopacity=0;
		imgObj.className = 'transparent';
		if (eval(isdefined("upAd")))
		{
			clearTimeout(upAd);
		}
	}

	imgObj.src	= Img.src;
	changeOpacity	(imgObj,direction);
	changeAnchor	(aObj,Txt,Lnk)
}



function changeOpacity (OP,direction){
	if (direction)
	{	
		if (adopacity < 100)
		{
			if (OP.filters)
			{ 
				OP.filters[0].opacity= adopacity+adstep;
			} else {
				OP.style.opacity =  (adopacity+adstep)/100;
				OP.style.MozOpacity =  (adopacity+adstep)/100;
			}
			adopacity+=adstep;
			downAd=setTimeout("addRunner()",adduration);
		} else {
			clearTimeout(downAd);
		}
			/*window.alert(adopacity); */
	} else {
		if (adopacity > 0)
		{
			if (OP.filters)
			{ 
				OP.filters[0].opacity= adopacity-adstep;
			} else {
				OP.style.opacity =  (adopacity-adstep)/100;
				OP.style.MozOpacity =  (adopacity-adstep)/100;
			}
			adopacity-=adstep;
			upAd=setTimeout("addRunner()",adduration);
		}   else {
			clearTimeout(upAd);
		}
	}
}



function changeAnchor(aObj,title,link){

	aObj.href	=		link;
	aObj.title	=		title;
	
}


function runSlide(aID, pID, wholeMovie, imgObj, aObj){
	adopacity=0;
	condition = 'fadeup';	
	if (frame_num>=wholeMovie.length) frame_num=0;
	changeAnchor(aObj,wholeMovie[frame_num][1],wholeMovie[frame_num][2]);
	changePagerState(frame_num,pagerID,wholeMovie.length);
	
	imgObj.className = 'transparent';
	imgObj.src = wholeMovie[frame_num][0].src; 

	window.frm= function() {runFrame(imgObj);}
	runFrame(imgObj);
}


function runFrame(OP){
	if (condition == 'fadeup'){
		if (adopacity < 100)
		{
			if (OP.filters)
			{ 
				OP.filters[0].opacity= adopacity+adstep;
			} else {
				OP.style.opacity =  (adopacity+adstep)/100;
				OP.style.MozOpacity =  (adopacity+adstep)/100;
			}
			adopacity+=adstep;
			
		} else {
			condition = 'still';
		}	
		frameTimer=setTimeout("frm()",adduration); 
		

	} else if (condition == 'still') {
		clearTimeout(frameTimer);
		condition = 'fadedown';
		if (!stopMovie) {
			condition = 'fadedown';
			frameTimer=setTimeout("frm()",adstilltime);
		}
	} else if (condition == 'fadedown') {
		if (adopacity > 0)
		{
			if (OP.filters)
			{ 
				OP.filters[0].opacity= adopacity-adstep;
			} else {
				OP.style.opacity =  (adopacity-adstep)/100;
				OP.style.MozOpacity =  (adopacity-adstep)/100;
			}
			adopacity-=adstep;
		}   else {
			condition = 'no';
		}

		frameTimer=setTimeout("frm()",adduration);

	} else if (condition == 'no'){
		clearTimeout(frameTimer);
		frame_num++;
		frameRunner();
	}

}



function changePagerState(frame_number,pagerid,qty){
	var class_a='pinact'
	for (var i=0; i<qty; i++){
		pageObj = document.getElementById(pagerid+"_"+i);
		class_a=(frame_number == i) ? 'pact' : 'pinact';
		pageObj.className = class_a;
		
	}
}

function buildPages(qty){
	var buff='';
	for (var i=0; i<qty; i++){
		buff+='<a href="" onClick="return jumpToFrame('+i+')" id="'+pagerID+'_'+i+'">'+(i+1)+'</a>';
	}
	return buff;
}


function  jumpToFrame(frameNo){

	if (isdefined(frameTimer)){
		clearTimeout(frameTimer);
	}
	stopMovie=1;
	frame_num=frameNo;
	frameRunner();
	return false;
}