function form_validation(type, picture, thumbnail, file) 
{ 	
	var msg = '';
	if ( type == 'download' )
	{
		if (document.forms['item_add'].name.value == '')
		{
			msg += '- Veuillez entrer un nom pour cet objet\n\n';
			document.forms['item_add'].name.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].name.focus();
		}
		
		if (document.forms['item_add'].price.value == '')
		{
			msg += '- Veuillez entrer un prix en Crédits VS pour cet objet\n\n';
			document.forms['item_add'].price.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].price.focus();
		}
		
		if (document.forms['item_add'].file.value == '' && file != 1)
		{
			msg += '- Veuillez sélectionnez le fichier que vous souhaitez mettre en vente (format ZIP uniquement)\n\n';
			document.forms['item_add'].file.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].file.focus();
		}
		
		if (document.forms['item_add'].short_description.value == '')
		{
			msg += '- Veuillez entrer une description courte de maximum 130 caractères pour cet objet\n\n';
			document.forms['item_add'].short_description.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].short_description.focus();
		}
		
		if (document.forms['item_add'].description.value == '')
		{
			msg += '- Veuillez entrer une description complète pour cet objet\n\n';
			document.forms['item_add'].description.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].description.focus();
		}
		
		if ( picture != '' )
		{			
			ext = get_extension(picture);
		
			if(ext != '.jpg' && ext != '.gif' && ext != '.png')
			{
			   msg += '- Seuls les fichiers image sont acceptés\n\n';
			}
		}
		if ( thumbnail != '' )
		{			
			ext = get_extension(thumbnail);
		
			if(ext != '.jpg' && ext != '.gif' && ext != '.png')
			{
			   msg += '- Seuls les fichiers image sont acceptés pour la miniature\n\n';
			}
		}
		
		if ( file != '' && file != 1)
		{			
			ext = get_extension(file);
		
			if(ext != '.zip')
			{
			   msg += '- Seuls les fichiers zip sont acceptés comme fichier à mettre en vente\n\n';
			}
		}			
		
	}
	else if ( type == 'gheist' )
	{
		if (document.forms['item_add'].name.value == '')
		{
			msg += '- Veuillez entrer un nom pour cet objet\n\n';
			document.forms['item_add'].name.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].name.focus();
		}
		
		if (document.forms['item_add'].price.value == '')
		{
			msg += '- Veuillez entrer un prix en Crédits VS pour cet objet\n\n';
			document.forms['item_add'].price.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].price.focus();
		}
		
		if (document.forms['item_add'].file.value == '')
		{
			msg += '- Veuillez entrer le numéro ID de l\'objet Gheist\n\n';
			document.forms['item_add'].file.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].file.focus();
		}
		
		if (document.forms['item_add'].short_description.value == '')
		{
			msg += '- Veuillez entrer une description courte de maximum 130 caractères pour cet objet\n\n';
			document.forms['item_add'].short_description.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].short_description.focus();
		}
		
		if (document.forms['item_add'].description.value == '')
		{
			msg += '- Veuillez entrer une description complète pour cet objet\n\n';
			document.forms['item_add'].description.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].description.focus();
		}
		
		if ( picture != '' )
		{			
			ext = get_extension(picture);
		
			if(ext != '.jpg' && ext != '.gif' && ext != '.png')
			{
			   msg += '- Seuls les fichiers image sont acceptés\n\n';
			}
		}
		if ( thumbnail != '' )
		{			
			ext = get_extension(thumbnail);
		
			if(ext != '.jpg' && ext != '.gif' && ext != '.png')
			{
			   msg += '- Seuls les fichiers image sont acceptés pour la miniature\n\n';
			}
		}
		
		document.forms[0].elements[1].checked==false
	}
	else if ( type == 'onlinedeliver' )
	{
		if (document.forms['item_add'].description.value == '')
		{
			msg += '- Veuillez entrer une description complète pour cet objet\n\n';
			document.forms['item_add'].description.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].description.focus();
		}
		
		if (document.forms['item_add'].short_description.value == '')
		{
			msg += '- Veuillez entrer une description courte de maximum 130 caractères pour cet objet\n\n';
			document.forms['item_add'].short_description.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].short_description.focus();
		}
		
		if (document.forms['item_add'].item.value == '')
		{
			msg += '- Veuillez entrer le nom de l\'objet G3D\n\n';
			document.forms['item_add'].item.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].item.focus();
		}
		
		if (document.forms['item_add'].price.value == '')
		{
			msg += '- Veuillez entrer un prix en Crédits VS pour cet objet\n\n';
			document.forms['item_add'].price.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].price.focus();
		}
		
		if (document.forms['item_add'].name.value == '')
		{
			msg += '- Veuillez entrer un nom pour cet objet\n\n';
			document.forms['item_add'].name.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].name.focus();
		}		
		
		if ( picture != '' )
		{			
			ext = get_extension(picture);
		
			if(ext != '.jpg' && ext != '.gif' && ext != '.png')
			{
			   msg += '- Seuls les fichiers image sont acceptés\n\n';
			}
		}
		if ( thumbnail != '' )
		{			
			ext = get_extension(thumbnail);
		
			if(ext != '.jpg' && ext != '.gif' && ext != '.png')
			{
			   msg += '- Seuls les fichiers image sont acceptés pour la miniature\n\n';
			}
		}
	}
	else if ( type == 'real' )
	{
		if (document.forms['item_add'].name.value == '')
		{
			msg += '- Veuillez entrer un nom pour cet objet\n\n';
			document.forms['item_add'].name.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].name.focus();
		}
		
		if (document.forms['item_add'].price.value == '')
		{
			msg += '- Veuillez entrer un prix en Crédits VS pour cet objet\n\n';
			document.forms['item_add'].price.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].price.focus();
		}
		
		if (document.forms['item_add'].short_description.value == '')
		{
			msg += '- Veuillez entrer une description courte de maximum 130 caractères pour cet objet\n\n';
			document.forms['item_add'].short_description.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].short_description.focus();
		}
		
		if (document.forms['item_add'].description.value == '')
		{
			msg += '- Veuillez entrer une description complète pour cet objet\n\n';
			document.forms['item_add'].description.style.backgroundColor = '#FFCC33';
			document.forms['item_add'].description.focus();
		}
		
		if ( picture != '' )
		{			
			ext = get_extension(picture);
		
			if(ext != '.jpg' && ext != '.gif' && ext != '.png')
			{
			   msg += '- Seuls les fichiers image sont acceptés\n\n';
			}
		}
		if ( thumbnail != '' )
		{			
			ext = get_extension(thumbnail);
		
			if(ext != '.jpg' && ext != '.gif' && ext != '.png')
			{
			   msg += '- Seuls les fichiers image sont acceptés pour la miniature\n\n';
			}
		}		
	}
	
	
	if (msg != '')
	{
		alert(msg);
		return false;
	}
}

