<?php

define("PAGE_USES_FACEBOX",true);
include_once("includes/header.php");


require_once("includes/classes/Commenter.inc.php");
$Commenter['senator'] = new Commenter(38,$user_data);
$Commenter['party'] = new Commenter(18,$user_data);
$Commenter['years_in_office'] = new Commenter(20,$user_data);
$Commenter['committees'] = new Commenter(22,$user_data);
$Commenter['address'] = new Commenter(24,$user_data);
$Commenter['url'] = new Commenter(26,$user_data);
$Commenter['youtube_url'] = new Commenter(36,$user_data);
$Commenter['twitter_url'] = new Commenter(34,$user_data);
$Commenter['words'] = new Commenter(40,$user_data);
$Commenter['email'] = new Commenter(45,$user_data);


require_once("includes/classes/CongressPerson.inc.php");
$CongressPerson = new CongressPerson($user_data['state']);



$representative = $CongressPerson->getSenator(0); //Get first senator

?>



<div id="representative" class="senator-one">
	<h2>
		<?=$representative['first_name'].' '.$representative['middle_name'].' '.$representative['last_name'];?> 
		<?php
			if(strlen($representative['party_abbreviated'])>0)
				echo "(".$representative['party_abbreviated'].")";
		?>
		<?=$Commenter['senator']->getLink();?></h2>
	</h2>
	<?=$Commenter['senator']->getSupportingHTML();?>
	<div>
		<?php
		//Check to make sure the file exists on this server, otherwise, fetch copy from govtrack.use
		if((int)curl_get_header('http://'.$_SERVER['SERVER_NAME'].'/assets/photos/'.$representative['gov_track_ID']."-200px.jpeg")==200){
		?>
			<img src="assets/photos/<?=$representative['gov_track_ID'];?>-200px.jpeg" id="photo" width="200" height="244">
		<?php
		}
		else{
		?>
			<img src="http://www.govtrack.us/data/photos/<?=$representative['gov_track_ID'];?>-200px.jpeg" id="photo" width="200" height="244">		
		<?php
		}
		?>


		<h3>Political Party<?=$Commenter['party']->getLink();?></h3><?=$Commenter['party']->getSupportingHTML();?>
		<P>
			<?=$representative['party'];?>
		</P>
		

		<h3>Year of Original Election</h3>
		<p>
			<?=date("Y",$representative['startTS']);?>
		</p>

		<h3>Year of Next Election</h3>
		<p>
			<?=date("Y",$representative['endTS']);?>
		</p>
		
		<h3>Years in Office<?=$Commenter['years_in_office']->getLink();?></h3><?=$Commenter['years_in_office']->getSupportingHTML();?>
		<p>
			<?=$representative['yearsInOffice'];?>
		</p>		
		
		<h3>Committees<?=$Commenter['committees']->getLink();?></h3><?=$Commenter['committees']->getSupportingHTML();?>
		<ul id="committees">
			<?php
			
			foreach($representative['committees'] as $committee){
				?>
					<li><?=$committee;?></li>
				<?php
			}
			?>
		</ul>


		<h3>Address<?=$Commenter['address']->getLink();?></h3><?=$Commenter['address']->getSupportingHTML();?>
		<p>
			<?=$representative['congress_office_address'];?><br/>
			Washington, D.C.
		</p>
		
		<h3>Senate Phone #</h3>
		<p>
			<input type="text" value="<?=phone_integer_to_string($representative['phone']);?>">
		</p>

		<?php
		if(strlen($representative['email'])>4){
		?>
			<h3>Official Email Address<?=$Commenter['email']->getLink();?></h3><?=$Commenter['email']->getSupportingHTML();?>
			<p>
				<input type="text" value="<?=$representative['email'];?>">
			</p>	
		<?php
		}
		?>
		
		<h3>Official RSS Feed</h3>
		<p>
			<input type="text" value="<?php
				if(strlen($representative['official_rss_url'])>1)
					print $representative['official_rss_url'];
				else
					print "No RSS feed available.";
			?>">
		
		</p>
		
		
		<h3>Official URL<?=$Commenter['url']->getLink();?></h3><?=$Commenter['url']->getSupportingHTML();?>
		<p>
			<input type="text" value="<?=$representative['official_url'];?>">
		</p>
		
		
		
		<h3>Contact Form URL</h3>
		<p>
			<input type="text" value="<?=$representative['contact_form_url'];?>">
		</p>
		
		
		<h3>Twitter URL<?=$Commenter['twitter_url']->getLink();?></h3><?=$Commenter['twitter_url']->getSupportingHTML();?>
		<p>
			<input type="text" value="<?php
			
			if(strlen($representative['twitter_ID'])>1)
				print "http://www.twitter.com/".$representative['twitter_ID'];
			else
				print "Not on Twitter.";
			?>">
		</p>
		
		
		<h3>Youtube URL<?=$Commenter['youtube_url']->getLink();?></h3><?=$Commenter['youtube_url']->getSupportingHTML();?>
		<p>
			<input type="text" value="<?php
			if(strlen($representative['youtube_url'])>1)
				print $representative['youtube_url'];
			else
				print "Not on Youtube.";
			?>">
		</p>
	

		<?php
		include_once("includes/classes/CapitolWords.inc.php");
		$CapitolWords = new CapitolWords($representative['gov_track_ID'],20);
		?>
		
		<h3><?=date("Y");?> Most Spoken Words
			<?=$Commenter['words']->getLink();?>
		</h3>
		<?=$Commenter['words']->getSupportingHTML();?>

		<table cellspacing="0" class="words">
			<thead>
				<tr>
					<th style="text-align:left">Word</th>
					<th style="text-align:right">Times Spoken in Congress</th>
				</tr>
			</thead>
			<tbody>
			<?php
			foreach($CapitolWords->words as $word=>$word_count){
			?>
			<tr>
				<td><?=ucfirst($word);?></td>
				<td style='text-align:right'><?=$word_count;?></td>
			</tr>
			<?php
			
			}
			?>
			</tbody>
		</table>
		

		<p>
		
			This information was sourced from <a href="about_data.php">CapitolWords</a> and is current as of today.
		
		</p>


			
	</div>


	

