// JavaScript Document
 
var $j = jQuery.noConflict();


// my Feedback Form
function showFeedbackBox() {
	//document.getElementById("feedbackForm").style.display = "block";
	$j('#feedbackForm').slideDown('slow');
	$j('#feedbackLinkPlus').css('display', 'none');
	$j('#feedbackLinkMinus').css('display', 'block');
};

function hideFeedbackBox() {
	$j('#feedbackForm').css('display', 'none');
	//new Effect.SwitchOff('feedbackForm');
	
	$j('#feedbackLinkMinus').css('display', 'none');
	$j('#feedbackLinkPlus').css('display', 'block');
	$j('form')[0].reset();
	
} 

// FEEDBACK SUBMIT
// thank you function
function thankyou() {
	$j('#thanks').css('display', 'inline');
	$j("#thanks").animate({ 
							right: "50",
        					opacity: 0.0
        				   }, 
						   1200 );
}
// SUBMIT
function submitForm() {
	 $('feedbackForm').request("email.php",
					 {
						 method: 'post',
						 postBody: 'fbText='+ $F('fbText')
					 });
	hideFeedbackBox();
	thankyou();
}
// END FEEDBACK FORM

// CONTACT FORM SUBMIT 
function submitContact() {
	 $('contactForm').request("contact.php",
					 {
						 method: 'post',
						 postBody: 'message='+ $F('message')
						 
					 });
	 $j('#main').html("<h3>Contact Form Submitted!</h3>")
        .append("<p>We will be in touch soon.</p>")
        .fadeIn(1500);
}
// back Home Button
function hideHome() {
	$('home-tag').style.visibility = 'hidden';
}
function showHome() {
	$('home-tag').style.cursor = 'pointer';
	$('home-tag').style.visibility = 'visible';
}

function homeBtn() {
	new Ajax.Updater('home', 'home-tag.html', {	method: 'get'} );
}

///////////////////////////////////////////////////////////////////////////////////////////////
// openPage(page)
// ==============
// 
// Called from the SWF file and loads the initial html for each area
// page can be one of 'portfolio', 'services', or 'about'
//////////////////////////////////////////////////////////////////////////////////////////////

function openPage(page) {
	new Ajax.Updater('container', page + '.html',	{	method: 'get', asynchronous: false}  );
	switch (page) {
		case "portfolio": 
			openPortfolio('webdesign','DoSportsEasy'); 
			break;
		case "about": 
			break;
		default:
			break;
	}	
	showHome();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// openPortfolio (chapter, project)
// ================================
//  
// called when page is first open (with openPage, see above) OR when the menu item is clicked on the left nav bar
// It opens the given chapter and all its thumbnails, and the given project within the chapter
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function openPortfolio(portfolioChapter, Project) {
	new Ajax.Updater('main', 'portfolio/' + portfolioChapter + '/thumbs.html', 
									{	method: 'get', 
										evalScripts:true,
										asynchronous: false
									}
							  );
	updateCurrentMenu(portfolioChapter);
	openProject(portfolioChapter, Project);
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// updateCurrentMenu(chapter)
// ==========================
//
// first clears the class 'current' from all elements having a 'nav' class. 
// Then, stick the 'current' class in the element that has an ID like the chapter argument.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
function updateCurrentMenu(chapter)
{	
	$j('.nav').removeClass("current");
	$j("#"+chapter).addClass("current");
}


function openProject(portfolioChapter, Project) {
	new Ajax.Updater('projectBox', 'portfolio/' + portfolioChapter + '/' + Project + '.html',
									{asynchronous: false, method: 'get', evalScripts: true});
	updateCurrentThumb(Project);
}


function updateCurrentThumb(Project)
{
	$('projects').childElements().each(function(el)
		{
			el.removeClassName("current");
		});
	
	$(Project).addClassName("current");
}



// Begin Open Project functions
function openService(section){
	$j('#main').load('services/' + section + '.html');
	updateCurrentMenu(section);
}

// resize Preview Pics

function resizePrev() {
	document.getElementById("prev").style.height = (document.body.clientHeight - 100) * 0.9;
}


// Article loading
function openArticle(section) {
$j('#main').load('services/' + section + '.html');
return false;
}