var selectedMenuBut = false;
$( function( ) {
	if( $('#menu a.selected').size() == 1 ) {
		selectedMenuBut = $('#menu a.selected').index();
		$('#menu a').hover( function() {
			if( $(this).hasClass('selected') == false )
				$('#menu a.selected').removeClass('selected');
		}, function() {
			/*$('#menu a:eq('+selectedMenuBut+')').addClass('selected');*/
		} );
	}

	$(window).resize( function( ) {
		if( $('.testplayer').size() > 0 ) {
			ytPlayerSize();
		}
	});
});

function relocate( url ) {
	location.href = url;

}

function ytPlayer( youtube_id, vid_name ) {
	$('body').append('<div class="testplayer"><center><div class="tplayer"><div class="title">'+vid_name+'</div><div class="close" onclick="javascript: $(\'.testplayer\').remove();">סגור</div><br class="clear" /><div id="ytapiplayer"><object width="380" height="280"><param name="movie" value="http://www.youtube.com/v/'+youtube_id+'&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+youtube_id+'&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="380" height="280"></embed></object></div></div></center></div>');
	ytPlayerSize();
}

function ytPlayerSize() {
	if( $(window).height() > $('body').height() ) {
		$('.testplayer').height( $(window).height() );
		var x = ($(window).height() / 2) - ($('.tplayer').height() / 2);
	} else {
		$('.testplayer').height( $('body').height() );
		var x = ($('body').height() / 2) - ($('.tplayer').height() / 2);
	}
	
	if( $(window).width() > $('#base').width() )
		$('.testplayer').width( $(window).width() );
	else $('.testplayer').width( $('#base').width() );
	
	$('.tplayer').css('margin-top', x+'px');
}

function WriteError( input_name, error ) {
	var div_id = 'error_' + input_name;
	var count = 0;
	if( obj = document.getElementById( div_id ) ) {
		if( error.length != 0 ) {
			obj.innerHTML = error;
		}
	} else {
		alert( error + " @ " + input_name );
	}
}
