var haveqt = false;
$(document).ready(function($) {
	if(detectPlugin()){
	appendMovie();
	}else{
	//alert('is flash');
	playmovie();	
	}
	$('a.lightbox').lightBox({
		overlayBgColor: 		'#000',
		overlayOpacity:			0.8,
		imageLoading:			'http://goodappl.com/wp-content/themes/janii/js/images/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
		imageBtnPrev:			'http://goodappl.com/wp-content/themes/janii/js/images/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
		imageBtnNext:			'http://goodappl.com/wp-content/themes/janii/js/images/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
		imageBtnClose:			'http://goodappl.com/wp-content/themes/janii/js/images/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
		imageBlank:				'http://goodappl.com/wp-content/themes/janii/js/images/lightbox-blank.gif'
	});
});

appendMovie = function(){
	var mediaSrc = $('.media').attr('href');
	//alert(mediaSrc);
	$('.media').media({ 
	    width:     235, 
	    height:    353, 
	    autoplay:  true, 
	    src:       mediaSrc, 
	    //attrs:     {controller: false },  // object/embed attrs 
	   // params:    {controller: false }, // object params/embed attrs 
	   // caption:   false, // supress caption text 
		bgColor: '#090909'
	});
}
/*isIphone = function(){
	var agent=navigator.userAgent.toLowerCase();
	var is_iphone = ((agent.indexOf('iphone')!=-1);
	if (is_iphone) {
		$('.movieHolder').css(padding:"0");
	}
}*/
var detectPlugin = function(){
	if (navigator.plugins) {
          for (i=0; i < navigator.plugins.length; i++ ) {
               if (navigator.plugins[i].name.indexOf("QuickTime") >= 0)
                    { 
						haveqt = true; 
					}
            }
			return haveqt;
        }
}
var playmovie = function()
{
	$('#movieHolder').append('<div id="movie"></div>');
	$('#movieHolder').css({position:"relative",top:"93px",left:"30px"});
	var mediaSrc = $('.media').attr('rel');
	$('.media').remove();
	var flashvars = {file:mediaSrc};
	var params = {video:mediaSrc,autoplay:'true'};
	var attributes = {};
	swfobject.embedSWF(
	'http://www.goodappl.com/videos/FLVPlayer.swf?video='+mediaSrc+'&autoplay=true',
	'movie',
	'235',
	'353',
	'9.0.0',
	'',
	flashvars,
	params,
	attributes);
}