</div>



<?php

$Commenter['senator'] = new Commenter(39,$user_data);
$Commenter['party'] = new Commenter(19,$user_data);
$Commenter['years_in_office'] = new Commenter(21,$user_data);
$Commenter['committees'] = new Commenter(23,$user_data);
$Commenter['address'] = new Commenter(25,$user_data);
$Commenter['url'] = new Commenter(27,$user_data);
$Commenter['youtube_url'] = new Commenter(37,$user_data);
$Commenter['twitter_url'] = new Commenter(35,$user_data);
$Commenter['words'] = new Commenter(41,$user_data);
$Commenter['email'] = new Commenter(46,$user_data);



$representative = $CongressPerson->getSenator(1); //Get second senator

?>



<div id="representative" class="senator-two">
	<h2>
		<?=$representative['first_name'].' '.$representative['middle_name'].' '.$representative['last_name'];?> 
		<?php
			if(strlen($representative['party_abbreviated'])>0)
				echo "(".$representative['party_abbreviated'].")";
		?>
		<?=$Commenter['senator']->getLink();?></h2>
	</h2>
	<?=$Commenter['senator']->getSupportingHTML();?>
	<div>
	<?php
		//Check to make sure the file exists on this server, otherwise, fetch copy from govtrack.use
		if((int)curl_get_header('http://'.$_SERVER['SERVER_NAME'].'/assets/photos/'.$representative['gov_track_ID']."-200px.jpeg")==200){
		?>
			<img src="assets/photos/<?=$representative['gov_track_ID'];?>-200px.jpeg" id="photo" width="200" height="244">
		<?php
		}
		else{
		?>
			<img src="http://www.govtrack.us/data/photos/<?=$representative['gov_track_ID'];?>-200px.jpeg" id="photo" width="200" height="244">		
		<?php
		}
		?>



		<h3>Political Party<?=$Commenter['party']->getLink();?></h3><?=$Commenter['party']->getSupportingHTML();?>
		<P>
			<?=$representative['party'];?>
		</P>
		

		<h3>Year of Original Election</h3>
		<p>
			<?=date("Y",$representative['startTS']);?>
		</p>

		<h3>Year of Next Election</h3>
		<p>
			<?=date("Y",$representative['endTS']);?>
		</p>
		
		<h3>Years in Office<?=$Commenter['years_in_office']->getLink();?></h3><?=$Commenter['years_in_office']->getSupportingHTML();?>
		<p>
			<?=$representative['yearsInOffice'];?>
		</p>
		
		
		<h3>Committees<?=$Commenter['committees']->getLink();?></h3><?=$Commenter['committees']->getSupportingHTML();?>
		<ul id="committees">
			<?php
			
			foreach($representative['committees'] as $committee){
				?>
					<li><?=$committee;?></li>
				<?php
			}
			?>
		</ul>


		<h3>Address<?=$Commenter['address']->getLink();?></h3><?=$Commenter['address']->getSupportingHTML();?>
		<p>
			<?=$representative['congress_office_address'];?><br/>
			Washington, D.C.
		</p>
		
		<h3>Senate Phone #</h3>
		<p>
			<input type="text" value="<?=phone_integer_to_string($representative['phone']);?>">
		</p>		
		
		<?php
		if(strlen($representative['email'])>4){
		?>
			<h3>Official Email Address<?=$Commenter['email']->getLink();?></h3><?=$Commenter['email']->getSupportingHTML();?>
			<p>
				<input type="text" value="<?=$representative['email'];?>">
			</p>	
		<?php
		}
		?>	


		<h3>Official RSS Feed</h3>
		<p>
			<input type="text" value="<?php
				if(strlen($representative['official_rss_url'])>1)
					print $representative['official_rss_url'];
				else
					print "No RSS feed available.";
			?>">
		
		</p>
		
		
		<h3>Official URL<?=$Commenter['url']->getLink();?></h3><?=$Commenter['url']->getSupportingHTML();?>
		<p>
			<input type="text" value="<?=$representative['official_url'];?>">
		</p>
		
		
		
		<h3>Contact Form URL</h3>
		<p>
			<input type="text" value="<?=$representative['contact_form_url'];?>">
		</p>
		
		
		<h3>Twitter URL<?=$Commenter['twitter_url']->getLink();?></h3><?=$Commenter['twitter_url']->getSupportingHTML();?>
		<p>
			<input type="text" value="<?php
			
			if(strlen($representative['twitter_ID'])>1)
				print "http://www.twitter.com/".$representative['twitter_ID'];
			else
				print "Not on Twitter.";
			?>">
		</p>
		
		
		<h3>Youtube URL<?=$Commenter['youtube_url']->getLink();?></h3><?=$Commenter['youtube_url']->getSupportingHTML();?>
		<p>
			<input type="text" value="<?php
			if(strlen($representative['youtube_url'])>1)
				print $representative['youtube_url'];
			else
				print "Not on Youtube.";
			?>">
		</p>
	

		<?php
		include_once("includes/classes/CapitolWords.inc.php");
		$CapitolWords = new CapitolWords($representative['gov_track_ID'],20);
		?>
		
		<h3><?=date("Y");?> Most Spoken Words
			<?=$Commenter['words']->getLink();?>
		</h3>
		<?=$Commenter['words']->getSupportingHTML();?>

		<table cellspacing="0" class="words">
			<thead>
				<tr>
					<th style="text-align:left">Word</th>
					<th style="text-align:right">Times Spoken in Congress</th>
				</tr>
			</thead>
			<tbody>
			<?php
			foreach($CapitolWords->words as $word=>$word_count){
			?>
			<tr>
				<td><?=ucfirst($word);?></td>
				<td style='text-align:right'><?=$word_count;?></td>
			</tr>
			<?php
			
			}
			?>
			</tbody>
		</table>
		
		<script type="text/javascript">
			/* Table Striping */
			$('table.words tbody tr:odd').css({'background-color' : '#f2f8ff'});
		</script>

		<p>
		
			This information was sourced from <a href="about_data.php">CapitolWords</a> and is current as of today.
		
		</p>


			
	</div>


	

</div>



<?php

include_once("includes/footer.php");

?>