jQuery(document).ready(function(){
jQuery("a[rel='article_tab']").click(function(){return swapArticle.swapContent(this.href);});
swapArticle.swapContent(document.location.hash);
});
var swapArticle={};
swapArticle.section='';
swapArticle.processing=false;
swapArticle.loadedSections={texte:true};
swapArticle.ressources={};
swapArticle.swapContent=function(link){
if(!swapArticle.processing){
swapArticle.processing=true;
var e=link.split('#');
var id=e[e.length-1];
id=(id=='texte'||!(swapArticle.ressources[id]))?'texte':id;
if(id!=swapArticle.section){
swapArticle.section=(swapArticle.section)?swapArticle.section:'texte';
jQuery('#tab_'+swapArticle.section).parent().parent().removeClass('selected');
jQuery('#tab_'+id).parent().parent().addClass('selected');
jQuery('#nouv_'+swapArticle.section).hide();
jQuery('#nouv_'+id).show();
swapArticle.section=id;
if(!swapArticle.loadedSections[swapArticle.section]){
separateur='?';
if(swapArticle.section=='video')
{
separateur='&';
}
jQuery.get(swapArticle.ressources[swapArticle.section]+separateur+new Date().getTime(),function(data){
jQuery('#nouv_'+swapArticle.section).html(data);
swapArticle.loadedSections[id]=true;
swapArticle.processing=false;
});
}else{
swapArticle.processing=false;
}
}else{
swapArticle.processing=false;
}
}
return true;
}
swapArticle.setRessources=function(data){
swapArticle.ressources=data;
return false;
}
var commentPNmber=0;
function swapComments(monUrl)
{
jQuery.get(monUrl,function(data){
jQuery('#comment_liste').html(data);
});
}
function submitComment(form){
var url=form.action+'?story_id='+escape(form.story_id.value)+'&author='+escape(form.author.value)+'&email='+escape(form.email.value)+'&comment='+escape(form.comment.value);
jQuery.get(url,function(data){
var elements=data.split('|');
var state=(Number(elements[0]))?'success':'error';
var field=elements[1];
var message=elements[2];
if(state=='error')
{
var err_fields=field.split(',');
for(var i=0;i<err_fields.length;i++){
jQuery('#'+err_fields[i]).addClass('error');
}
jQuery('#message_error').html(message).show('fast');
}
else
{
jQuery('#message_error').hide();
jQuery(form).hide('fast');
jQuery('#message_succes').addClass(state).html(message).show('fast');
}
});
return false;
}

