$(function() {


	var project_jump = jQuery.url.attr("anchor");
	var project_title = $("[href*="+ project_jump +"]").children().html();
	var pic_loaded;
	
	//Cached variables
	var p_web_list 			= $('#p_web_list');
	var p_print_list 		= $('#p_print_list');
	var p_photos_list 		= $('#p_photos_list');
	var port_left_menu 		= $('#port_left_menu'); // dd
	var portfolio_meta 		= $('#portfolio_meta');
	var port_top_menu_h2 	= $('#port_top_menu h2');
	var port_img 			= $('#port_img');
	var port_img_img  		= $('#port_img img');
	var flickr_photos 		= $('#flickr_photos');
	var class_port_hit		= $("[class*=port_hit]");
	var li_p_web			= $("li#p_web");
	var li_p_photos			= $("li#p_photos");
	
	
	if (project_jump !== null) { 
		$("[class*=port_left_hit]").removeClass('port_left_hit');
		$("[href*="+ project_jump +"]").addClass('port_left_hit');
		web_switch('#'+ project_jump, project_title); 
	} else {
		web_switch('#hearthstone', 'The Hearthstone Bistro'); 
	}
	
	$('#p_web_list').show();

/* 
      Web
*/
	 
	 	li_p_web.click(function() {
	 		
	 		p_web_list.show();
	 		p_print_list.hide();
	 		p_photos_list.hide();
	 		port_left_menu.show();
	 		portfolio_meta.show();
	 		port_img.css('display','block');
	 		flickr_photos.css('display','none');
	 		port_top_menu_h2.css('visibility','visible');
			$(this).addClass('port_hit');
			li_p_photos.removeClass('port_hit');	 	
	 	});
	 	
	 			
		
	 	
/* 
     Photos
*/
	 	li_p_photos.click(function() {
	 		p_web_list.hide();
	 		p_print_list.hide();
	 		port_left_menu.hide();
	 		port_top_menu_h2.css('visibility','hidden');
	 		portfolio_meta.hide();
	 		port_img.css('display','none');
	 		li_p_web.removeClass('port_hit');
			$(this).addClass('port_hit');	
	 		if(pic_loaded !== 1) {
	 			$('#portfolio_load').fadeIn('fast');
				$.ajax({
					type: "GET",
					url: "/flickr.php",
					success: function(wow_list) {
					$('#portfolio_load').fadeOut('fast');
					flickr_photos.html(wow_list).hide().fadeIn('slow');
					pic_loaded = 1; 
					
					$("a.zoom").fancybox();

					$("a.zoom1").fancybox({
						'overlayOpacity'	:	0.7,
						'overlayColor'		:	'#000'
					});
		
					$("a.zoom2").fancybox({
						'zoomSpeedIn'		:	500,
						'zoomSpeedOut'		:	500,
						'overlayShow'		:	false
					});

					                
				}	
        }); 
			} else {
				flickr_photos.css('display','block');
			}
  
 });
 


	$('#port_left_menu li a').click(function(){
	
		var p_title = $(this).children().html(); 
		
		
			if ($(this).attr('class') !== 'port_left_hit') { 
			
					$('#port_left_menu li a').removeClass('port_left_hit');
					port_img_img.hide();
					web_switch($(this).attr('href'), p_title); 
					$(this).addClass('port_left_hit');
			}
		
	});
	


/* 
     AJAX
*/

function ajax_switch(a_url,a_site,a_client,a_industry,a_description) {
	
	//Cached Vars..
	var visit_link_a	= $('.visit_link a');
	var pm_client 		= $('#pm_client');
	var pm_industry 	= $('#pm_industry');
	var pm_description 	= $('#pm_description');
	var portfolio_load 	= $('#portfolio_load');
	var port_thumb_link = $('a#port_thumb_link');
	port_thumb_link.removeAttr('target');
			
			if (a_site !== 'javascript:void(0)')  { 
				port_thumb_link.attr('target','_blank');
                               $('.visit_link').show();
			} else {
                          $('.visit_link').fadeOut();
                        }
			
			port_thumb_link.attr('href',''+a_site+'');
	if(ie_blows == 0) {
	
		$.Tache.Get({
			  url: ""+a_url+"",
			  cache: true,
			  success: function(html){
				port_img_img.attr('src',''+a_url+'');
				visit_link_a.attr('href',''+a_site+'');
				pm_client.next('dd').html(''+a_client+'');
				pm_industry.next('dd').html(''+a_industry+'');
				pm_description.next('dd').html(""+a_description+"");
				portfolio_load.hide();
			  }
		});
		
	} else {	
				//Because IE doesn't play nice....
				port_img_img.attr('src',''+a_url+'');
				visit_link_a.attr('href',''+a_site+'');
				pm_client.next('dd').html(''+a_client+'');
				pm_industry.next('dd').html(''+a_industry+'');
				pm_description.next('dd').html(""+a_description+"");
				portfolio_load.hide();

	}
}

	
	
function web_switch(p_item, p_title) {
	port_top_menu_h2.hide();
	port_top_menu_h2.html(p_title);
	port_top_menu_h2.fadeIn();
	$('#portfolio_load').fadeIn('fast');
	port_img_img.attr('src','/images/screens/load.jpg');



// Web Project Info... this is intentially in JS to prevent search engine indexing

	 switch(p_item) {
	 		
	 	case '#hearthstone':
			
			
				var a_url    		= '/images/screens/hstone.jpg';
				var a_site    		= 'http://www.hstonesoup.com';
				var a_client 		= 'The Hearthstone Bistro <span class="project_class">&nbsp;&nbsp;[freelance]</span>';
				var a_industry 		= 'Restaurant';
				var a_description 	= "<p>The Hearthstone Bistro has been a Western Michigan landmark since 1975. Serving classic and new world French, Italian and American cuisine, this award winning restaurant has received media attention both regionally and nationally.</p><p>An ongoing project since 1999, The Hearthstone Bistro's current website was built with Drupal CMS and a custom PHP interface for daily food special and twitter updates. Since receiving a design overhaul and the launch of a social media campaign in 2008, The Hearthstone has seen traffic increase by nearly 300%, grew their email newsletter membership by over 250% and is consistently ranked at the top of nearly all leading community driven food / travel websites for the greater Muskegon, MI area.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);			
			

	 		break;
	 		
	 	case '#burlaw':


				var a_url    		= '/images/screens/burlaw.jpg';
				var a_site    		= 'http://www.burlaw.com';
				var a_client 		= 'Judd Burstein, P.C. <span class="project_class">&nbsp;&nbsp;[freelance]</span>';
				var a_industry 		= 'Legal Services';
				var a_description 	= "<p>Judd Burstein, P.C. is a Boutique litigation firm based in New York, NY servicing many high profile and celebrity clients such as Oscar de La Hoya, Lisa Marie, Donald Trump, The Backstreet Boys and Don King.</p><p>This project was developed in PHP using Code Igniter MVC Framework to create a powerful, yet simple to use content management system. The design features bold, vibrant colors to express the fiery, passionate and aggressive reputation that the firm has earned in the legal community. Going from a basic flash site which some users found difficult to navigate and confusing, click paths were shortened and information pertaining to current events is automatically promoted to the bottom of every page.</p><p>The backend content management tool is enhanced by jQuery and AJAX to create a simple user experience requiring no more than two clicks per action.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);			
	
			
	 		break;
	 
	 	case '#johnjay':
	 			
	 
				var a_url    		= '/images/screens/jjay.jpg';
				var a_site    		= 'http://bit.ly/otym0';
				var a_client 		= 'John Jay College of Criminal Justice <span class="project_class">&nbsp;&nbsp;[agency]</span>';
				var a_industry 		= 'Education';
				var a_description 	= "<p>A branch of the City University of New York (CUNY), John Jay College is the only college in the nation founded specifically to study criminal justice and public service.</p><p>This project was built using a combination of RedDot CMS and custom PHP. Serving as lead developer I also created several custom XHTML templates, ran a two day on-site training session and provided project support for the first year of the project.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);			 
	 
	 		break;
	 		
	 	case '#tesc':
	 	
			
				var a_url    		= '/images/screens/tesc.jpg';
				var a_site    		= 'http://bit.ly/cqZIx';
				var a_client 		= 'Thomas Edison State College <span class="project_class">&nbsp;&nbsp;[agency]</span>';
				var a_industry 		= 'Education';
				var a_description 	= "<p>As the Development leader on the project, I implemented RedDot CMS, modernized existing PHP applications and created valid XHTML / CSS templates for the New Jersey based college specializing in distance education. Having worked two years on the project, also provided on-premises and phone consulting, a 100+ page user guide and custom programming.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);	
				 		
	 		break;

	 	case '#ford':
	 		
			
				var a_url    		= '/images/screens/ford.jpg';
				var a_site    		= 'http://bit.ly/AgBJv';
				var a_client 		= 'Ford Club 115 <span class="project_class">&nbsp;&nbsp;[agency]</span>';
				var a_industry 		= 'Automotive';
				var a_description 	= "<p>Website developed for a 2006 Ford Motor Company promotion. Created CSS layout, custom PHP based back-end reporting metrics and registration tools.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);	
	 	
	 		break;
	 		
	 	case '#hyatt':
 	
				var a_site    		= 'javascript:void(0)';
				var a_url    		= '/images/screens/hyatt.jpg';
				var a_client 		= 'Hyatt Classic Residences <span class="project_class">&nbsp;&nbsp;[agency]</span>';
				var a_industry 		= 'Luxury Retirement Community';
				var a_description 	= "<p>CSS and JavaScript consulting</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);
				
				
				
					
	 		break;
	 		
	 	case '#rush': 
			
				var a_url    		= '/images/screens/rush.jpg';
				var a_site    		= 'http://bit.ly/1sYwO';
				var a_client 		= 'Rush Associates Board <span class="project_class">&nbsp;&nbsp;[agency]</span>';
				var a_industry 		= 'Education';
				var a_description 	= "<p>Website for the board of associates at Chicago based Rush University Medical Center. Developed and deployed customized Drupal CMS implementation and XHTML Strict templates.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);	
					
	 		break;
	 		
	 	case '#miami':
			
				var a_url    		= '/images/screens/miami.jpg';
				var a_site    		= 'http://bit.ly/12BpZ1';
				var a_client 		= 'The University of Miami <span class="project_class">&nbsp;&nbsp;[agency]</span>';
				var a_industry 		= 'Education';
				var a_description 	= "<p>Developed 10 valid XHTML Strict, section 508 compliant templates and provided consulting services and a cost-benefit analysis to aid in selection of an article management software to be integrated into existing CMS.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);	
				 		
	 		break;
	 			 		
	 	case '#grunge':
			
				var a_url    		= '/images/screens/gc.jpg';
				var a_site    		= 'javascript:void(0)';
				var a_client 		= 'Grungers Corner <span class="project_class">&nbsp;&nbsp;[personal]</span>';
				var a_industry 		= 'Music';
				var a_description 	= "<p>From 1997 to 2002 I created and managed this popular fan site dedicated to legendary 1990's rock band, Nirvana. Site featured several thousand photos, videos and audio files from the band and featured many interactive content pieces such as a forum, free email addresses and flash-based quizzes.</p><p>Rated as one of the two three Nirvana sites on the internet by many \"Top Website\" lists, the site was also featured in several magazines and was the recipient of numerous design awards.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);	
				
				
	 		break;
	 		
	 	case '#lro':
			
				var a_url    		= '/images/screens/lro.jpg';
				var a_site    		= 'http://www.lakeshoreoriginals.com';
				var a_client 		= 'Lakeshore Restaurant Originals <span class="project_class">&nbsp;&nbsp;[freelance]</span>';
				var a_industry 		= 'Non-Profit, Restaurant';
				var a_description 	= "<p>Website for Non-Profit Restaurant Group based in Western Michigan. Site was created using CodeIgniter MVC Framework and jQuery</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);
				
	 		break;
	 		
	 	case '#bma':
	 		
				var a_url    		= '/images/screens/bma.jpg';
				var a_site    		= 'http://www.artbma.org/campaign/';
				var a_client 		= 'Baltimore Museum of Art: In a New Light <span class="project_class">&nbsp;&nbsp;[agency]</span>';
				var a_industry 		= 'Art';
				var a_description 	= "<p>Campaign for the Baltimore Museum of Art. Created valid XHTML Strict templates.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);
				
	 		break;
	 		
	 		
	 	case '#wmu':
			
				var a_url    		= '/images/screens/ceas.jpg';
				var a_site    		= 'http://www.darkcrimson.com/work/wmich/';
				var a_client 		= 'Western Michigan University College of Engineering and Applied Sciences <span class="project_class">&nbsp;&nbsp;[freelance]</span>';
				var a_industry 		= 'Education';
				var a_description 	= "<p>Website for Western Michigan University's engineering college. I designed, developed and managed the site from 2004-2006 using PHP, JavaScript and CSS. Project required extensive planning with college administrators to focus content on future and current students.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);
				 		
	 		break;
	 		
	 	case '#ajaxcal':

				var a_url    		= '/images/screens/jcal.jpg';
				var a_site    		= 'http://www.darkcrimson.com/client/arlin/calendar';
				var a_client 		= 'N/A <span class="project_class">&nbsp;&nbsp;[freelance]</span>';
				var a_industry 		= 'General';
				var a_description 	= "<p>AJAX powered calendar created as a freelance project. The application is powered on the back end by PHP and MySQL and uses custom AJAX code to display current data, events and future dates in both Gregorian and Hebrew formats.</p>";
				
				ajax_switch(a_url,a_site,a_client,a_industry,a_description);
				
									
	 		break;


		};
		
		port_img_img.fadeIn();
		
	}

});

