adicionar classe ao elemento especificado

Ok, eu tenho esse código

//start our session
session_start();
//check if there is a page request
if (isset($_GET['page']))
{
//if there is a request page then get it and put it on a session variable and sent back the data that was requested.
$_SESSION['page'] = $_GET['page'];
$currentpage = $_SESSION['page'];
}
//if there is no request then..
else
{
$_SESSION['page'] = "home"; //if there is no request page then we literally tell that we are in the main page so we session will be home
$currentpage = $_SESSION['page'];
}

//echo a hidden input fields that hold the value of current page which will be accessed  by the jquery for adding classes of the match value in the attribute 'page' of the element base on the value that the hidden input field has

echo "<input type='hidden' id='currentpage' value='".$currentpage."' />

Agora, eu quero adicionar uma classe 'active' ao elemento que corresponde ao valor do atributo 'page' no valor do campo de entrada oculto que tem o id de 'currentpage', para fazer isso, eu prefiro torná-lo no jquery, então heres o código.

$(document).ready(function(){
//get the value of the hidden input field
$page = $('#currentpage').val();
//now im stuck here ..
});

Eu não sei como adicionar uma classe no elemento especificado que tem um valor de correspondência de seu atributo 'page' do valor do campo oculto que tem um id de 'currentpage'

por exemplo:

<input type='hidden' id='currentpage' value='home' />

Portanto, com base na página 'attr' do elemento, uma classe ativa deve ser adicionada, portanto, deve ser assim.

<ul>
    <li><a page="home" href="index.php" class="active">home</a></li> <!--as you can see on this part an active class has been added thats because the value of the attr page of this element is match to the value of the hidden input fields which has the id of 'currentpage'-->
    <li><a page="gallery" href="index.php?page=gallery">gallery</a></li>
    <li><a page="about" href="index.php?page=about">about</a></li>
    <li><a page="contact" href="index.php?page=contact">contact</a></li>
</ul>

Espero que alguém poderia me dar algo que poderia ajudar a resolver este problema atual, obrigado antecipadamente.

PS: estou aberto em idéias, sugestões e recomendações.

questionAnswers(2)

yourAnswerToTheQuestion