var currentPlaylistItem;
var currentState;

function removeHTMLTags(htmlString){
        if(htmlString){
          var mydiv = document.createElement("div");
           mydiv.innerHTML = htmlString;
 
            if (document.all) // IE Stuff
            {
                return mydiv.innerText;
               
            }   
            else // Mozilla does not work with innerText
            {
                return mydiv.textContent;
            }                           
      }
   }
   

   
   
function getUpdate(type, arg1, arg2) {
	var showtitlebox = document.getElementById('showtitlebox');
	var epdescription = document.getElementById('epdescription');
	var eptitle = document.getElementById('eptitle');
	var player = document.getElementById('player');
	
        switch(type) {
		case "state":
			currentState = arg1;
		break;
		
		case "item":
			currentPlaylistItem = arg1;
			var episode = player.getCurrentItem();
			var epthumb = document.getElementById('epthumb');
			var trimmedtitle = removeHTMLTags(episode.title);
			var trimmeddescription = removeHTMLTags(episode.description);
			epdescription.innerHTML = trimmeddescription;
			eptitle.innerHTML = trimmedtitle;
			epthumb.src = episode.image;
			document.title = 'Wake UP! TV - '+trimmedtitle;



			var str = episode.title;
			firstword = str.split(/\b/)[0];
		
			if (firstword == "Radio")
				{
				showtitlebox.src = "http://www.ryanray.com/images/promo_box_yourewatching_Radio.jpg";
				showlink.href = "http://www.ryanray.com/radio/";
				showlink.title = "Watch more episodes of Wake UP! Radio";
		
				}
			else if (firstword == "Explore")
				{
				showtitlebox.src = "http://www.ryanray.com/images/promo_box_yourewatching_Explore.jpg";
				showlink.href = "http://wakeuptv.com/explore-your-passion";
				showlink.title = "Watch more episodes of Wake UP! Explore your Passion";
				}
			else if (firstword == "Passion")
				{
				showtitlebox.src = "http://www.ryanray.com/images/promo_box_yourewatching_Passion.jpg";
				showlink.href = "http://wakeuptv.com/passion-for-the-arts";
				showlink.title = "Watch more episodes of Passion for the Arts";
				}			else
				{
				showtitlebox.src = "http://www.ryanray.com/images/promo_box_yourewatching_Generic.jpg";
				showlink.href = "#";
				}
		
				break;
			}
}



function playerReady(obj) {
	var player;
	var start = player.getConfig().title;
	
	alert('the videoplayer '+obj+' has been instantiated');
	player = document.getElementById(obj);

	alert(start);
}

function thankyou() {
	if(submitted){
	document.forms[0].reset();
	document.getElementById('dynamicdiv').innerHTML = "<div class=glBox><span class=\"glText\"><span class=formthanks>Thank you for entering Wake UP! TV\'s Cash for your Passion&trade; Sweepstakes!</span> Your entry has been successfully recorded. You can enter the sweepstakes as often as you like. <a href=\"http://www.wakeupTV.com\">Click here</a> to reload this page and enter again right now! See <a target=_blank href=\"https://docs.google.com/document/edit?id=1IHeSefaCnnmJ7JbsqNymTo_YOrLb9fHgrpol3WXrZmc&hl=en\">Official Rules</a> for details.<p><iframe class=glfbShareBox src=\"http://www.facebook.com/plugins/likebox.php?id=51385252032&amp;width=460&amp;connections=0&amp;stream=true&amp;header=true&amp;height=300\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:460px; height:300px;\" allowTransparency=\"false\"></iframe></div>";
	}
}

function fbShareClick() {
	if(document.commentForm.group_8_1.checked==true){
	return;
	}
	else {
	document.commentForm.group_8_1.checked = true;
	}
}

function fbBoxClick() {
	if(document.commentForm.group_8_1.checked==true){
	newwindow=window.open('http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwakeuptv.com&t=Wake%20UP!%20TV%20%C2%BB%20Wake%20UP!%20TV&src=sp','sharer','toolbar=0,status=0,width=626,height=436').focus;
	document.commentForm.group_8_1.checked = true;

	}
}




