

function setOnAir() {



//var ustamp = Math.round(new Date().getTime()/1000.0);
var ustamp = document.getElementById('CurrentTimeOfServer').value;


var inputs = document.getElementsByTagName( 'input' );



for(var i=0;i<inputs.length;i++){



  if(inputs[i].id.indexOf('tc') != -1 ){



  	id = inputs[i].id.replace("tc","");



  	cell_val = inputs[i].value.split(';;');



  	t_val = cell_val[2].split(':');



  	hhmm = parseInt(t_val[0]);



  	len = parseInt(t_val[1]);



	    if( (hhmm<= ustamp && (hhmm +  len) > ustamp)    )



	    {



			_c(id,'onair',1);

			



	    }



	    if( (hhmm +  len) < ustamp)    



	    {



			inputs[i].parentNode.parentNode.childNodes[1].style.color='#999';



			inputs[i].parentNode.style.color='#999';



			titlea = document.getElementById("u"+id);



			if (titlea) titlea.style.color='#999';



				



	    }



    }



  }



}











function _c(id,mode,on)







{

	

	p_off();//hide popups

	var color = '#d3e6ff'; //default color



	if (mode=='onair') color  = '#fcfcdc';



	var div = document.getElementById("c"+id);  

	var divstyle = div.style;  

	var cell = document.getElementById("tc"+id);

	var loaded = 0;

	var eimg = new Image();

	var divel = document.createElement("DIV");

	

	if (document.getElementById("n"+id) == null)

	{

		function texts() {

			var cell = document.getElementById("tc"+id);

			cell_val = cell.value.split(';;');

			var nc = document.getElementById("c"+id).firstChild;

			//var nc=document.getElementById("t"+id);

			if (eimg.src) nc.appendChild(eimg);



			nc.appendChild(divel);

			

			nc.appendChild(document.createElement("br"));



			var title = ""; 

			titlea = document.getElementById("u"+id);

			

			if (titlea) title = titlea.innerHTML;

			

			nc.appendChild(document.createTextNode(cell_val[1]?cell_val[1]:"" ));

			nc.appendChild(document.createElement("br"));

			nc.appendChild(document.createElement("br"));

			eimg.id = "eimg"+id;

			divel.id = "n"+id;

			loaded=1;

		}

		cell_val = cell.value.split(';;');

		//alert(cell_val[0]);

		if (cell_val[0]!='0.gif')

		{

			eimg.onload = function() {

			//	texts();

			};

			eimg.onabort = function() {

				//texts();

			};

			// alert("loading image");



			eimg.src = "http://static.kava.ee/i/?"+cell_val[0]+"";

			texts();

			//eimg.src = "{/literal}{$_CONFIG.programmimages}{literal}/"+cell_val[0]+"?x";

		}

		

		



		if (mode=='onair')

		{

			cell.parentNode.parentNode.childNodes[1].style.color='#000';

			cell.parentNode.parentNode.childNodes[1].style.fontWeight ='bold';

		}	

		cell.parentNode.style.fontWeight ='bold';

	    cell.parentNode.parentNode.style.backgroundColor=color;

	    divstyle.backgroundColor=color;



		if (!eimg.src) texts();

    }



    if (on)

    	divstyle.display= 'block';

    else

    	divstyle.display= (divstyle.display=='block'?'none':'block');



}







































function on(id)







{





	if (document.getElementById("c"+id).style.display=='block') return; //hide popup on expanded view	







	var cell = document.getElementById("tc"+id);







	cell_val = cell.value.split(';;');







	text = cell_val[1]?cell_val[1]:"";







	title = document.getElementById("u"+id).innerHTML;







	document.getElementById("u"+id).onmouseout=p_off;







    return p_on(title,text);







}









function ts(urls)

{



// load the image in this temporay object



var cell = document.getElementById("testdiv");

var tempImage = new Image();



tempImage.onload = function () {

	cell.appendChild(tempImage);	

	cell.style.display='block';

}



tempImage.src = urls+"?s";



	//tempImage.onload=function setImage() {document.getElementById("concimage").src = tempImage.src;}

	// set the source of the tempImage - the onload-function does the rest.







}	







