	
	responseViewer = {
		// This should be updated to the location of the wordpress install
		serverUrl :	"http://84.20.130.193/data/",
		fullScreenUrl : "url must be set on each page"
		
	};
	
	function updateHTML(elmId, value) {
		var elem = document.getElementById(elmId);
		if (elem){
			elem.innerHTML = value;
		}
	  
	}

	function showResponseViewer() 
	{
		//console.log("hiding alt content");
		var element = document.getElementById("alt-content");
			element.style.display = "none";
	}

	function setytplayerState(newState) {
	  updateHTML("playerstate", newState);
	}

	// PLEASE NOTE: For the purpose of this demo:
	// This method is called from the onYouTubePlayerReady method inside _assets/js/youTubeLoader.js
	function secondaryOnYouTubePlayerReady(playerId) {
	  ytplayer = document.getElementById(SWFID);
	  setInterval(updateytplayerInfo, 250);
	  updateytplayerInfo();
	  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
	}

	// PLEASE NOTE: For the purpose of this demo:
	// This method is called from the onytplayerStateChange method inside _assets/js/youTubeLoader.js
	function secondaryOnytplayerStateChange(newState) {
	  setytplayerState(newState);
	}

	function updateytplayerInfo() {
	  updateHTML("bytesloaded", getBytesLoaded());
	  updateHTML("bytestotal", getBytesTotal());
	  updateHTML("videoduration", getDuration());
	  updateHTML("videotime", getCurrentTime());
	  updateHTML("startbytes", getStartBytes());
	  updateHTML("volume", getVolume());
	}

	function alertEmbed () {
		alert( getEmbedCode() );
	}

	function alertVideoUrl () {
		alert( getVideoUrl() );
	}

	function unloadVideo () {
		stop();
		clearVideo();
	}
	
	function open_fullscreen_page() {
		var p  = 'width='+screen.width;
		p += ', height='+screen.height;
		p += ', top=0, left=0, scrollbars=yes';

		newwin = window.open(responseViewer.fullScreenUrl,'newwindow', p);
		
		if (window.focus) {newwin.focus()};	
		
		return false;
	}
	
	function close_fullscreen_page() {
		window.close();
	}	
	
	function flash_facebook_share(p_url) {
			
		var u = p_url;
		var t=document.title;
		
		var url = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(u) + "&t=" + encodeURIComponent(t);
		
		var width  = 626;
		var height = 436;
		var left   = (window.screen.width  - width)/2;
		var top    = (window.screen.height - height)/2;
		var p = 'width='+width+', height='+height;
		p += ', top='+top+', left='+left;
		p += ', directories=no';
		p += ', location=no';
		p += ', menubar=no';
		p += ', resizable=no';
		p += ', scrollbars=no';
		p += ', status=no';
		p += ', toolbar=no';
		
		var newwin = window.open(url,'facebookwindow', p);
		
		if (window.focus) {newwin.focus()}
						
		return false;
	}
	
	function getFullScreenDimensions(){
		var 
			minWidth	= 755,
			minHeight	= 900,
			wWidth		= 0,
			wHeight		= 0,
			width		= minWidth,
			height 		= minHeight;
			
		if (window.innerHeight){ //for most browsers
			wWidth	= window.innerWidth;
			wHeight = window.innerHeight;
		}
		else if (document.documentElement.clientHeight){ //for IE
			wWidth	= document.documentElement.clientWidth;
			wHeight = document.documentElement.clientHeight;
		} 
		
		width = (wWidth > minWidth) ? "100%" : minWidth + "px";
		height = (wHeight > minHeight) ? "100%" : minHeight + "px";
		
		return {width:width,height:height};		
	}
	
	function resizeViewerWindow(){
		var 
			html = document.getElementsByTagName("html")[0];
			dims = getFullScreenDimensions();		
		html.style.overflow = "auto";
		html.style.width = dims.width;
		html.style.height = dims.height;
		document.body.style.width = dims.width;
		document.body.style.height = dims.height;
	}
	
	function loadInMainWindow(url){
		//RV_Main window.name is set in msg-tabs.js since it is used throughout the HUB pages
		var newWindow = window.open(url, "RV_Main");
		newWindow.focus();
	}
	
	function resizeWindowToFull(){
		window.moveTo(0,0);
		window.resizeTo(screen.width,screen.height-30); //subtract 30 to account for taskbar
	}

	window.onload = function(){
		resizeViewerWindow();
	};
	
	var _resizeTimeout;
	window.onresize = function(){
		clearTimeout(_resizeTimeout);
		_resizeTimeout = setTimeout(function(){
			resizeViewerWindow();
		},100);
	};
			