/*
  wt2 - Content Management System
  @author David Lemarier <david@wasabitechnologie.a>
  @date November 18, 2009
  @version 1.0
  
  www.wasabitechnologie.ca
*/


$(document).ready(function(){

});

function switchMenu(alias) {
  $('.bkg_menu_gauche').slideUp('slow',function() {         
    $.get("index.php", { m: 'submenu', page_alias: alias},
            function(data){
                $('.bkg_menu_gauche').html(data);
                $('.bkg_menu_gauche').slideDown('slow');
            }
        );
  });
}   

function switchBackMenu() {
  $('.bkg_menu_gauche').slideUp('slow',function() {         
    $.get("index.php", { m: 'submenu', action: 'reset'},
            function(data){
                $('.bkg_menu_gauche').html(data);
                $('.bkg_menu_gauche').slideDown('slow');
            }
        );
  });
}    

function switchFooterMenu(alias) {
  $('.footer_link').hide("slide", { direction: "up" }, 500, function() {      
    $.get("index.php", { m: 'submenu', action: 'footer', page_alias: alias},
            function(data){
                $('.footer_link').html(data);
            }
        );
    $('.footer_link').show("slide", { direction: "up" }, 500);
  });
} 

function switchBackFooterMenu() {
  $('.footer_link').hide("slide", { direction: "down" }, 500, function() {      
    $.get("index.php", { m: 'submenu', action: 'reset_footer'},
            function(data){
                $('.footer_link').html(data);
            }
        );
    $('.footer_link').show("slide", { direction: "down" }, 500);
  });
}   

 
/*
  NEWS
*/	
function popItUp(url) {
  newwindow=window.open(url,'name','height=560,width=680,scrollbars=yes');
  if (window.focus) {newwindow.focus()}
}

/*
  FORUM
*/	
function verifyAgree() {

	if (!document.forms.register.regagree.checked) {
		alert("Veuillez accepter les politiques d'utilisation.");
		return false;
	}

	return true;
}

function checkAgree() {
	document.forms.register.regSubmit.disabled = isEmptyText(document.forms.register.user) || isEmptyText(document.forms.register.email) || !document.forms.register.regagree.checked;
	setTimeout("checkAgree();", 1000);
}

function isEmptyText(theField) {
	var theValue = theField.value;
	while (theValue.length > 0 && (theValue.charAt(0) == ' ' || theValue.charAt(0) == '\t'))
		theValue = theValue.substring(1, theValue.length);
	while (theValue.length > 0 && (theValue.charAt(theValue.length - 1) == ' ' || theValue.charAt(theValue.length - 1) == '\t'))
		theValue = theValue.substring(0, theValue.length - 1);
	if (theValue == '')
		return true;
	else
		return false;
}





