
	/* AJAX */


function AjaxPost(Apage, Apost)
{
	var ParamPost = Form.serialize($(Apost+'Form'));
	Form.disable($(Apost+'Form'));
	AjaxWait(Apost, 'on');

	new Ajax.Request('http://www.youngandstyle.fr/ajax/'+Apage+'.php', {postBody: ParamPost});
}

function Enter(Apage, Apost, e)
{
	if(KeyBoard(e)==13)
	{
		var ParamPost = Form.serialize($(Apost+'Form'));
		Form.disable($(Apost+'Form'));
		AjaxWait(Apost, 'on');	
		new Ajax.Request('http://www.youngandstyle.fr/ajax/'+Apage+'.php', {postBody: ParamPost});
	}
}


function AjaxUpdate(Apage, Adiv, Aget, Apost)
{
	if(Apost)
		var ParamPost = Form.serialize($(Apost));

	if(Aget)
		var ParamGet = '?'+Aget;

	new Ajax.Updater(Adiv, 'http://www.youngandstyle.fr/ajax/'+Apage+'.php'+ParamGet, {postBody: ParamPost, evalScripts:true}); 
}

function AjaxLite(Apage, Aget)
{
	new Ajax.Request('http://www.youngandstyle.fr/ajax/'+Apage+'.php', {method:'get', parameters:Aget});
}

function AjaxWait(Adiv, Mode)
{
	if(Mode=='on')
		$(Adiv+'Wait').style.backgroundImage = 'url(http://www.youngandstyle.fr/img/Wait.gif)';
	else
		$(Adiv+'Wait').style.backgroundImage = 'url()';
}

function AjaxComplete(Adiv)
{
	AjaxWait(Adiv, 'off');
	Form.enable($(Adiv+"Form"));
	new Effect.Highlight(Adiv+"Submit", {startcolor:'#3C92DF',endcolor:'#25A617', restorecolor:'#25A617'});
	new Effect.Fade($(Adiv+"Error"));
}

function AjaxError(Adiv, Text)
{
	AjaxWait(Adiv, 'off');
	Form.enable($(Adiv+"Form"));
	$(Adiv+"Error").style.backgroundImage = 'url(../img/icons/minus-circle.png)'; 
	$(Adiv+"Error").innerHTML = Text+"<br>";
	new Effect.Appear($(Adiv+"Error"));
}

	/* NEWS */

function NewsHome(HightLight)
{
	// REMOVE EX BUTTON SELECT

	Element.removeClassName('News-'+HightLight, 'NewsButtonSelect');

	// NEW BUTTON SELECT

	if(HightLight==5) var NewHightLight = 1;
	else var NewHightLight = parseInt(HightLight,10)+ 1;
	Element.addClassName('News-'+NewHightLight, 'NewsButtonSelect');

	// IMAGE

	var NewsBack = $('News-'+NewHightLight).rel.split('|');
	$('NewsImage').innerHTML= '<a href="http://www.youngandstyle.fr/'+NewsBack[1]+'"><img src="http://www.youngandstyle.fr/content/news/'+NewsBack[0]+'-'+NewsBack[2]+'.jpg"></a>';

	// LOOP

	setTimeout("NewsHome('"+NewHightLight+"')",5000);
}

function NewsOver(id)
{
	var NewsBack = $('News-'+id).rel.split('|');
	$('NewsImage').innerHTML= '<a href="http://www.youngandstyle.fr/'+NewsBack[1]+'"><img src="http://www.youngandstyle.fr/content/news/'+NewsBack[0]+'-'+NewsBack[2]+'.jpg"></a>';
}

	/* ALERT */

function AjaxAlert()
{
	new Ajax.Request('http://www.youngandstyle.fr/ajax/alert.php');
	setTimeout("AjaxAlert()",20000);
}

	/* SEARCH ADVANCED */

function SearchAdvanced(table)
{
	if(table=="user") $("SearchAdvanced").show();
	else $("SearchAdvanced").hide();			
}

	/* VIDEO */

function Video(swf)
{
	var s1 = new SWFObject(swf,"ply","615","394","9","#FFFFFF");
	s1.addParam("allowfullscreen","true");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("wmode","opaque");
	s1.write("Player");
}

	/* LITBOX */

function LitBox(Apage, Title, Class, Aget)
{
	if(Apage=='close') 
		$('LitBox').innerHTML = '';
	else 
	{ 
		$('LitBox').innerHTML = '<div id="LitBoxFilter"><div class="Box"><h1 class="'+Class+'">'+Title+'</h1><img src="http://www.youngandstyle.fr/img/icons/cross.png" class="Close" onclick="LitBox(\'close\');"><br clear="all"><div id="LitBoxContent" class="Clean"><img src="http://www.youngandstyle.fr/img/BigWait.gif" class="Load"></div></div></div>';
		new Ajax.Updater('LitBoxContent', 'http://www.youngandstyle.fr/ajax/'+Apage+'.php', {method:'get', parameters:Aget, evalScripts:true});
	}
}


function ResizeLitBox()
{
	var TopFilter = -$('LitBoxFilter').scrollHeight/2;
	$('LitBoxFilter').style.marginTop = TopFilter+'px';
}

	/* KEYBOARD */

function KeyBoard(e)
{
	var KeyID = (window.event) ? event.keyCode : e.keyCode;
	return KeyID;
}

	/* PHOTO KEYBOARD */

function PhotoKey(e)
{
	if($('comment_focus').value==0)
	{
		if(KeyBoard(e)==37) AjaxLite("photo", "id="+$('PhotoPreview').value);
		if(KeyBoard(e)==39) AjaxLite("photo", "id="+$('PhotoNext').value);
	}
}

	/* ONLINE */

function Online()
{
	new Ajax.PeriodicalUpdater('OnlineCount', 'http://www.youngandstyle.fr/ajax/online.php',{frequency: 14, evalScripts:true});
}

function WhoIsOnline()
{
	Effect.toggle('WhoIsOnline','appear',{duration:0.1});
	new Ajax.Updater('WhoIsOnline', 'http://www.youngandstyle.fr/ajax/online.list.php');
}

	/* CLASS */

function GetDiv(name, type) 
{
	var elem = document.getElementsByTagName("div"); 
	var arr = new Array(); 
	for(i = 0,iarr = 0; i < elem.length; i++) 
	{ 
		att = elem[i].getAttribute("name"); 
		if(att == name) 
		{ 
			if(type=='hide') new Effect.Fade(elem[i]); 
			else $(elem[i]).style.display = 'block'; 
		} 
	} 
}

	/* SHARE */

function FaceBook(Url, Title)
{
	u= 'http://www.youngandstyle.fr/'+Url;
	t= Title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

