var sas_tmstp = Math.round(Math.random() * 10000000000);
sas_masterflag = 1;
function SmartAdServer(sas_pageid, sas_formatid, sas_target)
{
	if (sas_masterflag==1)
	{
		sas_masterflag=0;
		sas_master='M';
	}
	else
		sas_master='S';
	document.write('<SCR'+'IPT SRC="http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' + sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' + escape(sas_target) + '?"></SCR'+'IPT>');
}

function url_confirm(q, u)
{
	if (confirm(q))
	document.location.href = u;
}

function ippp(url)
{
	w = open('','image','width=300,height=300,toolbar=no,scrollbars=no,resizable=yes');
	w.document.write('<HTML><HEAD><META HTTP-EQUIV=imagetoolbar CONTENT=no><TITLE>Zepeople</TITLE></HEAD>');
	w.document.write('<SCRIPT LANGUAGE="javascript">function checksize(){if(document.images[0].complete){window.resizeTo(document.images[0].width+20,document.images[0].height+50);window.focus();}else{setTimeout("check()",250)}}</' + 'SCRIPT>');
	w.document.write('<BODY onload=checksize() WIDTHMARGIN=0 HEIGHTMARGIN=0 TOPMARGIN=0 LEFTMARGIN=0><A HREF="javascript:close();"><IMG src="' + url + '" ALT="Cliquez sur l\'image pour fermer la fenêtre" BORDER=0></a>');
	w.document.write('</BODY></HTML>');
	w.document.close();
}

function zPho(id)
{
	window.open('popup.php?id=' + id,'photo','width=300,height=300,toolbar=no,scrollbars=no,resizable=yes');
}

function zPhoX(id, height, width)
{
	window.open('popup.php?id=' + id,'photo','width='+width+',height='+height+',toolbar=no,scrollbars=no,resizable=yes');
}

function zPhoTag(id, height, width)
{
	window.open('/soirees/photos/popuptag.php?id=' + id,'photo','width='+width+',height='+height+',toolbar=no,scrollbars=no,resizable=yes');
}

function zPhoType(type, id)
{
	window.open('/' + type + '/popup.php?id=' + id,'photo','width=300,height=300,toolbar=no,scrollbars=no,resizable=yes');
}

function zPhoTypeX(type, id, height, width)
{
	window.open('/' + type + '/popup.php?id=' + id,'photo','width='+width+',height='+height+',toolbar=no,scrollbars=no,resizable=yes');
}

function zTag(f, id)
{
	window.open('/tag/tag.php?f=' + f + '&id=' + id,'tag','width=300,height=300,toolbar=no,scrollbars=no,resizable=yes');
}

function zTagX(f, id, height, width)
{
	window.open('/tag/tag.php?f=' + f + '&id=' + id,'tag','width='+(width+200)+',height='+height+',toolbar=no,scrollbars=no,resizable=yes');
}

function input_label(f, once)
{
	var v = f.value;
	f.onfocus = function ()
	{
		if (this.value == v)
		this.value = '';
	}
	if (!once)
	f.onblur = function ()
	{
		if (this.value == '')
		this.value = v;
	}
}

function bookmarks_toggle()
{
	$('#bookmarks').toggle();
}

function search_toggle(id)
{
	$('#' + id).toggle();
}

function write_music(src, play)
{
	var autoplay = 'false';
	var temp = '';
	if (play)
	if ((temp = LireCookie('autoplaymusic')) == null)
	{
		if (confirm("La page sur laquelle vous vous trouvez contient une musique.\nVoulez la jouer maintenant ?"))
		autoplay = "true";
		date = new Date;
		date.setMonth(date.getMonth() + 6);
		EcrireCookie("autoplaymusic", autoplay, date, "/");
	}
	else
	autoplay = temp;
	document.write('<EMBED align="middle" src="' + src + '" width="300" height="45" autostart="' + autoplay + '"></EMBED><br>');
	document.write('</embed>');
}

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;
}

function EcrireCookie(nom, valeur)
{
	var argv=EcrireCookie.arguments;
	var argc=EcrireCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=nom+"="+escape(valeur)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}

function write_obj(src, width, height)
{
	document.write('<object width="' + width + '" height="' + height + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0">');
	document.write('<param name="movie" value="' + src + '">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="quality" value="high">');
	document.write('<embed src="' + src + '" width="' + width + '" height="' + height + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">');
	document.write('</embed>');
	document.write('</object>');
}

function retu_obj(src, width, height)
{
	var retu = '';
	retu +='<object width="' + width + '" height="' + height + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0">';
	retu +='<param name="movie" value="' + src + '">';
	retu +='<param name="wmode" value="transparent">';
	retu +='<param name="quality" value="high">';
	retu +='<embed src="' + src + '" width="' + width + '" height="' + height + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">';
	retu +='</embed>';
	retu +='</object>';
	return retu;
}

function resize_img(img_id)
{
	resize(img_id);
}

function resize(img_id)
{
	img = $(img_id);
	if(img.complete == true)
	{
		old_width = img.width;
		if(old_width > 450)
		{
			img.width = 450;
			img.title = 'La photo originale a été réduite pour un meilleur affichage de la page.';
		}
	}
	else
	setTimeout("resize('" + img_id +"')", 500);
}

function play_music(url, name)
{
	$('#music_player').html('<object type="application/x-shockwave-flash" data="'+R+'lib/swf/dewplayer.swf?son='+url+'&autoplay=1" width="63" height="20"> <param name="movie" value="'+R+'lib/swf/dewplayer.swf?son='+url+'&autoplay=1" /> <param name="wmode" value="transparent" /> </object>');
	$('#playing').html(name);
}

function loadMembers()
{
	$.ajax(
	{
		url: R + 'data/online.php',
		success: function (code)
		{
			$('#online_members').html(code);
		},
		error: loadMembers
	});
}

function loadMembersie6()
{
	$.ajax(
	{
		url: R + 'data/onlineie6.php',
		success: function (code)
		{
			$('#online_members').html(code);
		},
		error: loadMembersie6
	});
}

$(document).ready(function ()
{
	$(document).ready(function ()
	{
		$('.tblock h3').click(function ()
		{
			$(this).parent().children('.box_content').toggle();
			$(this).toggleClass('closed');
		});
	});
});