
function sError(){ return true; }
window.onerror = sError;

function music_status(_value)
{
	if( window.document.tdb_player )
	{
		// alert('Set in Flash: '+_value);
		window.document.tdb_player.SetVariable("SoundStatus",_value);
		// alert('OK');
	}
}
function play_sound(tit,fn)
{
	//alert('PlaySound');
	if( window.document.tdb_player )
	{
		//alert('Set in Flash:\nOtherSoundTitle: '+tit+'\nOtherSoundFile: '+fn);
		window.document.tdb_player.SetVariable("OtherSoundTitle",tit);
		window.document.tdb_player.SetVariable("OtherSoundFile",fn);
		//alert('OK');
	}
}

function imagewin(img,w,h)
{
	var win_x = (screen.width-w)/2;
	var win_y = (screen.height-h)/2;
	var wPARAM = '';
	wPARAM += 'left='+win_x+',top='+win_y+',width='+w+',height='+h;
	wPARAM += ',location=0,resizable=0,titlebar=0,directories=0,toolbar=0,menubar=0,scrollbars=0,status=no';
	
	var pw = window.open( 'index.php?page=image&img='+img, 'imgwin', wPARAM );
}

function changeIMG(_id,_imgsource)
{
	var e = document.getElementById(_id);
	if(e)
	{
		e.src = _imgsource;
	}
}

function timestamp()
{
	var n = new Date();
	_y = n.getYear(); if( _y < 1000 ) _y += 1900;
	_y *= 31556926;
	_m = n.getMonth()*2629744;
	_d = n.getDate()*86400;
	_h = n.getHours();
	_n = n.getMinutes();
	_s = n.getSeconds();
	return ( _y + _m + _d + _h + _n + _s );
}

function popup_window(_url,_id,_width,_height)
{
	var win_x = (screen.width-_width)/2;
	var win_y = (screen.height-_height)/2;
	var wPARAM = '';
	wPARAM += 'left='+win_x+',top='+win_y+',width='+_width+',height='+_height;
	wPARAM += ',location=0,resizable=0,titlebar=0,directories=0,toolbar=0,menubar=0,scrollbars=1,status=no';
	var pw = window.open(_url,_id,wPARAM);
}

function popwin( wURL, wNAME, wWIDTH, wHEIGHT, wRESIZE, wSCROLL )
{
	var x = null;
	
	wX = (screen.width!=null)? screen.width/2-wWIDTH/2:0;
	wY = (screen.height!=null)? screen.height/2-wHEIGHT/2:0;
	
	if( wSCROLL == undefined ) wSCROLL = "0";
	if( wRESIZE == undefined ) wRESIZE = "0";
	
	wPARAM  = "left=" + wX + ",top=" + wY;
	wPARAM += ",WIDTH=" + wWIDTH + ",HEIGHT=" + wHEIGHT;
	wPARAM += ",location=0,resizable="+wRESIZE+",titlebar=1,directories=0";
	wPARAM += ",toolbar=0,menubar=0,scrollbars="+wSCROLL+",status=no";

	x = window.open( wURL, wNAME, wPARAM );
	x.focus();
}

function check_prevawards(cbox)
{
	//a cada jornada posarem un name=prevaward_x_ i un id=jorn_x_
	var e1 = document.getElementById('jorn_1'); 
	var e2 = document.getElementById('jorn_2');
	var e3 = document.getElementById('jorn_3');
	var e4 = document.getElementById('jorn_4');
	var e5 = document.getElementById('jorn_5');
	var e6 = document.getElementById('jorn_6');
	var e7 = document.getElementById('jorn_7');
	
	if( e1 && e2 && e3 && e4 && e5 && e6 && e7)
	{
		// if I have checked 'no previous award submission'
		if( cbox.name=='check1' && e1.checked )
		{
			// de-check others
			e2.checked = false;
			e3.checked = false;
			e4.checked = false;
			e5.checked = false;
			e6.checked = false;
			e7.checked = false;
		}
		else if(cbox.checked)
		{
			e1.checked = false;
		}
	}
}

function particip_quin_sh(cbox)
{
	document.getElementById('particip_quin').style.display = cbox.checked ? 'block' : 'none';
}

function changeimg(i,s)
{
	 document.getElementById(i).src = s;
}


function menu_on(i,la)
{
	// if(typeof mto != 'undefined' ) clearTimeout(mto);
	 switch_menu(i,2,la);
}

function menu_out(i,b,la)
{
	// mto = setTimeout('switch_menu('+i+','+b+')',100);
	 switch_menu(i,b,la);
}

function switch_menu(i,m,l)
{
	changeimg('m0'+i,'img/'+l+'/menu/menu_'+i+'_'+m+'.gif');
}


function hover_logo(i,m)
{
	 changeimg('pl0'+i,'img/logos/logo_'+i+'_'+m+'.jpg');
}
