/* fulltext query */
var fulltextQuery = '';
function fillFulltextQuery() {
	if (fulltextQuery!='') {
		document.forms[0].query.value=fulltextQuery;
	}
	 return false;
}

var sExpr = "";
function exprFocused(dom) {
	if ( dom.value == "Search") {
		sExpr = dom.value;
		dom.value = "";
	}
}
function exprBlured(dom) {
	if ( dom.value == "" ) dom.value = sExpr;
}

/* Function to write current date */
function writeCurrentDate() {
	document.write(formatDate(new Date(),"E M/d/y"));
}

// format numbers
function addCommas(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function writeQuotes() {
	//document.write("NASDAQ: <span>Last:</span> $58.69 <span>Time: 12:17 &nbsp;|&nbsp;</span> <a href=\"#\">See more</a>");
}

function InsertFlash(src,width,height) { 
	document.writeln("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + width + "\" height=\"" + height + "\">");
	document.writeln("<param name=\"movie\" value=\"" + src + "\" />");
	document.writeln("<param name=\"quality\" value=\"high\" />");
	document.writeln("<param name=\"wmode\" value=\"transparent\" />");
	document.writeln("<embed src=\"" + src + "\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\"></embed></object>");
	}

function tvstations_out(element){
  if(element)element.className = "static";
}
function tvstations_over(element){
  if(element)element.className = "active";
}
function head_on(id_thead){
  if(document.getElementById && id_thead){
  var thead = document.getElementById(id_thead);
  thead.className = 'head_dinamic-a';

  }
}
function head_off(id_thead){
  if(document.getElementById && id_thead){
  var thead = document.getElementById(id_thead);
  thead.className = 'head_dinamic';
  }
}

function getCenterW(width) {
	return parseInt( eval( (screen.width-parseInt(width))/2 ) );
}

function getCenterH(height) {
	return parseInt( eval( (screen.height-parseInt(height))/2 ) );
}
function openWin( name, path, width, height, scroll ) {
		if (!scroll || scroll != 'yes') { scroll = 'no' };
		var _win = window.open(path,name,'scrollbars=' + scroll + ',resizable=no,resize=no,width='+width+',height='+height+',screenX='+getCenterW(width)+',screenY='+getCenterH(height)+',top='+getCenterH(height)+',left='+getCenterW(width)+',locationbar=no,directories=no,dependent=yes' );
		if (_win)	_win.focus();
		return false;
}


var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

/*var aRow = 1;
var bRow = 2;
var cRow = 3;
var logoCycle;
function logoCycleStop() {
	clearInterval(logoCycle);
}

function logoCycleStart() {
	logoCycle=setInterval('logoRow()', 5000);
}
function logoRow(id) {
	clearInterval(logoCycle);
	if (!id) {
		id = aRow;
	}
	aRowE = document.getElementById('row'+aRow);
	bRowE = document.getElementById('row'+bRow);
	cRowE = document.getElementById('row'+cRow);
	aRowE.style.display = 'block';
	bRowE.style.display = 'none';
	cRowE.style.display = 'none';
	aRow = bRow;
	bRow = cRow;
	cRow = id;
	logoCycle=setInterval('logoRow()', 5000);
} 
logoCycleStart(); */

/* rotovani log */
var actualRow = 1;
var actualInt = null; // set to prevent multiple timers from start
var intervalRuns = false; // set to prevent multiple timers from start
var intervalDuration = 6500; // [ms]

function logoRowSwitch() {
	logoAutoSwitchStop();
	if (actualRow != 3) { actualRow = actualRow + 1; } else { actualRow = 1; }
	var parentId = "row" + actualRow;

	$("#tvstations ul").addClass("hidden");
	$("#tvstations #" + parentId).removeClass("hidden");

	logoAutoSwitchStart();
}

function logoAutoSwitchStart() {
	if (intervalRuns) {
		return;
	} else {
		actualInt = window.setInterval("logoRowSwitch();", intervalDuration);
		intervalRuns = true;
	}
}
function logoAutoSwitchStop() {
	if (intervalRuns) {
		window.clearInterval(actualInt);
		actualInt = null;
		intervalRuns = false;
	} else {
		return;
	}
}

/* jQuery area */
$(document).ready(function() {
	logoAutoSwitchStart();

	$("#tvstations .switch").click(function(){ return logoRowSwitch(); });
	$("#tvstations ul li").bind("mouseenter",function(){
		logoAutoSwitchStop();
		$(this).addClass('active');
	}).bind("mouseleave", function(){
 		logoAutoSwitchStart();
		$(this).removeClass('active');
	});

// propagate the link to a TV station website
	$("#tvstations ul li div").each(function(){
	  var link = "window.open('"+$("span.www", $(this) ).text()+"','_blank');";
	  $("span:not('.detail')", $(this) ).bind("click", function() {
			eval(link);
		});
	});
});
/* /jQuery area */

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
