function showTip(elem) {
        child=elem.childElements().first()
        //var link = document.createElement('a');
        //link.href=child.href
        //var txt=document.createTextNode("PLAY");
        //link.appendChild(txt)
        the_link=child.href
        the_length=the_link.length
        number=the_link.charAt(the_length-1)
        equal=the_link.charAt(the_length-2)
        if (equal!="=") {
           number=equal+number
        }
        play="<p/><center><a href=\""+the_link+"\" onclick=\"tx_bddbflvvideogallery_pi1xajaxNewVideo("+number+");return false;\"><img border=0 src='/fileadmin/img/button_play_small.gif'></a></center><p/>"
        tip=elem.down('div.tipcaption')
	return tip.innerHTML+play;
}

function setupVideoTooltips() {
	$$('div.flvplayer_listpic').each(function(elem){
		elem.observe('mouseover', function() {
			Tip(showTip(this),FONTSIZE,"12px",PADDING,1,DELAY,500,FONTCOLOR,'#000000',BGCOLOR,'#ffff33',BORDERWIDTH,1,WIDTH,0, OPACITY,89, FOLLOWMOUSE, 0, CLOSEBTN, 1, DURATION, 0, STICKY, 1, CLICKCLOSE, 1);
		});
	});
	if ($('player')) {$('player').childElements().first().focus();}
}


// function showRuleTip(elem) {
//         tip=elem.down('div.tipcaption')
// 	return tip.innerHTML;
// }

function setupGroundruletips() {
	$$('td.groundrulecell').each(function(elem){
		elem.observe('mouseover', function(evt) {
			var kode = this.readAttribute('id').substr(14); // groundrulecell
			if($('postit'+kode) != null && !$('postit'+kode).empty()) {
				TagToTip('postit'+kode,CLICKCLOSE,1,STICKY,1,FONTSIZE,"12px",PADDING,1,DELAY,500,FONTCOLOR,'#000000',BGCOLOR,'#A6C9EA',BORDERWIDTH,1,WIDTH,300, OPACITY,89);
			}
		});
	});
}

// adding suckerfish class for IE
function setupSuckerfish() {
//	$('menu').select('li').each(function(elem) {
        $$('ul#menu li').each(function(elem) {
		elem.observe('mouseover', function() {
			elem.addClassName('sfhover');
		});
		elem.observe('mouseout', function() {
			elem.removeClassName('sfhover');
		});
	});
}

function updateFLVMenu(claz) {
	$('playlist').select('div.flvplayer_listpic').each(function(elem){
		if (elem.hasClassName(claz))
			elem.addClassName('flvplayer_listpic_act');
		else
			elem.removeClassName('flvplayer_listpic_act');
	});
	if ($('player')) {$('player').childElements().first().focus();}
}

function setupTestFeatures() {
	var frmPbSurvey = $('frmPbSurvey');
	if(frmPbSurvey != null) {
		$$('tr.nowmin3months').each(function(elem){
			if(elem.down('input[type=text]').getValue() == ''){
				var d = new Date();
				d.setMonth(d.getMonth() - 3);
				elem.down('input[type=text]').value = d.getDate() + '-' + (d.getMonth() + 1) + '-' + d.getFullYear();
			}
		});

		var formChanged = false;
		Event.observe(frmPbSurvey, 'click', function(event){
			var element = Event.element(event);
			if (element.tagName == 'INPUT' && element.readAttribute('type') != 'submit') {
				// this is not completly true, but a close approximation
				formChanged = true;
			}
		});

		var backbutton;
		if((backbutton = $('backbutton')) != null) {
			backbutton.observe('click', function(evt){
				if(formChanged && !confirm('If you go back this page will not be saved.\nDo you really want to go back?')) evt.stop();
			});
		}
	}



}

// main
// document.observe('dom:loaded', function() {
// Event.observe(window, 'load', function() {
//
// 	setupSuckerfish();
// 	setupVideoTooltips();
// 	setupGroundruletips();
// 	setupTestFeatures();
//
// });
