/*	var myGlobalHandlers = {
		onCreate: function(){
			Element.show('loading');
		},
			
		onComplete: function() {
			if(Ajax.activeRequestCount == 0){
				Element.hide('loading');
		}
		}
	};

	Ajax.Responders.register(myGlobalHandlers);
*/	
	
function formSubmitter(form)
{
	new Ajax.Updater('contactForm','http://unconfusing.com/includes/emailer.php', {parameters: Form.serialize(form) });
	if (flag)
	{
		$(updateMe).update(
						"<h3>Thank you for contacting us!</h3><p>You will be hearing from us very soon.</p><p><a href='javascript:void(0);' onclick='Modalbox.hide(); return false;'>Back to the site!</a></p>"
						);
	}
	else
	{
		$(updateMe).update(
						"<h3>Oh no!  There's been a problem!</h3><p>Please contact us directly at <a href='mailto:support@unconfusing.com'>support@unconfusing.com</a></p>"
						);
		}
}

function showPortfolioItem(thisun)
{
	$('loading').show();
	new Ajax.Updater('portfolio','http://unconfusing.com/includes/portfolio.php',{parameters: {id: thisun} });	
}

function updater(thePlace,theUpdate)
{
	
	/*
	var contentNode = dojo.byId(thePlace);
	dojo.fadeOut({
		    node: contentNode,
		    onEnd: function(){
			// set the data, fade it back in
			contentNode.innerHTML = theUpdate;
			dojo.fadeIn({ node: contentNode }).play();    
		    }
		}).play();
	*/
	
	
	
	new Effect.Fade(thePlace, {
    duration: 0.5,
    afterFinish: function(){
      $(thePlace).update(theUpdate).Appear( { duration: 0.5 })
    }
  });


}

function login(formname,whereTo)
{
	var contentNode = dojo.byId("message");
	var auth = false;
	
	var xhrArgs = {
        form: dojo.byId(formname),
        handleAs: "text",
		url: urlc+"functions/checkLogin.php",
        load: function(data){
			update("message",data);
			auth = true;
			if (auth == true)
	  		{
		  		setTimeout(window.location.href=whereTo,3000);
		  	}
        },
        error: function(error){
          dojo.byId("message").innerHTML = "<p class='error'>"+error+"</p>";
        }
      }
      //Call the asynchronous xhrPost
      update("message","<p class='loading'>Checking credentials...</p>");
      var deferred = dojo.xhrPost(xhrArgs);
}

