/* 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(),"EE MMM 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>");
}

// Flash Player features
function doPassVar(args){
	window.document.FLV_Player.SetVariable("flvPlay.co", args);
}
function InsertPlayer(src,width,height,args) { 
	document.writeln("<div style=\"margin-left: 200px;\"><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 + "?" + args +"\" />");
	document.writeln("<param name=\"quality\" value=\"high\" />");
	document.writeln("<param name=\"wmode\" value=\"transparent\" /><param name=\"swliveconnect\" value=\"true\">");
	document.writeln("<embed src=\"" + src + "?" + args + "\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\" swLiveConnect=\"true\"></embed></object></div>");
}


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';
  }
}



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}

// ------------------------------------------------------------------
// 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;
	}

/*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*/
function logoRowSwitch() {
	clearInterval(actualInterval);
	if (actualRow != 3) {
		actualRow = actualRow + 1;
	}
	else {
		actualRow = 1;
	}

	var parentId = "row" + actualRow;

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

	actualInterval = setInterval("logoRowSwitch()", 5000);
	return false;
}

function logoAutoSwitchStart() {
	actualInterval = setInterval("logoRowSwitch()", 5000);
}
function logoAutoSwitchStop() {
	clearInterval(actualInterval);
}

var actualRow = 1;
var actualInterval;
$(document).ready(function() {
	logoAutoSwitchStart();
	$("#tvstations .switch").click(function(){ return logoRowSwitch(); });
	$("#tvstations ul li.tvstation a").mouseover(function(){ tvstationsOver(this); logoAutoSwitchStop(); return false; });
	$("#tvstations ul li.tvstation a").mouseout(function(){ tvstationsOut(this); logoAutoSwitchStart(); return false; });
});

function tvstationsOut(element){
  if(element)element.className = "static";
}
function tvstationsOver(element){
  if(element)element.className = "active";
}

function newWin (link,width,height) {
	window.open(link, "nove","width="+width+",height="+height+",menubar=yes,resizable=yes,left=150,top=150");
}

function obj(id) {
	return document.getElementById(id);
}
function showCalendar(item_id) {
	var
	    oItem, oLink;

	for (i=1;i<=10;i++) {
	    oItem = obj('investor'+i);
	    if (oItem != null) { oItem.className = 'first hidden'; }
	    oLink = obj('l_investor'+i);
	    if (oLink != null) { oLink.className = 'active'; }
	}
	obj('investor'+item_id).className = 'first';
	obj('l_investor'+item_id).className = 'hidden';
}


function investor_calendar_show_item(item) {
	investor_calendar_hide_all_items();

	document.getElementById(item + "-label").className = "active";
	document.getElementById(item).style.display = "block";
}

function investor_calendar_hide_items_start() {
	investor_calendar_hide_all_items();
	if(document.getElementById("notify-on-update-label")) {
		document.getElementById("notify-on-update-label").className = "active";
		document.getElementById("notify-on-update").style.display = "block";
	}
	else if(document.getElementById("save-to-outlook-label")) {
		document.getElementById("save-to-outlook-label").className = "active";
		document.getElementById("save-to-outlook").style.display = "block";
	}
	else if(document.getElementById("send-to-friend-label")) {
		document.getElementById("send-to-friend-label").className = "active";
		document.getElementById("send-to-friend").style.display = "block";
	}
}

function investor_calendar_hide_all_items() {
	if(document.getElementById("notify-on-update-label")) {
		document.getElementById("notify-on-update-label").className = "";
		document.getElementById("notify-on-update").style.display = "none";
	}
	if(document.getElementById("save-to-outlook-label")) {
		document.getElementById("save-to-outlook-label").className = "";
		document.getElementById("save-to-outlook").style.display = "none";
	}
	if(document.getElementById("send-to-friend-label")) {
		document.getElementById("send-to-friend-label").className = "";
		document.getElementById("send-to-friend").style.display = "none";
	}
}

function check_email(adresa){
	re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
	return adresa.search(re) == 0;
}

function check_form_investor_calendar_notify_on_update(formular){
	if (formular.name.value==""){
		alert("First Name field is required!");
		formular.name.focus();
		return false;
	}
	else if (formular.lastname.value==""){
		alert("Last Name field is required!");
		formular.lastname.focus();
		return false;
	}
	else if (formular.company.value==""){
		alert("Company  field is required!");
		formular.company.focus();
		return false;
	}
	else if (formular.email.value==""){
		alert("E-mail field is required!");
		formular.email.focus();
		return false;
	}
	else if (!check_email(formular.email.value)){
		alert("The e-mail address is not valid!");
		formular.email.focus();
		return false;
	}
	else if (formular.phone.value==""){
		alert("Phone field is required!");
		formular.phone.focus();
		return false;
	}
	else if (formular.fax.value==""){
		alert("Fax field is required!");
		formular.fax.focus();
		return false;
	}
	else 
		return true;
}


function check_form_investor_calendar_save_to_outlook(formular){
	if (formular.outlook_email.value==""){
		alert("E-mail field is required!");
		formular.outlook_email.focus();
		return false;
	}
	else if (!check_email(formular.outlook_email.value)){
		alert("The e-mail address is not valid!");
		formular.outlook_email.focus();
		return false;
	}
	else 
		return true;
}


function check_form_investor_calendar_send_to_friend(formular){
	if (formular.friend_name.value==""){
		alert("Name field is required!");
		formular.friend_name.focus();
		return false;
	}
	else if (formular.friend_email.value==""){
		alert("E-mail field is required!");
		formular.friend_email.focus();
		return false;
	}
	else if (!check_email(formular.friend_email.value)){
		alert("The e-mail address is not valid!");
		formular.friend_email.focus();
		return false;
	}
	else if (formular.friend_text.value==""){
		alert("Text field is required!");
		formular.friend_text.focus();
		return false;
	}
	else 
		return true;
}
