
//---------------------------------------------------------------------
// Author:		Lars Schmitz
// Date:		16-01-2004
// Description: This Script file will be used for the Login function
// Input:
// Output: 
// Reference:	TD Webshop 300
//---------------------------------------------------------------------

//---------------------------------------------------------------------
// Author:		Lars Schmitz
// Date:		16-01-2004
// Description: This function loads the topmenu of the webshop
//				after succesfull login			
// Input:		TargetFrame and Hyperlink to get
// Output: 
// Reference:	TD Webshop 300
//---------------------------------------------------------------------

function LoadPageInOtherFrame(TargetFrame, HyperLink)
{
		//---------------------------------------------------------------------
		// Change page in other frame
		//---------------------------------------------------------------------
		var strUrl;
		strUrl = HyperLink
		//parent.frames[TargetFrame].location.href = strUrl;
		parent.location.href = strUrl;
}


//---------------------------------------------------------------------
// Author:		Lars Schmitz
// Date:		16-01-2004
// Description: This function loads a page in the 
//				main frame of the page
// Input:		TargetFrame and Hyperlink to get
// Output: 
// Reference:	TD Webshop 300
//---------------------------------------------------------------------
function LoadPageInMainFrame(TargetFrame, HyperLink)
{
		//---------------------------------------------------------------------
		// Change page in other frame
		//---------------------------------------------------------------------
		//parent.frames['MainFrame'].frames[TargetFrame].location.href = HyperLink;
		parent.location.href = strUrl;
}

//---------------------------------------------------------------------
// Author:		Lars Schmitz
// Date:		16-01-2004
// Description: This function loads the quick order of the webshop
//				after succesfull login			
// Input:		Hyperlink to get in the existing frame
// Output: 
// Reference:	TD Webshop 300
//---------------------------------------------------------------------
function NavigateTo(HyperLink)
{
		//---------------------------------------------------------------------
		// Change page in existing frame
		//---------------------------------------------------------------------
		window.navigate(HyperLink);
}

//---------------------------------------------------------------------
// Author:		Richard Wittens
// Date:		21-01-2004
// Description: This function sets the focus to the first item,
//				which is not filled
// Input:		
// Output: 
// Reference:	TD Webshop 300
//---------------------------------------------------------------------
function setFocus(frmToCheck)
{
	//---------------------------------------------------------------------
	// check which field has to have the focus
	//---------------------------------------------------------------------

	if(frmToCheck.txtUserName.value == "")
	{
		frmToCheck.txtUserName.focus();
	}	
	else
	{
		if(frmToCheck.txtPassword.value == "")
		{
			frmToCheck.txtPassword.focus();
		}
		else
		{
			frmToCheck.txtCustomerName.focus();
		}
	}
	return true;
}

//---------------------------------------------------------------------
// Author:		Daniel Frissen
// Date:		28-02-2005
// Description: This function sets the focus to the first item,
//				which is not filled for the cahnge password screen
// Input:		
// Output: 
// Reference:	TD Webshop 300
//---------------------------------------------------------------------
function setFocusChangePassword(frmToCheck)
{
	//---------------------------------------------------------------------
	// check which field has to have the focus
	//---------------------------------------------------------------------
	if(frmToCheck.txtOldPassword.value == "")
	{
		frmToCheck.txtOldPassword.focus();
	}
	else
	{
		if(frmToCheck.txtNewPassword.value == "")
		{
			frmToCheck.txtNewPassword.focus();
		}
		else
		{
			frmToCheck.txtConfirmNewPassword.focus();
		}
	}
	return true;
}

//---------------------------------------------------------------------
// Author:		Richard Wittens
// Date:		21-01-2004
// Description: This function checks if one or more than one fields has
//				been left empty
// Input:		CustomerNameEmpty - message, if the Customer name is empty
//				UserNameEmpty     - message, if the User name is empty
//				PasswordEmpty     - message, if the Password is empty
// Output: 
// Reference:	TD Webshop 300
//---------------------------------------------------------------------
function checkEmpty(frmToCheck, CustomerNameEmpty, UserNameEmpty, PasswordEmpty)
{
	//---------------------------------------------------------------------
	// declare variables
	//---------------------------------------------------------------------
	var strAlert = "";

	//---------------------------------------------------------------------
	// check if all fields are filled
	//---------------------------------------------------------------------
	if(frmToCheck.txtCustomerName.value == "")
	{
		strAlert += CustomerNameEmpty + "\n";
	}
	if(frmToCheck.txtUserName.value == "")
	{
		strAlert += UserNameEmpty + "\n";
	}
	if(frmToCheck.txtPassword.value == "")
	{
		strAlert += PasswordEmpty + "\n";
	}

	if (strAlert != "")
	{
		alert(strAlert);
		return false;
	}
	else
	{
		DisableButton(frmToCheck.btnLogin);
		__doPostBack(frmToCheck.btnLogin.name,'')
		return true;
	}
}

function checkEmptyMain(frmToCheck, UserNameEmpty, PasswordEmpty)
{
	//---------------------------------------------------------------------
	// declare variables
	//---------------------------------------------------------------------
	var strAlert = "";

	//---------------------------------------------------------------------
	// check if all fields are filled
	//---------------------------------------------------------------------
	if(frmToCheck.txtUserName.value == "")
	{
		strAlert += UserNameEmpty + "\n";
	}
	if(frmToCheck.txtPassword.value == "")
	{
		strAlert += PasswordEmpty + "\n";
	}

	if (strAlert != "")
	{
		alert(strAlert);
		return false;
	}
	else
	{
		DisableButton(frmToCheck.btnLogin);
		__doPostBack(frmToCheck.btnLogin.name,'')
		return true;
	}
}

//---------------------------------------------------------------------
// Author:		Lars Schmitz
// Date:		03-03-2004
// Description: This function set the focus to a button
// Input:		frmToSetFocus	- Form object
//				btnToSetFocus   - Button object
// Output: 
// Reference:	TD Webshop 300
//---------------------------------------------------------------------
function ButtonSetFocus(frmToSetFocus)
{
	//---------------------------------------------------------------------
	// Check if the field that receives the focus is enabled
	//---------------------------------------------------------------------
	if(frmToSetFocus.btnYes.disabled == false)
	{
		//---------------------------------------------------------------------
		// Set the focus to the button
		//---------------------------------------------------------------------	
		frmToSetFocus.btnYes.focus();
	}
}
