function getCookieVal(offset)
{
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function LireCookie(nom)
{
	var arg = nom + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i+alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal(j);
		i = document.cookie.indexOf(" ",i) + 1;
		if (i == 0)
		break;
	}
	return null;
}
		
netehash = LireCookie('netesession');

/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////

function openchatv2(login,sex,id)
{
	if (window.opener && window.opener.openchatv2 && !window.opener.openDialogue) // pas dans nav              
    window.opener.openchatv2(login,sex,id);
  else {
    if (parent.frames['nav'])
      parent.frames['nav'].openDialogue(login,sex,id);
    else
      if (window.opener)
				window.opener.openDialogue(login,sex,id);
  }
}
	
function sendMail (to, from, qsa) {
  var url = '?tpl=ajaxmsg&amp;to='+to+'&amp;np=1&amp;from='+from+qsa;
  win = new Window ({
	  'title': "Envoyer un message mail", 
		'className': "alphacube",
		'top':185, 
		'left':15, 
		'width':618, 
		'height':338, 
		'destroyOnClose':false,
		'resizable':false,
		'maximizable':false,
    		'minimizable':false,
		'url':url
		})
	win.show ()
}

function openfichev2(aspidf, hashcode)
{
	window.opener.top.TopDesk.location.href = '?tpl=fiche2&aspidf='+aspidf;
}

function opencontactv2 (aspidf, hashcode) {
	var url = '?tpl=addcontact&aspidf='+aspidf+'&hash='+hashcode;
	var win = new Window ({
		'title': "Ajouter à vos contacts", 
		'className': "alphacube",
		'top':205, 
		'left':100, 
		'width':300, 
		'height':268, 
		'destroyOnClose':true,
		'resizable':false,
		'maximizable':false,
    'minimizable':false
	})

	new Ajax.Request (url, {
		onSuccess: function (xhr) {
			win.getContent().innerHTML = xhr.responseText || "no response text";
		}
	});

	//win.show ();
	return win;
}
	
function openalbumsv2(aspidf,album_id,hashcode)
	{
		falbums = window.open('?tpl=albumshowphotos&aspidf=' + aspidf +'&album_id=' +album_id +'&hash='+hashcode, 'albumnetech','width=300,height=400,toolbar=no,location=no,scrollbars=yes')
		if (falbums)
			falbums.focus();
	}