function form_validation_redeem() 
{ 	
	var msg = '';
	
	if (document.forms['redeem_add'].amount.value == '')
	{
		msg += '- Veuillez entrer un montant pour ce code redeem\n\n';
		document.forms['redeem_add'].amount.style.backgroundColor = '#FFCC33';
		document.forms['redeem_add'].amount.focus();
	}

	if (document.forms['redeem_add'].nb.value <= 0 || isNaN(document.forms['redeem_add'].nb.value))
	{
		msg += '- Veuillez entrer un nombre valide pour ce code redeem\n\n';
		document.forms['redeem_add'].nb.style.backgroundColor = '#FFCC33';
		document.forms['redeem_add'].nb.focus();
	}
	if (isNaN(document.forms['redeem_add'].cid.value))
	{
		msg += '- Veuillez entrer un nombre valide pour un id utilisateur\n\n';
		document.forms['redeem_add'].cid.style.backgroundColor = '#FFCC33';
		document.forms['redeem_add'].cid.focus();
	}	
	
	if (msg != '')
	{
		alert(msg);
		return false;
	}
}

function form_validation_users(actual_mail, actual_pseudo) 
{ 	
	var msg = '';
	
	if (document.forms['user_edit'].mail.value != '')
	{
		if(VerifFormeMail(document.forms['user_edit'].mail.value) == false)
		{
			msg += '- Veuillez entrer un mail valide\n\n';
			document.forms['user_edit'].mail.style.backgroundColor = '#FFCC33';
			document.forms['user_edit'].mail.focus();
		}
		else if(texte = file('includes/verifmail.php?mail=' +escape(document.forms['user_edit'].mail.value) + '&session=0'))
		{
			if(texte == 1 && document.forms['user_edit'].mail.value != actual_mail)
			{
				msg += '- Veuillez entrer un mail non utilisée\n\n';
				document.forms['user_edit'].mail.style.backgroundColor = '#FFCC33';
				document.forms['user_edit'].mail.focus();
			}
		}
	}

	if (document.forms['user_edit'].pseudo.value != '')
	{
		if(document.forms['user_edit'].pseudo.value.length<4)
		{
			msg += '- Veuillez entrer un pseudo plus long\n\n';
			document.forms['user_edit'].pseudo.style.backgroundColor = '#FFCC33';
			document.forms['user_edit'].pseudo.focus();
		}
		else if(document.forms['user_edit'].pseudo.value.length>20)
		{
			msg += '- Veuillez entrer un pseudo plus court\n\n';
			document.forms['user_edit'].pseudo.style.backgroundColor = '#FFCC33';
			document.forms['user_edit'].pseudo.focus();
		}
		else if(texte = file('includes/verifpseudo.php?pseudo='+escape(document.forms['user_edit'].value)))
		{
			if(texte == 1 && document.forms['user_edit'].pseudo.value != actual_pseudo)
			{
				msg += '- Veuillez entrer un pseudo non utilisé\n\n';
				document.forms['user_edit'].pseudo.style.backgroundColor = '#FFCC33';
				document.forms['user_edit'].pseudo.focus();
			}
		}
	}
	
	if (document.forms['user_edit'].pass.value != '' && document.forms['user_edit'].pass.value.length<5)
	{
		msg += '- Mot de passe trop court\n\n';
		document.forms['user_edit'].pass.style.backgroundColor = '#FFCC33';
		document.forms['user_edit'].pass.focus();
	}
	
	if (document.forms['user_edit'].money.value == '' || isNaN(document.forms['user_edit'].money.value) )
	{
		msg += '- Veuillez entrer un montant de crédits valide\n\n';
		document.forms['user_edit'].money.style.backgroundColor = '#FFCC33';
		document.forms['user_edit'].money.focus();
	}
	
	if (msg != '')
	{
		alert(msg);
		return false;
	}
}

function disable_clan()
{
	document.getElementById('clan').disabled = 'readonly';
}

function change_disabled()
{
	if(document.getElementById('sub_type').options[document.getElementById('sub_type').selectedIndex].value=='item')
	{
		document.getElementById('clan').disabled=true;
		document.getElementById('amount').readOnly=true;
		document.getElementById('item').readOnly=false;
		document.getElementById('money_amount').style.display = 'none';
		document.getElementById('itemtype').style.display = 'block';
	}
	else
	{
		document.getElementById('item').readOnly=true;		
		document.getElementById('clan').disabled=false;
		document.getElementById('amount').readOnly=false;
		document.getElementById('money_amount').style.display = 'block';
		document.getElementById('itemtype').style.display = 'none';
	}
	
	if(document.getElementById('item_type').options[document.getElementById('item_type').selectedIndex].value=='conso')
	{
		document.getElementById('conso').style.display = 'block';
		document.getElementById('number').readOnly=false;
	}
	else
	{
		document.getElementById('conso').style.display = 'none';
		document.getElementById('number').readOnly=true;
	}
}
