
$(document).ready(function (){
	if($.browser.webkit){
        $('body').addClass('browserChrome');
        $.browser.safari = false;
    }
    else if($.browser.opera) $('body').addClass('browserOpera');
    else if($.browser.mozilla) $('body').addClass('browserMozilla');
	else if($.browser.msie){
		var browserId = $.browser.version.split('.');
		$('body').addClass('browserIE');
		$('body').addClass('ie' + browserId[0]);
		isIE = true;
	}
	
	var base_url = "http://www.weirdtv.com/";
	var this_image_path = "http://images.weirdtv.com/";
	var adInterval = 60000;
	var overMore = false;
	var overDD = false;
	var ddIn = false;
	var nT = false;
	var mI;
	var menuInterval = 500;
	var thumbsWidth = parseInt($('#pods').css('width'));
	var thumbContWidth = parseInt($('#pod-slider').css('width'));
	var imgSrc = this_image_path + "weirdamericaV2_Background.jpg";
	
	var catTop = parseInt($('#categories-cont').css('top')) + $('#categories-cont').height();
	$('#bg').css({'top': catTop});
	
	rotateBanners(true);
	
	window.fbAsyncInit = function() {
		var commentScroll = $('#comments-scroll'),
		comWidth = $('#comments-scroll .viewport').width(),
		contHeight = 0,
		commentHeight = 72,
		bottomHeight = 145,
		base_url = "http://cp.weirdtv.com/";
		
		if($('.comments').length > 0 || $('.comments-single').length > 0){
			$('.comments').append('<div id="fb-root"></div><div class="fb-comments" data-href="' + curPageURL + '" data-num-posts="4" data-width="' + comWidth + '"></div>');
			$('.comments-single').append('<div id="fb-root"></div><div class="fb-comments" data-href="http://www.weirdtv.com/" data-num-posts="4" data-width="' + comWidth + '" notify="true"></div>');
			var fI = setInterval(function(){
				if($('.fb-comments iframe').length > 0){
					clearInterval(fI);
					setTimeout(function(){
						contHeight = $(commentScroll).find('.viewport').height();
						$(commentScroll).tinyscrollbar();
						updateComments();			
					}, 1500);
				}
			}, 1500);
		}    
		FB.Event.subscribe('comment.create', commentChange);
		FB.Event.subscribe('comment.remove', commentChange);
		
		function commentChange(r){
			updateComments();
		}
		
		function updateComments(){
			$.post(base_url + 'assets/php/getcomments.php',
			{url: curPageURL},
			function(data){
				var comsHeight = ((data.comments + 1) * commentHeight) + bottomHeight;
				if(comsHeight > contHeight){
					setTimeout(function(){
						$(commentScroll).tinyscrollbar_update();
						$(commentScroll).find('.scrollbar').fadeTo(500, 1);
					}, 2000);
				}
			},
			"json");
		}	
	};
	
	$('#comments').css({'height': ($('#about-pod').height() + 20 + 250) + 'px'});
	
	$('#comments-scroll').css({'height': ($('#comments').height() - $('#comments .header').height() - 20) + 'px'});
	
	if($('#video-info-scroll').length > 0) $('#video-info-scroll').tinyscrollbar();
	
	$('.right-content').find('.item-list-scroll').each(function(){
		var thisScroll = $(this),
		thisHeight = $(thisScroll).height(),
		totalHeight = 0;
		
		setTimeout(function(){
			$(thisScroll).find('#item-list .item').each(function(){
				totalHeight += $(this).height();
			});
			
			$(thisScroll).tinyscrollbar();
			$(thisScroll).find('.scrollbar').hide();
			
			if(totalHeight > thisHeight){
				$(thisScroll).addClass('hasSB');
				$(thisScroll).tinyscrollbar_update();
				$(thisScroll).find('.scrollbar').fadeTo(500, 1);
				setTimeout(function(){
					$(thisScroll).tinyscrollbar_update();	
				}, 1000);
			}else $(thisScroll).find('.viewport').css({'width': '100%'});
		}, 1000);
	});
	
	$('#player-image').hide();
	
	$('.item-list-scroll').filter(':first').addClass('current');
	if($('#tab-cont').length > 0){
		$("#tab-cont").tabs(".item-list-scroll", {
			effect: 'fade',
			fadeInSpeed: 1000,
			fadeOutSpeed: 0
		});
	}else $('.item-list-scroll').fadeTo(500, 1);	
	
	if($('html').find('.collapse').length > 0){
		var initCollapse = $('html').find('.collapse')[0],
		initParent = $(initCollapse).parents('.item-list-scroll');
		
		if($(initParent).hasClass('current')){
			var rightPar = $(initParent).parents('.right-content'),
			vidCont = $(rightPar).prev();
			$(rightPar).addClass('collapse');
			$(vidCont).addClass('fullSize');
		}
	}
	
	$('#pod-slider').css({'overflow': 'hidden'});
	$('#mp-slider').mpScroll({speed: 0.05});	
	
	$("#categories #more").mouseenter(function(){
		$('#drop-down').slideDown(200);
		overMore = ddIn = true;
	}).mouseleave(function(){
		overMore = false;
		mI = setTimeout(closeMenu, menuInterval);
	});
	
	$("#drop-down").mouseenter(function(){
		overDD = true;
	}).mouseleave(function(){
		overDD = false;
		mI = setTimeout(closeMenu, menuInterval);
	});
		
	$('.item').click(function(){
		var thisItem = $(this),
		id = Number($(thisItem).find('.id').html()),
		mF = false;
		if(vids[curIndex]){
			for(var i = 0; i < vids[curIndex].length; i++){
				if(vids[curIndex][i].id == id){
					v = i;
					mF = true;
					break;
				}
			}	
		}
		if(!mF) vE = true;
		else vE = false;
		isClicked = true;
		
		getFlashMovie("videoplayer").itemClicked();
	});
	
	if($('#tab-cont').length > 0){
		var tabs = $("#tab-cont").data('tabs'),
		thisCont = $('#tab-cont'),
		thisParent = $(thisCont).parent(),
		thiswidth = thisCont.width(),
		parWidth = thisParent.width(),
		movementZone = 100,
		speed = 0.15,
		isAnimating = false;
		
		if(thiswidth > parWidth){
			var maxTravel = parWidth - thiswidth,
			midPoint = parWidth / 2,
			animTime = Math.abs(maxTravel) / speed;
			$(thisCont).mouseenter(function(e){
				var mouseX = 0,
				mouseY = 0,
				parentOffset = $(this).parent().offset();
				
				$(thisParent).mousemove();
				$(thisParent).mousemove(function(e){
					mouseX = e.pageX - parentOffset.left;
					mouseY = e.pageY - parentOffset.top;
					var curPos = parseInt($(thisCont).css('left'));
					if(mouseX < movementZone){
						if(curPos !== 0 && !isAnimating){
							isAnimating = true;
							$(thisCont).animate({'left': '0px'}, animTime, "linear", function(){
								isAnimating = false;
							});
						}
					}else if(mouseX > parWidth - movementZone){
						if(curPos !== Math.abs(maxTravel) && !isAnimating){
							isAnimating = true;
							$(thisCont).animate({'left': maxTravel}, animTime, "linear", function(){
								isAnimating = false;
							});
						}
					}else if(isAnimating){
						$(thisCont).stop();
						isAnimating = false;
					}
				});
				
			}).mouseleave(function(){
				$(thisCont).stop();
			});
		}
		
		tabs.onClick(function(e, index){
			var curPane = tabs.getCurrentPane();
			if($(curPane).hasClass('hasSB')){
				$(curPane).tinyscrollbar_update();	
				$(curPane).find('.scrollbar').show();
			}
		});
	
		tabs.onBeforeClick(function(e, index){
			var panes = tabs.getPanes();
			var curPane = panes[index];
			$('.right-content').find('.item-list-scroll').each(function(){$(this).removeClass('current');});
			$(curPane).addClass('current');
			if(curIndex !== index) {
				curIndex = index;
				var rightPar = $(curPane).parents('.right-content'),
				vidCont = $(rightPar).prev();
				if($(curPane).find('.item').length > 0){
					$(rightPar).removeClass('collapse');
					$(vidCont).removeClass('fullSize');
					emptyTab = false;
					$(curPane).find('.item').filter(':first').click();
				}else{
					$(rightPar).addClass('collapse');
					$(vidCont).addClass('fullSize');
					emptyTab = true;
					showImg(staticImg, "static");
					getFlashMovie("videoplayer").itemClicked();
				}
			}
		});
	}

	if($('#category').length > 0){
		$('#categories').find('#category').each(function(){
			var thisObj = $(this),
			overDD = false,
			overCat = false,
			catDDIn = false,
			catDD = $(thisObj).find('#cat-dd'),
			cI,
			cInt = 100;
			$(thisObj).mouseenter(function(){
				$(catDD).slideDown();
				overCat = catDDIn = true;
			}).mouseleave(function(){
				overCat = false;
				cI = setInterval(closeDD, cInt);
			});

			$(catDD).mouseenter(function(){
				overDD = true;		
			}).mouseleave(function(){
				overDD = false;
				cI = setInterval(closeDD, cInt);
			});

			function closeDD(){
				if(!overCat && !overDD && catDDIn) $(catDD).slideUp();
			}	
		})
	}

	function loadImage(){
		var newImg = new Image();
		newImg.onload = function() 
		{
			$('#bg').fadeTo(500, 0, function()
			{
				$(this).append('<img src="'+ imgSrc + '" alt="Category Background" /></a>');
		 		centerImg();
				$(this).fadeTo(500, 1, function(){centerImg();});	
			});
		};
		newImg.src = imgSrc; 	}
	
	function centerImg(){
		var vpWidth = $(window).width(),
		img = $('#bg').find('img'),
		imgWidth = $(img).width();
		
		if($('#bg').find('img').length > 0){
			var newMargin = Number(vpWidth - imgWidth) / 2;
			$('#bg img').css({'marginLeft' : newMargin + 'px'});
		}
	}
	function closeMenu(){
		if(!overDD && !overMore && ddIn) $('#drop-down').slideUp(200);
	}
	function rotateBanners(f){
		if(f){
			if($('.banner-ad').length > 0) $('.banner-ad').loadBanner('728', 728, 90);
			if($('.square-ad').length > 0) $('.square-ad').loadBanner('300', '100%', 250);
			if($('.square-ad-comp').length > 0) $('.square-ad-comp').loadBanner('300', '100%', 250);
		}else{
			if($('.banner-ad').length > 0) $('.banner-ad').loadBanner('728', 728, 90);
			setTimeout(function(){
				if($('.square-ad').length > 0) $('.square-ad').loadBanner('300', '100%', 250);
			}, 4000);
			setTimeout(function(){
				if($('.square-ad-comp').length > 0) $('.square-ad-comp').loadBanner('300', '100%', 250);
			}, 8000);
		}
	}
	$(window).resize(centerImg);
	if($('#bg').length > 0) loadImage();
	aR = setInterval(rotateBanners, adInterval);});

