<?
// This ensures all code knows it's being called by the bandTopia app
// If this variable is missing when another page is loaded.  It will redirect to bandTopia home.
define('IN_BANDTOPIA', "You're here!!!");

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

// Starts the processing for the page.
require ("include/pageStart.php");

// Set main html page to use for page
$template -> set_filenames(array(
	"body" => "main.htm"));
	
// Start Navigation
$nav = '<a href="index.php">Home</a>';

if(defined('LOGGEDIN')) {
	$template -> assign_block_vars("logged_in", array());
}
else {
	$template -> assign_block_vars("logged_out", array());
}

/******************************************************/
/*  Login Page                                        */
/******************************************************/
if($action == 'login') 
{

header("Location: /include/userpage.php");

}
/******************************************************/
/*  Main Page                                         */
/******************************************************/
elseif($action == 'main')
{
	$template -> assign_block_vars("page_main",array());
	$profileOn = false;
	
	if(!is_null(ARTIST_ID)) {
		$template -> assign_block_vars("page_main.artist_cp",array());
	}
}
/******************************************************/
/*  Profile Page
/******************************************************/
elseif($action == 'profile')
{ 
header("Location: /include/artist_profile.php");//?UserId=".$userObj->get_UserId());
}
/******************************************************/
/*  Profile Page
/******************************************************/
elseif($action == 'band_public')
{
	
}



/******************************************************/
/*  Signup Page                                        */
/******************************************************/
elseif($action == 'signup') 
{
	$template -> assign_block_vars("page_signup",array());
}
elseif($action == 'signupsubmit')
{
	$userObj = new UserObj();
	$userObj -> set_UserName($_POST['username']);
	$userObj -> set_Password($_POST['password']);
	$userObj -> set_FirstName($_POST['firstname']);
	$userObj -> set_LastName($_POST['lastname']);
	$userMsg = $userObj -> updateUser();
	
	if($userMsg == "User has been added successfully.")
	{
		header("Location: index.php?action=artistAdd&prev_action=signupsubmit&UserId=".$userObj->get_UserId());
	}
}
/******************************************************/
/*  Artist Add Page                                        */
/******************************************************/
elseif($action == 'artistAdd') 
{
	$template -> assign_block_vars("page_artistAdd",array());
	$template -> assign_var("USERID", $_GET['UserId']);
}
elseif($action == 'artistAddsubmit')
{
	$artistObj = new ArtistObj();
	$artistObj -> set_Name($_POST['name']);
	$artistObj -> set_Address($_POST['address']);
	$artistObj -> set_City($_POST['city']);
	$artistObj -> set_State($_POST['state']);
	$artistObj -> set_Phone($_POST['phone']);
	$artistObj -> set_Email($_POST['email']);
	$artistObj -> set_URL($_POST['url']);
	$artistObj -> set_Bio($_POST['bio']);
	$artistObj -> set_UserId($_POST['userid']);
	$artistMsg = $artistObj -> updateArtist();
	
	if($artistMsg == "Artist has been added successfully.")
	{
		header("Location: index.php?action=main");
	}
}
else
{
	$template -> assign_block_vars("page_error",array());
	$template -> assign_block_vars("page_error.action", array());
}
if($action != 'login')
{
	//$template -> assign_block_vars("logout", array());
}

$template->assign_var('NAV',$nav);

include(INCLUDE_PATH."pageend.php");
?>