function toggleUsrLoginBox()
{
	if ($('.usrLoginBox').length) 
	{
		$('a.usrLoginBox').click(function() 
		{
			if ( $.browser.msie && $.browser.version == '6.0' ) {
				
				$('#usrLoginBox').show();
				
			} else {
				
				$('#usrLoginBox').slideToggle("slow");
			}
			
			return false;
		});
	}
}

function setDirectEmail() 
{
	if ($('#toggleDirectEmail').length)
	{
		if ($('.sysMsg:visible, .errMsg:visible').length) { $('#directEmail').show(); }
		$('#toggleDirectEmail').click(function(){ $('#directEmail').slideToggle('slow'); return false; });
		$('#def_submit').click(function(){ return def_validate(); });
	}
}

function def_validate()
{
	var ok = false,
		errMsg = 'Please, fill in all mandatory fields.',
		inpName = $('#def_name').val().length,
		inpEmail = $('#def_email').val().length,
		attachment = $('#def_attachment').val().length;
		
	if(inpName>1 && inpEmail>6 && attachment>4) { ok = true; } else { alert( errMsg); }
	
	return ok;
}

$(document).ready(function() 
{
	$('#slideshow').jqFancyTransitions({ width: 438, height: 178 });
	
	toggleUsrLoginBox();
	
	setDirectEmail();
	
	// Expand Panel
	$("#open").click(function(){ $("div#panel").slideDown("slow"); });	
	
	// Collapse Panel
	$("#close").click(function(){ $("div#panel").slideUp("slow"); });		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function(){ $("#toggle a").toggle(); return false; });
	
	// IE6 Select Box z-index Bug
	if ( $.browser.msie && $.browser.version == '6.0' ) { $('#toppanel').bgiframe(); }
	
});
