function showLoading(msg)
{
    $("#loading-overlay").show();
    $("#loading-msg").text(msg);
    $("#loading").show();   
}
function hideLoading()
{
    $("#loading").hide();
    $("#loading-overlay").hide();
}   
function showRequest(formData, jqForm, options) { 
    var queryString = $.param(formData); 
    showLoading(); 
    return true; 
} 	
function swap(){this.className="msieFix";}
function swapBack(){this.className="trigger";}
function toggle(){(this.parentNode.className=="trigger")?this.parentNode.className="msieFix":this.parentNode
.className="trigger";return true;}
function reveal(){
this.parentNode.parentNode.parentNode.className="msieFix";
}
function cleanUp(){
	var zA;
	var LI = document.getElementsByTagName("li");
	var zLI= LI.length;
		for(var k=0;k<zLI;k++){
		if(LI[k]!=this.parentNode){
		LI[k].className="trigger";
		}
	}	
}
function TJK_keyBoardDropDown(){// v1.2.1 Copyright (c) 2006 TJKDesign - Thierry Koblentz
	var LI = document.getElementById('TJK_dropDownMenu').getElementsByTagName("li");
	var zLI= LI.length;
	if (document.getElementById){	
		for(var k=0;k<zLI;k++){
			if(LI[k].id){
				LI[k].className="trigger";
				//LI[k].firstChild.onclick=toggle;
				LI[k].firstChild.title="show/hide the sub-menu";				
				LI[k].firstChild.onfocus=cleanUp;
			}
			if(LI[k].className=="trigger"){
				LI[k].onmouseover=swap;
				LI[k].onmouseout=swapBack;
			}
			if(!LI[k].id){
				LI[k].firstChild.onfocus=reveal;
			}
		}
	}
}
function onAfter() {
    $('#picTitle').html("<a href='"+this.href+"'>"+this.childNodes[0].alt+"</a>")
	$('#picSub').html(this.childNodes[0].title);
	$('#pic-data').slideDown('slow');
}
function onBefore() {
	$('#pic-data').slideUp('fast');

}
function LoginResponse(responseText, statusText)  { 
    if(responseText.errors.length>0) 
    {
        $("#output1").setTemplateElement("errorTMP");
        $("#output1").processTemplate(responseText);
        hideLoading();
    }
    else 
    {
        //alert("successful login");
        $("#output1").html("");
        $('#loginBox').slideUp('slow');
        $('#logindisplay').html('Welcome, <b>'+responseText.username+'</b>. <a href="/account/signout/">Sign Out.</a>');
        isAuthenticated = true;
        hideLoading();   
    }
} 
var options = { 
	target:        '#output1',   // target element(s) to be updated with server response 
	beforeSubmit:  showRequest,  // pre-submit callback 
	success:       LoginResponse,  // post-submit callback 
	dataType:       'json'
};  
$(document).ready(function(){							   
	$('div.round-me').corner();
	$('div.round-inner').corner("bottom");	
	TJK_keyBoardDropDown();
});
