/*
// Site : Nice Historique - http://www.nicehistorique.org/
// Date : 2005-07-01
// swd  : Swap Display.
// cwd  : Swap Content.
*/


// Viewer : Object.
function viewer(path, pages, content, current){

	this.content = content;
	this.pages   = pages;
	this.path    = path;
	this.current = current-1;
	this.message = 'Vous devez d\'abord cliquer sur consulter l\'article pour accéder au document';
	this.display = 0;

	this.set     = set;
	this.fwd     = fwd;
	this.bwd     = bwd;
		
}

// Viewer  : Object : Set
function set(page){
	if(!this.display){
		alert(this.message);
		return;
	}
	this.current = page-1;
	var menu     = document.getElementById('vwr_menu');
	var elements = menu.getElementsByTagName('a');
	this.content.src = this.path + this.pages[this.current];

	for(var i = 0; i < elements.length; i++){
		if(i == this.current){
			elements[i].className = 'current';
		}else{
			elements[i].className = 'page';
		}
	}
	$('#page').retina({css:{width:300,height:300}});
}

// Viewer : Object : Forward
function fwd(){
	if(this.current < (this.pages.length-1)) this.current ++;
	doc.set(this.current+1);
}

// Viewer : Object : Backward
function bwd(){
	if(this.current > 0) this.current --;
	doc.set(this.current+1);
}

// Switch display attributes
function swd(objId){
	var element = document.getElementById(objId);
	if(element.style.display != 'block'){
		element.style.display   = 'block';
	}else{
		element.style.display   = 'none';
	}
}

// Switch Message/Page
function smsg(){
	var message = document.getElementById('message');
	var content = document.getElementById('page');
	if(message.style.display != 'block'){
		message.style.display   = 'none';
		content.style.display   = 'block';
		doc.display             = 1;
	}else{
		doc.display             = 0;
	}
}

// Print document
function pctn(){
	if(!doc.display){
		alert(doc.message);
		return;
	}
	window.print();
}

/*
// Switch document display
function cwd(image){
	var content = document.getElementById('page');
	content.src = image;
}

// Set Document :: Current :: Page
function ccrt(obj, image){
	raz();
	obj.setAttribute('class','current');
	cwd(image);	
}

// Document :: FwdPage
function cfwd(){
	mnu_mgr(0);
}

// Document :: BkwPage
function cbkw(){
	mnu_mgr(1);
}

// Document :: Menu :: Reset.
function mnu_mgr(dir){
	var mnu = document.getElementById('vwr_menu');
	var pgs = mnu.getElementsByTagName('a');

	for(var pge=0; pge < pgs.length; pge++){
		if(pgs[pge].getAttribute('class') == 'current'){
			// alert(pgs[pge].getAttribute('class'));
			pgs[pge].setAttribute('class','');
			dir?pgs[pge-1].setAttribute('class','current'):pgs[pge+1].setAttribute('class','current');
			// STOP // pgs[pge].onclick;
			return;
		}

		var md = "Vous êtes au début du numéro, souhaiteriez vous...";
		var me = "Vous êtes à la fin du numéro, souhaiteriez vous...";
		//dir?next(dir, md):next(dir, me);
	}
}

function raz(){
	var mnu = document.getElementById('vwr_menu');
	var pgs = mnu.getElementsByTagName('a');
	for(var pge=0; pge < (pgs.length); pge++){
		pgs[pge].setAttribute('class','');
	}	
}

// Document :: Thumbnail
function sthl(thumbnail){
		alert(thumbnail);
}

// Document :: Next
function next(dir, msg){
	var usr = confirm(msg);
}

// Document :: Content :: Print
function pctn(){
	window.print();
}
*/
