var	mngID, expiredPage, validHours, expiredCookieName, firstTimeCookieName;

function getTimeLimit( id, page, hours ) {
mngID = id;
expiredPage = page;
validHours = hours;
expiredCookieName = 'EXPIRED_' + mngID;
firstTimeCookieName = 'FIRSTTIME_' + mngID;

var timeLimit = isLimited();

if ( !timeLimit ){
displayExpiredPage();
}

return timeLimit;
}



function getFirstTimeAccess() {

var	firstTime =new Date( $.cookie( firstTimeCookieName ) );

firstTime = firstTime.getFullYear() + '”N' + ( firstTime.getMonth() + 1 ) + 'ŒŽ' + firstTime.getDate() + '“ú ' +  addZero( firstTime.getHours() ) + ':' +  addZero( firstTime.getMinutes() ) + ':' +  addZero( firstTime.getSeconds() );

return firstTime;

}



function isLimited()	{

var	timeLimit = ( $.cookie( expiredCookieName ) );

now =  ( new Date() ).getTime();

if ( !timeLimit )	{
var	limitDate = new Date( ( validHours * 60 * 60 * 1000 ) + now );
timeLimit = limitDate.getTime();

$.cookie( expiredCookieName, timeLimit, { expires: 30 } );

$.cookie( firstTimeCookieName, new Date(), { expires: 30 } );

}

if ( timeLimit <= now )	{
return false;
}

return timeLimit;
}


function displayExpiredPage()	{
window.location.href = expiredPage;
}


function addZero( num )	{
num = '00' + num;
str = num.substring( num.length - 2, num.length );

return str ;
}

