/////////////////////////////////////////////////////////////////////////////
// SETUP EFFECTS -> JUST GETTING THE BASICS READY
/////////////////////////////////////////////////////////////////////////////

function setupEffects(){

	$("ul.projects li").hover(function() { //On hover...

		var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
		//Set a background image(thumbOver) on the <a> tag - Set position to bottom
		$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
		//Animate the image to 0 opacity (fade it out)
		$(this).find("span").stop().fadeTo(750, 0 , function() {
			$(this).hide() //Hide the image after fade
		});
		} , function() { //on hover out...
		//Fade the image to full opacity 
		$(this).find("span").stop().fadeTo(750, 1).show();
	});

	// fade out the footer and content at load
	$("#container").fadeOut(0);
		//	$("#footer").fadeOut(0);
	
	// at 500ms run the 1 second fade in of the footer and main content
	$(this).oneTime(500, function() {
		$("#container").fadeIn(1500);
			
		// SiFR Font Replacement - Flash Fonts
		fontReplacement();
		
		//  The image gallery for project views
		$("#slideList").slideView({
			easeFunc: "easeOutQuart",
			easeTime: 750
		});
	});

	// slide the networking icons up and down on hover
	$("ul.listSocial li").hover(
		function() {
			$(this).animate({backgroundColor: '#555555', 'margin-top': '-5px'}, 'fast');
		},
		function() {
			$(this).animate({backgroundColor: '#111111', 'margin-top': '0px'}, 'fast');
		}
	);

	// Add drop shadow to all panel elements
	$('.panel').addClass('shadow0');

	// Navigation Simple hover
	$("ul.navBar li a").hover(
		function() {
			$(this).animate({color: '#E4E4E4'}, 300);
		}, 
		function () {
			$(this).animate({color: '#999999'}, 300);
		}
	);

	// swap out shadow class on hover and back afterwards
	$(".panel").hover(
		function(){
			$(this).switchClass('shadow0', 'shadow1', 2000);
		},
		function(){
			$(this).switchClass('shadow1', 'shadow0', 2000);
		}
	);


	// CONTACT FORM AJAX SUBMISSION - PREVFNT REDIRECT FOR EMAILS
		//	$("#contactForm").validate();	
	$('#contactForm').ajaxForm({ 
        beforeSubmit:  contactValidation,  // pre-submit callback 
        success:       contactSuccess  // post-submit callback 
    });
}

function contactValidation() {
	var options = { 
        target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
    }; 

	$('#myForm1').ajaxForm(options);
}

function contactSuccess() {
	$("#contactForm").hide();
	$("#contactThanks").show();
}
function showRequest(formData, jqForm, options) { 
    var queryString = $.param(formData); 
    alert('About to submit: \n\n' + queryString); 
    return true; 
} 
function showResponse(responseText, statusText, xhr, $form)  { 
	$("#contactForm").hide();
	$("#contactThanks").show();
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
        '\n\nThe output div should have already been updated with the responseText.'); 
} 




/////////////////////////////////////////////////////////////////////////////
// SETUP EFFECTS -> JUST GETTING THE BASICS READY
/////////////////////////////////////////////////////////////////////////////



function contactValues(test) {
	if(test == 'cName') {
		if( $(":input[name=fName]").val() == 'Name:'){
			$(":input[name=fName]").val('');
		}
	} else if(test == 'cEmail') {
		if( $(":input[name=fEmail]").val() == 'Email:'){
			$(":input[name=fEmail]").val('');
		}
	} else if(test == 'cMessage') {
		if( $(":input[name=fMessage]").val() == 'Message:'){
			$(":input[name=fMessage]").val('');
		}
	}
}


function checkContact() {
	if($(":input[name=fName]").val() == ''){
		$(":input[name=fName]").val('Name:');
	} 
	if ($(":input[name=fEmail]").val() == ''){
		$(":input[name=fEmail]").val('Email:');
	}
	if ($(":input[name=fMessage]").val() == ''){
		$(":input[name=fMessage]").val('Message:');
	}
}

/////////////////////////////////////////////////////////////////////////////
// SIFR - USES FLASH AND JAVASCRIPT TO ENABLE ANY FONT ON A PAGE -> DEGRADES NICELY TOO
/////////////////////////////////////////////////////////////////////////////

function fontReplacement() {
	var rockwell = {
	  src: '/assets/sifr3/demo/rockwell.swf',
	  selectable: false
	};
	
	sIFR.activate(rockwell);

	sIFR.replace(rockwell, {
		selector: '.fontReplace',
		css: [ '.sIFR-root {color: #FFFFFF; }, a {color: #82D4F7; text-decoration: none; font-weight: bold;}, a:hover {color: #44bEF0; text-decoration: none; border: none; outline: none;}' ],
		wmode: 'transparent'
	});

	sIFR.replace(rockwell, {
		selector: 'h3.fontReplace',
		css: [ '.sIFR-root {color: #FFFFFF; }, a {color: #82D4F7; text-decoration: none; font-weight: normal;}, a:hover {color: #44bEF0; text-decoration: none; border: none; outline: none;}' ],
		wmode: 'transparent'
	});

}

/////////////////////////////////////////////////////////////////////////////
// USER LOGIN -> TOGGLES VISIBILITY OF LOGIN & CREATE ACCOUNT
/////////////////////////////////////////////////////////////////////////////

function moduleLogin() {
	$(".existingAccount").show();
		$(".existingAccount :input").addClass('required');
	$(".createAccount").hide();
		$(".createAccount :input").removeClass('required');
}

function moduleLoginToggle(curValue) {
	if(curValue == true) {
		$(".existingAccount").show();
		$(".existingAccount :input").addClass('required');
		
		$(".createAccount").hide();
		$(".createAccount :input").removeClass('required');
	}
	else if (curValue == false) {
		$(".existingAccount").hide();
		$(".existingAccount :input").removeClass('required');
		
		$(".createAccount").show();
		$(".createAccount :input").addClass('required');
		fontReplacement();
	}
}

/////////////////////////////////////////////////////////////////////////////
// END || CUSTOM
/////////////////////////////////////////////////////////////////////////////