﻿if (!window.Spark) Spark=new Object();
if (!window.Spark.Web) Spark.Web=new Object();
if (!window.Spark.Web.Portal) Spark.Web.Portal=new Object();
if (!window.Spark.Web.Portal.Renaultsport) Spark.Web.Portal.Renaultsport=new Object();
if (!window.Spark.Web.Portal.Renaultsport.UserProfile) Spark.Web.Portal.Renaultsport.UserProfile=new Object();
Spark.Web.Portal.Renaultsport.UserProfile.ActiveMainMenuItem=null;
Spark.Web.Portal.Renaultsport.UserProfile.OnBodyLoad=null;
Spark.Web.Portal.Renaultsport.UserProfile.OnLoad=function(evt)
{
	if (!evt) evt=window.event;
	Spark.Web.Portal.Renaultsport.UserProfile.OnTitleSelectedIndexChanged({target:document.getElementById(TitleId)});
	Spark.Web.Portal.Renaultsport.UserProfile.OnPasswordTextChanged({target:document.getElementById(PasswordId)});
	if ((MyMobile!=null)&&(MyMobile!="")&&(MobileRequiredFieldValidator!="")&&
		(MobileRequiredFieldValidator!=null)&&(Mobile!=null)&&(Mobile!=""))
	{
		MyMobile=document.getElementById(MyMobile);
		MobileRequiredFieldValidator=document.getElementById(MobileRequiredFieldValidator);
		Mobile=document.getElementById(Mobile);
		Spark.Web.Portal.Renaultsport.UserProfile.OnMyMobileCheckedChanged({target:MyMobile});
	}
	if (Spark.Web.Portal.Renaultsport.UserProfile.OnBodyLoad!=null)
		Spark.Web.Portal.Renaultsport.UserProfile.OnBodyLoad(evt);
}

if (navigator.userAgent.toLowerCase().indexOf("msie")!=-1)
{
	if ((document.body.onload!=null)&&(document.body.onload!=Spark.Web.Portal.Renaultsport.UserProfile.OnLoad))
		Spark.Web.Portal.Renaultsport.UserProfile.OnBodyLoad=document.body.onload;
	document.body.onload=Spark.Web.Portal.Renaultsport.UserProfile.OnLoad;
}
else
{
	if ((window.onload!=null)&&(window.onload!=Spark.Web.Portal.Renaultsport.UserProfile.OnLoad))
		Spark.Web.Portal.Renaultsport.UserProfile.OnBodyLoad=window.onload;
	window.onload=Spark.Web.Portal.Renaultsport.UserProfile.OnLoad;
}

Spark.Web.Portal.Renaultsport.UserProfile.OnMyMobileCheckedChanged=function(evt)
{
	if (!evt) evt=window.event;
	var Source=(evt.srcElement?evt.srcElement:evt.target);
	if (Source!=null)
	{
	    if (Source.checked==true)
	    {
		    if (MobileRequiredFieldValidator.validationGroup.charAt(0)=="_")
			    MobileRequiredFieldValidator.validationGroup=MobileRequiredFieldValidator.validationGroup.substring(1);
	    }
	    else
		    MobileRequiredFieldValidator.validationGroup="_"+MobileRequiredFieldValidator.validationGroup;
	}
}

Spark.Web.Portal.Renaultsport.UserProfile.OnTermsChanged=function(evt)
{
	if (!evt) evt=window.event;
	var Source=(evt.srcElement?evt.srcElement:evt.target);
	if (Source!=null)
	{
	    if (Source.checked==true)
	    {
            document.getElementById("SubmitContainer").style.display="";
	    }
	    else
            document.getElementById("SubmitContainer").style.display="none";
	}
}

Spark.Web.Portal.Renaultsport.UserProfile.OnTitleSelectedIndexChanged=function(evt)
{
	if (!evt) evt=window.event;
	var Source=(evt.srcElement?evt.srcElement:evt.target);
	if (Source!=null)
	{
	    if (Source.OtherTitleValidator==undefined)
	    {
		    Source.OtherTitle=Source.parentNode.parentNode.getElementsByTagName("input")[0];
		    Source.OtherTitleValidator=Source.parentNode.parentNode.getElementsByTagName("span")[1];
	    }
	    if (Source.options[Source.selectedIndex].value=="0")
	    {
		    Source.OtherTitle.style.display="";
		    Source.OtherTitleValidator.validationGroup=Source.OtherTitleValidator.validationGroup.replace("_","");
	    }
	    else
	    {
		    Source.OtherTitle.style.display="none";
		    Source.OtherTitleValidator.validationGroup="_"+Source.OtherTitleValidator.validationGroup;
	    }
	}
}

Spark.Web.Portal.Renaultsport.UserProfile.OnPasswordTextChanged=function(evt)
{
	if (!evt) evt=window.event;
	var Source=(evt.srcElement?evt.srcElement:evt.target);
	if (Source!=null)
	{
	    if (!((window.location.href.toLowerCase().indexOf("uniqueid")!=-1)&&
		    (window.location.href.toLowerCase().indexOf("externalniqueid")==-1)&&(Source!=null)))
	    {
	        if (Source.PasswordValidator==undefined)
		        Source.PasswordValidator=Source.parentNode.parentNode.getElementsByTagName("span")[0];
	        RepeatPasswordValidator=document.getElementById(RepeatPasswordId).parentNode.parentNode.getElementsByTagName("span")[0];
	        if (Source.value!="")
	        {
		        Source.PasswordValidator.validationGroup=Source.PasswordValidator.validationGroup.replace("_","");
		        RepeatPasswordValidator.validationGroup=RepeatPasswordValidator.validationGroup.replace("_","");
		    }
	        else
	        {
		        Source.PasswordValidator.validationGroup="_"+Source.PasswordValidator.validationGroup;
		        RepeatPasswordValidator.validationGroup="_"+RepeatPasswordValidator.validationGroup;
		    }
	    }
	}
}
