function login()
{
	var security = new SpringBoard.Security();
	
	var UserName = document.getElementById("txtUserName");
	var Password = document.getElementById("txtPassword");
	
	security.UserLogin(UserName.value, Password.value, UserLogin_CallBack);
}

function UserLogin_CallBack(succes)
{
	var url = "/dealer/home-1.aspx";
	if (board_culture == "fr-CA")
		url = "/dealerfr/accueil-1.aspx";
	if (succes)
		document.location = url;		
	else
		alert(SBPhrases["LGN_BADPASS"]);	
}

function logout()
{
	var security = new SpringBoard.Security();	

	security.UserLogout();
	document.location = "/";	
}

function submitenter(myfield,e) {         

	var keycode;         

	if (window.event) 
		keycode = window.event.keyCode; 
	else if (e) keycode = e.which; 
	else return true;          

	if (keycode == 13) { 
		login();
		return false;  
	} 
	else
		return true;     
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

var lastFaded;
function showMnu(index)
{
	if (lastFaded != index)
	{
 		$(".tab-panel-selected").hide();
 		$(".tab-panel-selected").removeClass("tab-panel-selected");
 		$(".tab-selected").removeClass("tab-selected");
 		$("#tab-" + index).addClass("tab-selected");	 		
 		$("#tab-panel-" + index).fadeIn("fast");
 		$("#tab-panel-" + index).addClass("tab-panel-selected");	 		
				
		lastFaded = index;
	}
}
