<?php

define('IN_BANDTOPIA', "You're here!!!");

ini_set("display_errors","1");
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);

include_once("include/pageStart.php");

$fanslist = array(); //init as empty array			

//info for facebook, twitter
$fbuser;
$twuser;

$artist; //whose page this is
$user; //who is accessing this page

//get all the global values
function init()
{
    global $fbuser, $twuser, $artist, $user;
	$fbuser = "pages/Jason-Watson-Band/123433347782842";
	$twuser = "jasonwatsonband";
	$artist = $_GET['aID'];
	$user = SESSION_USERID;
}


/*******************************************/ 
/*            Widget Functions             */
/*******************************************/

function getFacebookWidget()
{
	global $fbuser;
	
   	$retVal = '
   		<div id="fb-root"></div>
		<script>(function(d, s, id) {
  		var js, fjs = d.getElementsByTagName(s)[0];
  		if (d.getElementById(id)) return;
  		js = d.createElement(s); js.id = id;
  		js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  		fjs.parentNode.insertBefore(js, fjs);
		}(document, \'script\', \'facebook-jssdk\'));</script>

		<div class="fb-like-box" data-href="https://www.facebook.com/'
		 . $fbuser
		 . '" data-width="500" data-height="400" data-show-faces="true" 
		 data-stream="true" data-header="true"></div>';

   return $retVal;
}


function getTwitterWidget()
{
	global $twuser;
	
	$retVal = 	"<script charset=\"utf-8\" src=\"http://widgets.twimg.com/j/2/widget.js\"></script>
				<script>
				new TWTR.Widget({
				version: 2,
  				type: 'profile',
  				rpp: 5,
  				interval: 30000,
  				width: 500,
  				height: 400,
  				theme: {
    				shell: {
      				background: '#333333',
      				color: '#ffffff'
    				},
    			tweets: {
      				background: '#000000',
      				color: '#ffffff',
      				links: '#4aed05'
    				}
  				},
  				features: {
    				scrollbar: false,
    				loop: false,
    				live: false,
    				behavior: 'all'
  				}
				}).render().setUser('". $twuser . "').start();
				</script>";
	
	return $retVal;
}

function getAddButton()
{
	global $user, $artist;
	$retVal =  '<form method="post" action="artistdisplay.php?aID=' . $artist . '">
				<input type="submit" value="Add Band to Favorites" />
				</form>
				';
	
	return $retVal;	
}

function getMessageButton()
{
	global $artist;
	$retVal =  '<form method="post" action="/promotion/index.php?action=sendmessage>
				<input type="submit" value="Send Message to Band" />
				</form>
				';
	
	return $retVal;	
}


/*******************************************/ 
/*                 Fan Stuff               */
/*******************************************/

function getFans()
{
    
}

function displayFans()
{
    //generate and output HTML code for a fanslist
}

function requestStreetTeamStatus()
{
    //functionality for requesting status
}


/*******************************************/ 
/*                 Main                    */
/*******************************************/

init();

//form processing for adding a favorite band
if($_SERVER['REQUEST_METHOD'] == 'POST') {
	$r = mysql_query("INSERT INTO FavArtists(UserId,ArtistId,StreetTeam) VALUES('$user','$artist', 0)") or die(mysql_error()); 
}



?>

<html>
<head>
<title> Band Public Page </title>
</head>
<body>
<?php echo getFacebookWidget(); ?>

<?php echo getTwitterWidget(); ?>

<?php if(isset($user)){echo getAddButton();} ?>
<?php if(isset($user)){echo getMessageButton();} ?>

</body>
</html>