function displayFixtureContainer(id){
    $('.fixture_container').hide();
    $('#'+id).show();
}

function competitionRedirect(select){
    if($('#competition').val() != ''){
        window.location.href = '/static/league/index.php?league_id='+$('#competition').val();
    }
}

function teamRedirect(select){
    if($('#teams').val() != ''){
        window.location.href = '/static/teams/index.php?team_id='+$('#teams').val();
    }
}

function postNewsComment(news_id){
    if($("#user_email").val() == ''){
        loginUser();
    }else{
        if(confirm('You are about to submit your comment, are you happy with it?')){
            $.ajax({
                    url: "/static/league/post_comment.php?news_id="+news_id+"&article_comment="+$("#article_comment").val(),
                    cache: false,
                    asynchronous:false,
                    success: function(html){
                        alert(html);
                    }
                });
        }
    }
    return false;
}

function loginUser(){
    var email = prompt('Please supply your Email Address');
    var password = prompt('Please supply your Password');
    var jsonString = $.toJSON({class_name: 'Users', method: 'findUserByEmailPassword', params:[email,password]});

    $.ajax({
            url: "/toolbox/classes/users.class.php",
            type:'POST',
            cache: false,
            asynchronous:false,
            success: function(html){
                        alert(html);
                     }
    });
}

function isValidEmailFormat(value){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!(filter.test(value))) {
		return false;
	}else{
		return true;
	}
}
