function openTechData(productId)
{
	window.open("/produits/details.php?ref="+productId,null,"height=520,width=440,toolbar=no,location=no,menubar=no,resize=no, scrollbars=yes");
}

function alignTop()
{
	window.moveTo(0,0);
	window.focus();
}

function submitForm(varToChange, actionToDO, FormName)
{
	Form = findForm(FormName);
	if(Form == null) return;
	alterForm(varToChange, actionToDO);
	Form.submit();
}

function findForm(formName)
{
	for(i=0;i<document.forms.length;i++)
	{
		if(document.forms[i].name==formName) return document.forms[i]
	}
	return null
}

function chekUser(checkBoxId)
{
	checkBox = document.getElementById(checkBoxId);
	if(!checkBox.checked ) checkBox.checked = true;
}

function linkForm(checkBoxId, varToChange, actionToDO, FormName)
{
	chekUser(checkBoxId);
	submitForm(varToChange, actionToDO, FormName);
}

function confirmLinkForm(message, checkBoxId, varToChange, actionToDO, FormName)
{
	if(!confirm(message)) return;
	chekUser(checkBoxId);
	submitForm(varToChange, actionToDO, FormName);
}

function confirmSubmitForm(message, varToChange, actionToDO, FormName)
{
	if(!confirm(message)) return;
	submitForm(varToChange, actionToDO, FormName);
}

function alterForm(varToChange, actionToDO)
{
	variable = document.getElementById(varToChange);
	variable.value = actionToDO;
}

function validateDate(year, month, day)
{
	day=parseInt(String(day));
	month=parseInt(String(month));
	year=parseInt(String(year));
	switch(month)
	{
		case	2	:	if(day>29) return false;
						if((day==29) && (!isBisextile(year))) return false;
						break;
		case	4	:
		case	6	:
		case	9	:
		case	11	:	if(day>30) return false;
						break;

	}
	return String(year)+"-"+String(month)+"-"+String(day);
}

//Determine si l'année est bisextile ou pas (29 jours pour février)
function isBisextile(year)
{
	if(!(year % 4)) //Divisible par 4
	{
		if(!(year % 100)) //Divisible par 100
			return ((year % 400)==0) //Si divisible par 400
		else return true
	}
	else return false;
}
