// JavaScript Document
function initPagination(){
	var page = new PAGINATION_GINFO(this, document.forms["pagination_form"]);
	page.init();
}



/*function openVideoGamesPopup(videogameid){
	var inner = window.open(URLPATH + 'mon_compte_videogames_popup.php?selected_id=' + videogameid,'','toolbar=no,location=0,directories=no,status=no,menubar=0,scrollbars=yes,resizable=no,copyhistory=0,width=490,height=480');
}
*/

function textSize(dir) {
	
    if (dir == 'up') {
        if (currentTextSize <= 16) {
            currentTextSize += 2;
            currentTitleSize += 2;
        }
    } else if (dir == 'down') {
        if (currentTextSize >= 10) {
            currentTextSize -= 2;
            currentTitleSize -= 2;
        }
    }else{
    	currentTextSize = 11;
    	currentTitleSize = 15;
    }

    currentLineHeight = currentTextSize + 5;
    
    if (document.getElementById('content_container') != null) {
    	document.getElementById('content_container').style.fontSize = currentTextSize + 'px';
    	document.getElementById('content_container').style.lineHeight = currentLineHeight + 'px';
    }
        
   	if (document.getElementById('title_container') != null) {
    	document.getElementById('title_container').style.fontSize = currentTitleSize + 'px';
    	document.getElementById('title_container').style.lineHeight = currentLineHeight + 'px';
   	}
   	
   /*	 // write/rewrite cookie
	setCookie("contentFontSize",currentTextSize,1,"/","www.aplcp.org");
	setCookie("contentTitleSize",currentTitleSize,1,"/","www.aplcp.org");
	setCookie("contentLineHeight",currentLineHeight,1,"/","www.aplcp.org");*/
}

function get_text_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results ) {
    return ( unescape ( results[1] ) );
  }
  else { return null; }
}

function get_cookie(Name) {
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
	offset = document.cookie.indexOf(search)
	if (offset != -1) { // if cookie exists
		offset += search.length
		// set index of beginning of value
		end = document.cookie.indexOf(";", offset);
		// set index of end of cookie value
		if (end == -1)
		 end = document.cookie.length;
		returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function setCookie( name, value, expires, path, domain, secure ) 
{

	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
} 

function initHistoryTab(){
	
	var img = document.getElementById("history_btn");
	var title = document.getElementById("history_title");
	var div = document.getElementById("history_container");
						
	img._div = div;
		
	if (!img.status)
		img.status = "opened";
			
	img.onclick = function(){
		
		if (this.status == "opened"){
			this._div.style.display = "none";
			this.src = this.src.split("/icons/")[0] + "/icons/"+ "icon_arrow_right.gif";
			this.status = "closed";
		}
		else{
			this._div.style.display = "block";
			this.src = this.src.split("/icons/")[0] + "/icons/"+ "icon_arrow_down_grey.gif";
			this.status = "opened";
		}
	}
	
	title._div = div;
			
	if (!title.status)
		title.status = "opened";
	
	title.onclick = function(){
		
		if (this.status == "opened"){
			this._div.style.display = "none";
			document.getElementById("history_btn").src = document.getElementById("history_btn").src.split("/icons/")[0] + "/icons/"+ "icon_arrow_right.gif";
			this.status = "closed";
		}
		else{
			this._div.style.display = "block";
			document.getElementById("history_btn").src = document.getElementById("history_btn").src.split("/icons/")[0] + "/icons/"+ "icon_arrow_down_grey.gif";
			this.status = "opened";
		}
	}
}
