/* 

DMRS 2008 |  DELTA WEB http://www.delta-web.com



*/

function ow (url)
{
	window.open(url);
}

function writeNav (selectItem)
{
	var nb_bt = tab_nav.length;
	var listNav = "";
	for(i=0;i<nb_bt;i++)
	{
		if(i!=selectItem)
		{
			listNav = listNav+"<li id='bt"+i+"'><a href="+traceur+tab_nav[i]+">"+tab_lib_nav[i]+"</a></li>";
		} else {
			listNav = listNav+"<li id='bt"+i+"' class='selected'><a href="+traceur+tab_nav[i]+">"+tab_lib_nav[i]+"</a></li>";
		}
	}
	document.write("<ul id='nav'>"+listNav+"</ul>");
}

//--

function writeMenuLeft (selectItem)
{
	var nb_bt = tab_lib_cres.length;
	var tab_lib = tab_lib_cres;
	var tab_lien = tab_lien_cres;
	var listNav = "";
	for(i=0;i<nb_bt;i++)
	{
		if(i!=selectItem)
		{
			listNav = listNav+"<li><a href="+tab_lien[i]+">"+tab_lib[i]+"</a></li>";
		} else {
			listNav = listNav+"<li class='selected'><a href="+tab_lien[i]+">"+tab_lib[i]+"</a></li>";
		}
	}
	document.write("<ul id='leftMenu'>"+listNav+"</ul>");
}

//--



function writeFooter ()
{
	document.write("<div>2007 CRES | <a href='#'>haut de page</a></div>");
}

//--

function writeFL (id,src,W,H,WM)
{
	document.write("<object id='"+id+"' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,19,0' width='"+W+"' height='"+H+"' align='middle'>");
	document.write("<param name='allowScriptAccess' value='always'>");
	document.write("<param name='wmode' value='"+WM+"'>");
	document.write("<param name='movie' value="+src+">");
	document.write("<param name='quality' value='high'>");
	document.write("<embed name='"+id+"' src="+src+" allowScriptAccess='always' width='"+W+"' height='"+H+"' wmode='"+WM+"' align='middle' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>");
	document.write("</object>");
}

//--

function alphalizer(id,val)
{
	alpha = 0;
	idAlpha = id;
	alphaDest = val;
	alphalizerAction();
}

function alphalizerAction()
{
        alpha+=5;
		
		document.getElementById(idAlpha).style.opacity = alpha / 100;
		// IE
        if (document.body.filters != undefined)
        {
                document.getElementById(idAlpha).style.filter = 'alpha(opacity:' + alpha + ')';
        }
		
		if(alpha<alphaDest)
		{
			setTimeout(alphalizerAction,1);
		}
}

//--

function preloadImageSystem (nm,source)
{
	if(document.getElementById(nm).complete)
	{
		document.getElementById(nm).src = source;
		clearInterval(up[document.getElementById(nm).curID]);
		alphalizer(nm,100);
	}
}

up = new Array();
var curentId = 0;

function preloadImage (traceur,nm)
{
	source = document.getElementById(nm).src;
	document.getElementById(nm).src = traceur+"images/loader.gif";
	
	curentId++;
	document.getElementById(nm).curID = Number(curentId);
	
	up[document.getElementById(nm).curID] = setInterval("preloadImageSystem('"+nm+"','"+source+"')",500);
}

//--

function position(event){
	var event = event || window.event;
	mouse_x = event.clientX;
	mouse_y = event.clientY;
	if(navigator.appName == 'Microsoft Internet Explorer' )
	{
		y = mouse_y+document.documentElement.scrollTop;
	} else {
		y = mouse_y+window.pageYOffset;
	}
}

function setEleY(id)
{
	document.getElementById(id).style.top = y+"px";
}
document.onclick = position;

//--

function show(id)
{
    document.getElementById(id).style.display = "block";
}

function hide(id)
{
    document.getElementById(id).style.display = "none";
}

//--

function setImgZoom(url)
{
	var content = "<a href=javascript:hide('zoomPhoto');><img id='zoomPhotoRecep' src="+url+" alt='Cliquez pour fermer' /></a>";
	document.getElementById('zoomPhoto').innerHTML = content;
	preloadImage(traceur,'zoomPhotoRecep');
}

function zoomPhoto(ele, url)
{
	ele.onmouseover = function()
	{
		this.style.opacity = .8;
		this.style.filter = 'alpha(opacity:' + 80 + ')';
		this.style.cursor = "pointer";
		
	}
	ele.onmouseout = function()
	{
		this.style.opacity = 1;
		this.style.filter = 'alpha(opacity:' + 100 + ')';
	}
	ele.onmousedown = position;
	ele.onclick = function()
	{
		setImgZoom(url);
		show('zoomPhoto');
		setEleY('zoomPhoto');
	}
}
