/**
 * JS scripts that are executed on page load to format / enchance page elements
 */
$(function(){
	
	uiTabsStatic();
    uiCenterNavTabs();
	uiBlockButtons();
	
	uiDefaultBannerTitle();
		
})




function uiDefaultBannerTitle(){
	$('#default-banner-title').html( $('h1').html() )
}

function uiCenterNavTabs(){
    $('.ui-tabs-nav li a').each(function(){
        if ($(this).children().length == 0) { // if there are any <br> tags in the tab title it will have a child-count > 0 
            $(this).css('line-height', '29px')
        }
    })
}


function uiBlockButtons(){
		
    $('.block-button').each(function(){
        var linkUrl = false;
        var block = $(this);
        $('p a', block).each(function(){
            linkUrl = $(this).attr('href')
            $(this).remove();
			block.click( function(){
				document.location = linkUrl;				
			})	
        });
    });
}


function uiTabsStatic()
{
	// remove the block style so that existing styles (ui-tab-nav) can be applied
	var tabBlock = $('.tabbed-static'); 
	tabBlock.removeClass('block-menu_block')
	tabBlock.find('ul').addClass('ui-tabs-nav')
	tabBlock.find('li.active').addClass('ui-tabs-selected')	
	tabBlock.find('li').addClass('ui-corner-top') // add marker classes so the curvey corners can be applied
	
	tabBlock.corner({
              tl: { radius: 3 },
              tr: { radius: 3 },
              bl: { radius: 3 },
              br: { radius: 3 },
              antiAlias: false,
              autoPad: false
			  })
}


function uiShowMovie( id, title, w, h){

	if ( !Shadowbox )
	{
		
	}

	var embedSrc =  youtube_video_embedd[id];
	
	wMatch = embedSrc.match(/width=(?:"|')?(\d+)/);
	hMatch = embedSrc.match(/height=(?:"|')?(\d+)/);

	
	
	var w = parseInt(wMatch[1]) +5  ;
	var h = parseInt(hMatch[1]) +5  ;
	
//	embedSrc = $('<div>').html(embedSrc).height(h).width(w).css('overflow','hidden').css('scrollbars','none').html()

//alert(">" + youtube_video_embedd[id]);	
	
//	$('#youtube-'+id+' .youtube-container').height(h).width(w).css('overflow','hidden');
//	var sizedSrc = $('#youtube-'+id).html();	
	
//	alert( sizedSrc );

//	sizedSrc = '<object width="425" height="344" data="http://www.youtube.com/v/cxE20jaSyBM&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash"><param name="data" value="http://www.youtube.com/v/cxE20jaSyBM&amp;hl=en_US&amp;fs=1&amp;"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><param name="src" value="http://www.youtube.com/v/cxE20jaSyBM&amp;hl=en_US&amp;fs=1&amp;"><param name="allowfullscreen" value="true"></object>';
	
	
	Shadowbox.open({
		content: embedSrc,
		player: "html",
		title: title,
		height: h,
		width: w
	});
}

	

