<!--te
// File name: channel.js
// Created: 2002.05.21. by Zoltan Kovacs .: Werdy :.
// Last modification: 2002.06.06. by Zoltan Kovacs .: Werdy :.


//adas object definition
function adas (main_title) {
	this.main_title = main_title;
	this.felvetel = new Array();
}

//felvetel object definition
function felvetel(title,url,content) {
	this.title = title;
	this.url = url;
	this.content = content;
	this.pictures = new Array();
}

//search object definition
function search() {
	this.found = 0;
	this.adas = "";
	this.felvetel = "";
}

//channel object definition
function channel(objname) {
	this.objname = objname;
	this.adas = new Array();
	this.add_adas = add_adas;
	this.add_felvetel = add_felvetel;
	this.add_pictures = add_pictures;
	this.list_adasok = list_adasok;
	this.list_felvetelek = list_felvetelek;
	this.show_content = show_content;
	this.searcher = searcher;
	this.search_result = new search();
}


function add_adas(main_title) {
	this.adas.push(new adas(main_title));
}


function add_felvetel(main_title,title,url,content) {
	this.searcher(main_title);
	if ( this.search_result.found ) {
		this.adas[this.search_result.adas].felvetel.push(new felvetel(title,url,content));
	} else { alert ('HIBA az adatfelvitel közben:\ncím: '+main_title+'\nfelvétel: '+title+'\nNincs ilyen felvétel az adatbázisban.'); }
}


function add_pictures(main_title,title) {
	this.searcher(main_title,title);
	if ( this.search_result.found ) {
		for ( var t = 2; t < arguments.length; t++ ) {
			this.adas[this.search_result.adas].felvetel[this.search_result.felvetel].pictures.push(arguments[t]);
		}
	} else { alert ('HIBA az adatfelvitel közben:\ncím: '+main_title+'\nfelvétel: '+title+'\nNincs ilyen felvétel az adatbázisban.'); }
}


function list_adasok() {
	for ( var t in this.adas ) {
		document.write (' \
<TABLE border=0 cellpadding=4 cellspacing=0 width=500> \
	<TR> \
		<TD class="bgdheadtext" colspan=8 align=center>'+this.adas[t].main_title+'</TD> \
	</TR>');
		this.list_felvetelek(this.adas[t].main_title);
		document.write (' \
</TABLE> \
<BR> \
		');
	}
}

function list_felvetelek(main_title) {
	this.searcher(main_title);
	if ( this.search_result.found ) {
		var html = "";
		for ( var t in this.adas[this.search_result.adas].felvetel ) {
			html += ' \
	<TR> \
		<TD class="bgdtext" width=300>'+this.adas[this.search_result.adas].felvetel[t].title+'</TD> \
		<TD class="bgdtext" width=20>';
			if ( !this.adas[this.search_result.adas].felvetel[t].url ) { html += '<A href="#" onClick=\'alert("Feltöltés alatt!"); return false;\' '; }
			else { html += '<A href="'+this.adas[this.search_result.adas].felvetel[t].url+'"'; }
			html += '><IMG src="images/www/channels/play.gif" border=0 width=18 height=19 alt="Lejátszás"></A></TD> \
		<TD class="bgdtext" width=20><A href="#" onClick=\''+this.objname+'.show_content("'+this.adas[this.search_result.adas].main_title+'","'+this.adas[this.search_result.adas].felvetel[t].title+'"); return false;\'><IMG src="images/www/channels/content.gif" border=0 width=21 height=21 alt="Tartalom"></A></TD> \
		<TD class="bgdtext" width=160 align=center>';
			if ( this.adas[this.search_result.adas].felvetel[t].pictures.length ) {
				var picnum = 0;
				html += 'Képek:<br>\n';
				for ( var t2 in this.adas[this.search_result.adas].felvetel[t].pictures ) {
					picnum++;
					html += '\t\t\t<A href="'+this.adas[this.search_result.adas].felvetel[t].pictures[t2]+'" target="_blank">&nbsp;[ '+picnum+' ]</A>\n';
					if ( t2%5 == 4 ) { html += '<BR>\n'; }
				}
			} else { html += '&nbsp'; }
			html += '\t\t</TD> \
	</TR>';
		}
		document.write (html);
	}
}


function show_content(main_title,title) {
	this.searcher (main_title,title);
	if ( this.search_result.found ) {
		popup (320,240,"",this.adas[this.search_result.adas].felvetel[this.search_result.felvetel].content);
	}
}

function searcher(main_title,title) {
	this.search_result.found = 0;
	this.search_result.adas = "";
	this.search_result.felvetel = "";
	var t = 0;
	while ( t < this.adas.length && !this.search_result.found ) {
		if ( this.adas[t].main_title == main_title ) {
			if ( title ) {
				var t2 = 0;
				while ( t2 < this.adas[t].felvetel.length && !this.search_result.found ) {
					if ( this.adas[t].felvetel[t2].title == title ) { 
						this.search_result.found = 1;
						this.search_result.adas = t; 
						this.search_result.felvetel = t2; 
					} 
					t2++; 
				}
			} else { 
				this.search_result.found = 1; 
				this.search_result.adas = t;
			}
		} 
		t++;
	}
}

//-->

