// JavaScript Document
function PreSubmit(frmName, act, imgName)
{
	document.forms[frmName].task.value = act;

	//alert(document.forms[frmName].id.value);

	if (imgName)
		document.forms[frmName].imageDelete.value  = imgName;

	document.forms[frmName].submit();
}


function ShowDiv(Id)
{
	//alert(Id);
	try{
	document.getElementById(Id).style.display = "block";
	}
	catch(e){}
}

function HideDiv(Id)
{
	try{
	document.getElementById(Id).style.display = "none";
	}
	catch(e){}
}

function ShowHideDiv(Id)
{
	if (document.getElementById(Id).style.display == "none")
		document.getElementById(Id).style.display = "block";
	else
		document.getElementById(Id).style.display = "none";
}

function ChangeStyle(Obj,className)
{
	try
	{
		Obj.setAttribute("class",className);
	}
	catch(e){};
	
	try
	{
		Obj.setAttribute("className",className);
	}
	catch(e){}
}

function ChangeStyleById(objId,className)
{
	ChangeStyle(document.getElementById(objId),className);
}

var arrOnLoadFunctions = new Array();
function OnLoad()
{
	//alert(arrOnLoadFunctions.length);
	for (i=0; i < arrOnLoadFunctions.length; i++)
	{
		eval(arrOnLoadFunctions[i]);
	}
}

function ShowPopup(pPage, pId)
{
	var objPopup = document.getElementById("Popup");
	objPopup.style.display = "block";
	objPopup.style.top = document.body.scrollTop;
	window.open("./?page=" + pPage + "&id=" + pId,"PopupFrame");
}

function HidePopup()
{
	window.open("./loading.html","PopupFrame");
	HideDiv("Popup");
}

var TaskBar_TimeOut;

function MoveTaskBar_Start()
{
	var obj = document.getElementById("TaskBar");
	obj.style.display = "block";
	obj.style.bottom = 0;
	TaskBar_TimeOut = setTimeout("MoveTaskBar()",0);
}

function MoveTaskBar()
{
	clearTimeout(TaskBar_TimeOut);
	//Move Task Bar
	var obj = document.getElementById("TaskBar");
	//obj.style.bottom = - document.body.scrollTop;
	obj.style.bottom = parseInt(obj.style.bottom) - Math.round((document.body.scrollTop + parseInt(obj.style.bottom))/2);
	TaskBar_TimeOut = setTimeout("MoveTaskBar()",50);
}

function WindowResize()
{
	//MoveTaskBar();
	
}

window.onresize = WindowResize;

function callCalendarShow(pId)
{
	var tDivContentId;
	tDivContent = (pId == "Tournee")?"Other":"Paris";
	tDivOpContent = (pId == "Tournee")?"Paris":"Other";

	tOpId = (pId == "Tournee")?"Paris":"Tournee";

	//content
	ShowDiv("province" + tDivContent); 	HideDiv("province" + tDivOpContent);
	
	//tab
	ShowDiv(pId + "Active" ); 	HideDiv(pId);
	ShowDiv(tOpId); 			HideDiv(tOpId + "Active");
	init_dw_Scroll();
	
	
}


/*FOR RICHAR - SHOW HIDE DIV MARK CHILD WHEN MOUSE OVER*/
var menuOverId = 0;
var menuTimer;

function	SubTopMenuActive(pId)
{
	clearTimeout(menuTimer);
	//deactive older
	if (menuOverId > 0)
	{
		tTdId	=	"TdIcon_" + menuOverId;
		tObject = document.getElementById(tTdId);
		ChangeStyle(tObject, "");
		//Hide SubMenu
		//HideDiv("MarkChild_" + menuOverId);
	}
	//active newer
	menuOverId = pId;
	tTdId	=	"TdIcon_" + pId;
	tObject = document.getElementById(tTdId);
	//alert(tObject);
	ChangeStyle(tObject, "CategoryMarkMenu_BG_Icon_Active");
	//Show SubMenu
	//ShowDiv("MarkChild_" + pId);
	//document.title = pId;
}

function	SubTopMenuReturn(pId)
{
	//document.title = pId;
	menuTimer = setTimeout('SubTopMenuActive(' + pId + ');',500);
}


function	changeValue(pObject, pInitValue)
{
	if (pObject.value == pInitValue)
	{
		pObject.value	=	"";		
	}
	else if (pObject.value == "")
	{
		pObject.value	=	pInitValue;	
	}
	
}


