$(document).ready(function() {
    $('#btCloseVideo').hide();

	$('.hd-menu li').hover(function(){
		$(this).children('div').show();
	}, function(){
		$(this).children('div').hide();
	});
	
	$('.menu-abas ul li:first div').show()
	$('.menu-abas ul li:first').addClass('selecionado');
	$('.menu-abas ul li').bind('click', function(){
		$('.menu-abas ul li').removeClass('selecionado');
		$('.menu-abas ul li').children('div').hide();
		$(this).children('div').show();
		$(this).addClass('selecionado');
	});
	
	$('form fieldset ul li label').each(function(){
		$(this).attr('for', $(this).children().attr('name'));
	});
});

function showVideo(source,target,width,height) {
        $('.videoPlayer').children().each(function(){
            closeVideo($(this).attr('id'));
            //alert($(this).attr('id'));
        });
        $('#' + target).parent('div').show();
        $('.videoPlayer').parent().css('position', 'relative');
        var attributes = {};
        var params = {
            wmode: 'transparent',            
            allowScriptAccess: 'sameDomain',
            loop: false
        };
        var flashvars = {alvo: target};
        swfobject.embedSWF(source, target, width, height, "9.0.0", "expressInstall.swf", flashvars, params, attributes);
//        var att = { data:"videos/' + source", width:width, height:height };
//        var par = { flashvars:"alvo=" + target, loop: false, wmode: 'transparent' };
//        var id = target;
//        swfobject.createSWF(att, par, id);
}

function closeVideo(target) {
       div = $('#' + target).parent('div');
       div.hide();
    swfobject.removeSWF(target);
//        var playerExists = $('.videoPlayer').children().is('div');
//        if (!playerExists) {
            div.html('<div id="' + target + '"></id>');
//        }
    
//    swfobject.registerObject(target, "9.0.0", "expressInstall.swf"); 
}