var v = 0.
curIndex = 0,
fR = false,
vR = false,
vE = false,
emptyTab = false;
sE = false,
isClicked = false,
continuousPlay = 1,
autoPlay = 1,
errorImg = "http://images.mypodstudios.com/pod/broke.jpg",
	staticImg = "http://images.mypodstudios.com/pod/mpph.jpg",
vids = [
	[{title: "Art Cars Part One ",url: "http://videos.weirdtv.com/Art_Cars_1.flv", id: 1602, views: 181, takesAds: 1, aspect: "16:9", desc: "Weird America takes a look at Art Cars...and this is only part one!", tags: "art, cars, automobile, art, found, objects, san, francisco, houston, orange, show, art, car, parade"},{title: "BBQ with Marty Chang ",url: "http://videos.weirdtv.com/BBQ_with_Marty_Chang.flv", id: 1603, views: 13, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Marty (his Dad is Asian) Chang is the modern </span>know-it-all. Here he shares some of his tasty BBQ secrets. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "BBQ, with, Marty, Chang, jason, berlin, weird, tv, weird, funny, hilarious, crazy, random, strange, odd, dog, licking, goofy, lol"},{title: "Burning Man - Early Years",url: "http://videos.weirdtv.com/Burning_Man___Early_Years.flv", id: 1604, views: 10, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Weird TV broke the news of Burning Man to the </span>world in our 1994 broadcast on Fox Television in San Francisco. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Burning, Man, 1994, alternative, funny, brilliant, weird, fire, random, amazing, burn, weird, tv, chuck, cirino"},{title: "Burning Man 1994 - 1995",url: "http://videos.weirdtv.com/Burning_Man_1994_1995.flv", id: 1605, views: 8, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Here is some rare footage from Burning Man... <span class=\"s1\">early on...when it was WILD!</span></p>", tags: "Burning, Man, art, festival, nude, wild, fun, funny, burn, fire, weird, crazy, random"},{title: "Car Hunt",url: "http://videos.weirdtv.com/Car_Hunt.flv", id: 1606, views: 4, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Deep in the Nevada back country rocket </span>scientists radio control a full-sized station wagon and let it go in the desert, then hunt it down with high-powered weapons.</p>", tags: "car, hunt, weird, tv, john, law, cacophony, society, art, cars, strange, odd, funny, crazy, random, driving, guns, machine, gun, weapon, firearms, nevada, drive, shoot, fire, sexy, girl"},{title: "Cathedral Canyon ",url: "http://videos.weirdtv.com/Cathedral_Canyon.flv", id: 1607, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Weird America finds Cathedral Canyon... just out <span class=\"s1\">there in the desert.</span></p>", tags: "cathedral, canyon, death, valley, nevada, art, roadside, attraction, spiritual, reverent, crazy, weird, funny, strange, deserted, abandon"},{title: "Classic Weird TV Chunk",url: "http://videos.weirdtv.com/Classic_Weird_TV_Chunk.flv", id: 1608, views: 5, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Here is a good example of what Weird TV is. </span>There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Classic, Weird, TV, Segment, weird, strange, funny"},{title: "Computer Repair with Marty Chang",url: "http://videos.weirdtv.com/Computer_Repair_with_Marty_Chang.flv", id: 1609, views: 3, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Computer Repair with Marty Chang is something </span>you need to see to believe. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "marty, chang, jason, berlin, weird, tv, weird, random, funny, strange, crazy, silly, odd, computer, repair, technical, hilarious, goofy"},{title: "Dog Marries Human Couple",url: "http://videos.weirdtv.com/Dog_Marries_Human_Couple.flv", id: 1610, views: 2, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">We couldn't decide what to name this segment: </span>Weird Wedding or Dog Marries Human Couple.&nbsp; What do you think?&nbsp; There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "dog, minister, marry, marriage, wedding, weird, weird, tv, satire, cacophony, society, funny, animal, pet, crazy, random"},{title: "Micaela O'Herlihy",url: "http://videos.weirdtv.com/Micaela_OHerlihy___Interview.flv", id: 1611, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Artist and film maker, Micaela O'Herlihy, is </span>interviewed. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Micaela, O'Herlihy, weird, tv, weird, art, artist, filmmaker"},{title: "Mr. Uncertain ",url: "http://videos.weirdtv.com/Mr_Uncertain___Uncertain.flv", id: 1612, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Star of stage and screen...Mr. Uncertain! There </span>are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Mr., Uncertain, weird, tv, entertainer, stage, performer, sad, silly, funny, crazy, odd, random, strange, hilarious"},{title: "Shadoe Stevens ",url: "http://videos.weirdtv.com/Shadoe_Stevens___Interview.flv", id: 1613, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Actor, producer, artist and utopian enthusiast, </span>Shadoe Stevens, is interviewed. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Shadoe, Stevens, shadoevision, weird, tv, funny, hilarious, federated, group, commercials, art, strange, odd, random, interview, crazy"},{title: "Stan Trempe's Amazing ",url: "http://videos.weirdtv.com/Stan_Trempes_Amazing_Creations.flv", id: 1614, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Chuck Woodbury shot this segment in Yucca </span>Valley, California.&nbsp; Stan Trempe was just 'out there'. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Stan, Trempe, creations, weird, yucca, art, yard, art, crazy, creature, random, funny, silly, weird, tv"},{title: "Sylvestor Williams' Yard",url: "http://videos.weirdtv.com/Sylvestor_Williams___Yard_Art.flv", id: 1615, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Sylvestor Williams lives in Houston and likes his <span class=\"s1\">yard just so.</span></p>", tags: "sylvestor, williams, houston, yard, art, opinionated, slavery, funny, black, weird, crazy, strange, random, beautiful, love"},{title: "The Great San Francisco ",url: "http://videos.weirdtv.com/The_Great_San_Francisco_Zippy_Protest.flv", id: 1616, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">There was once a Great San Francisco Zippy the <span class=\"s1\">Pinhead Protest!</span></p>", tags: "zippy, the, pinhead, bill, griffith, john, law, bishop, joey, st., stupids, day, san, francisco, funny, weird, odd, silly, random, strange, crazy, hilarious"},{title: "The Odeon - Ask Dr. Hal",url: "http://videos.weirdtv.com/The_Odeon__Ask_Dr_Hal_.flv", id: 1617, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">People ask Dr. Hal questions and he answers </span>them. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Dr., Hal, Robbins, Chicken, John, Odeon, Bar, San, Francisco, Church, of, the, SubGenius, random, funny, brilliant, strange, odd, weird, weird, tv"},{title: "Two-Guitar Rodney Branigan",url: "http://videos.weirdtv.com/Two_Guitar_Rodney_Branigan.flv", id: 1618, views: 2, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Guitarist Rodney Branigan can play two guitars </span>simultaneously and beautifully. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "two, Guitars, Rodney, Branigan, show, nightclub, brilliant, genius, dual, guitars, weird, creative, odd, country, music"},{title: "World Wide Weird-New God",url: "http://videos.weirdtv.com/World_Wide_Weird___New_God.flv", id: 1619, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Does Earth need a new God?&nbsp; Let's see....</p>", tags: "World, Wide, Weird, weird, tv, strange, events, festivals, people, funny, strange, crazy, random, eric, trueheart"},{title: "World Wide Weird - Stupid",url: "http://videos.weirdtv.com/World_Wide_Weird___Stupid.flv", id: 1620, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Warning: this video is more about something </span>else than it is about puppies. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "World, Wide, Weird, stupid, eric, trueheart, lazuli, weird, tv, strange, silly, random, funny, politics, crazy, odd, hilarious"},{title: "World Wide Weird - Puppies",url: "http://videos.weirdtv.com/World_Wide_Weird_Puppies.flv", id: 1621, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Warning: this video is more about something </span>else than it is about puppies. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "World, Wide, Weird, weird, tv, puppies, eric, trueheart, lazuli, strange, odd, funny, crazy, random, silly, dog, puppy"},{title: "Art Cars Part Two",url: "http://videos.weirdtv.com/Art_Cars_2.flv", id: 1622, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Art Cars in San Francisco and Houston dazzle the </span>eyes. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Art, Cars, weird, tv, automobiles, art, folk, art, Americana, weird, strange, odd, funny, crazy, colorful, random"},{title: "Beatrice Wyatt's Yard ",url: "http://videos.weirdtv.com/Beatrice_Wyatts_Yard.flv", id: 1623, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Bea Wyatt is a collector of stuff…lots of stuff!&nbsp; </span>There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Beatrice, Wyatt, yard, art, found, objects, old, lady, creative, religious, church, weird, funny, strange, random, crazy"},{title: "Dame Darcy",url: "http://videos.weirdtv.com/Dame_Darcy___Interview.flv", id: 1624, views: 2, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Artist Dame Darcy is interviewed. There are over </span>15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Dame, Darcy, artist, weird, tv, weird, strange, odd"},{title: "Dr. Franklin Ruehl ",url: "http://videos.weirdtv.com/Dr_Franklin_Ruehl___UFOs.flv", id: 1625, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">The ominous Dr. Franklin Ruehl explains UFOs in <span class=\"s1\">his own language.</span></p>", tags: "Weird, TV, Dr., Franklin, Ruehl, ufo, ufos, flying, saucers, vintage, film, footage, space, funny, crazy, random, short, alien, aliens, strange, silly, odd"},{title: "Inferior Showdowns",url: "http://videos.weirdtv.com/Inferior_Showdowns_of_the_Wild_West_III.flv", id: 1626, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Welcome to another historic account of the true </span>west. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "weird, tv, western, spoof, parody, random, comedy, funny, crazy, strange, hilarious"},{title: "King Kukulele ",url: "http://videos.weirdtv.com/King_Kukulele.flv", id: 1627, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">King Kukulele is quite a strange song writer and <span class=\"s1\">he also needs to clean up his bedroom!</span></p>", tags: "King, Kukulele, ukelele, funny, weird, strange, random, silly, musician, songs, crazy"},{title: "Les Poubelles - Weird Am",url: "http://videos.weirdtv.com/Les_Poubelles___Weird_America.flv", id: 1628, views: 2, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Performance art taken many steps beyond the <span class=\"s1\">norm.</span></p>", tags: "Les, Poubelles, professional, wrestling, french, maids, weird, random, silly, funny, crazy, strange, odd, hilarious, goofy"},{title: "Mark Mothersbaugh",url: "http://videos.weirdtv.com/Mark_Mothersbaugh___Interview.flv", id: 1629, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Rock musician of DEVO, artist and film composer, </span>Mark Mothersbaugh tell his own history in his own words.</p>", tags: "mark, mothersbaugh, weird, tv, DEVO, 1980s, music, rock, funny, interview, vintage, footage, kent, state, massacre, protest"},{title: "Peoplehater Robotic Shop",url: "http://videos.weirdtv.com/Peoplehater_Robotic_Shop.flv", id: 1630, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Chip Flynn and his crew of brilliant misfits make </span>rip and tear robots. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Peoplehater, robots, SRL, weird, tv, strange, dangerous, funny, random, crazy, odd, welding, mechanics, science"},{title: "Portland Saturday Market",url: "http://videos.weirdtv.com/Portland_Saturday_Market.flv", id: 1631, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Every Saturday morning in Portland, Oregon they </span>do this.&nbsp; There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Portland, Saturday, Market, oregon, weird, strange, funny, crazy, random"},{title: "Portland UFO Museum ",url: "http://videos.weirdtv.com/Portland_UFO_Museum.flv", id: 1632, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">There was once a tiny UFO museum in Portland, </span>Oregon. It's gone now, but here's what it was like. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Portland, UFO, Museum, flying, saucers, ufo, art, portland, museum, funny, crazy, history, space, alien, weird, oregon, random"},{title: "Robt. Williams Interview",url: "http://videos.weirdtv.com/Robt_Williams___Interview_.flv", id: 1633, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Artist - Robt. Williams</p>", tags: "robt., williams, big, daddy, roth, art, funny, weird, crazy, strange, underground, drawing, painting"},{title: "Scot Nery at the Odeon ",url: "http://videos.weirdtv.com/Scot_Nery_at_the_Odeon_Bar.flv", id: 1634, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Chicken John hosts some very strange acts on his </span>little stage in San Francisco.&nbsp; Scot Nery, entertainer, takes the ball and runs with it.</p>", tags: "The, Odeon, Bar, Scot, Nery, Chicken, John, juggling, san, francisco, burning, man, funny, short, film, weird, crazy, random, silly, strange, odd"},{title: "Spongorama",url: "http://videos.weirdtv.com/Spongorama___Tarpon_Springs.flv", id: 1635, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Spongorama is an attraction on the west coast of <span class=\"s1\">Florida.</span></p>", tags: "spongorama, florida, tarpon, springs, sponge, diving, attraction, funny, weird, crazy"},{title: "The Driveby Shooting Gal",url: "http://videos.weirdtv.com/The_Driveby_Shooting_Gallery__Weird_America.flv", id: 1636, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">At Burning Man 1994, people drove by stuffed </span>animals and shot at them. So did we, the camera crew.</p>", tags: "driveway, shooting, gallery, guns, weapons, weird, crazy, strange, funny, random, odd, hilarious, shooting, barney, stuffed, animals, 357, magnum, m-16"},{title: "Weird TV Labs ",url: "http://videos.weirdtv.com/Weird_TV_Labs.flv", id: 1637, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">In the secret Weird TV labs, we are one step </span>ahead. There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Weird, TV, Labs, weird, tv, strange, odd, random, crazy, funny, hilarious, testing, lab, coats, experiment"},{title: "Zeke the Shiek ",url: "http://videos.weirdtv.com/Zeke_the_Shiek.flv", id: 1638, views: 0, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Permaculture and big mounds of poop round out </span>this expose'.&nbsp; There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "zeke, the, sheik, permaculture, planting, organic, garden, manure, fertilizer, compost, pile, hippie, songs, guitar, green, flowers, environment, nature, gardens, gardening"},{title: "Fart Joke Shop ",url: "http://videos.weirdtv.com/Fart_Joke_Shop.flv", id: 1680, views: 2, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">On the coastal highway in Oregon, there was </span>once a joke shop in a trolly car.&nbsp; There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "Fart, Joke, Shop, oregon, fart, farts, joke, weird, strange, funny, silly, novelty, comedy, crazy, laugh, hilarious, random, jokes, prank, laughs, laughing, humor, humor, laughter, haha, lol, odd"},{title: "Newsweird - Art Bras ",url: "http://videos.weirdtv.com/Newsweird___Art_Bras.flv", id: 1681, views: 5, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Here is a fashion show worth writing home <span class=\"s1\">about. The latest in boobie-wear.</span></p>", tags: "Newsweird, weird, news, bras, art, fashion, show, funny, crazy, silly, random, strange, girls, boobies, women, sex"},{title: "The Funny Farm",url: "http://videos.weirdtv.com/The_Funny_Farm_Weird_Travel.flv", id: 1682, views: 1, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\">Weird America's Chuck Cirino takes you to Bend, <span class=\"s1\">Oregon and The Funny Farm... or Funny Farm The!</span></p>", tags: "The, Funny, Farm, funny, farm, the, roadside, attraction, road, art, art, folk, art, amazing, weird, random, interview, silly, crazy, bend, oregon, strange"},{title: "The LIttle Ale' Inn ",url: "http://videos.weirdtv.com/The_LIttle_Ale_Inn.flv", id: 1683, views: 2, takesAds: 1, aspect: "16:9", desc: "<p class=\"p1\"><span class=\"s1\">Way out near Area 51 is a small town with a </span>small cafe...and they serve space aliens!&nbsp; There are over 15 fast-paced hours of Weird TV available on DVD.</p>", tags: "The, LIttle, Ale', Inn, area, 51, rachel, nevada, cafe, remote, weird, weird, tv, funny, ufo, flying, saucer, random, space, aliens, crazy, strange"}]];

function playerReady(){
	console.log("JS received player is ready callback");
	if(sE){
		console.log("System error.  Displaying image.");
		showImg(errorImg, "sysError");
	}else{
		if(autoPlay){
			console.log("Autoplay is enabled, calling preparevideo");
			$('.current .item').filter(':first').click();
		}else{
			console.log("Autoplay not enabled.  Showing static image");
			showImg(staticImg, "static");
		}	
	}
}

function prepareVideo(){
	console.log("Arrived in prepareVideo, calling prepareAd in player");
	if(v >= vids[curIndex].length) v = 0;
	changeColor(vids[curIndex][v]);
	getFlashMovie("videoplayer").prepareAd(vids[curIndex][v]);
	var headerTextObj = $('#video-info .header h1'),
	headerText = $(headerTextObj).html();
	if(-1 !== headerText.toLowerCase().indexOf('pod')){
		$(headerTextObj).fadeTo(500, 0, function(){
			$(headerTextObj).empty().append('About This Video').fadeTo(500, 1);
		});
	}
	$('#video-info-scroll .scrollbar').fadeTo(500, 0);
	$('#video-info-scroll .overview').fadeTo(500, 0, function(){
		var thisObj = $(this),
		itemText = vids[curIndex][v].desc;
		if(vids[curIndex][v].tags.length > 0) itemText += '<p><span>Tags: </span>' + vids[curIndex][v].tags + '</p>';
		$(thisObj).html('').append(itemText);
		
		$('#video-info-scroll').tinyscrollbar_update();
		if($(thisObj).height() > $(thisObj).parent().height()) $('#video-info-scroll .scrollbar').fadeTo(500, 1);
		else $('#video-info-scroll .scrollbar').hide();
		$(thisObj).fadeTo(500, 1);	
		v++;
	});
	
}

function videoReady(){
	console.log("JS received video is ready callback");
	vR = true;
	setTimeout(startNewMovie, 500);
}

function startNewMovie(){
	console.log("Arrived in startNewMovie");
	getFlashMovie("videoplayer").startNewMovie();
	isClicked = false;
}

function videoComplete(){
	console.log("JS received videoComplete callback");
	vR = false;
	if(emptyTab) showImg(staticImg, "static");
	else if(!vE && (continuousPlay || isClicked)){
		if($('#player-image').css('opacity') == 1){
			$('#player-image').fadeTo(500, 0, function(){
				$(this).hide();
				prepareVideo();
			});
		}else prepareVideo();
	}else if(vE) showImg(errorImg ,"error");
	else{
		showImg(staticImg, "static");
		var headerTextObj = $('#video-info .header h1'),
		headerText = $(headerTextObj).html();
		if(-1 !== headerText.toLowerCase().indexOf('video')){
			$(headerTextObj).fadeTo(500, 0, function(){
				$(headerTextObj).empty().append('About This Pod').fadeTo(500, 1);
				$('#video-info-scroll .overview').fadeTo(500, 0, function(){
					var thisObj = $(this),
					podText = $('#pod-desc-info').html();
					$(thisObj).empty().append(podText);
					$('#video-info-scroll').tinyscrollbar_update();
					if($(thisObj).height() > $(thisObj).parent().height()) $('#video-info-scroll .scrollbar').fadeTo(500, 1);
					else $('#video-info-scroll .scrollbar').fadeTo(500, 0);
					$(thisObj).fadeTo(500, 1);
				});
			});
		}
	}
}

function changeColor(vidObj){
	var mF = false;
	$('.current .item').each(function(){
		$(this).removeClass('current');
		if(!mF){
			var id = Number($(this).find('.id').html());
			if(vidObj.id == id){
				$(this).addClass('current');
				mF = true;
			}		
		}
	});
}

function showImg(imgSrc, type){
	var newImg = new Image();
	newImg.onload = function(){
		$('#player-image').fadeTo(500, 0, function(){
			var defaultView = '';
			switch(type){
				case "error":
					defaultView = $('<div id="error-img"><img src="' + imgSrc + '" alt="Video Not Found" /><div id="img-info"><p>Sorry.  Looks like there was an error with your video.  <span>Please pick antoher.</span></p></div></div>');
					break;
				case "sysError":
					defaultView = $('<div id="static-img"><div id="img-info"><h1>Something\'s Always On.</h1><p class="mypod-logo"><img src="http://images.mypodstudios.com/logos/newcolors/logocolor.png" alt="MyPod Logo" /></p></div></div>');
					break;
				default:
					if(imgSrc !== 'http://images.mypodstudios.com/pod/mpph.jpg') defaultView = $('<div id="static-img"><img src="' + imgSrc + '" alt="Placeholder Image" /></div>');
					else defaultView = $('<div id="static-img"><div id="img-info"><h1>Something\'s Always On.</h1><p>Please select a new video to watch.</p><p class="mypod-logo"><img src="http://images.mypodstudios.com/logos/newcolors/logocolor.png" alt="MyPod Logo" /></p></div></div>');
					break;
			}
			$('#player-image').empty().append(defaultView);
			$('#player-image').fadeTo(500, 1);
		})
	};
	newImg.src = imgSrc;
}

function getFlashMovie(movieName){
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}