function	checkEnterSite(pFormName)
{
	var tDay	=	document.forms[pFormName].DayBirth.value;
	var tMonth	=	document.forms[pFormName].MonthBirth.value;
	var tYear	=	document.forms[pFormName].YearBirth.value;
	var tResult	=	1;
	var tError	=	"";
	
	if (tDay == "JJ" || tMonth == "MM" ||  tYear == "AAAA")
	{
		tResult	=	0;
		tError	=	"Veuillez renseigner tous les champs obligatoires";
	}
	else if (!isInteger(parseInt(tDay)) || !isInteger(parseInt(tMonth)) || !isInteger(parseInt(tYear)) )
	{
		tResult	=	0;
		tError	=	"Vous devez certifier etre majeur et accepter les conditions legales en cochant la case prevue";
	}
	else if ( (parseInt(tDay) < 0 || parseInt(tDay) > 31) || (parseInt(tMonth) < 0 || parseInt(tMonth) > 12) || (parseInt(tYear) < 1900) )
	{
		tResult	=	0;
		tError	=	"Vous devez certifier etre majeur et accepter les conditions legales en cochant la case prevue";
	}
	else
	{
		var todaysDate = new Date();
		var y = todaysDate.getFullYear();
		var m = todaysDate.getMonth() + 1;
		var d = todaysDate.getDate() + 0;
		
		//var tAge	=	((tDay - d) / 365) +  ((tMonth - m) / 12) + (tYear - y);
		var tAge = (y-tYear);
		
		//alert("M = " + m + " - d = " + d + " = [ " + tMonth + " - " + tDay);
		if (tMonth <= m  && tDay > d) 
		{
			
			tAge = tAge - 1;
		}
		
		//alert("AGE = " + tAge);
		
	}
	
	
	if (tResult	==	0)
	{
		alert(tError);
	}
	else 
	{
		if (tAge >= 18)
		{
			PreSubmit(pFormName, 'login');
			//document.location.reload(true);
			//document.location.href	=	"./?page=Home&action=Intro";
		}
		else
			alert("Vous n'\xEAtes pas majeur\nVous ne pouvez pas visiter le site Collection Grandes Marques.");
	}
}



function	setIframeCocktailSrc(pIframeId, pStringParam)
{
	document.getElementById(pIframeId).src	=	pStringParam;
}


function	directPageCocktail(pDivId, pStringParam)
{
	var tDivId	=	document.getElementById(pDivId);
	var tDivTop	=	tDivId.scrollTop;
	if (tDivTop == "")
		tDivTop	=	0;

	//not SEO
	//document.location.href	=	pStringParam + "&top=" + tDivTop;
	
	document.location.href	=	pStringParam + "-" + tDivTop + ".html";
}


function getPosition(obj)
{
    var topValue= 0,leftValue= 0;
    while(obj)
	{
		leftValue+= obj.offsetLeft;
		topValue+= obj.offsetTop;
		obj= obj.offsetParent;
    }
    
	//finalvalue = leftValue + "," + topValue;
   
	return topValue;
}

function	setDivPosition(divId, pTop)
{
	document.getElementById(divId).scrollTop = pTop;
}

function	ScrollVertical(divId, pDistance)
{
	document.getElementById(divId).scrollTop += parseInt(pDistance);
}

var timeScrollVertical;
function	StartScrollUp()
{
	clearTimeout(timeScrollVertical);
	ScrollVertical('ScrollContent',5);
	timeScrollVertical = setTimeout('StartScrollUp()',100);
}
function	StopScrollUp()
{
	clearTimeout(timeScrollVertical);
}
function	StartScrollDown()
{
	clearTimeout(timeScrollVertical);
	ScrollVertical('ScrollContent',-5);
	timeScrollVertical = setTimeout('StartScrollDown()',100);
}
function	StopScrollDown()
{
	clearTimeout(timeScrollVertical);
}

function	checkValueToPassFocus( pObject, pType, pFormName)
{
	var tLen	=	0;
	tLen	=	pObject.value.length;
	if (pType == "Day")
	{
		if (pObject.value >= 4 && tLen == 1)
		{
			pObject.value = "0" + pObject.value;
			document.forms[pFormName].MonthBirth.focus();
			return;
		}
		
		if (tLen ==2 )
			document.forms[pFormName].MonthBirth.focus();
		
	}
	else if (pType == "Month")
	{
		if (parseInt(pObject.value) >= 2 && parseInt(pObject.value) <= 9 && tLen == 1) 
		{
			pObject.value = "0" + pObject.value;
			document.forms[pFormName].YearBirth.focus();
			return;
		}
		
		if (tLen ==2 )
			document.forms[pFormName].YearBirth.focus();
		
	}
}


function runScript(evt, pFormName) 
{
    if (evt.keyCode == 13) 
	{
        checkEnterSite(pFormName);
		return false;
    }
}


//don't move
//arrOnLoadFunctions.push("MoveTaskBar_Start();");


